| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/app_modal/javascript_dialog_manager.h" | 5 #include "components/app_modal/javascript_dialog_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/app_modal/app_modal_dialog.h" | 10 #include "components/app_modal/app_modal_dialog.h" |
| 11 #include "components/app_modal/app_modal_dialog_queue.h" | 11 #include "components/app_modal/app_modal_dialog_queue.h" |
| 12 #include "components/app_modal/javascript_dialog_extensions_client.h" | 12 #include "components/app_modal/javascript_dialog_extensions_client.h" |
| 13 #include "components/app_modal/javascript_native_dialog_factory.h" | 13 #include "components/app_modal/javascript_native_dialog_factory.h" |
| 14 #include "components/app_modal/native_app_modal_dialog.h" | 14 #include "components/app_modal/native_app_modal_dialog.h" |
| 15 #include "components/url_formatter/url_formatter.h" |
| 15 #include "content/public/common/javascript_message_type.h" | 16 #include "content/public/common/javascript_message_type.h" |
| 16 #include "grit/components_strings.h" | 17 #include "grit/components_strings.h" |
| 17 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 | 20 |
| 20 namespace app_modal { | 21 namespace app_modal { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 class DefaultExtensionsClient : public JavaScriptDialogExtensionsClient { | 24 class DefaultExtensionsClient : public JavaScriptDialogExtensionsClient { |
| 24 public: | 25 public: |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 203 } |
| 203 | 204 |
| 204 // For extensions, show the extension name, but only if the origin of | 205 // For extensions, show the extension name, but only if the origin of |
| 205 // the alert matches the top-level WebContents. | 206 // the alert matches the top-level WebContents. |
| 206 std::string name; | 207 std::string name; |
| 207 if (extensions_client_->GetExtensionName(web_contents, origin_url, &name)) | 208 if (extensions_client_->GetExtensionName(web_contents, origin_url, &name)) |
| 208 return base::UTF8ToUTF16(name); | 209 return base::UTF8ToUTF16(name); |
| 209 | 210 |
| 210 // Otherwise, return the formatted URL. | 211 // Otherwise, return the formatted URL. |
| 211 // In this case, force URL to have LTR directionality. | 212 // In this case, force URL to have LTR directionality. |
| 212 base::string16 url_string = net::FormatUrl(origin_url, accept_lang); | 213 base::string16 url_string = url_formatter::FormatUrl(origin_url, accept_lang); |
| 213 return l10n_util::GetStringFUTF16( | 214 return l10n_util::GetStringFUTF16( |
| 214 is_alert ? IDS_JAVASCRIPT_ALERT_TITLE | 215 is_alert ? IDS_JAVASCRIPT_ALERT_TITLE |
| 215 : IDS_JAVASCRIPT_MESSAGEBOX_TITLE, | 216 : IDS_JAVASCRIPT_MESSAGEBOX_TITLE, |
| 216 base::i18n::GetDisplayStringInLTRDirectionality(url_string)); | 217 base::i18n::GetDisplayStringInLTRDirectionality(url_string)); |
| 217 } | 218 } |
| 218 | 219 |
| 219 void JavaScriptDialogManager::CancelActiveAndPendingDialogs( | 220 void JavaScriptDialogManager::CancelActiveAndPendingDialogs( |
| 220 content::WebContents* web_contents) { | 221 content::WebContents* web_contents) { |
| 221 AppModalDialogQueue* queue = AppModalDialogQueue::GetInstance(); | 222 AppModalDialogQueue* queue = AppModalDialogQueue::GetInstance(); |
| 222 AppModalDialog* active_dialog = queue->active_dialog(); | 223 AppModalDialog* active_dialog = queue->active_dialog(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 236 const base::string16& user_input) { | 237 const base::string16& user_input) { |
| 237 // If an extension opened this dialog then the extension may shut down its | 238 // If an extension opened this dialog then the extension may shut down its |
| 238 // lazy background page after the dialog closes. (Dialogs are closed before | 239 // lazy background page after the dialog closes. (Dialogs are closed before |
| 239 // their WebContents is destroyed so |web_contents| is still valid here.) | 240 // their WebContents is destroyed so |web_contents| is still valid here.) |
| 240 extensions_client_->OnDialogClosed(web_contents); | 241 extensions_client_->OnDialogClosed(web_contents); |
| 241 | 242 |
| 242 callback.Run(success, user_input); | 243 callback.Run(success, user_input); |
| 243 } | 244 } |
| 244 | 245 |
| 245 } // namespace app_modal | 246 } // namespace app_modal |
| OLD | NEW |