Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3401)

Unified Diff: chrome/browser/ui/views/javascript_app_modal_dialog_views.cc

Issue 16172006: Center wide new-style Views JavaScript dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a parent_window NULL check. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/javascript_app_modal_dialog_views.cc
diff --git a/chrome/browser/ui/views/javascript_app_modal_dialog_views.cc b/chrome/browser/ui/views/javascript_app_modal_dialog_views.cc
index 57d17a50cec2e3d4674c6a32241f37e44b5197f0..8b4a02e2578badda88a8d25824ce0727b4ab1fc4 100644
--- a/chrome/browser/ui/views/javascript_app_modal_dialog_views.cc
+++ b/chrome/browser/ui/views/javascript_app_modal_dialog_views.cc
@@ -171,6 +171,16 @@ NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt(
JavaScriptAppModalDialog* dialog,
gfx::NativeWindow parent_window) {
JavaScriptAppModalDialogViews* d = new JavaScriptAppModalDialogViews(dialog);
- views::DialogDelegate::CreateDialogWidget(d, NULL, parent_window);
+ views::Widget* widget =
+ views::DialogDelegate::CreateDialogWidget(d, NULL, parent_window);
+ views::Widget* parent_widget = parent_window ?
+ views::Widget::GetWidgetForNativeWindow(parent_window) : NULL;
+ // Horizontally center the dialog window within the parent window's bounds.
+ if (widget && parent_widget) {
+ gfx::Rect bounds(widget->GetWindowBoundsInScreen());
+ gfx::Rect parent_bounds(parent_widget->GetWindowBoundsInScreen());
+ bounds.set_x(parent_bounds.CenterPoint().x() - bounds.width() / 2);
+ widget->SetBounds(bounds);
+ }
return d;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698