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

Side by Side Diff: components/app_modal_dialogs/views/javascript_app_modal_dialog_views.cc

Issue 666533007: Move JavaScriptDialogManager, JavascriptAppModalDialogViews to components/app_modal_dialogs (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
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 "components/app_modal_dialogs/views/javascript_app_modal_dialog_views.h "
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "components/app_modal_dialogs/javascript_app_modal_dialog.h" 8 #include "components/app_modal_dialogs/javascript_app_modal_dialog.h"
9 #include "components/constrained_window/constrained_window_views.h" 9 #include "components/constrained_window/constrained_window_views.h"
10 #include "grit/components_strings.h" 10 #include "grit/components_strings.h"
11 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/events/keycodes/keyboard_codes.h" 12 #include "ui/events/keycodes/keyboard_codes.h"
13 #include "ui/views/controls/message_box_view.h" 13 #include "ui/views/controls/message_box_view.h"
14 #include "ui/views/controls/textfield/textfield.h" 14 #include "ui/views/controls/textfield/textfield.h"
15 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
16 #include "ui/views/window/dialog_client_view.h" 16 #include "ui/views/window/dialog_client_view.h"
17 17
18 #if defined(USE_X11) && !defined(OS_CHROMEOS)
19 #include "chrome/browser/ui/views/javascript_app_modal_event_blocker_x11.h"
20 #endif
21
22 //////////////////////////////////////////////////////////////////////////////// 18 ////////////////////////////////////////////////////////////////////////////////
23 // JavaScriptAppModalDialogViews, public: 19 // JavaScriptAppModalDialogViews, public:
24 20
25 JavaScriptAppModalDialogViews::JavaScriptAppModalDialogViews( 21 JavaScriptAppModalDialogViews::JavaScriptAppModalDialogViews(
26 JavaScriptAppModalDialog* parent) 22 JavaScriptAppModalDialog* parent)
27 : parent_(parent) { 23 : parent_(parent) {
28 int options = views::MessageBoxView::DETECT_DIRECTIONALITY; 24 int options = views::MessageBoxView::DETECT_DIRECTIONALITY;
29 if (parent->javascript_message_type() == 25 if (parent->javascript_message_type() ==
30 content::JAVASCRIPT_MESSAGE_TYPE_PROMPT) 26 content::JAVASCRIPT_MESSAGE_TYPE_PROMPT)
31 options |= views::MessageBoxView::HAS_PROMPT_FIELD; 27 options |= views::MessageBoxView::HAS_PROMPT_FIELD;
(...skipping 16 matching lines...) Expand all
48 } 44 }
49 45
50 //////////////////////////////////////////////////////////////////////////////// 46 ////////////////////////////////////////////////////////////////////////////////
51 // JavaScriptAppModalDialogViews, NativeAppModalDialog implementation: 47 // JavaScriptAppModalDialogViews, NativeAppModalDialog implementation:
52 48
53 int JavaScriptAppModalDialogViews::GetAppModalDialogButtons() const { 49 int JavaScriptAppModalDialogViews::GetAppModalDialogButtons() const {
54 return GetDialogButtons(); 50 return GetDialogButtons();
55 } 51 }
56 52
57 void JavaScriptAppModalDialogViews::ShowAppModalDialog() { 53 void JavaScriptAppModalDialogViews::ShowAppModalDialog() {
58 #if defined(USE_X11) && !defined(OS_CHROMEOS)
59 // BrowserView::CanActivate() ensures that other browser windows cannot be
60 // activated for long while the dialog is visible. Block events to other
61 // browser windows so that the user cannot interact with other browser windows
62 // in the short time that the other browser windows are active. This hack is
63 // unnecessary on Windows and Chrome OS.
64 // TODO(pkotwicz): Find a better way of doing this and remove this hack.
65 if (!event_blocker_x11_.get()) {
66 event_blocker_x11_.reset(
67 new JavascriptAppModalEventBlockerX11(GetWidget()->GetNativeView()));
68 }
69 #endif
70
71 GetWidget()->Show(); 54 GetWidget()->Show();
72 } 55 }
73 56
74 void JavaScriptAppModalDialogViews::ActivateAppModalDialog() { 57 void JavaScriptAppModalDialogViews::ActivateAppModalDialog() {
75 GetWidget()->Show(); 58 GetWidget()->Show();
76 GetWidget()->Activate(); 59 GetWidget()->Activate();
77 } 60 }
78 61
79 void JavaScriptAppModalDialogViews::CloseAppModalDialog() { 62 void JavaScriptAppModalDialogViews::CloseAppModalDialog() {
80 GetWidget()->Close(); 63 GetWidget()->Close();
(...skipping 19 matching lines...) Expand all
100 content::JAVASCRIPT_MESSAGE_TYPE_ALERT) 83 content::JAVASCRIPT_MESSAGE_TYPE_ALERT)
101 return ui::DIALOG_BUTTON_OK; 84 return ui::DIALOG_BUTTON_OK;
102 85
103 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; 86 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
104 } 87 }
105 88
106 base::string16 JavaScriptAppModalDialogViews::GetWindowTitle() const { 89 base::string16 JavaScriptAppModalDialogViews::GetWindowTitle() const {
107 return parent_->title(); 90 return parent_->title();
108 } 91 }
109 92
110 void JavaScriptAppModalDialogViews::WindowClosing() {
111 #if defined(USE_X11) && !defined(OS_CHROMEOS)
112 event_blocker_x11_.reset();
113 #endif
114 }
115
116 void JavaScriptAppModalDialogViews::DeleteDelegate() { 93 void JavaScriptAppModalDialogViews::DeleteDelegate() {
117 delete this; 94 delete this;
118 } 95 }
119 96
120 bool JavaScriptAppModalDialogViews::Cancel() { 97 bool JavaScriptAppModalDialogViews::Cancel() {
121 parent_->OnCancel(message_box_view_->IsCheckBoxSelected()); 98 parent_->OnCancel(message_box_view_->IsCheckBoxSelected());
122 return true; 99 return true;
123 } 100 }
124 101
125 bool JavaScriptAppModalDialogViews::Accept() { 102 bool JavaScriptAppModalDialogViews::Accept() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 144
168 views::View* JavaScriptAppModalDialogViews::GetContentsView() { 145 views::View* JavaScriptAppModalDialogViews::GetContentsView() {
169 return message_box_view_; 146 return message_box_view_;
170 } 147 }
171 148
172 views::View* JavaScriptAppModalDialogViews::GetInitiallyFocusedView() { 149 views::View* JavaScriptAppModalDialogViews::GetInitiallyFocusedView() {
173 if (message_box_view_->text_box()) 150 if (message_box_view_->text_box())
174 return message_box_view_->text_box(); 151 return message_box_view_->text_box();
175 return views::DialogDelegate::GetInitiallyFocusedView(); 152 return views::DialogDelegate::GetInitiallyFocusedView();
176 } 153 }
177
178 ////////////////////////////////////////////////////////////////////////////////
179 // NativeAppModalDialog, public:
180
181 // static
182 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt(
183 JavaScriptAppModalDialog* dialog,
184 gfx::NativeWindow parent_window) {
185 JavaScriptAppModalDialogViews* d = new JavaScriptAppModalDialogViews(dialog);
186 CreateBrowserModalDialogViews(d, parent_window);
187 return d;
188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698