| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/javascript_dialog_manager.h" | 5 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 void ChromeJavaScriptDialogManager::RunBeforeUnloadDialog( | 202 void ChromeJavaScriptDialogManager::RunBeforeUnloadDialog( |
| 203 WebContents* web_contents, | 203 WebContents* web_contents, |
| 204 const base::string16& message_text, | 204 const base::string16& message_text, |
| 205 bool is_reload, | 205 bool is_reload, |
| 206 const DialogClosedCallback& callback) { | 206 const DialogClosedCallback& callback) { |
| 207 const base::string16 title = l10n_util::GetStringUTF16(is_reload ? | 207 const base::string16 title = l10n_util::GetStringUTF16(is_reload ? |
| 208 IDS_BEFORERELOAD_MESSAGEBOX_TITLE : IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE); | 208 IDS_BEFORERELOAD_MESSAGEBOX_TITLE : IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE); |
| 209 const base::string16 footer = l10n_util::GetStringUTF16(is_reload ? | 209 const base::string16 footer = l10n_util::GetStringUTF16(is_reload ? |
| 210 IDS_BEFORERELOAD_MESSAGEBOX_FOOTER : IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); | 210 IDS_BEFORERELOAD_MESSAGEBOX_FOOTER : IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); |
| 211 | 211 |
| 212 base::string16 full_message = message_text + ASCIIToUTF16("\n\n") + footer; | 212 base::string16 full_message = |
| 213 message_text + base::ASCIIToUTF16("\n\n") + footer; |
| 213 | 214 |
| 214 const Extension* extension = GetExtensionForWebContents(web_contents); | 215 const Extension* extension = GetExtensionForWebContents(web_contents); |
| 215 if (extension) | 216 if (extension) |
| 216 IncrementLazyKeepaliveCount(extension, web_contents); | 217 IncrementLazyKeepaliveCount(extension, web_contents); |
| 217 | 218 |
| 218 AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( | 219 AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( |
| 219 web_contents, | 220 web_contents, |
| 220 &javascript_dialog_extra_data_, | 221 &javascript_dialog_extra_data_, |
| 221 title, | 222 title, |
| 222 content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, | 223 content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 bool is_alert) { | 265 bool is_alert) { |
| 265 // If the URL hasn't any host, return the default string. | 266 // If the URL hasn't any host, return the default string. |
| 266 if (!origin_url.has_host()) { | 267 if (!origin_url.has_host()) { |
| 267 return l10n_util::GetStringUTF16( | 268 return l10n_util::GetStringUTF16( |
| 268 is_alert ? IDS_JAVASCRIPT_ALERT_DEFAULT_TITLE | 269 is_alert ? IDS_JAVASCRIPT_ALERT_DEFAULT_TITLE |
| 269 : IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); | 270 : IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); |
| 270 } | 271 } |
| 271 | 272 |
| 272 const Extension* extension = GetExtensionForWebContents(web_contents); | 273 const Extension* extension = GetExtensionForWebContents(web_contents); |
| 273 if (extension) | 274 if (extension) |
| 274 return UTF8ToUTF16(extension->name()); | 275 return base::UTF8ToUTF16(extension->name()); |
| 275 | 276 |
| 276 // Otherwise, return the formatted URL. | 277 // Otherwise, return the formatted URL. |
| 277 // In this case, force URL to have LTR directionality. | 278 // In this case, force URL to have LTR directionality. |
| 278 base::string16 url_string = net::FormatUrl(origin_url, accept_lang); | 279 base::string16 url_string = net::FormatUrl(origin_url, accept_lang); |
| 279 return l10n_util::GetStringFUTF16( | 280 return l10n_util::GetStringFUTF16( |
| 280 is_alert ? IDS_JAVASCRIPT_ALERT_TITLE | 281 is_alert ? IDS_JAVASCRIPT_ALERT_TITLE |
| 281 : IDS_JAVASCRIPT_MESSAGEBOX_TITLE, | 282 : IDS_JAVASCRIPT_MESSAGEBOX_TITLE, |
| 282 base::i18n::GetDisplayStringInLTRDirectionality(url_string)); | 283 base::i18n::GetDisplayStringInLTRDirectionality(url_string)); |
| 283 } | 284 } |
| 284 | 285 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 308 DecrementLazyKeepaliveCount(extension, web_contents); | 309 DecrementLazyKeepaliveCount(extension, web_contents); |
| 309 | 310 |
| 310 callback.Run(success, user_input); | 311 callback.Run(success, user_input); |
| 311 } | 312 } |
| 312 | 313 |
| 313 } // namespace | 314 } // namespace |
| 314 | 315 |
| 315 content::JavaScriptDialogManager* GetJavaScriptDialogManagerInstance() { | 316 content::JavaScriptDialogManager* GetJavaScriptDialogManagerInstance() { |
| 316 return ChromeJavaScriptDialogManager::GetInstance(); | 317 return ChromeJavaScriptDialogManager::GetInstance(); |
| 317 } | 318 } |
| OLD | NEW |