| 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 "components/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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "components/app_modal_dialogs/app_modal_dialog.h" | 12 #include "components/app_modal_dialogs/app_modal_dialog.h" |
| 13 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" | 13 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" |
| 14 #include "components/app_modal_dialogs/javascript_app_modal_dialog.h" | 14 #include "components/app_modal_dialogs/javascript_app_modal_dialog.h" |
| 15 #include "components/app_modal_dialogs/javascript_dialog_manager_client.h" |
| 15 #include "components/app_modal_dialogs/native_app_modal_dialog.h" | 16 #include "components/app_modal_dialogs/native_app_modal_dialog.h" |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/common/content_client.h" | 18 #include "content/public/common/content_client.h" |
| 18 #include "content/public/common/javascript_message_type.h" | 19 #include "content/public/common/javascript_message_type.h" |
| 19 #include "grit/components_strings.h" | 20 #include "grit/components_strings.h" |
| 20 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 22 | 23 |
| 23 #if defined(ENABLE_EXTENSIONS) | |
| 24 #include "extensions/browser/process_manager.h" | |
| 25 #include "extensions/common/extension.h" | |
| 26 #endif // defined(ENABLE_EXTENSIONS) | |
| 27 | |
| 28 using content::BrowserContext; | 24 using content::BrowserContext; |
| 29 using content::JavaScriptDialogManager; | 25 using content::JavaScriptDialogManager; |
| 30 using content::WebContents; | 26 using content::WebContents; |
| 31 | 27 |
| 32 #if defined(ENABLE_EXTENSIONS) | |
| 33 using extensions::Extension; | |
| 34 #endif // defined(ENABLE_EXTENSIONS) | |
| 35 | |
| 36 namespace { | 28 namespace { |
| 37 | 29 |
| 38 #if defined(ENABLE_EXTENSIONS) | 30 class JavaScriptDialogManagerImpl : public JavaScriptDialogManager { |
| 39 // Returns the ProcessManager for the browser context from |web_contents|. | |
| 40 extensions::ProcessManager* GetExtensionsProcessManager( | |
| 41 WebContents* web_contents) { | |
| 42 return extensions::ProcessManager::Get(web_contents->GetBrowserContext()); | |
| 43 } | |
| 44 | |
| 45 // Returns the extension associated with |web_contents| or NULL if there is no | |
| 46 // associated extension (or extensions are not supported). | |
| 47 const Extension* GetExtensionForWebContents(WebContents* web_contents) { | |
| 48 extensions::ProcessManager* pm = GetExtensionsProcessManager(web_contents); | |
| 49 return pm->GetExtensionForRenderViewHost(web_contents->GetRenderViewHost()); | |
| 50 } | |
| 51 #endif // defined(ENABLE_EXTENSIONS) | |
| 52 | |
| 53 // Keeps an |extension| from shutting down its lazy background page. If an | |
| 54 // extension opens a dialog its lazy background page must stay alive until the | |
| 55 // dialog closes. | |
| 56 void IncrementLazyKeepaliveCount(WebContents* web_contents) { | |
| 57 #if defined(ENABLE_EXTENSIONS) | |
| 58 const Extension* extension = GetExtensionForWebContents(web_contents); | |
| 59 if (extension == NULL) | |
| 60 return; | |
| 61 | |
| 62 DCHECK(web_contents); | |
| 63 extensions::ProcessManager* pm = GetExtensionsProcessManager(web_contents); | |
| 64 if (pm) | |
| 65 pm->IncrementLazyKeepaliveCount(extension); | |
| 66 #endif // defined(ENABLE_EXTENSIONS) | |
| 67 } | |
| 68 | |
| 69 // Allows an |extension| to shut down its lazy background page after a dialog | |
| 70 // closes (if nothing else is keeping it open). | |
| 71 void DecrementLazyKeepaliveCount(WebContents* web_contents) { | |
| 72 #if defined(ENABLE_EXTENSIONS) | |
| 73 const Extension* extension = GetExtensionForWebContents(web_contents); | |
| 74 if (extension == NULL) | |
| 75 return; | |
| 76 | |
| 77 DCHECK(web_contents); | |
| 78 extensions::ProcessManager* pm = GetExtensionsProcessManager(web_contents); | |
| 79 if (pm) | |
| 80 pm->DecrementLazyKeepaliveCount(extension); | |
| 81 #endif // defined(ENABLE_EXTENSIONS) | |
| 82 } | |
| 83 | |
| 84 class ChromeJavaScriptDialogManager : public JavaScriptDialogManager { | |
| 85 public: | 31 public: |
| 86 static ChromeJavaScriptDialogManager* GetInstance(); | 32 static JavaScriptDialogManagerImpl* GetInstance(); |
| 87 | 33 |
| 88 void RunJavaScriptDialog(WebContents* web_contents, | 34 void RunJavaScriptDialog(WebContents* web_contents, |
| 89 const GURL& origin_url, | 35 const GURL& origin_url, |
| 90 const std::string& accept_lang, | 36 const std::string& accept_lang, |
| 91 content::JavaScriptMessageType message_type, | 37 content::JavaScriptMessageType message_type, |
| 92 const base::string16& message_text, | 38 const base::string16& message_text, |
| 93 const base::string16& default_prompt_text, | 39 const base::string16& default_prompt_text, |
| 94 const DialogClosedCallback& callback, | 40 const DialogClosedCallback& callback, |
| 95 bool* did_suppress_message) override; | 41 bool* did_suppress_message) override; |
| 96 | 42 |
| 97 void RunBeforeUnloadDialog(WebContents* web_contents, | 43 void RunBeforeUnloadDialog(WebContents* web_contents, |
| 98 const base::string16& message_text, | 44 const base::string16& message_text, |
| 99 bool is_reload, | 45 bool is_reload, |
| 100 const DialogClosedCallback& callback) override; | 46 const DialogClosedCallback& callback) override; |
| 101 | 47 |
| 102 bool HandleJavaScriptDialog(WebContents* web_contents, | 48 bool HandleJavaScriptDialog(WebContents* web_contents, |
| 103 bool accept, | 49 bool accept, |
| 104 const base::string16* prompt_override) override; | 50 const base::string16* prompt_override) override; |
| 105 | 51 |
| 106 void CancelActiveAndPendingDialogs(WebContents* web_contents) override; | 52 void CancelActiveAndPendingDialogs(WebContents* web_contents) override; |
| 107 | 53 |
| 108 void WebContentsDestroyed(WebContents* web_contents) override; | 54 void WebContentsDestroyed(WebContents* web_contents) override; |
| 109 | 55 |
| 110 private: | 56 private: |
| 111 friend struct DefaultSingletonTraits<ChromeJavaScriptDialogManager>; | 57 friend struct DefaultSingletonTraits<JavaScriptDialogManagerImpl>; |
| 112 | 58 |
| 113 ChromeJavaScriptDialogManager(); | 59 JavaScriptDialogManagerImpl(); |
| 114 ~ChromeJavaScriptDialogManager() override; | 60 ~JavaScriptDialogManagerImpl() override; |
| 115 | 61 |
| 116 base::string16 GetTitle(WebContents* web_contents, | 62 base::string16 GetTitle(WebContents* web_contents, |
| 117 const GURL& origin_url, | 63 const GURL& origin_url, |
| 118 const std::string& accept_lang, | 64 const std::string& accept_lang, |
| 119 bool is_alert); | 65 bool is_alert); |
| 120 | 66 |
| 121 // Wrapper around a DialogClosedCallback so that we can intercept it before | 67 // Wrapper around a DialogClosedCallback so that we can intercept it before |
| 122 // passing it onto the original callback. | 68 // passing it onto the original callback. |
| 123 void OnDialogClosed(WebContents* web_contents, | 69 void OnDialogClosed(WebContents* web_contents, |
| 124 DialogClosedCallback callback, | 70 DialogClosedCallback callback, |
| 125 bool success, | 71 bool success, |
| 126 const base::string16& user_input); | 72 const base::string16& user_input); |
| 127 | 73 |
| 128 // Mapping between the WebContents and their extra data. The key | 74 // Mapping between the WebContents and their extra data. The key |
| 129 // is a void* because the pointer is just a cookie and is never dereferenced. | 75 // is a void* because the pointer is just a cookie and is never dereferenced. |
| 130 JavaScriptAppModalDialog::ExtraDataMap javascript_dialog_extra_data_; | 76 JavaScriptAppModalDialog::ExtraDataMap javascript_dialog_extra_data_; |
| 131 | 77 |
| 132 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptDialogManager); | 78 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogManagerImpl); |
| 133 }; | 79 }; |
| 134 | 80 |
| 135 //////////////////////////////////////////////////////////////////////////////// | 81 //////////////////////////////////////////////////////////////////////////////// |
| 136 // ChromeJavaScriptDialogManager, public: | 82 // JavaScriptDialogManagerImpl, public: |
| 137 | 83 |
| 138 ChromeJavaScriptDialogManager::ChromeJavaScriptDialogManager() { | 84 JavaScriptDialogManagerImpl::JavaScriptDialogManagerImpl() { |
| 139 } | 85 } |
| 140 | 86 |
| 141 ChromeJavaScriptDialogManager::~ChromeJavaScriptDialogManager() { | 87 JavaScriptDialogManagerImpl::~JavaScriptDialogManagerImpl() { |
| 142 } | 88 } |
| 143 | 89 |
| 144 // static | 90 // static |
| 145 ChromeJavaScriptDialogManager* ChromeJavaScriptDialogManager::GetInstance() { | 91 JavaScriptDialogManagerImpl* JavaScriptDialogManagerImpl::GetInstance() { |
| 146 return Singleton<ChromeJavaScriptDialogManager>::get(); | 92 return Singleton<JavaScriptDialogManagerImpl>::get(); |
| 147 } | 93 } |
| 148 | 94 |
| 149 void ChromeJavaScriptDialogManager::RunJavaScriptDialog( | 95 void JavaScriptDialogManagerImpl::RunJavaScriptDialog( |
| 150 WebContents* web_contents, | 96 WebContents* web_contents, |
| 151 const GURL& origin_url, | 97 const GURL& origin_url, |
| 152 const std::string& accept_lang, | 98 const std::string& accept_lang, |
| 153 content::JavaScriptMessageType message_type, | 99 content::JavaScriptMessageType message_type, |
| 154 const base::string16& message_text, | 100 const base::string16& message_text, |
| 155 const base::string16& default_prompt_text, | 101 const base::string16& default_prompt_text, |
| 156 const DialogClosedCallback& callback, | 102 const DialogClosedCallback& callback, |
| 157 bool* did_suppress_message) { | 103 bool* did_suppress_message) { |
| 158 *did_suppress_message = false; | 104 *did_suppress_message = false; |
| 159 | 105 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 178 base::TimeDelta::FromMilliseconds(kJavaScriptMessageExpectedDelay)) { | 124 base::TimeDelta::FromMilliseconds(kJavaScriptMessageExpectedDelay)) { |
| 179 display_suppress_checkbox = true; | 125 display_suppress_checkbox = true; |
| 180 } else { | 126 } else { |
| 181 display_suppress_checkbox = false; | 127 display_suppress_checkbox = false; |
| 182 } | 128 } |
| 183 | 129 |
| 184 bool is_alert = message_type == content::JAVASCRIPT_MESSAGE_TYPE_ALERT; | 130 bool is_alert = message_type == content::JAVASCRIPT_MESSAGE_TYPE_ALERT; |
| 185 base::string16 dialog_title = | 131 base::string16 dialog_title = |
| 186 GetTitle(web_contents, origin_url, accept_lang, is_alert); | 132 GetTitle(web_contents, origin_url, accept_lang, is_alert); |
| 187 | 133 |
| 188 IncrementLazyKeepaliveCount(web_contents); | 134 GetJavaScriptDialogManagerClient()->IncrementLazyKeepaliveCount(web_contents); |
| 189 | 135 |
| 190 AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( | 136 AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( |
| 191 web_contents, | 137 web_contents, |
| 192 &javascript_dialog_extra_data_, | 138 &javascript_dialog_extra_data_, |
| 193 dialog_title, | 139 dialog_title, |
| 194 message_type, | 140 message_type, |
| 195 message_text, | 141 message_text, |
| 196 default_prompt_text, | 142 default_prompt_text, |
| 197 display_suppress_checkbox, | 143 display_suppress_checkbox, |
| 198 false, // is_before_unload_dialog | 144 false, // is_before_unload_dialog |
| 199 false, // is_reload | 145 false, // is_reload |
| 200 base::Bind(&ChromeJavaScriptDialogManager::OnDialogClosed, | 146 base::Bind(&JavaScriptDialogManagerImpl::OnDialogClosed, |
| 201 base::Unretained(this), web_contents, callback))); | 147 base::Unretained(this), web_contents, callback))); |
| 202 } | 148 } |
| 203 | 149 |
| 204 void ChromeJavaScriptDialogManager::RunBeforeUnloadDialog( | 150 void JavaScriptDialogManagerImpl::RunBeforeUnloadDialog( |
| 205 WebContents* web_contents, | 151 WebContents* web_contents, |
| 206 const base::string16& message_text, | 152 const base::string16& message_text, |
| 207 bool is_reload, | 153 bool is_reload, |
| 208 const DialogClosedCallback& callback) { | 154 const DialogClosedCallback& callback) { |
| 209 const base::string16 title = l10n_util::GetStringUTF16(is_reload ? | 155 const base::string16 title = l10n_util::GetStringUTF16(is_reload ? |
| 210 IDS_BEFORERELOAD_MESSAGEBOX_TITLE : IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE); | 156 IDS_BEFORERELOAD_MESSAGEBOX_TITLE : IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE); |
| 211 const base::string16 footer = l10n_util::GetStringUTF16(is_reload ? | 157 const base::string16 footer = l10n_util::GetStringUTF16(is_reload ? |
| 212 IDS_BEFORERELOAD_MESSAGEBOX_FOOTER : IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); | 158 IDS_BEFORERELOAD_MESSAGEBOX_FOOTER : IDS_BEFOREUNLOAD_MESSAGEBOX_FOOTER); |
| 213 | 159 |
| 214 base::string16 full_message = | 160 base::string16 full_message = |
| 215 message_text + base::ASCIIToUTF16("\n\n") + footer; | 161 message_text + base::ASCIIToUTF16("\n\n") + footer; |
| 216 | 162 |
| 217 IncrementLazyKeepaliveCount(web_contents); | 163 GetJavaScriptDialogManagerClient()->IncrementLazyKeepaliveCount(web_contents); |
| 218 | 164 |
| 219 AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( | 165 AppModalDialogQueue::GetInstance()->AddDialog(new JavaScriptAppModalDialog( |
| 220 web_contents, | 166 web_contents, |
| 221 &javascript_dialog_extra_data_, | 167 &javascript_dialog_extra_data_, |
| 222 title, | 168 title, |
| 223 content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, | 169 content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, |
| 224 full_message, | 170 full_message, |
| 225 base::string16(), // default_prompt_text | 171 base::string16(), // default_prompt_text |
| 226 false, // display_suppress_checkbox | 172 false, // display_suppress_checkbox |
| 227 true, // is_before_unload_dialog | 173 true, // is_before_unload_dialog |
| 228 is_reload, | 174 is_reload, |
| 229 base::Bind(&ChromeJavaScriptDialogManager::OnDialogClosed, | 175 base::Bind(&JavaScriptDialogManagerImpl::OnDialogClosed, |
| 230 base::Unretained(this), web_contents, callback))); | 176 base::Unretained(this), web_contents, callback))); |
| 231 } | 177 } |
| 232 | 178 |
| 233 bool ChromeJavaScriptDialogManager::HandleJavaScriptDialog( | 179 bool JavaScriptDialogManagerImpl::HandleJavaScriptDialog( |
| 234 WebContents* web_contents, | 180 WebContents* web_contents, |
| 235 bool accept, | 181 bool accept, |
| 236 const base::string16* prompt_override) { | 182 const base::string16* prompt_override) { |
| 237 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 183 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
| 238 if (!dialog_queue->HasActiveDialog() || | 184 if (!dialog_queue->HasActiveDialog() || |
| 239 !dialog_queue->active_dialog()->IsJavaScriptModalDialog() || | 185 !dialog_queue->active_dialog()->IsJavaScriptModalDialog() || |
| 240 dialog_queue->active_dialog()->web_contents() != web_contents) { | 186 dialog_queue->active_dialog()->web_contents() != web_contents) { |
| 241 return false; | 187 return false; |
| 242 } | 188 } |
| 243 JavaScriptAppModalDialog* dialog = static_cast<JavaScriptAppModalDialog*>( | 189 JavaScriptAppModalDialog* dialog = static_cast<JavaScriptAppModalDialog*>( |
| 244 dialog_queue->active_dialog()); | 190 dialog_queue->active_dialog()); |
| 245 if (accept) { | 191 if (accept) { |
| 246 if (prompt_override) | 192 if (prompt_override) |
| 247 dialog->SetOverridePromptText(*prompt_override); | 193 dialog->SetOverridePromptText(*prompt_override); |
| 248 dialog->native_dialog()->AcceptAppModalDialog(); | 194 dialog->native_dialog()->AcceptAppModalDialog(); |
| 249 } else { | 195 } else { |
| 250 dialog->native_dialog()->CancelAppModalDialog(); | 196 dialog->native_dialog()->CancelAppModalDialog(); |
| 251 } | 197 } |
| 252 return true; | 198 return true; |
| 253 } | 199 } |
| 254 | 200 |
| 255 void ChromeJavaScriptDialogManager::WebContentsDestroyed( | 201 void JavaScriptDialogManagerImpl::WebContentsDestroyed( |
| 256 WebContents* web_contents) { | 202 WebContents* web_contents) { |
| 257 CancelActiveAndPendingDialogs(web_contents); | 203 CancelActiveAndPendingDialogs(web_contents); |
| 258 javascript_dialog_extra_data_.erase(web_contents); | 204 javascript_dialog_extra_data_.erase(web_contents); |
| 259 } | 205 } |
| 260 | 206 |
| 261 base::string16 ChromeJavaScriptDialogManager::GetTitle( | 207 base::string16 JavaScriptDialogManagerImpl::GetTitle( |
| 262 WebContents* web_contents, | 208 WebContents* web_contents, |
| 263 const GURL& origin_url, | 209 const GURL& origin_url, |
| 264 const std::string& accept_lang, | 210 const std::string& accept_lang, |
| 265 bool is_alert) { | 211 bool is_alert) { |
| 266 // If the URL hasn't any host, return the default string. | 212 // If the URL hasn't any host, return the default string. |
| 267 if (!origin_url.has_host()) { | 213 if (!origin_url.has_host()) { |
| 268 return l10n_util::GetStringUTF16( | 214 return l10n_util::GetStringUTF16( |
| 269 is_alert ? IDS_JAVASCRIPT_ALERT_DEFAULT_TITLE | 215 is_alert ? IDS_JAVASCRIPT_ALERT_DEFAULT_TITLE |
| 270 : IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); | 216 : IDS_JAVASCRIPT_MESSAGEBOX_DEFAULT_TITLE); |
| 271 } | 217 } |
| 272 | 218 |
| 273 // For extensions, show the extension name, but only if the origin of | 219 // For extensions, show the extension name, but only if the origin of |
| 274 // the alert matches the top-level WebContents. | 220 // the alert matches the top-level WebContents. |
| 275 #if defined(ENABLE_EXTENSIONS) | 221 std::string name; |
| 276 const Extension* extension = GetExtensionForWebContents(web_contents); | 222 if (GetJavaScriptDialogManagerClient() |
| 277 if (extension && | 223 ->GetExtensionName(web_contents, origin_url, &name)) { |
| 278 web_contents->GetLastCommittedURL().GetOrigin() == origin_url) { | 224 return base::UTF8ToUTF16(name); |
| 279 return base::UTF8ToUTF16(extension->name()); | |
| 280 } | 225 } |
| 281 #endif // defined(ENABLE_EXTENSIONS) | |
| 282 | 226 |
| 283 // Otherwise, return the formatted URL. | 227 // Otherwise, return the formatted URL. |
| 284 // In this case, force URL to have LTR directionality. | 228 // In this case, force URL to have LTR directionality. |
| 285 base::string16 url_string = net::FormatUrl(origin_url, accept_lang); | 229 base::string16 url_string = net::FormatUrl(origin_url, accept_lang); |
| 286 return l10n_util::GetStringFUTF16( | 230 return l10n_util::GetStringFUTF16( |
| 287 is_alert ? IDS_JAVASCRIPT_ALERT_TITLE | 231 is_alert ? IDS_JAVASCRIPT_ALERT_TITLE |
| 288 : IDS_JAVASCRIPT_MESSAGEBOX_TITLE, | 232 : IDS_JAVASCRIPT_MESSAGEBOX_TITLE, |
| 289 base::i18n::GetDisplayStringInLTRDirectionality(url_string)); | 233 base::i18n::GetDisplayStringInLTRDirectionality(url_string)); |
| 290 } | 234 } |
| 291 | 235 |
| 292 void ChromeJavaScriptDialogManager::CancelActiveAndPendingDialogs( | 236 void JavaScriptDialogManagerImpl::CancelActiveAndPendingDialogs( |
| 293 WebContents* web_contents) { | 237 WebContents* web_contents) { |
| 294 AppModalDialogQueue* queue = AppModalDialogQueue::GetInstance(); | 238 AppModalDialogQueue* queue = AppModalDialogQueue::GetInstance(); |
| 295 AppModalDialog* active_dialog = queue->active_dialog(); | 239 AppModalDialog* active_dialog = queue->active_dialog(); |
| 296 if (active_dialog && active_dialog->web_contents() == web_contents) | 240 if (active_dialog && active_dialog->web_contents() == web_contents) |
| 297 active_dialog->Invalidate(); | 241 active_dialog->Invalidate(); |
| 298 for (AppModalDialogQueue::iterator i = queue->begin(); | 242 for (AppModalDialogQueue::iterator i = queue->begin(); |
| 299 i != queue->end(); ++i) { | 243 i != queue->end(); ++i) { |
| 300 if ((*i)->web_contents() == web_contents) | 244 if ((*i)->web_contents() == web_contents) |
| 301 (*i)->Invalidate(); | 245 (*i)->Invalidate(); |
| 302 } | 246 } |
| 303 } | 247 } |
| 304 | 248 |
| 305 void ChromeJavaScriptDialogManager::OnDialogClosed( | 249 void JavaScriptDialogManagerImpl::OnDialogClosed( |
| 306 WebContents* web_contents, | 250 WebContents* web_contents, |
| 307 DialogClosedCallback callback, | 251 DialogClosedCallback callback, |
| 308 bool success, | 252 bool success, |
| 309 const base::string16& user_input) { | 253 const base::string16& user_input) { |
| 310 // If an extension opened this dialog then the extension may shut down its | 254 // If an extension opened this dialog then the extension may shut down its |
| 311 // lazy background page after the dialog closes. (Dialogs are closed before | 255 // lazy background page after the dialog closes. (Dialogs are closed before |
| 312 // their WebContents is destroyed so |web_contents| is still valid here.) | 256 // their WebContents is destroyed so |web_contents| is still valid here.) |
| 313 DecrementLazyKeepaliveCount(web_contents); | 257 GetJavaScriptDialogManagerClient()->DecrementLazyKeepaliveCount(web_contents); |
| 314 | 258 |
| 315 callback.Run(success, user_input); | 259 callback.Run(success, user_input); |
| 316 } | 260 } |
| 317 | 261 |
| 318 } // namespace | 262 } // namespace |
| 319 | 263 |
| 320 content::JavaScriptDialogManager* GetJavaScriptDialogManagerInstance() { | 264 content::JavaScriptDialogManager* GetJavaScriptDialogManagerInstance() { |
| 321 return ChromeJavaScriptDialogManager::GetInstance(); | 265 return JavaScriptDialogManagerImpl::GetInstance(); |
| 322 } | 266 } |
| OLD | NEW |