| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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 "components/safe_browsing/base_resource_throttle.h" | 5 #include "components/safe_browsing/base_resource_throttle.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 scoped_refptr<BaseUIManager> ui_manager, | 321 scoped_refptr<BaseUIManager> ui_manager, |
| 322 const security_interstitials::UnsafeResource& resource) { | 322 const security_interstitials::UnsafeResource& resource) { |
| 323 content::WebContents* web_contents = resource.web_contents_getter.Run(); | 323 content::WebContents* web_contents = resource.web_contents_getter.Run(); |
| 324 if (web_contents) { | 324 if (web_contents) { |
| 325 // Once activated, the subresource filter will filter subresources, but is | 325 // Once activated, the subresource filter will filter subresources, but is |
| 326 // triggered when the main frame document matches Safe Browsing blacklists. | 326 // triggered when the main frame document matches Safe Browsing blacklists. |
| 327 if (!resource.is_subresource) { | 327 if (!resource.is_subresource) { |
| 328 using subresource_filter::ContentSubresourceFilterDriverFactory; | 328 using subresource_filter::ContentSubresourceFilterDriverFactory; |
| 329 ContentSubresourceFilterDriverFactory* driver_factory = | 329 ContentSubresourceFilterDriverFactory* driver_factory = |
| 330 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents); | 330 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents); |
| 331 DCHECK(driver_factory); | 331 // Content embedders (such as Android Webview) does not have a |
| 332 | 332 // driver_factory. |
| 333 // For a redirect chain of A -> B -> C, the subresource filter expects C | 333 if (driver_factory) { |
| 334 // as the resource URL and [A, B] as redirect URLs. | 334 // For a redirect chain of A -> B -> C, the subresource filter expects C |
| 335 std::vector<GURL> redirect_parent_urls; | 335 // as the resource URL and [A, B] as redirect URLs. |
| 336 if (!resource.redirect_urls.empty()) { | 336 std::vector<GURL> redirect_parent_urls; |
| 337 redirect_parent_urls.push_back(resource.original_url); | 337 if (!resource.redirect_urls.empty()) { |
| 338 redirect_parent_urls.insert(redirect_parent_urls.end(), | 338 redirect_parent_urls.push_back(resource.original_url); |
| 339 resource.redirect_urls.begin(), | 339 redirect_parent_urls.insert(redirect_parent_urls.end(), |
| 340 std::prev(resource.redirect_urls.end())); | 340 resource.redirect_urls.begin(), |
| 341 std::prev(resource.redirect_urls.end())); |
| 342 } |
| 343 driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist( |
| 344 resource.url, redirect_parent_urls, resource.threat_type, |
| 345 resource.threat_metadata.threat_pattern_type); |
| 341 } | 346 } |
| 342 | |
| 343 driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist( | |
| 344 resource.url, redirect_parent_urls, resource.threat_type, | |
| 345 resource.threat_metadata.threat_pattern_type); | |
| 346 } | 347 } |
| 347 | 348 |
| 348 ui_manager->DisplayBlockingPage(resource); | 349 ui_manager->DisplayBlockingPage(resource); |
| 349 return; | 350 return; |
| 350 } | 351 } |
| 351 | 352 |
| 352 // Tab is gone or it's being prerendered. | 353 // Tab is gone or it's being prerendered. |
| 353 content::BrowserThread::PostTask( | 354 content::BrowserThread::PostTask( |
| 354 content::BrowserThread::IO, FROM_HERE, | 355 content::BrowserThread::IO, FROM_HERE, |
| 355 base::Bind(&BaseResourceThrottle::Cancel, throttle)); | 356 base::Bind(&BaseResourceThrottle::Cancel, throttle)); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 } | 438 } |
| 438 } | 439 } |
| 439 | 440 |
| 440 if (resume) { | 441 if (resume) { |
| 441 defer_state_ = DEFERRED_NONE; | 442 defer_state_ = DEFERRED_NONE; |
| 442 Resume(); | 443 Resume(); |
| 443 } | 444 } |
| 444 } | 445 } |
| 445 | 446 |
| 446 } // namespace safe_browsing | 447 } // namespace safe_browsing |
| OLD | NEW |