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

Side by Side Diff: chrome/browser/ui/views/js_modal_dialog_views.cc

Issue 8553001: views: Add an Options enum to MessageBoxView control. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding an IPC_MESSAGE_EXPORT to line 30 of param_traits_macro.h makes it link in shared build Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/js_modal_dialog_views.h" 5 #include "chrome/browser/ui/views/js_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/js_modal_dialog.h" 8 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h"
9 #include "chrome/browser/ui/dialog_style.h" 9 #include "chrome/browser/ui/dialog_style.h"
10 #include "chrome/browser/ui/views/window.h" 10 #include "chrome/browser/ui/views/window.h"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 #include "ui/base/keycodes/keyboard_codes.h" 12 #include "ui/base/keycodes/keyboard_codes.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/message_box_flags.h"
15 #include "ui/views/controls/message_box_view.h" 14 #include "ui/views/controls/message_box_view.h"
16 #include "ui/views/controls/textfield/textfield.h" 15 #include "ui/views/controls/textfield/textfield.h"
17 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
18 17
19 //////////////////////////////////////////////////////////////////////////////// 18 ////////////////////////////////////////////////////////////////////////////////
20 // JSModalDialogViews, public: 19 // JSModalDialogViews, public:
21 20
22 JSModalDialogViews::JSModalDialogViews( 21 JSModalDialogViews::JSModalDialogViews(JavaScriptAppModalDialog* parent)
23 JavaScriptAppModalDialog* parent) 22 : parent_(parent) {
24 : parent_(parent), 23 int options = views::MessageBoxView::DETECT_ALIGNMENT;
25 message_box_view_(new views::MessageBoxView( 24 if (parent->javascript_message_type() == ui::JAVASCRIPT_MESSAGE_TYPE_PROMPT)
26 parent->dialog_flags() | ui::MessageBoxFlags::kAutoDetectAlignment, 25 options |= views::MessageBoxView::HAS_PROMPT_FIELD;
27 parent->message_text(), 26
28 parent->default_prompt_text())) { 27 message_box_view_ = new views::MessageBoxView(options,
28 parent->message_text(),
29 parent->default_prompt_text());
29 DCHECK(message_box_view_); 30 DCHECK(message_box_view_);
30 31
31 message_box_view_->AddAccelerator( 32 message_box_view_->AddAccelerator(
32 ui::Accelerator(ui::VKEY_C, false, true, false)); 33 ui::Accelerator(ui::VKEY_C, false, true, false));
33 if (parent->display_suppress_checkbox()) { 34 if (parent->display_suppress_checkbox()) {
34 message_box_view_->SetCheckBoxLabel( 35 message_box_view_->SetCheckBoxLabel(
35 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION)); 36 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION));
36 } 37 }
37 } 38 }
38 39
(...skipping 25 matching lines...) Expand all
64 } 65 }
65 66
66 void JSModalDialogViews::CancelAppModalDialog() { 67 void JSModalDialogViews::CancelAppModalDialog() {
67 GetDialogClientView()->CancelWindow(); 68 GetDialogClientView()->CancelWindow();
68 } 69 }
69 70
70 ////////////////////////////////////////////////////////////////////////////// 71 //////////////////////////////////////////////////////////////////////////////
71 // JSModalDialogViews, views::DialogDelegate implementation: 72 // JSModalDialogViews, views::DialogDelegate implementation:
72 73
73 int JSModalDialogViews::GetDefaultDialogButton() const { 74 int JSModalDialogViews::GetDefaultDialogButton() const {
74 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasOKButton) 75 if (parent_->javascript_message_type() == ui::JAVASCRIPT_MESSAGE_TYPE_ALERT)
75 return ui::DIALOG_BUTTON_OK; 76 return ui::DIALOG_BUTTON_OK;
76 77
77 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasCancelButton) 78 return ui::DIALOG_BUTTON_CANCEL;
78 return ui::DIALOG_BUTTON_CANCEL;
79
80 return ui::DIALOG_BUTTON_NONE;
81 } 79 }
82 80
83 int JSModalDialogViews::GetDialogButtons() const { 81 int JSModalDialogViews::GetDialogButtons() const {
84 int dialog_buttons = ui::DIALOG_BUTTON_NONE; 82 if (parent_->javascript_message_type() == ui::JAVASCRIPT_MESSAGE_TYPE_ALERT)
85 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasOKButton) 83 return ui::DIALOG_BUTTON_OK;
86 dialog_buttons = ui::DIALOG_BUTTON_OK;
87 84
88 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasCancelButton) 85 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
89 dialog_buttons |= ui::DIALOG_BUTTON_CANCEL;
90
91 return dialog_buttons;
92 } 86 }
93 87
94 string16 JSModalDialogViews::GetWindowTitle() const { 88 string16 JSModalDialogViews::GetWindowTitle() const {
95 return parent_->title(); 89 return parent_->title();
96 } 90 }
97 91
98
99 void JSModalDialogViews::WindowClosing() { 92 void JSModalDialogViews::WindowClosing() {
100 } 93 }
101 94
102 void JSModalDialogViews::DeleteDelegate() { 95 void JSModalDialogViews::DeleteDelegate() {
103 delete this; 96 delete this;
104 } 97 }
105 98
106 bool JSModalDialogViews::Cancel() { 99 bool JSModalDialogViews::Cancel() {
107 parent_->OnCancel(message_box_view_->IsCheckBoxSelected()); 100 parent_->OnCancel(message_box_view_->IsCheckBoxSelected());
108 return true; 101 return true;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 155
163 // static 156 // static
164 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( 157 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt(
165 JavaScriptAppModalDialog* dialog, 158 JavaScriptAppModalDialog* dialog,
166 gfx::NativeWindow parent_window) { 159 gfx::NativeWindow parent_window) {
167 JSModalDialogViews* d = new JSModalDialogViews(dialog); 160 JSModalDialogViews* d = new JSModalDialogViews(dialog);
168 161
169 browser::CreateViewsWindow(parent_window, d, STYLE_GENERIC); 162 browser::CreateViewsWindow(parent_window, d, STYLE_GENERIC);
170 return d; 163 return d;
171 } 164 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/external_protocol_dialog.cc ('k') | chrome/browser/ui/views/repost_form_warning_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698