Commit 8dae3f2f authored by ntfschr's avatar ntfschr Committed by Commit bot

WebView: create AwSafeBrowsingBlockingPage

No change in logic.

This creates an initial implementation of a new WebView-specific
blocking page. This has no change in logic, but paves the way for
choosing between two different blocking pages (loud and quiet).

Currently, all this does is specify SBErrorDisplayOptions without
depending on the defaults set in BaseBlockingPage.

This exposes CreateControllerClient() in BaseBlockingPage as protected
so that AwSafeBrowsingBlockingPage can take advantage of it.

BUG=718545

Review-Url: https://codereview.chromium.org/2863723002
Cr-Commit-Position: refs/heads/master@{#469488}
parent 270315a2
......@@ -412,6 +412,8 @@ source_set("common") {
"browser/aw_resource_context.cc",
"browser/aw_resource_context.h",
"browser/aw_result_codes.h",
"browser/aw_safe_browsing_blocking_page.cc",
"browser/aw_safe_browsing_blocking_page.h",
"browser/aw_safe_browsing_config_helper.cc",
"browser/aw_safe_browsing_config_helper.h",
"browser/aw_safe_browsing_resource_throttle.cc",
......
......@@ -22,7 +22,7 @@ include_rules = [
"+components/printing/common",
"+components/safe_browsing",
"+components/safe_browsing_db",
"+components/security_interstitials/content",
"+components/security_interstitials",
"+components/spellcheck/browser",
"+components/spellcheck/common",
"+components/url_formatter",
......
// 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
// 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.
#ifndef ANDROID_WEBVIEW_BROWSER_AW_SAFE_BROWSING_BLOCKING_PAGE_H_
#define ANDROID_WEBVIEW_BROWSER_AW_SAFE_BROWSING_BLOCKING_PAGE_H_
#include "components/safe_browsing/base_blocking_page.h"
#include "components/security_interstitials/core/safe_browsing_error_ui.h"
namespace security_interstitials {
struct UnsafeResource;
} // namespace security_interstitials
namespace android_webview {
class AwSafeBrowsingUIManager;
class AwSafeBrowsingBlockingPage : public safe_browsing::BaseBlockingPage {
public:
typedef security_interstitials::UnsafeResource UnsafeResource;
static void ShowBlockingPage(AwSafeBrowsingUIManager* ui_manager,
const UnsafeResource& unsafe_resource);
protected:
// Don't instantiate this class directly, use ShowBlockingPage instead.
AwSafeBrowsingBlockingPage(
AwSafeBrowsingUIManager* ui_manager,
content::WebContents* web_contents,
const GURL& main_frame_url,
const UnsafeResourceList& unsafe_resources,
std::unique_ptr<
security_interstitials::SecurityInterstitialControllerClient>
controller_client,
const SafeBrowsingErrorUI::SBErrorDisplayOptions& display_options);
};
} // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_AW_SAFE_BROWSING_BLOCKING_PAGE_H_
......@@ -4,6 +4,7 @@
#include "android_webview/browser/aw_safe_browsing_ui_manager.h"
#include "android_webview/browser/aw_safe_browsing_blocking_page.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
......@@ -33,4 +34,9 @@ void AwSafeBrowsingUIManager::DisplayBlockingPage(
safe_browsing::BaseUIManager::DisplayBlockingPage(resource);
}
void AwSafeBrowsingUIManager::ShowBlockingPageForResource(
const UnsafeResource& resource) {
AwSafeBrowsingBlockingPage::ShowBlockingPage(this, resource);
}
} // namespace android_webview
......@@ -32,6 +32,8 @@ class AwSafeBrowsingUIManager : public safe_browsing::BaseUIManager {
protected:
~AwSafeBrowsingUIManager() override;
void ShowBlockingPageForResource(const UnsafeResource& resource) override;
private:
DISALLOW_COPY_AND_ASSIGN(AwSafeBrowsingUIManager);
};
......
......@@ -110,13 +110,13 @@ class BaseBlockingPage
void SetThreatDetailsProceedDelayForTesting(int64_t delay);
private:
static std::unique_ptr<
security_interstitials::SecurityInterstitialControllerClient>
CreateControllerClient(content::WebContents* web_contents,
const UnsafeResourceList& unsafe_resources,
BaseUIManager* ui_manager);
private:
// For reporting back user actions.
BaseUIManager* ui_manager_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment