Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 | 293 |
| 294 void SafeBrowsingResourceThrottle::StartDisplayingBlockingPage( | 294 void SafeBrowsingResourceThrottle::StartDisplayingBlockingPage( |
| 295 const base::WeakPtr<SafeBrowsingResourceThrottle>& throttle, | 295 const base::WeakPtr<SafeBrowsingResourceThrottle>& throttle, |
| 296 scoped_refptr<SafeBrowsingUIManager> ui_manager, | 296 scoped_refptr<SafeBrowsingUIManager> ui_manager, |
| 297 const SafeBrowsingUIManager::UnsafeResource& resource) { | 297 const SafeBrowsingUIManager::UnsafeResource& resource) { |
| 298 content::WebContents* web_contents = resource.web_contents_getter.Run(); | 298 content::WebContents* web_contents = resource.web_contents_getter.Run(); |
| 299 if (web_contents) { | 299 if (web_contents) { |
| 300 prerender::PrerenderContents* prerender_contents = | 300 prerender::PrerenderContents* prerender_contents = |
| 301 prerender::PrerenderContents::FromWebContents(web_contents); | 301 prerender::PrerenderContents::FromWebContents(web_contents); |
| 302 | 302 |
| 303 subresource_filter::ContentSubresourceFilterDriverFactory* driver_factory = | 303 // Once activated, the subresource filter will filters subresources, but is |
| 304 subresource_filter::ContentSubresourceFilterDriverFactory:: | 304 // triggered when the main frame document matches Safe Browsing blacklists. |
| 305 FromWebContents(web_contents); | 305 if (!resource.is_subresource) { |
| 306 DCHECK(driver_factory); | 306 using subresource_filter::ContentSubresourceFilterDriverFactory; |
| 307 driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist( | 307 ContentSubresourceFilterDriverFactory* driver_factory = |
| 308 resource.url, resource.redirect_urls, resource.threat_type, | 308 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents); |
| 309 resource.threat_metadata.threat_pattern_type); | 309 DCHECK(driver_factory); |
| 310 | |
| 311 // For a redirect chain of A -> B -> C, the subresource filter expects C | |
| 312 // as the resource URL and [A, B] as redirect URLs. | |
| 313 std::vector<GURL> redirect_parent_urls; | |
| 314 if (!resource.redirect_urls.empty()) { | |
| 315 redirect_parent_urls.push_back(resource.original_url); | |
| 316 redirect_parent_urls.insert(redirect_parent_urls.end(), | |
| 317 resource.redirect_urls.begin(), | |
| 318 --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
| |
| 319 } | |
| 320 | |
| 321 driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist( | |
| 322 resource.url, redirect_parent_urls, resource.threat_type, | |
| 323 resource.threat_metadata.threat_pattern_type); | |
| 324 } | |
| 310 | 325 |
| 311 if (prerender_contents) { | 326 if (prerender_contents) { |
| 312 prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING); | 327 prerender_contents->Destroy(prerender::FINAL_STATUS_SAFE_BROWSING); |
| 313 } else { | 328 } else { |
| 314 ui_manager->DisplayBlockingPage(resource); | 329 ui_manager->DisplayBlockingPage(resource); |
| 315 return; | 330 return; |
| 316 } | 331 } |
| 317 } | 332 } |
| 318 | 333 |
| 319 // Tab is gone or it's being prerendered. | 334 // Tab is gone or it's being prerendered. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 unchecked_redirect_url_, "defer_reason", | 421 unchecked_redirect_url_, "defer_reason", |
| 407 "resumed_redirect"); | 422 "resumed_redirect"); |
| 408 } | 423 } |
| 409 } | 424 } |
| 410 | 425 |
| 411 if (resume) { | 426 if (resume) { |
| 412 defer_state_ = DEFERRED_NONE; | 427 defer_state_ = DEFERRED_NONE; |
| 413 controller()->Resume(); | 428 controller()->Resume(); |
| 414 } | 429 } |
| 415 } | 430 } |
| OLD | NEW |