| OLD | NEW |
| 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/message_box_flags.h" | |
| 9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 9 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
| 11 #include "chrome/browser/ui/views/window.h" | 10 #include "chrome/browser/ui/views/window.h" |
| 12 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 13 #include "ui/base/keycodes/keyboard_codes.h" | 12 #include "ui/base/keycodes/keyboard_codes.h" |
| 13 #include "ui/base/message_box_flags.h" |
| 14 #include "views/controls/message_box_view.h" | 14 #include "views/controls/message_box_view.h" |
| 15 #include "views/window/window.h" | 15 #include "views/window/window.h" |
| 16 | 16 |
| 17 //////////////////////////////////////////////////////////////////////////////// | 17 //////////////////////////////////////////////////////////////////////////////// |
| 18 // JSModalDialogViews, public: | 18 // JSModalDialogViews, public: |
| 19 | 19 |
| 20 JSModalDialogViews::JSModalDialogViews( | 20 JSModalDialogViews::JSModalDialogViews( |
| 21 JavaScriptAppModalDialog* parent) | 21 JavaScriptAppModalDialog* parent) |
| 22 : parent_(parent), | 22 : parent_(parent), |
| 23 message_box_view_(new MessageBoxView( | 23 message_box_view_(new MessageBoxView( |
| 24 parent->dialog_flags() | MessageBoxFlags::kAutoDetectAlignment, | 24 parent->dialog_flags() | ui::MessageBoxFlags::kAutoDetectAlignment, |
| 25 parent->message_text(), parent->default_prompt_text())) { | 25 parent->message_text(), parent->default_prompt_text())) { |
| 26 DCHECK(message_box_view_); | 26 DCHECK(message_box_view_); |
| 27 | 27 |
| 28 message_box_view_->AddAccelerator( | 28 message_box_view_->AddAccelerator( |
| 29 views::Accelerator(ui::VKEY_C, false, true, false)); | 29 views::Accelerator(ui::VKEY_C, false, true, false)); |
| 30 if (parent->display_suppress_checkbox()) { | 30 if (parent->display_suppress_checkbox()) { |
| 31 message_box_view_->SetCheckBoxLabel(UTF16ToWide( | 31 message_box_view_->SetCheckBoxLabel(UTF16ToWide( |
| 32 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION))); | 32 l10n_util::GetStringUTF16(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION))); |
| 33 } | 33 } |
| 34 } | 34 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 void JSModalDialogViews::CancelAppModalDialog() { | 63 void JSModalDialogViews::CancelAppModalDialog() { |
| 64 GetDialogClientView()->CancelWindow(); | 64 GetDialogClientView()->CancelWindow(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 ////////////////////////////////////////////////////////////////////////////// | 67 ////////////////////////////////////////////////////////////////////////////// |
| 68 // JSModalDialogViews, views::DialogDelegate implementation: | 68 // JSModalDialogViews, views::DialogDelegate implementation: |
| 69 | 69 |
| 70 int JSModalDialogViews::GetDefaultDialogButton() const { | 70 int JSModalDialogViews::GetDefaultDialogButton() const { |
| 71 if (parent_->dialog_flags() & MessageBoxFlags::kFlagHasOKButton) | 71 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasOKButton) |
| 72 return MessageBoxFlags::DIALOGBUTTON_OK; | 72 return ui::MessageBoxFlags::DIALOGBUTTON_OK; |
| 73 | 73 |
| 74 if (parent_->dialog_flags() & MessageBoxFlags::kFlagHasCancelButton) | 74 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasCancelButton) |
| 75 return MessageBoxFlags::DIALOGBUTTON_CANCEL; | 75 return ui::MessageBoxFlags::DIALOGBUTTON_CANCEL; |
| 76 | 76 |
| 77 return MessageBoxFlags::DIALOGBUTTON_NONE; | 77 return ui::MessageBoxFlags::DIALOGBUTTON_NONE; |
| 78 } | 78 } |
| 79 | 79 |
| 80 int JSModalDialogViews::GetDialogButtons() const { | 80 int JSModalDialogViews::GetDialogButtons() const { |
| 81 int dialog_buttons = 0; | 81 int dialog_buttons = 0; |
| 82 if (parent_->dialog_flags() & MessageBoxFlags::kFlagHasOKButton) | 82 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasOKButton) |
| 83 dialog_buttons = MessageBoxFlags::DIALOGBUTTON_OK; | 83 dialog_buttons = ui::MessageBoxFlags::DIALOGBUTTON_OK; |
| 84 | 84 |
| 85 if (parent_->dialog_flags() & MessageBoxFlags::kFlagHasCancelButton) | 85 if (parent_->dialog_flags() & ui::MessageBoxFlags::kFlagHasCancelButton) |
| 86 dialog_buttons |= MessageBoxFlags::DIALOGBUTTON_CANCEL; | 86 dialog_buttons |= ui::MessageBoxFlags::DIALOGBUTTON_CANCEL; |
| 87 | 87 |
| 88 return dialog_buttons; | 88 return dialog_buttons; |
| 89 } | 89 } |
| 90 | 90 |
| 91 std::wstring JSModalDialogViews::GetWindowTitle() const { | 91 std::wstring JSModalDialogViews::GetWindowTitle() const { |
| 92 return parent_->title(); | 92 return parent_->title(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 | 95 |
| 96 void JSModalDialogViews::WindowClosing() { | 96 void JSModalDialogViews::WindowClosing() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 110 parent_->OnAccept(message_box_view_->GetInputText(), | 110 parent_->OnAccept(message_box_view_->GetInputText(), |
| 111 message_box_view_->IsCheckBoxSelected()); | 111 message_box_view_->IsCheckBoxSelected()); |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| 114 | 114 |
| 115 void JSModalDialogViews::OnClose() { | 115 void JSModalDialogViews::OnClose() { |
| 116 parent_->OnClose(); | 116 parent_->OnClose(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 std::wstring JSModalDialogViews::GetDialogButtonLabel( | 119 std::wstring JSModalDialogViews::GetDialogButtonLabel( |
| 120 MessageBoxFlags::DialogButton button) const { | 120 ui::MessageBoxFlags::DialogButton button) const { |
| 121 if (parent_->is_before_unload_dialog()) { | 121 if (parent_->is_before_unload_dialog()) { |
| 122 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { | 122 if (button == ui::MessageBoxFlags::DIALOGBUTTON_OK) { |
| 123 return UTF16ToWide(l10n_util::GetStringUTF16( | 123 return UTF16ToWide(l10n_util::GetStringUTF16( |
| 124 IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL)); | 124 IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL)); |
| 125 } else if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL) { | 125 } else if (button == ui::MessageBoxFlags::DIALOGBUTTON_CANCEL) { |
| 126 return UTF16ToWide(l10n_util::GetStringUTF16( | 126 return UTF16ToWide(l10n_util::GetStringUTF16( |
| 127 IDS_BEFOREUNLOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL)); | 127 IDS_BEFOREUNLOAD_MESSAGEBOX_CANCEL_BUTTON_LABEL)); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 return DialogDelegate::GetDialogButtonLabel(button); | 130 return DialogDelegate::GetDialogButtonLabel(button); |
| 131 } | 131 } |
| 132 | 132 |
| 133 /////////////////////////////////////////////////////////////////////////////// | 133 /////////////////////////////////////////////////////////////////////////////// |
| 134 // JSModalDialogViews, views::WindowDelegate implementation: | 134 // JSModalDialogViews, views::WindowDelegate implementation: |
| 135 | 135 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 148 | 148 |
| 149 // static | 149 // static |
| 150 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( | 150 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( |
| 151 JavaScriptAppModalDialog* dialog, | 151 JavaScriptAppModalDialog* dialog, |
| 152 gfx::NativeWindow parent_window) { | 152 gfx::NativeWindow parent_window) { |
| 153 JSModalDialogViews* d = new JSModalDialogViews(dialog); | 153 JSModalDialogViews* d = new JSModalDialogViews(dialog); |
| 154 | 154 |
| 155 browser::CreateViewsWindow(parent_window, gfx::Rect(), d); | 155 browser::CreateViewsWindow(parent_window, gfx::Rect(), d); |
| 156 return d; | 156 return d; |
| 157 } | 157 } |
| OLD | NEW |