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

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: more fixes 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/app_modal_dialog.h" 8 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
9 #include "chrome/browser/ui/views/window.h" 9 #include "chrome/browser/ui/views/window.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
11 #include "ui/base/keycodes/keyboard_codes.h" 11 #include "ui/base/keycodes/keyboard_codes.h"
12 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/message_box_flags.h"
14 #include "ui/views/controls/textfield/textfield.h" 13 #include "ui/views/controls/textfield/textfield.h"
15 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
16 #include "views/controls/message_box_view.h" 15 #include "views/controls/message_box_view.h"
17 16
18 //////////////////////////////////////////////////////////////////////////////// 17 ////////////////////////////////////////////////////////////////////////////////
19 // JSModalDialogViews, public: 18 // JSModalDialogViews, public:
20 19
21 JSModalDialogViews::JSModalDialogViews( 20 JSModalDialogViews::JSModalDialogViews(JavaScriptAppModalDialog* parent)
22 JavaScriptAppModalDialog* parent) 21 : parent_(parent) {
23 : parent_(parent), 22 int options = views::MessageBoxView::DETECT_ALIGNMENT;
24 message_box_view_(new views::MessageBoxView( 23 if (parent->message_box_type() == ui::MESSAGE_BOX_TYPE_JAVASCRIPT_PROMPT)
25 parent->dialog_flags() | ui::MessageBoxFlags::kAutoDetectAlignment, 24 options |= views::MessageBoxView::HAS_PROMPT_FIELD;
26 parent->message_text(), 25
27 parent->default_prompt_text())) { 26 message_box_view_ = new views::MessageBoxView(options,
27 parent->message_text(),
28 parent->default_prompt_text());
28 DCHECK(message_box_view_); 29 DCHECK(message_box_view_);
29 30
30 message_box_view_->AddAccelerator( 31 message_box_view_->AddAccelerator(
31 ui::Accelerator(ui::VKEY_C, false, true, false)); 32 ui::Accelerator(ui::VKEY_C, false, true, false));
32 if (parent->display_suppress_checkbox()) { 33 if (parent->display_suppress_checkbox()) {
33 message_box_view_->SetCheckBoxLabel( 34 message_box_view_->SetCheckBoxLabel(
34 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION)); 35 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION));
35 } 36 }
36 } 37 }
37 38
(...skipping 25 matching lines...) Expand all
63 } 64 }
64 65
65 void JSModalDialogViews::CancelAppModalDialog() { 66 void JSModalDialogViews::CancelAppModalDialog() {
66 GetDialogClientView()->CancelWindow(); 67 GetDialogClientView()->CancelWindow();
67 } 68 }
68 69
69 ////////////////////////////////////////////////////////////////////////////// 70 //////////////////////////////////////////////////////////////////////////////
70 // JSModalDialogViews, views::DialogDelegate implementation: 71 // JSModalDialogViews, views::DialogDelegate implementation:
71 72
72 int JSModalDialogViews::GetDefaultDialogButton() const { 73 int JSModalDialogViews::GetDefaultDialogButton() const {
73 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasOKButton) 74 if (parent_->message_box_type() == ui::MESSAGE_BOX_TYPE_JAVASCRIPT_ALERT)
74 return ui::DIALOG_BUTTON_OK; 75 return ui::DIALOG_BUTTON_OK;
75 76
76 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasCancelButton) 77 return ui::DIALOG_BUTTON_CANCEL;
77 return ui::DIALOG_BUTTON_CANCEL;
78
79 return ui::DIALOG_BUTTON_NONE;
80 } 78 }
81 79
82 int JSModalDialogViews::GetDialogButtons() const { 80 int JSModalDialogViews::GetDialogButtons() const {
83 int dialog_buttons = ui::DIALOG_BUTTON_NONE; 81 if (parent_->message_box_type() == ui::MESSAGE_BOX_TYPE_ALERT)
84 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasOKButton) 82 return ui::DIALOG_BUTTON_OK;
85 dialog_buttons = ui::DIALOG_BUTTON_OK;
86 83
87 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasCancelButton) 84 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
88 dialog_buttons |= ui::DIALOG_BUTTON_CANCEL;
89
90 return dialog_buttons;
91 } 85 }
92 86
93 string16 JSModalDialogViews::GetWindowTitle() const { 87 string16 JSModalDialogViews::GetWindowTitle() const {
94 return parent_->title(); 88 return parent_->title();
95 } 89 }
96 90
97
98 void JSModalDialogViews::WindowClosing() { 91 void JSModalDialogViews::WindowClosing() {
99 } 92 }
100 93
101 void JSModalDialogViews::DeleteDelegate() { 94 void JSModalDialogViews::DeleteDelegate() {
102 delete parent_; 95 delete parent_;
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());
(...skipping 54 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); 162 browser::CreateViewsWindow(parent_window, d);
170 return d; 163 return d;
171 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698