| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/javascript_app_modal_dialog_views.h" | 5 #include "chrome/browser/ui/views/javascript_app_modal_dialog_views.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" | 9 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 //////////////////////////////////////////////////////////////////////////////// | 166 //////////////////////////////////////////////////////////////////////////////// |
| 167 // NativeAppModalDialog, public: | 167 // NativeAppModalDialog, public: |
| 168 | 168 |
| 169 // static | 169 // static |
| 170 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( | 170 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( |
| 171 JavaScriptAppModalDialog* dialog, | 171 JavaScriptAppModalDialog* dialog, |
| 172 gfx::NativeWindow parent_window) { | 172 gfx::NativeWindow parent_window) { |
| 173 JavaScriptAppModalDialogViews* d = new JavaScriptAppModalDialogViews(dialog); | 173 JavaScriptAppModalDialogViews* d = new JavaScriptAppModalDialogViews(dialog); |
| 174 views::DialogDelegate::CreateDialogWidget(d, NULL, parent_window); | 174 views::Widget* widget = |
| 175 views::DialogDelegate::CreateDialogWidget(d, NULL, parent_window); |
| 176 views::Widget* parent_widget = parent_window ? |
| 177 views::Widget::GetWidgetForNativeWindow(parent_window) : NULL; |
| 178 // Horizontally center the dialog window within the parent window's bounds. |
| 179 if (widget && parent_widget) { |
| 180 gfx::Rect bounds(widget->GetWindowBoundsInScreen()); |
| 181 gfx::Rect parent_bounds(parent_widget->GetWindowBoundsInScreen()); |
| 182 bounds.set_x(parent_bounds.CenterPoint().x() - bounds.width() / 2); |
| 183 widget->SetBounds(bounds); |
| 184 } |
| 175 return d; | 185 return d; |
| 176 } | 186 } |
| OLD | NEW |