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

Side by Side Diff: components/safe_browsing_db/database_manager.h

Issue 1895743002: Revert of Safe Browsing: CheckApiBlacklist request implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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_db/DEPS ('k') | components/safe_browsing_db/database_manager.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 // The Safe Browsing service is responsible for downloading anti-phishing and 5 // The Safe Browsing service is responsible for downloading anti-phishing and
6 // anti-malware tables and checking urls against them. 6 // anti-malware tables and checking urls against them.
7 7
8 #ifndef COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ 8 #ifndef COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_
9 #define COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ 9 #define COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_
10 10
11 #include <deque> 11 #include <deque>
12 #include <map> 12 #include <map>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/gtest_prod_util.h"
18 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
20 #include "components/safe_browsing_db/hit_report.h" 18 #include "components/safe_browsing_db/hit_report.h"
21 #include "components/safe_browsing_db/util.h" 19 #include "components/safe_browsing_db/util.h"
22 #include "content/public/common/resource_type.h" 20 #include "content/public/common/resource_type.h"
23 #include "url/gurl.h" 21 #include "url/gurl.h"
24 22
25 namespace net { 23 namespace net {
26 class URLRequestContextGetter; 24 class URLRequestContextGetter;
27 } // namespace net 25 } // namespace net
28 26
(...skipping 29 matching lines...) Expand all
58 // Called when the result of checking the API blacklist is known. 56 // Called when the result of checking the API blacklist is known.
59 virtual void OnCheckApiBlacklistUrlResult(const GURL& url, 57 virtual void OnCheckApiBlacklistUrlResult(const GURL& url,
60 const ThreatMetadata& metadata) {} 58 const ThreatMetadata& metadata) {}
61 59
62 // Called when the result of checking the resource blacklist is known. 60 // Called when the result of checking the resource blacklist is known.
63 virtual void OnCheckResourceUrlResult(const GURL& url, 61 virtual void OnCheckResourceUrlResult(const GURL& url,
64 SBThreatType threat_type, 62 SBThreatType threat_type,
65 const std::string& threat_hash) {} 63 const std::string& threat_hash) {}
66 }; 64 };
67 65
66
68 // Returns true if URL-checking is supported on this build+device. 67 // Returns true if URL-checking is supported on this build+device.
69 // If false, calls to CheckBrowseUrl may dcheck-fail. 68 // If false, calls to CheckBrowseUrl may dcheck-fail.
70 virtual bool IsSupported() const = 0; 69 virtual bool IsSupported() const = 0;
71 70
72 // Returns the ThreatSource for this implementation. 71 // Returns the ThreatSource for this implementation.
73 virtual ThreatSource GetThreatSource() const = 0; 72 virtual ThreatSource GetThreatSource() const = 0;
74 73
75 // Returns true if checks are never done synchronously, and therefore 74 // Returns true if checks are never done synchronously, and therefore
76 // always have some latency. 75 // always have some latency.
77 virtual bool ChecksAreAlwaysAsync() const = 0; 76 virtual bool ChecksAreAlwaysAsync() const = 0;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // an error occurs. This method must be called on the IO thread. 141 // an error occurs. This method must be called on the IO thread.
143 virtual bool MatchModuleWhitelistString(const std::string& str) = 0; 142 virtual bool MatchModuleWhitelistString(const std::string& str) = 0;
144 143
145 // Check if the CSD malware IP matching kill switch is turned on. 144 // Check if the CSD malware IP matching kill switch is turned on.
146 virtual bool IsMalwareKillSwitchOn() = 0; 145 virtual bool IsMalwareKillSwitchOn() = 0;
147 146
148 // Check if the CSD whitelist kill switch is turned on. 147 // Check if the CSD whitelist kill switch is turned on.
149 virtual bool IsCsdWhitelistKillSwitchOn() = 0; 148 virtual bool IsCsdWhitelistKillSwitchOn() = 0;
150 149
151 // Called on the IO thread to cancel a pending check if the result is no 150 // Called on the IO thread to cancel a pending check if the result is no
152 // longer needed. Also called after the result has been handled. Api checks 151 // longer needed. Also called after the result has been handled.
153 // are handled separately. To cancel an API check use CancelApiCheck.
154 virtual void CancelCheck(Client* client) = 0; 152 virtual void CancelCheck(Client* client) = 0;
155 153
156 // TODO(kcarattini): Add a CancelApiCheck method.
157
158 // Called on the IO thread to check if the given url has blacklisted APIs. 154 // Called on the IO thread to check if the given url has blacklisted APIs.
159 // "client" is called asynchronously with the result when it is ready. 155 // "client" is called asynchronously with the result when it is ready.
160 // This method has the same implementation for both the local and remote 156 // This method has the same implementation for both the local and remote
161 // database managers since it pings Safe Browsing servers directly without 157 // database managers since it pings Safe Browsing servers directly without
162 // accessing the database at all. Returns true if we can synchronously 158 // accessing the database at all.
163 // determine that the url is safe. Otherwise it returns false, and "client" is 159 virtual void CheckApiBlacklistUrl(const GURL& url, Client* client);
164 // called asynchronously with the result when it is ready.
165 virtual bool CheckApiBlacklistUrl(const GURL& url, Client* client);
166 160
167 // Called to initialize objects that are used on the io_thread, such as the 161 // Called to initialize objects that are used on the io_thread, such as the
168 // v4 protocol manager. This may be called multiple times during the life of 162 // v4 protocol manager. This may be called multiple times during the life of
169 // the DatabaseManager. Must be called on IO thread. 163 // the DatabaseManager. Must be called on IO thread.
170 virtual void StartOnIOThread( 164 virtual void StartOnIOThread(
171 net::URLRequestContextGetter* request_context_getter, 165 net::URLRequestContextGetter* request_context_getter,
172 const V4ProtocolConfig& config); 166 const V4ProtocolConfig& config);
173 167
174 // Called to stop or shutdown operations on the io_thread. 168 // Called to stop or shutdown operations on the io_thread.
175 virtual void StopOnIOThread(bool shutdown); 169 virtual void StopOnIOThread(bool shutdown);
176 170
177 protected: 171 protected:
178 SafeBrowsingDatabaseManager(); 172 SafeBrowsingDatabaseManager();
179 173
180 virtual ~SafeBrowsingDatabaseManager(); 174 virtual ~SafeBrowsingDatabaseManager();
181 175
182 friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>; 176 friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>;
183 177
184 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, 178 // Created and destroyed via StartonIOThread/StopOnIOThread.
185 CheckApiBlacklistUrlPrefixes);
186
187 // Bundled client info for an API abuse hash prefix check.
188 class SafeBrowsingApiCheck {
189 public:
190 SafeBrowsingApiCheck(const GURL& url,
191 const std::vector<SBFullHash>& full_hashes,
192 Client* client);
193 ~SafeBrowsingApiCheck();
194
195 private:
196 GURL url_;
197 std::vector<SBFullHash> full_hashes_;
198 // Not owned.
199 SafeBrowsingDatabaseManager::Client* client_;
200
201 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingApiCheck);
202 };
203
204 // Called on the IO thread wheh the SafeBrowsingProtocolManager has received
205 // the full hash and api results for prefixes of the |url| argument in
206 // CheckApiBlacklistUrl.
207 virtual void HandleGetHashesWithApisResults(
208 std::shared_ptr<SafeBrowsingApiCheck> check,
209 const std::vector<SBFullHashResult>& full_hash_results,
210 const base::TimeDelta& negative_cache_duration);
211
212 // Created and destroyed via StartOnIOThread/StopOnIOThread.
213 V4GetHashProtocolManager* v4_get_hash_protocol_manager_; 179 V4GetHashProtocolManager* v4_get_hash_protocol_manager_;
214 }; // class SafeBrowsingDatabaseManager 180 }; // class SafeBrowsingDatabaseManager
215 181
216 } // namespace safe_browsing 182 } // namespace safe_browsing
217 183
218 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ 184 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_
OLDNEW
« no previous file with comments | « components/safe_browsing_db/DEPS ('k') | components/safe_browsing_db/database_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698