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

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

Issue 2623733002: Componentize SafeBrowsingBlockingPage for WebView use (Closed)
Patch Set: address final comments Created 3 years, 11 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
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/loader/safe_browsing_resource_throttle.h" 5 #include "chrome/browser/loader/safe_browsing_resource_throttle.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "chrome/browser/prerender/prerender_contents.h" 12 #include "chrome/browser/prerender/prerender_contents.h"
13 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 13 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
14 #include "components/safe_browsing/base_ui_manager.h" 14 #include "components/safe_browsing/base_ui_manager.h"
15 #include "components/safe_browsing_db/util.h" 15 #include "components/safe_browsing_db/util.h"
16 #include "components/safe_browsing_db/v4_feature_list.h" 16 #include "components/safe_browsing_db/v4_feature_list.h"
17 #include "components/safe_browsing_db/v4_local_database_manager.h" 17 #include "components/safe_browsing_db/v4_local_database_manager.h"
18 #include "components/security_interstitials/content/unsafe_resource.h" 18 #include "components/security_interstitials/content/unsafe_resource.h"
19 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h" 19 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/resource_request_info.h" 21 #include "content/public/browser/resource_request_info.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "net/url_request/redirect_info.h" 23 #include "net/url_request/redirect_info.h"
24 #include "net/url_request/url_request.h" 24 #include "net/url_request/url_request.h"
25 25
26 using safe_browsing::BaseSafeBrowsingUIManager; 26 using safe_browsing::BaseUIManager;
27 27
28 namespace { 28 namespace {
29 29
30 // Destroys the prerender contents associated with the web_contents, if any. 30 // Destroys the prerender contents associated with the web_contents, if any.
31 void DestroyPrerenderContents( 31 void DestroyPrerenderContents(
32 const content::ResourceRequestInfo::WebContentsGetter& 32 const content::ResourceRequestInfo::WebContentsGetter&
33 web_contents_getter) { 33 web_contents_getter) {
34 content::WebContents* web_contents = web_contents_getter.Run(); 34 content::WebContents* web_contents = web_contents_getter.Run();
35 if (web_contents) { 35 if (web_contents) {
36 prerender::PrerenderContents* prerender_contents = 36 prerender::PrerenderContents* prerender_contents =
(...skipping 13 matching lines...) Expand all
50 if (sb_service->database_manager()->IsSupported()) { 50 if (sb_service->database_manager()->IsSupported()) {
51 return new SafeBrowsingResourceThrottle(request, resource_type, sb_service); 51 return new SafeBrowsingResourceThrottle(request, resource_type, sb_service);
52 } 52 }
53 return nullptr; 53 return nullptr;
54 } 54 }
55 55
56 SafeBrowsingResourceThrottle::SafeBrowsingResourceThrottle( 56 SafeBrowsingResourceThrottle::SafeBrowsingResourceThrottle(
57 const net::URLRequest* request, 57 const net::URLRequest* request,
58 content::ResourceType resource_type, 58 content::ResourceType resource_type,
59 safe_browsing::SafeBrowsingService* sb_service) 59 safe_browsing::SafeBrowsingService* sb_service)
60 : BaseSafeBrowsingResourceThrottle( 60 : safe_browsing::BaseResourceThrottle(
61 request, 61 request,
62 resource_type, 62 resource_type,
63 safe_browsing::V4FeatureList::IsV4HybridEnabled() 63 safe_browsing::V4FeatureList::IsV4HybridEnabled()
64 ? sb_service->v4_local_database_manager() 64 ? sb_service->v4_local_database_manager()
65 : sb_service->database_manager(), 65 : sb_service->database_manager(),
66 sb_service->ui_manager()) {} 66 sb_service->ui_manager()) {}
67 67
68 SafeBrowsingResourceThrottle::~SafeBrowsingResourceThrottle() {} 68 SafeBrowsingResourceThrottle::~SafeBrowsingResourceThrottle() {}
69 69
70 const char* SafeBrowsingResourceThrottle::GetNameForLogging() const { 70 const char* SafeBrowsingResourceThrottle::GetNameForLogging() const {
(...skipping 12 matching lines...) Expand all
83 void SafeBrowsingResourceThrottle::StartDisplayingBlockingPageHelper( 83 void SafeBrowsingResourceThrottle::StartDisplayingBlockingPageHelper(
84 security_interstitials::UnsafeResource resource) { 84 security_interstitials::UnsafeResource resource) {
85 content::BrowserThread::PostTask( 85 content::BrowserThread::PostTask(
86 content::BrowserThread::UI, FROM_HERE, 86 content::BrowserThread::UI, FROM_HERE,
87 base::Bind(&SafeBrowsingResourceThrottle::StartDisplayingBlockingPage, 87 base::Bind(&SafeBrowsingResourceThrottle::StartDisplayingBlockingPage,
88 AsWeakPtr(), ui_manager_, resource)); 88 AsWeakPtr(), ui_manager_, resource));
89 } 89 }
90 90
91 // Static 91 // Static
92 void SafeBrowsingResourceThrottle::StartDisplayingBlockingPage( 92 void SafeBrowsingResourceThrottle::StartDisplayingBlockingPage(
93 const base::WeakPtr<BaseSafeBrowsingResourceThrottle>& throttle, 93 const base::WeakPtr<safe_browsing::BaseResourceThrottle>& throttle,
94 scoped_refptr<BaseSafeBrowsingUIManager> ui_manager, 94 scoped_refptr<BaseUIManager> ui_manager,
95 const security_interstitials::UnsafeResource& resource) { 95 const security_interstitials::UnsafeResource& resource) {
96 content::WebContents* web_contents = resource.web_contents_getter.Run(); 96 content::WebContents* web_contents = resource.web_contents_getter.Run();
97 if (web_contents) { 97 if (web_contents) {
98 // Once activated, the subresource filter will filter subresources, but is 98 // Once activated, the subresource filter will filter subresources, but is
99 // triggered when the main frame document matches Safe Browsing blacklists. 99 // triggered when the main frame document matches Safe Browsing blacklists.
100 if (!resource.is_subresource) { 100 if (!resource.is_subresource) {
101 using subresource_filter::ContentSubresourceFilterDriverFactory; 101 using subresource_filter::ContentSubresourceFilterDriverFactory;
102 ContentSubresourceFilterDriverFactory* driver_factory = 102 ContentSubresourceFilterDriverFactory* driver_factory =
103 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents); 103 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents);
104 DCHECK(driver_factory); 104 DCHECK(driver_factory);
(...skipping 21 matching lines...) Expand all
126 ui_manager->DisplayBlockingPage(resource); 126 ui_manager->DisplayBlockingPage(resource);
127 return; 127 return;
128 } 128 }
129 } 129 }
130 130
131 // Tab is gone or it's being prerendered. 131 // Tab is gone or it's being prerendered.
132 content::BrowserThread::PostTask( 132 content::BrowserThread::PostTask(
133 content::BrowserThread::IO, FROM_HERE, 133 content::BrowserThread::IO, FROM_HERE,
134 base::Bind(&SafeBrowsingResourceThrottle::Cancel, throttle)); 134 base::Bind(&SafeBrowsingResourceThrottle::Cancel, throttle));
135 } 135 }
OLDNEW
« no previous file with comments | « chrome/browser/loader/safe_browsing_resource_throttle.h ('k') | chrome/browser/safe_browsing/safe_browsing_blocking_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698