Commit cd83cf21 authored by Tim Volodine's avatar Tim Volodine Committed by Commit Bot

[WebLayer] Add support for safebrowsing interstitials.

Add support for safebrowsing interstitials, i.e.
showing of special warning pages when navigating
to unsafe urls with threats like phishing, malware,
unwanted software and billing.

In this patch the default implementation in
components/safe_browsing/ is used for the actual
interstitials.

BUG=1015418

Change-Id: I102c587a59c26152127f52315232d036d9b27663
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1917260
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715789}
parent 11de3b27
......@@ -12,18 +12,10 @@ namespace weblayer {
SafeBrowsingUIManager::SafeBrowsingUIManager() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// TODO(timvolodine): properly init the ui manager and the context.
}
SafeBrowsingUIManager::~SafeBrowsingUIManager() {}
void SafeBrowsingUIManager::DisplayBlockingPage(
const UnsafeResource& resource) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// TODO(timvolodine): check if we can reuse the base class implementation here
// as is.
}
void SafeBrowsingUIManager::SendSerializedThreatDetails(
const std::string& serialized) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
......
......@@ -15,7 +15,6 @@ class SafeBrowsingUIManager : public safe_browsing::BaseUIManager {
SafeBrowsingUIManager();
// BaseUIManager overrides.
void DisplayBlockingPage(const UnsafeResource& resource) override;
void SendSerializedThreatDetails(const std::string& serialized) override;
protected:
......
......@@ -4,7 +4,12 @@
#include "weblayer/browser/safe_browsing/url_checker_delegate_impl.h"
#include "base/bind.h"
#include "base/task/post_task.h"
#include "components/safe_browsing/db/database_manager.h"
#include "components/security_interstitials/content/unsafe_resource.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "weblayer/browser/safe_browsing/safe_browsing_ui_manager.h"
namespace weblayer {
......@@ -31,7 +36,24 @@ void UrlCheckerDelegateImpl::StartDisplayingBlockingPageHelper(
const net::HttpRequestHeaders& headers,
bool is_main_frame,
bool has_user_gesture) {
// TODO(timvolodine): figure out what to do here.
base::PostTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(
&UrlCheckerDelegateImpl::StartDisplayingDefaultBlockingPage,
base::Unretained(this), resource));
}
void UrlCheckerDelegateImpl::StartDisplayingDefaultBlockingPage(
const security_interstitials::UnsafeResource& resource) {
content::WebContents* web_contents = resource.web_contents_getter.Run();
if (web_contents) {
GetUIManager()->DisplayBlockingPage(resource);
return;
}
// Report back that it is not ok to proceed with loading the URL.
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(resource.callback, false));
}
bool UrlCheckerDelegateImpl::IsUrlWhitelisted(const GURL& url) {
......@@ -57,7 +79,6 @@ void UrlCheckerDelegateImpl::NotifySuspiciousSiteDetected(
web_contents_getter) {}
const safe_browsing::SBThreatTypeSet& UrlCheckerDelegateImpl::GetThreatTypes() {
// TODO(timvolodine): revisit with the relevant threat types.
return threat_types_;
}
......
......@@ -9,6 +9,10 @@
#include "base/memory/ref_counted.h"
#include "components/safe_browsing/browser/url_checker_delegate.h"
namespace security_interstitials {
struct UnsafeResource;
}
namespace weblayer {
class SafeBrowsingUIManager;
......@@ -47,6 +51,9 @@ class UrlCheckerDelegateImpl : public safe_browsing::UrlCheckerDelegate {
safe_browsing::SafeBrowsingDatabaseManager* GetDatabaseManager() override;
safe_browsing::BaseUIManager* GetUIManager() override;
void StartDisplayingDefaultBlockingPage(
const security_interstitials::UnsafeResource& resource);
scoped_refptr<safe_browsing::SafeBrowsingDatabaseManager> database_manager_;
scoped_refptr<SafeBrowsingUIManager> ui_manager_;
safe_browsing::SBThreatTypeSet threat_types_;
......
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