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

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

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
« no previous file with comments | « no previous file | chrome/browser/loader/safe_browsing_resource_throttle.cc » ('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) 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 #ifndef CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_ 5 #ifndef CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_
6 #define CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_ 6 #define CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
16 #include "chrome/browser/safe_browsing/ui_manager.h" 16 #include "chrome/browser/safe_browsing/ui_manager.h"
17 #include "components/safe_browsing/base_safe_browsing_resource_throttle.h" 17 #include "components/safe_browsing/base_resource_throttle.h"
18 #include "components/safe_browsing/base_ui_manager.h" 18 #include "components/safe_browsing/base_ui_manager.h"
19 #include "components/safe_browsing_db/database_manager.h" 19 #include "components/safe_browsing_db/database_manager.h"
20 #include "components/security_interstitials/content/unsafe_resource.h" 20 #include "components/security_interstitials/content/unsafe_resource.h"
21 #include "content/public/browser/resource_throttle.h" 21 #include "content/public/browser/resource_throttle.h"
22 #include "content/public/common/resource_type.h" 22 #include "content/public/common/resource_type.h"
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 24
25 namespace content { 25 namespace content {
26 class ResourceRequestInfo; 26 class ResourceRequestInfo;
27 } 27 }
28 28
29 namespace net { 29 namespace net {
30 class URLRequest; 30 class URLRequest;
31 } 31 }
32 32
33 namespace safe_browsing { 33 namespace safe_browsing {
34 class BaseSafeBrowsingUIManager; 34 class BaseUIManager;
35 } 35 }
36 36
37 // SafeBrowsingResourceThrottle functions as BaseSafeBrowsingResourceThrottle, 37 // SafeBrowsingResourceThrottle functions as its base class
38 // but dispatches to either the local or remote SafeBrowsingDatabaseManager, 38 // safe_browsing::BaseResourceThrottle, but dispatches to either the local or
39 // depending on if running on desktop or mobile. It also has its own chrome- 39 // remote SafeBrowsingDatabaseManager, depending on if running on desktop or
40 // specific prerender check of redirect URLs inside 40 // mobile. It also has its own chrome-specific prerender check of redirect URLs
41 // StartDisplayingBlockingPage(). 41 // inside StartDisplayingBlockingPage().
42 // 42 //
43 // See also BaseSafeBrowsingResourceThrottle for details on how the safe 43 // See also safe_browsing::BaseResourceThrottle for details on how the safe
44 // browsing check occurs. 44 // browsing check occurs.
45 // 45 //
46 // On desktop (ifdef SAFE_BROWSING_DB_LOCAL) 46 // On desktop (ifdef SAFE_BROWSING_DB_LOCAL)
47 // ----------------------------------------- 47 // -----------------------------------------
48 // This check is done before requesting the original URL, and additionally 48 // This check is done before requesting the original URL, and additionally
49 // before following any subsequent redirect. In the common case the check 49 // before following any subsequent redirect. In the common case the check
50 // completes synchronously (no match in the in-memory DB), so the request's 50 // completes synchronously (no match in the in-memory DB), so the request's
51 // flow is un-interrupted. However if the URL fails this quick check, it 51 // flow is un-interrupted. However if the URL fails this quick check, it
52 // has the possibility of being on the blacklist. Now the request is 52 // has the possibility of being on the blacklist. Now the request is
53 // deferred (prevented from starting), and a more expensive safe browsing 53 // deferred (prevented from starting), and a more expensive safe browsing
54 // check is begun (fetches the full hashes). 54 // check is begun (fetches the full hashes).
55 // 55 //
56 // On mobile (ifdef SAFE_BROWSING_DB_REMOTE): 56 // On mobile (ifdef SAFE_BROWSING_DB_REMOTE):
57 // ----------------------------------------- 57 // -----------------------------------------
58 // The check is started and runs in parallel with the resource load. If the 58 // The check is started and runs in parallel with the resource load. If the
59 // check is not complete by the time the headers are loaded, the request is 59 // check is not complete by the time the headers are loaded, the request is
60 // suspended until the URL is classified. We let the headers load on mobile 60 // suspended until the URL is classified. We let the headers load on mobile
61 // since the RemoteSafeBrowsingDatabase checks always have some non-zero 61 // since the RemoteSafeBrowsingDatabase checks always have some non-zero
62 // latency -- there no synchronous pass. This parallelism helps 62 // latency -- there no synchronous pass. This parallelism helps
63 // performance. Redirects are handled the same way as desktop so they 63 // performance. Redirects are handled the same way as desktop so they
64 // always defer. 64 // always defer.
65 class SafeBrowsingResourceThrottle : public BaseSafeBrowsingResourceThrottle { 65 class SafeBrowsingResourceThrottle
66 : public safe_browsing::BaseResourceThrottle {
66 public: 67 public:
67 // Will construct a SafeBrowsingResourceThrottle, or return NULL 68 // Will construct a SafeBrowsingResourceThrottle, or return NULL
68 // if on Android and not in the field trial. 69 // if on Android and not in the field trial.
69 static SafeBrowsingResourceThrottle* MaybeCreate( 70 static SafeBrowsingResourceThrottle* MaybeCreate(
70 net::URLRequest* request, 71 net::URLRequest* request,
71 content::ResourceType resource_type, 72 content::ResourceType resource_type,
72 safe_browsing::SafeBrowsingService* sb_service); 73 safe_browsing::SafeBrowsingService* sb_service);
73 74
74 const char* GetNameForLogging() const override; 75 const char* GetNameForLogging() const override;
75 76
76 protected: 77 protected:
77 SafeBrowsingResourceThrottle(const net::URLRequest* request, 78 SafeBrowsingResourceThrottle(const net::URLRequest* request,
78 content::ResourceType resource_type, 79 content::ResourceType resource_type,
79 safe_browsing::SafeBrowsingService* sb_service); 80 safe_browsing::SafeBrowsingService* sb_service);
80 81
81 private: 82 private:
82 ~SafeBrowsingResourceThrottle() override; 83 ~SafeBrowsingResourceThrottle() override;
83 84
84 // This posts a task to destroy prerender contents 85 // This posts a task to destroy prerender contents
85 void MaybeDestroyPrerenderContents( 86 void MaybeDestroyPrerenderContents(
86 const content::ResourceRequestInfo* info) override; 87 const content::ResourceRequestInfo* info) override;
87 88
88 void StartDisplayingBlockingPageHelper( 89 void StartDisplayingBlockingPageHelper(
89 security_interstitials::UnsafeResource resource) override; 90 security_interstitials::UnsafeResource resource) override;
90 91
91 // Starts displaying the safe browsing interstitial page if it's not 92 // Starts displaying the safe browsing interstitial page if it's not
92 // prerendering. Called on the UI thread. 93 // prerendering. Called on the UI thread.
93 static void StartDisplayingBlockingPage( 94 static void StartDisplayingBlockingPage(
94 const base::WeakPtr<BaseSafeBrowsingResourceThrottle>& throttle, 95 const base::WeakPtr<safe_browsing::BaseResourceThrottle>& throttle,
95 scoped_refptr<safe_browsing::BaseSafeBrowsingUIManager> ui_manager, 96 scoped_refptr<safe_browsing::BaseUIManager> ui_manager,
96 const security_interstitials::UnsafeResource& resource); 97 const security_interstitials::UnsafeResource& resource);
97 98
98 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottle); 99 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottle);
99 }; 100 };
100 101
101 #endif // CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_ 102 #endif // CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/loader/safe_browsing_resource_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698