| 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/ui/app_modal_dialogs/javascript_app_modal_dialog.h" | 8 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
| 9 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 9 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 10 #include "ui/base/keycodes/keyboard_codes.h" | 11 #include "ui/base/keycodes/keyboard_codes.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/views/controls/message_box_view.h" | 13 #include "ui/views/controls/message_box_view.h" |
| 13 #include "ui/views/controls/textfield/textfield.h" | 14 #include "ui/views/controls/textfield/textfield.h" |
| 14 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 15 #include "ui/views/window/dialog_client_view.h" | 16 #include "ui/views/window/dialog_client_view.h" |
| 16 | 17 |
| 17 //////////////////////////////////////////////////////////////////////////////// | 18 //////////////////////////////////////////////////////////////////////////////// |
| 18 // JavaScriptAppModalDialogViews, public: | 19 // JavaScriptAppModalDialogViews, public: |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 156 } |
| 156 | 157 |
| 157 //////////////////////////////////////////////////////////////////////////////// | 158 //////////////////////////////////////////////////////////////////////////////// |
| 158 // NativeAppModalDialog, public: | 159 // NativeAppModalDialog, public: |
| 159 | 160 |
| 160 // static | 161 // static |
| 161 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( | 162 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( |
| 162 JavaScriptAppModalDialog* dialog, | 163 JavaScriptAppModalDialog* dialog, |
| 163 gfx::NativeWindow parent_window) { | 164 gfx::NativeWindow parent_window) { |
| 164 JavaScriptAppModalDialogViews* d = new JavaScriptAppModalDialogViews(dialog); | 165 JavaScriptAppModalDialogViews* d = new JavaScriptAppModalDialogViews(dialog); |
| 165 views::Widget* widget = | 166 CreateBrowserModalDialogViews(d, parent_window); |
| 166 views::DialogDelegate::CreateDialogWidget(d, NULL, parent_window); | |
| 167 views::Widget* parent_widget = parent_window ? | |
| 168 views::Widget::GetWidgetForNativeWindow(parent_window) : NULL; | |
| 169 // Horizontally center the dialog window within the parent window's bounds. | |
| 170 if (widget && parent_widget) { | |
| 171 gfx::Rect bounds(widget->GetWindowBoundsInScreen()); | |
| 172 gfx::Rect parent_bounds(parent_widget->GetWindowBoundsInScreen()); | |
| 173 bounds.set_x(parent_bounds.CenterPoint().x() - bounds.width() / 2); | |
| 174 widget->SetBounds(bounds); | |
| 175 } | |
| 176 return d; | 167 return d; |
| 177 } | 168 } |
| OLD | NEW |