Chromium Code Reviews| Index: android_webview/browser/aw_safe_browsing_blocking_page.cc |
| diff --git a/android_webview/browser/aw_safe_browsing_blocking_page.cc b/android_webview/browser/aw_safe_browsing_blocking_page.cc |
| index 1ed04244d2cb62f0969e9f4eb3b5160433481f40..a503e37c9e115867d520e2c434a2b611f91ffe39 100644 |
| --- a/android_webview/browser/aw_safe_browsing_blocking_page.cc |
| +++ b/android_webview/browser/aw_safe_browsing_blocking_page.cc |
| @@ -7,6 +7,8 @@ |
| #include "android_webview/browser/aw_browser_context.h" |
| #include "android_webview/browser/aw_safe_browsing_ui_manager.h" |
| #include "android_webview/browser/net/aw_url_request_context_getter.h" |
| +#include "components/safe_browsing/browser/threat_details.h" |
| +#include "components/safe_browsing/triggers/trigger_manager.h" |
| #include "components/security_interstitials/content/security_interstitial_controller_client.h" |
| #include "components/security_interstitials/content/unsafe_resource.h" |
| #include "components/security_interstitials/core/base_safe_browsing_error_ui.h" |
| @@ -36,7 +38,8 @@ AwSafeBrowsingBlockingPage::AwSafeBrowsingBlockingPage( |
| main_frame_url, |
| unsafe_resources, |
| std::move(controller_client), |
| - display_options) { |
| + display_options), |
| + threat_details_in_progress_(false) { |
| if (errorUiType == ErrorUiType::QUIET_SMALL || |
| errorUiType == ErrorUiType::QUIET_GIANT) { |
| set_sb_error_ui(base::MakeUnique<SafeBrowsingQuietErrorUI>( |
| @@ -46,9 +49,21 @@ AwSafeBrowsingBlockingPage::AwSafeBrowsingBlockingPage( |
| errorUiType == ErrorUiType::QUIET_GIANT)); |
| } |
| - // TODO(timvolodine): invoke TriggerManager::StartCollectingThreatDetails(), |
| - // (via AwBrowserContext, e.g. |
| - // AwBrowserContext::FromWebContents(web_contents)), crbug.com/731747. |
| + if (unsafe_resources.size() == 1 && |
| + ShouldReportThreatDetails(unsafe_resources[0].threat_type)) { |
| + AwBrowserContext* aw_browser_context = |
| + AwBrowserContext::FromWebContents(web_contents); |
| + // TODO(timvolodine): create a proper history service; currently the |
| + // HistoryServiceFactory lives in the chrome/ layer and relies on Profile |
| + // which we don't have in Android WebView (crbug.com/731744). |
| + threat_details_in_progress_ = |
| + aw_browser_context->GetSafeBrowsingTriggerManager() |
| + ->StartCollectingThreatDetails( |
| + web_contents, unsafe_resources[0], |
| + aw_browser_context->GetAwURLRequestContext(), |
| + /*history_service*/ nullptr, |
| + sb_error_ui()->get_error_display_options()); |
| + } |
| } |
| // static |
| @@ -93,4 +108,27 @@ void AwSafeBrowsingBlockingPage::ShowBlockingPage( |
| } |
| } |
| +void AwSafeBrowsingBlockingPage::FinishThreatDetails( |
| + const base::TimeDelta& delay, |
| + bool did_proceed, |
| + int num_visits) { |
| + // Not all interstitials collect threat details (eg., incognito mode). |
| + if (!threat_details_in_progress_) |
| + return; |
| + |
| + // Finish computing threat details. TriggerManager will decide if it is safe |
| + // to send the report. |
| + AwBrowserContext* aw_browser_context = |
| + AwBrowserContext::FromWebContents(web_contents()); |
| + bool report_sent = aw_browser_context->GetSafeBrowsingTriggerManager() |
| + ->FinishCollectingThreatDetails( |
| + web_contents(), delay, did_proceed, num_visits, |
| + sb_error_ui()->get_error_display_options()); |
| + |
| + if (report_sent) { |
|
Jialiu Lin
2017/06/29 19:31:16
If I remember correct, WebView doesn't have UMA.
timvolodine
2017/06/30 14:15:10
We actually have UMA in webview now, so this is st
|
| + controller()->metrics_helper()->RecordUserInteraction( |
| + security_interstitials::MetricsHelper::EXTENDED_REPORTING_IS_ENABLED); |
| + } |
| +} |
| + |
| } // namespace android_webview |