| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/javascript_dialogs/javascript_dialog_tab_helper.h" | 5 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 if (dialog_) { | 81 if (dialog_) { |
| 82 CloseDialog(false, base::string16(), DismissalCause::TAB_HELPER_DESTROYED); | 82 CloseDialog(false, base::string16(), DismissalCause::TAB_HELPER_DESTROYED); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 void JavaScriptDialogTabHelper::SetDialogShownCallbackForTesting( | 86 void JavaScriptDialogTabHelper::SetDialogShownCallbackForTesting( |
| 87 base::Closure callback) { | 87 base::Closure callback) { |
| 88 dialog_shown_ = callback; | 88 dialog_shown_ = callback; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool JavaScriptDialogTabHelper::IsShowingDialogForTesting() const { |
| 92 return !!dialog_; |
| 93 } |
| 94 |
| 91 void JavaScriptDialogTabHelper::RunJavaScriptDialog( | 95 void JavaScriptDialogTabHelper::RunJavaScriptDialog( |
| 92 content::WebContents* alerting_web_contents, | 96 content::WebContents* alerting_web_contents, |
| 93 const GURL& origin_url, | 97 const GURL& origin_url, |
| 94 content::JavaScriptDialogType dialog_type, | 98 content::JavaScriptDialogType dialog_type, |
| 95 const base::string16& message_text, | 99 const base::string16& message_text, |
| 96 const base::string16& default_prompt_text, | 100 const base::string16& default_prompt_text, |
| 97 const DialogClosedCallback& callback, | 101 const DialogClosedCallback& callback, |
| 98 bool* did_suppress_message) { | 102 bool* did_suppress_message) { |
| 99 SiteEngagementService* site_engagement_service = SiteEngagementService::Get( | 103 SiteEngagementService* site_engagement_service = SiteEngagementService::Get( |
| 100 Profile::FromBrowserContext(alerting_web_contents->GetBrowserContext())); | 104 Profile::FromBrowserContext(alerting_web_contents->GetBrowserContext())); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 dialog_callback_.Run(success, user_input); | 348 dialog_callback_.Run(success, user_input); |
| 345 | 349 |
| 346 ClearDialogInfo(); | 350 ClearDialogInfo(); |
| 347 } | 351 } |
| 348 | 352 |
| 349 void JavaScriptDialogTabHelper::ClearDialogInfo() { | 353 void JavaScriptDialogTabHelper::ClearDialogInfo() { |
| 350 dialog_.reset(); | 354 dialog_.reset(); |
| 351 dialog_callback_.Reset(); | 355 dialog_callback_.Reset(); |
| 352 BrowserList::RemoveObserver(this); | 356 BrowserList::RemoveObserver(this); |
| 353 } | 357 } |
| OLD | NEW |