Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1502)

Unified Diff: android_webview/browser/aw_safe_browsing_blocking_page.cc

Issue 2863723002: WebView: create AwSafeBrowsingBlockingPage (Closed)
Patch Set: Fixing comment, fixing forward decl. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..0e1b40a81ffef90ec56741b6ff9ed02381beede5
--- /dev/null
+++ b/android_webview/browser/aw_safe_browsing_blocking_page.cc
@@ -0,0 +1,73 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/browser/aw_safe_browsing_blocking_page.h"
+
+#include "android_webview/browser/aw_safe_browsing_ui_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/safe_browsing_error_ui.h"
+#include "content/public/browser/interstitial_page.h"
+#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/web_contents.h"
+
+using content::InterstitialPage;
+using content::WebContents;
+using security_interstitials::SafeBrowsingErrorUI;
+using security_interstitials::SecurityInterstitialControllerClient;
+
+namespace android_webview {
+
+AwSafeBrowsingBlockingPage::AwSafeBrowsingBlockingPage(
+ AwSafeBrowsingUIManager* ui_manager,
+ WebContents* web_contents,
+ const GURL& main_frame_url,
+ const UnsafeResourceList& unsafe_resources,
+ std::unique_ptr<SecurityInterstitialControllerClient> controller_client,
+ const SafeBrowsingErrorUI::SBErrorDisplayOptions& display_options)
+ : BaseBlockingPage(ui_manager,
+ web_contents,
+ main_frame_url,
+ unsafe_resources,
+ std::move(controller_client),
+ display_options) {}
+
+// static
+void AwSafeBrowsingBlockingPage::ShowBlockingPage(
+ AwSafeBrowsingUIManager* ui_manager,
+ const UnsafeResource& unsafe_resource) {
+ DVLOG(1) << __func__ << " " << unsafe_resource.url.spec();
+ WebContents* web_contents = unsafe_resource.web_contents_getter.Run();
+
+ if (InterstitialPage::GetInterstitialPage(web_contents) &&
+ unsafe_resource.is_subresource) {
+ // This is an interstitial for a page's resource, let's queue it.
+ UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap();
+ (*unsafe_resource_map)[web_contents].push_back(unsafe_resource);
+ } else {
+ // There is no interstitial currently showing, or we are about to display a
+ // new one for the main frame. If there is already an interstitial, showing
+ // the new one will automatically hide the old one.
+ content::NavigationEntry* entry =
+ unsafe_resource.GetNavigationEntryForResource();
+ const UnsafeResourceList unsafe_resources{unsafe_resource};
+ SafeBrowsingErrorUI::SBErrorDisplayOptions display_options =
+ SafeBrowsingErrorUI::SBErrorDisplayOptions(
+ IsMainPageLoadBlocked(unsafe_resources),
+ false, // kSafeBrowsingExtendedReportingOptInAllowed
+ false, // is_off_the_record
+ false, // is_extended_reporting
+ false, // is_scout
+ false, // kSafeBrowsingProceedAnywayDisabled
+ true); // is_resource_cancellable
+ AwSafeBrowsingBlockingPage* blocking_page = new AwSafeBrowsingBlockingPage(
+ ui_manager, web_contents, entry ? entry->GetURL() : GURL(),
+ unsafe_resources,
+ CreateControllerClient(web_contents, unsafe_resources, ui_manager),
+ display_options);
+ blocking_page->Show();
+ }
+}
+
+} // namespace android_webview
« no previous file with comments | « android_webview/browser/aw_safe_browsing_blocking_page.h ('k') | android_webview/browser/aw_safe_browsing_ui_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698