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

Unified Diff: chrome/browser/renderer_host/safe_browsing_resource_throttle.cc

Issue 2339733003: Transform redirect chains for the Safe Browsing subresource filter. (Closed)
Patch Set: Obtain reference to factory within is-subresource check. Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/safe_browsing_resource_throttle.cc
diff --git a/chrome/browser/renderer_host/safe_browsing_resource_throttle.cc b/chrome/browser/renderer_host/safe_browsing_resource_throttle.cc
index a917f501a18c2fdcd31cfcfbec68f092e377a83e..39050e89cb43610df3f59c73711b654340476ba5 100644
--- a/chrome/browser/renderer_host/safe_browsing_resource_throttle.cc
+++ b/chrome/browser/renderer_host/safe_browsing_resource_throttle.cc
@@ -300,13 +300,28 @@ void SafeBrowsingResourceThrottle::StartDisplayingBlockingPage(
prerender::PrerenderContents* prerender_contents =
prerender::PrerenderContents::FromWebContents(web_contents);
- subresource_filter::ContentSubresourceFilterDriverFactory* driver_factory =
- subresource_filter::ContentSubresourceFilterDriverFactory::
- FromWebContents(web_contents);
- DCHECK(driver_factory);
- driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist(
- resource.url, resource.redirect_urls, resource.threat_type,
- resource.threat_metadata.threat_pattern_type);
+ // Once activated, the subresource filter will filters 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);
+ DCHECK(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(),
+ --resource.redirect_urls.end());
Nathan Parker 2016/09/15 21:19:45 How does decrement work on a const iterator? Is th
engedy 2016/09/16 09:04:43 It works as you'd expect it to, i.e. the temporary
+ }
+
+ driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist(
+ resource.url, redirect_parent_urls, resource.threat_type,
+ resource.threat_metadata.threat_pattern_type);
+ }
if (prerender_contents) {
prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698