| 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/app_modal_dialogs/message_box_handler.h" | 5 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/i18n/rtl.h" |
| 10 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 12 #include "base/i18n/rtl.h" | |
| 13 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 13 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
| 14 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" | 14 #include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" |
| 15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 16 #include "content/browser/javascript_dialogs.h" | 16 #include "content/browser/javascript_dialogs.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/message_box_flags.h" | 19 #include "ui/base/message_box_flags.h" |
| 20 | 20 |
| 21 class ChromeJavaScriptDialogCreator : public content::JavaScriptDialogCreator { | 21 class ChromeJavaScriptDialogCreator : public content::JavaScriptDialogCreator { |
| 22 public: | 22 public: |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 extra_data->last_javascript_message_dismissal_; | 94 extra_data->last_javascript_message_dismissal_; |
| 95 bool display_suppress_checkbox = false; | 95 bool display_suppress_checkbox = false; |
| 96 // Show a checkbox offering to suppress further messages if this message is | 96 // Show a checkbox offering to suppress further messages if this message is |
| 97 // being displayed within kJavascriptMessageExpectedDelay of the last one. | 97 // being displayed within kJavascriptMessageExpectedDelay of the last one. |
| 98 if (time_since_last_message < | 98 if (time_since_last_message < |
| 99 base::TimeDelta::FromMilliseconds( | 99 base::TimeDelta::FromMilliseconds( |
| 100 chrome::kJavascriptMessageExpectedDelay)) { | 100 chrome::kJavascriptMessageExpectedDelay)) { |
| 101 display_suppress_checkbox = true; | 101 display_suppress_checkbox = true; |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool is_alert = dialog_flags == ui::MessageBoxFlags::kIsJavascriptAlert; | 104 bool is_alert = dialog_flags == ui::MESSAGE_BOX_IS_JAVASCRIPT_ALERT_DIALOG; |
| 105 string16 dialog_title = GetTitle(title_type, title, is_alert); | 105 string16 dialog_title = GetTitle(title_type, title, is_alert); |
| 106 | 106 |
| 107 AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( | 107 AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( |
| 108 delegate, | 108 delegate, |
| 109 extra_data, | 109 extra_data, |
| 110 dialog_title, | 110 dialog_title, |
| 111 dialog_flags, | 111 dialog_flags, |
| 112 message_text, | 112 message_text, |
| 113 default_prompt_text, | 113 default_prompt_text, |
| 114 display_suppress_checkbox, | 114 display_suppress_checkbox, |
| 115 false, // is_before_unload_dialog | 115 false, // is_before_unload_dialog |
| 116 reply_message)); | 116 reply_message)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void ChromeJavaScriptDialogCreator::RunBeforeUnloadDialog( | 119 void ChromeJavaScriptDialogCreator::RunBeforeUnloadDialog( |
| 120 content::JavaScriptDialogDelegate* delegate, | 120 content::JavaScriptDialogDelegate* delegate, |
| 121 const string16& message_text, | 121 const string16& message_text, |
| 122 IPC::Message* reply_message) { | 122 IPC::Message* reply_message) { |
| 123 ChromeJavaScriptDialogExtraData* extra_data = | 123 ChromeJavaScriptDialogExtraData* extra_data = |
| 124 &javascript_dialog_extra_data_[delegate]; | 124 &javascript_dialog_extra_data_[delegate]; |
| 125 | 125 |
| 126 string16 full_message = message_text + ASCIIToUTF16("\n\n") + | 126 string16 full_message = message_text + ASCIIToUTF16("\n\n") + |
| 127 l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); | 127 l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); |
| 128 | 128 |
| 129 AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( | 129 AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( |
| 130 delegate, | 130 delegate, |
| 131 extra_data, | 131 extra_data, |
| 132 l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE), | 132 l10n_util::GetStringUTF16(IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE), |
| 133 ui::MessageBoxFlags::kIsJavascriptConfirm, | 133 ui::MESSAGE_BOX_IS_JAVASCRIPT_CONFIRM_DIALOG, |
| 134 full_message, | 134 full_message, |
| 135 string16(), // default_prompt_text | 135 string16(), // default_prompt_text |
| 136 false, // display_suppress_checkbox | 136 false, // display_suppress_checkbox |
| 137 true, // is_before_unload_dialog | 137 true, // is_before_unload_dialog |
| 138 reply_message)); | 138 reply_message)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void ChromeJavaScriptDialogCreator::ResetJavaScriptState( | 141 void ChromeJavaScriptDialogCreator::ResetJavaScriptState( |
| 142 content::JavaScriptDialogDelegate* delegate) { | 142 content::JavaScriptDialogDelegate* delegate) { |
| 143 CancelPendingDialogs(delegate); | 143 CancelPendingDialogs(delegate); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 if ((*i)->delegate() == delegate) | 182 if ((*i)->delegate() == delegate) |
| 183 (*i)->Invalidate(); | 183 (*i)->Invalidate(); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 //------------------------------------------------------------------------------ | 187 //------------------------------------------------------------------------------ |
| 188 | 188 |
| 189 content::JavaScriptDialogCreator* GetJavaScriptDialogCreatorInstance() { | 189 content::JavaScriptDialogCreator* GetJavaScriptDialogCreatorInstance() { |
| 190 return ChromeJavaScriptDialogCreator::GetInstance(); | 190 return ChromeJavaScriptDialogCreator::GetInstance(); |
| 191 } | 191 } |
| OLD | NEW |