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

Side by Side Diff: components/safe_browsing/base_resource_throttle.cc

Issue 2814733002: Add the SocEng as a type for checking in CheckUrlForSubresourceFilter. (Closed)
Patch Set: . Created 3 years, 7 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 | « components/safe_browsing/DEPS ('k') | components/safe_browsing_db/v4_database.h » ('j') | 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) 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 "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "components/safe_browsing/base_ui_manager.h" 10 #include "components/safe_browsing/base_ui_manager.h"
11 #include "components/safe_browsing_db/util.h" 11 #include "components/safe_browsing_db/util.h"
12 #include "components/security_interstitials/content/unsafe_resource.h" 12 #include "components/security_interstitials/content/unsafe_resource.h"
13 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h"
14 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/resource_request_info.h" 14 #include "content/public/browser/resource_request_info.h"
16 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
17 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
18 #include "net/log/net_log_capture_mode.h" 17 #include "net/log/net_log_capture_mode.h"
19 #include "net/log/net_log_source.h" 18 #include "net/log/net_log_source.h"
20 #include "net/log/net_log_source_type.h" 19 #include "net/log/net_log_source_type.h"
21 #include "net/url_request/redirect_info.h" 20 #include "net/url_request/redirect_info.h"
22 #include "net/url_request/url_request.h" 21 #include "net/url_request/url_request.h"
23 22
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 294
296 void BaseResourceThrottle::StartDisplayingBlockingPageHelper( 295 void BaseResourceThrottle::StartDisplayingBlockingPageHelper(
297 security_interstitials::UnsafeResource resource) { 296 security_interstitials::UnsafeResource resource) {
298 content::BrowserThread::PostTask( 297 content::BrowserThread::PostTask(
299 content::BrowserThread::UI, FROM_HERE, 298 content::BrowserThread::UI, FROM_HERE,
300 base::Bind(&BaseResourceThrottle::StartDisplayingBlockingPage, 299 base::Bind(&BaseResourceThrottle::StartDisplayingBlockingPage,
301 AsWeakPtr(), ui_manager_, resource)); 300 AsWeakPtr(), ui_manager_, resource));
302 } 301 }
303 302
304 // Static 303 // Static
305 void BaseResourceThrottle::NotifySubresourceFilterOfBlockedResource(
306 const security_interstitials::UnsafeResource& resource) {
307 content::WebContents* web_contents = resource.web_contents_getter.Run();
308 DCHECK(web_contents);
309 // Once activated, the subresource filter will filter subresources, but is
310 // triggered when the main frame document matches Safe Browsing blacklists.
311 if (!resource.is_subresource) {
312 using subresource_filter::ContentSubresourceFilterDriverFactory;
313 ContentSubresourceFilterDriverFactory* driver_factory =
314 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents);
315
316 // Content embedders (such as Android Webview) do not have a driver_factory.
317 if (driver_factory) {
318 // For a redirect chain of A -> B -> C, the subresource filter expects C
319 // as the resource URL and [A, B] as redirect URLs.
320 std::vector<GURL> redirect_parent_urls;
321 if (!resource.redirect_urls.empty()) {
322 redirect_parent_urls.push_back(resource.original_url);
323 redirect_parent_urls.insert(redirect_parent_urls.end(),
324 resource.redirect_urls.begin(),
325 std::prev(resource.redirect_urls.end()));
326 }
327 driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist(
328 resource.url, redirect_parent_urls, resource.threat_type,
329 resource.threat_metadata.threat_pattern_type);
330 }
331 }
332 }
333
334 // Static
335 void BaseResourceThrottle::StartDisplayingBlockingPage( 304 void BaseResourceThrottle::StartDisplayingBlockingPage(
336 const base::WeakPtr<BaseResourceThrottle>& throttle, 305 const base::WeakPtr<BaseResourceThrottle>& throttle,
337 scoped_refptr<BaseUIManager> ui_manager, 306 scoped_refptr<BaseUIManager> ui_manager,
338 const security_interstitials::UnsafeResource& resource) { 307 const security_interstitials::UnsafeResource& resource) {
339 content::WebContents* web_contents = resource.web_contents_getter.Run(); 308 content::WebContents* web_contents = resource.web_contents_getter.Run();
340 if (web_contents) { 309 if (web_contents) {
341 NotifySubresourceFilterOfBlockedResource(resource);
342 ui_manager->DisplayBlockingPage(resource); 310 ui_manager->DisplayBlockingPage(resource);
343 return; 311 return;
344 } 312 }
345 313
346 // Tab is gone or it's being prerendered. 314 // Tab is gone or it's being prerendered.
347 content::BrowserThread::PostTask( 315 content::BrowserThread::PostTask(
348 content::BrowserThread::IO, FROM_HERE, 316 content::BrowserThread::IO, FROM_HERE,
349 base::Bind(&BaseResourceThrottle::Cancel, throttle)); 317 base::Bind(&BaseResourceThrottle::Cancel, throttle));
350 } 318 }
351 319
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 405 }
438 } 406 }
439 407
440 if (resume) { 408 if (resume) {
441 defer_state_ = DEFERRED_NONE; 409 defer_state_ = DEFERRED_NONE;
442 Resume(); 410 Resume();
443 } 411 }
444 } 412 }
445 413
446 } // namespace safe_browsing 414 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing/DEPS ('k') | components/safe_browsing_db/v4_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698