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

Unified Diff: components/safe_browsing/base_resource_throttle.cc

Issue 2692273006: Refactor safebrowsing StartDisplayingBlockingPage (Closed)
Patch Set: Fix method description Created 3 years, 10 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
« no previous file with comments | « components/safe_browsing/base_resource_throttle.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing/base_resource_throttle.cc
diff --git a/components/safe_browsing/base_resource_throttle.cc b/components/safe_browsing/base_resource_throttle.cc
index 744ad4c4930695f07946e857ab4ac8333b413fd0..333a2a09fa240d8a747ee6acf6f3f5c50ac9fbd4 100644
--- a/components/safe_browsing/base_resource_throttle.cc
+++ b/components/safe_browsing/base_resource_throttle.cc
@@ -316,36 +316,43 @@ void BaseResourceThrottle::StartDisplayingBlockingPageHelper(
}
// Static
+void BaseResourceThrottle::NotifySubresourceFilterOfBlockedResource(
+ const security_interstitials::UnsafeResource& resource) {
+ content::WebContents* web_contents = resource.web_contents_getter.Run();
+ DCHECK(web_contents);
+ // Once activated, the subresource filter will filter subresources, but is
+ // triggered when the main frame document matches Safe Browsing blacklists.
+ if (!resource.is_subresource) {
+ using subresource_filter::ContentSubresourceFilterDriverFactory;
+ ContentSubresourceFilterDriverFactory* driver_factory =
+ ContentSubresourceFilterDriverFactory::FromWebContents(web_contents);
+
+ // Content embedders (such as Android Webview) do not have a driver_factory.
+ if (driver_factory) {
+ // For a redirect chain of A -> B -> C, the subresource filter expects C
+ // as the resource URL and [A, B] as redirect URLs.
+ std::vector<GURL> redirect_parent_urls;
+ if (!resource.redirect_urls.empty()) {
+ redirect_parent_urls.push_back(resource.original_url);
+ redirect_parent_urls.insert(redirect_parent_urls.end(),
+ resource.redirect_urls.begin(),
+ std::prev(resource.redirect_urls.end()));
+ }
+ driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist(
+ resource.url, redirect_parent_urls, resource.threat_type,
+ resource.threat_metadata.threat_pattern_type);
+ }
+ }
+}
+
+// Static
void BaseResourceThrottle::StartDisplayingBlockingPage(
const base::WeakPtr<BaseResourceThrottle>& throttle,
scoped_refptr<BaseUIManager> ui_manager,
const security_interstitials::UnsafeResource& resource) {
content::WebContents* web_contents = resource.web_contents_getter.Run();
if (web_contents) {
- // Once activated, the subresource filter will filter subresources, but is
- // triggered when the main frame document matches Safe Browsing blacklists.
- if (!resource.is_subresource) {
- using subresource_filter::ContentSubresourceFilterDriverFactory;
- ContentSubresourceFilterDriverFactory* driver_factory =
- ContentSubresourceFilterDriverFactory::FromWebContents(web_contents);
- // Content embedders (such as Android Webview) does not have a
- // driver_factory.
- if (driver_factory) {
- // For a redirect chain of A -> B -> C, the subresource filter expects C
- // as the resource URL and [A, B] as redirect URLs.
- std::vector<GURL> redirect_parent_urls;
- if (!resource.redirect_urls.empty()) {
- redirect_parent_urls.push_back(resource.original_url);
- redirect_parent_urls.insert(redirect_parent_urls.end(),
- resource.redirect_urls.begin(),
- std::prev(resource.redirect_urls.end()));
- }
- driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist(
- resource.url, redirect_parent_urls, resource.threat_type,
- resource.threat_metadata.threat_pattern_type);
- }
- }
-
+ NotifySubresourceFilterOfBlockedResource(resource);
ui_manager->DisplayBlockingPage(resource);
return;
}
« no previous file with comments | « components/safe_browsing/base_resource_throttle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698