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