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

Side by Side Diff: chrome/browser/renderer_host/safe_browsing_resource_throttle.cc

Issue 2339733003: Transform redirect chains for the Safe Browsing subresource filter. (Closed)
Patch Set: Use std::prev(). 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" 5 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h"
6 6
7 #include <iterator>
7 #include <utility> 8 #include <utility>
8 9
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
11 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/prerender/prerender_contents.h" 15 #include "chrome/browser/prerender/prerender_contents.h"
15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 16 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
16 #include "components/safe_browsing_db/util.h" 17 #include "components/safe_browsing_db/util.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 294
294 void SafeBrowsingResourceThrottle::StartDisplayingBlockingPage( 295 void SafeBrowsingResourceThrottle::StartDisplayingBlockingPage(
295 const base::WeakPtr<SafeBrowsingResourceThrottle>& throttle, 296 const base::WeakPtr<SafeBrowsingResourceThrottle>& throttle,
296 scoped_refptr<SafeBrowsingUIManager> ui_manager, 297 scoped_refptr<SafeBrowsingUIManager> ui_manager,
297 const SafeBrowsingUIManager::UnsafeResource& resource) { 298 const SafeBrowsingUIManager::UnsafeResource& resource) {
298 content::WebContents* web_contents = resource.web_contents_getter.Run(); 299 content::WebContents* web_contents = resource.web_contents_getter.Run();
299 if (web_contents) { 300 if (web_contents) {
300 prerender::PrerenderContents* prerender_contents = 301 prerender::PrerenderContents* prerender_contents =
301 prerender::PrerenderContents::FromWebContents(web_contents); 302 prerender::PrerenderContents::FromWebContents(web_contents);
302 303
303 subresource_filter::ContentSubresourceFilterDriverFactory* driver_factory = 304 // Once activated, the subresource filter will filters subresources, but is
304 subresource_filter::ContentSubresourceFilterDriverFactory:: 305 // triggered when the main frame document matches Safe Browsing blacklists.
305 FromWebContents(web_contents); 306 if (!resource.is_subresource) {
306 DCHECK(driver_factory); 307 using subresource_filter::ContentSubresourceFilterDriverFactory;
307 driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist( 308 ContentSubresourceFilterDriverFactory* driver_factory =
308 resource.url, resource.redirect_urls, resource.threat_type, 309 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents);
309 resource.threat_metadata.threat_pattern_type); 310 DCHECK(driver_factory);
311
312 // For a redirect chain of A -> B -> C, the subresource filter expects C
313 // as the resource URL and [A, B] as redirect URLs.
314 std::vector<GURL> redirect_parent_urls;
315 if (!resource.redirect_urls.empty()) {
316 redirect_parent_urls.push_back(resource.original_url);
317 redirect_parent_urls.insert(redirect_parent_urls.end(),
318 resource.redirect_urls.begin(),
319 std::prev(resource.redirect_urls.end()));
320 }
321
322 driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist(
323 resource.url, redirect_parent_urls, resource.threat_type,
324 resource.threat_metadata.threat_pattern_type);
325 }
310 326
311 if (prerender_contents) { 327 if (prerender_contents) {
312 prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING); 328 prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING);
313 } else { 329 } else {
314 ui_manager->DisplayBlockingPage(resource); 330 ui_manager->DisplayBlockingPage(resource);
315 return; 331 return;
316 } 332 }
317 } 333 }
318 334
319 // Tab is gone or it's being prerendered. 335 // Tab is gone or it's being prerendered.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 unchecked_redirect_url_, "defer_reason", 422 unchecked_redirect_url_, "defer_reason",
407 "resumed_redirect"); 423 "resumed_redirect");
408 } 424 }
409 } 425 }
410 426
411 if (resume) { 427 if (resume) {
412 defer_state_ = DEFERRED_NONE; 428 defer_state_ = DEFERRED_NONE;
413 controller()->Resume(); 429 controller()->Resume();
414 } 430 }
415 } 431 }
OLDNEW
« 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