summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/gtk_util.cc
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 20:56:36 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 20:56:36 +0000
commitf2887ad8d57d8ff1c826bda4311f7acd4edf637e (patch)
treed84499494880d0d78ea6f7562728360cf2b7ea53 /chrome/browser/gtk/gtk_util.cc
parent560440269665f15714c2dd1cee17dc2a7ed501dd (diff)
downloadchromium_src-f2887ad8d57d8ff1c826bda4311f7acd4edf637e.zip
chromium_src-f2887ad8d57d8ff1c826bda4311f7acd4edf637e.tar.gz
chromium_src-f2887ad8d57d8ff1c826bda4311f7acd4edf637e.tar.bz2
Host cookie modal dialog and js modal modal dialog in NativeDialogHost
- Enable modal dialog in NativeDialogHost. This is not fully work in ChromeOS because e.g. user could still alt-tab away. However, setting modal would block user from interacting with relevant browser window and avoid crashes; - Move dialog close code from NativeHostDialog's destructor to WindowClosing because a dialog's "response" signal handler could rely on the contents; - Add "check-resize" signal handler to make GtkExpander work nicely with NativeDialogHost; - Add ShowModalDialogWithMinLocalizedWidth to gtk_util for cookie and js modal dialog; - Change in WidgetGtk::SetBounds to call gtk_window_move/resize always to keep GtkWindow's geometry info up-to-date; BUG=none TEST=Verify cookie prompt and js dialog on ChromeOS is hosted in a Chrome window and not occupy the whole screen. Review URL: http://codereview.chromium.org/1995001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46619 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/gtk_util.cc')
-rw-r--r--chrome/browser/gtk/gtk_util.cc31
1 files changed, 29 insertions, 2 deletions
diff --git a/chrome/browser/gtk/gtk_util.cc b/chrome/browser/gtk/gtk_util.cc
index cab430c..c170da1 100644
--- a/chrome/browser/gtk/gtk_util.cc
+++ b/chrome/browser/gtk/gtk_util.cc
@@ -918,7 +918,7 @@ bool AddWindowAlphaChannel(GtkWidget* window) {
void ShowDialog(GtkWidget* dialog) {
chromeos::ShowNativeDialog(chromeos::GetOptionsViewParent(),
- dialog, gfx::Size(), false);
+ dialog, chromeos::DIALOG_FLAG_DEFAULT, gfx::Size(), gfx::Size());
}
void ShowDialogWithLocalizedSize(GtkWidget* dialog,
@@ -932,8 +932,22 @@ void ShowDialogWithLocalizedSize(GtkWidget* dialog,
chromeos::ShowNativeDialog(chromeos::GetOptionsViewParent(),
dialog,
+ resizeable ? chromeos::DIALOG_FLAG_RESIZEABLE :
+ chromeos::DIALOG_FLAG_DEFAULT,
gfx::Size(width, height),
- resizeable);
+ gfx::Size());
+}
+
+void ShowModalDialogWithMinLocalizedWidth(GtkWidget* dialog,
+ int width_id) {
+ int width = (width_id == -1) ? 0 :
+ views::Window::GetLocalizedContentsWidth(width_id);
+
+ chromeos::ShowNativeDialog(chromeos::GetOptionsViewParent(),
+ dialog,
+ chromeos::DIALOG_FLAG_MODAL,
+ gfx::Size(),
+ gfx::Size(width, 0));
}
void PresentWindow(GtkWidget* window, int timestamp) {
@@ -964,6 +978,19 @@ void ShowDialogWithLocalizedSize(GtkWidget* dialog,
gtk_widget_show_all(dialog);
}
+void ShowModalDialogWithMinLocalizedWidth(GtkWidget* dialog,
+ int width_id) {
+ gtk_widget_show_all(dialog);
+
+ // Suggest a minimum size.
+ gint width;
+ GtkRequisition req;
+ gtk_widget_size_request(dialog, &req);
+ gtk_util::GetWidgetSizeFromResources(dialog, width_id, 0, &width, NULL);
+ if (width > req.width)
+ gtk_widget_set_size_request(dialog, width, -1);
+}
+
void PresentWindow(GtkWidget* window, int timestamp) {
if (timestamp)
gtk_window_present_with_time(GTK_WINDOW(window), timestamp);