| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/jsmessage_box_dialog.h" | 5 #include "chrome/browser/views/jsmessage_box_dialog.h" |
| 6 | 6 |
| 7 #include "chrome/browser/app_modal_dialog.h" | 7 #include "chrome/browser/app_modal_dialog.h" |
| 8 #include "chrome/browser/tab_contents/web_contents.h" | 8 #include "chrome/browser/tab_contents/web_contents.h" |
| 9 #include "chrome/common/l10n_util.h" | 9 #include "chrome/common/l10n_util.h" |
| 10 #include "chrome/common/message_box_flags.h" | 10 #include "chrome/common/message_box_flags.h" |
| 11 #include "chrome/views/controls/message_box_view.h" | 11 #include "chrome/views/controls/message_box_view.h" |
| 12 #include "chrome/views/window/window.h" | 12 #include "chrome/views/window/window.h" |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 | 14 |
| 15 JavascriptMessageBoxDialog::JavascriptMessageBoxDialog( | 15 JavascriptMessageBoxDialog::JavascriptMessageBoxDialog( |
| 16 AppModalDialog* parent, | 16 AppModalDialog* parent, |
| 17 const std::wstring& message_text, | 17 const std::wstring& message_text, |
| 18 const std::wstring& default_prompt_text, | 18 const std::wstring& default_prompt_text, |
| 19 bool display_suppress_checkbox) | 19 bool display_suppress_checkbox) |
| 20 : parent_(parent), | 20 : parent_(parent), |
| 21 dialog_(NULL), | 21 dialog_(NULL), |
| 22 message_box_view_(new MessageBoxView( | 22 message_box_view_(new MessageBoxView( |
| 23 parent->dialog_flags() | MessageBoxFlags::kAutoDetectAlignment, | 23 parent->dialog_flags() | MessageBoxFlags::kAutoDetectAlignment, |
| 24 message_text, default_prompt_text)) { | 24 message_text, default_prompt_text)) { |
| 25 DCHECK(message_box_view_); | 25 DCHECK(message_box_view_); |
| 26 | 26 |
| 27 message_box_view_->AddAccelerator( |
| 28 views::Accelerator('C', false, true, false)); |
| 27 if (display_suppress_checkbox) { | 29 if (display_suppress_checkbox) { |
| 28 message_box_view_->SetCheckBoxLabel( | 30 message_box_view_->SetCheckBoxLabel( |
| 29 l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION)); | 31 l10n_util::GetString(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION)); |
| 30 } | 32 } |
| 31 } | 33 } |
| 32 | 34 |
| 33 JavascriptMessageBoxDialog::~JavascriptMessageBoxDialog() { | 35 JavascriptMessageBoxDialog::~JavascriptMessageBoxDialog() { |
| 34 } | 36 } |
| 35 | 37 |
| 36 void JavascriptMessageBoxDialog::ShowModalDialog() { | 38 void JavascriptMessageBoxDialog::ShowModalDialog() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 delete parent_; | 84 delete parent_; |
| 83 delete this; | 85 delete this; |
| 84 } | 86 } |
| 85 | 87 |
| 86 bool JavascriptMessageBoxDialog::Cancel() { | 88 bool JavascriptMessageBoxDialog::Cancel() { |
| 87 parent_->OnCancel(); | 89 parent_->OnCancel(); |
| 88 return true; | 90 return true; |
| 89 } | 91 } |
| 90 | 92 |
| 91 bool JavascriptMessageBoxDialog::Accept() { | 93 bool JavascriptMessageBoxDialog::Accept() { |
| 92 | |
| 93 parent_->OnAccept(message_box_view_->GetInputText(), | 94 parent_->OnAccept(message_box_view_->GetInputText(), |
| 94 message_box_view_->IsCheckBoxSelected()); | 95 message_box_view_->IsCheckBoxSelected()); |
| 95 return true; | 96 return true; |
| 96 } | 97 } |
| 97 | 98 |
| 98 std::wstring JavascriptMessageBoxDialog::GetDialogButtonLabel( | 99 std::wstring JavascriptMessageBoxDialog::GetDialogButtonLabel( |
| 99 MessageBoxFlags::DialogButton button) const { | 100 MessageBoxFlags::DialogButton button) const { |
| 100 if (parent_->is_before_unload_dialog()) { | 101 if (parent_->is_before_unload_dialog()) { |
| 101 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { | 102 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { |
| 102 return l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL); | 103 return l10n_util::GetString(IDS_BEFOREUNLOAD_MESSAGEBOX_OK_BUTTON_LABEL); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 113 | 114 |
| 114 views::View* JavascriptMessageBoxDialog::GetContentsView() { | 115 views::View* JavascriptMessageBoxDialog::GetContentsView() { |
| 115 return message_box_view_; | 116 return message_box_view_; |
| 116 } | 117 } |
| 117 | 118 |
| 118 views::View* JavascriptMessageBoxDialog::GetInitiallyFocusedView() { | 119 views::View* JavascriptMessageBoxDialog::GetInitiallyFocusedView() { |
| 119 if (message_box_view_->text_box()) | 120 if (message_box_view_->text_box()) |
| 120 return message_box_view_->text_box(); | 121 return message_box_view_->text_box(); |
| 121 return views::DialogDelegate::GetInitiallyFocusedView(); | 122 return views::DialogDelegate::GetInitiallyFocusedView(); |
| 122 } | 123 } |
| OLD | NEW |