| OLD | NEW |
| 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 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 // Called when the result of checking a download URL is known. | 50 // Called when the result of checking a download URL is known. |
| 51 virtual void OnCheckDownloadUrlResult(const std::vector<GURL>& url_chain, | 51 virtual void OnCheckDownloadUrlResult(const std::vector<GURL>& url_chain, |
| 52 SBThreatType threat_type) {} | 52 SBThreatType threat_type) {} |
| 53 | 53 |
| 54 // Called when the result of checking a set of extensions is known. | 54 // Called when the result of checking a set of extensions is known. |
| 55 virtual void OnCheckExtensionsResult( | 55 virtual void OnCheckExtensionsResult( |
| 56 const std::set<std::string>& threats) {} | 56 const std::set<std::string>& threats) {} |
| 57 | 57 |
| 58 // Called when the result of checking the API blacklist is known. | 58 // Called when the result of checking the API blacklist is known. |
| 59 // TODO(kcarattini): Consider if we need |url| passed here, remove if not. |
| 59 virtual void OnCheckApiBlacklistUrlResult(const GURL& url, | 60 virtual void OnCheckApiBlacklistUrlResult(const GURL& url, |
| 60 const ThreatMetadata& metadata) {} | 61 const ThreatMetadata& metadata) {} |
| 61 | 62 |
| 62 // Called when the result of checking the resource blacklist is known. | 63 // Called when the result of checking the resource blacklist is known. |
| 63 virtual void OnCheckResourceUrlResult(const GURL& url, | 64 virtual void OnCheckResourceUrlResult(const GURL& url, |
| 64 SBThreatType threat_type, | 65 SBThreatType threat_type, |
| 65 const std::string& threat_hash) {} | 66 const std::string& threat_hash) {} |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 // Returns true if URL-checking is supported on this build+device. | 69 // Returns true if URL-checking is supported on this build+device. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // v4 protocol manager. This may be called multiple times during the life of | 169 // v4 protocol manager. This may be called multiple times during the life of |
| 169 // the DatabaseManager. Must be called on IO thread. | 170 // the DatabaseManager. Must be called on IO thread. |
| 170 virtual void StartOnIOThread( | 171 virtual void StartOnIOThread( |
| 171 net::URLRequestContextGetter* request_context_getter, | 172 net::URLRequestContextGetter* request_context_getter, |
| 172 const V4ProtocolConfig& config); | 173 const V4ProtocolConfig& config); |
| 173 | 174 |
| 174 // Called to stop or shutdown operations on the io_thread. | 175 // Called to stop or shutdown operations on the io_thread. |
| 175 virtual void StopOnIOThread(bool shutdown); | 176 virtual void StopOnIOThread(bool shutdown); |
| 176 | 177 |
| 177 protected: | 178 protected: |
| 178 SafeBrowsingDatabaseManager(); | |
| 179 | |
| 180 virtual ~SafeBrowsingDatabaseManager(); | |
| 181 | |
| 182 friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>; | |
| 183 | |
| 184 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, | |
| 185 CheckApiBlacklistUrlPrefixes); | |
| 186 | |
| 187 // Bundled client info for an API abuse hash prefix check. | 179 // Bundled client info for an API abuse hash prefix check. |
| 188 class SafeBrowsingApiCheck { | 180 class SafeBrowsingApiCheck { |
| 189 public: | 181 public: |
| 190 SafeBrowsingApiCheck(const GURL& url, | 182 SafeBrowsingApiCheck(const GURL& url, |
| 191 const std::vector<SBFullHash>& full_hashes, | 183 const std::vector<SBFullHash>& full_hashes, |
| 192 Client* client); | 184 Client* client); |
| 193 ~SafeBrowsingApiCheck(); | 185 ~SafeBrowsingApiCheck(); |
| 194 | 186 |
| 187 const GURL& url() {return url_;} |
| 188 std::vector<SBFullHash>& full_hashes() {return full_hashes_;} |
| 189 SafeBrowsingDatabaseManager::Client* client() {return client_;} |
| 190 |
| 195 private: | 191 private: |
| 196 GURL url_; | 192 GURL url_; |
| 197 std::vector<SBFullHash> full_hashes_; | 193 std::vector<SBFullHash> full_hashes_; |
| 198 // Not owned. | 194 // Not owned. |
| 199 SafeBrowsingDatabaseManager::Client* client_; | 195 SafeBrowsingDatabaseManager::Client* client_; |
| 200 | 196 |
| 201 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingApiCheck); | 197 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingApiCheck); |
| 202 }; | 198 }; |
| 203 | 199 |
| 200 SafeBrowsingDatabaseManager(); |
| 201 |
| 202 virtual ~SafeBrowsingDatabaseManager(); |
| 203 |
| 204 friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>; |
| 205 |
| 206 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 207 CheckApiBlacklistUrlPrefixes); |
| 208 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 209 HandleGetHashesWithApisResults); |
| 210 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 211 HandleGetHashesWithApisResultsNoMatch); |
| 212 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 213 HandleGetHashesWithApisResultsMatches); |
| 214 |
| 204 // Called on the IO thread wheh the SafeBrowsingProtocolManager has received | 215 // Called on the IO thread wheh the SafeBrowsingProtocolManager has received |
| 205 // the full hash and api results for prefixes of the |url| argument in | 216 // the full hash and api results for prefixes of the |url| argument in |
| 206 // CheckApiBlacklistUrl. | 217 // CheckApiBlacklistUrl. |
| 207 virtual void HandleGetHashesWithApisResults( | 218 virtual void HandleGetHashesWithApisResults( |
| 208 std::shared_ptr<SafeBrowsingApiCheck> check, | 219 std::shared_ptr<SafeBrowsingApiCheck> check, |
| 209 const std::vector<SBFullHashResult>& full_hash_results, | 220 const std::vector<SBFullHashResult>& full_hash_results, |
| 210 const base::TimeDelta& negative_cache_duration); | 221 const base::TimeDelta& negative_cache_duration); |
| 211 | 222 |
| 212 // Created and destroyed via StartOnIOThread/StopOnIOThread. | 223 // Created and destroyed via StartOnIOThread/StopOnIOThread. |
| 213 V4GetHashProtocolManager* v4_get_hash_protocol_manager_; | 224 V4GetHashProtocolManager* v4_get_hash_protocol_manager_; |
| 214 }; // class SafeBrowsingDatabaseManager | 225 }; // class SafeBrowsingDatabaseManager |
| 215 | 226 |
| 216 } // namespace safe_browsing | 227 } // namespace safe_browsing |
| 217 | 228 |
| 218 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ | 229 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ |
| OLD | NEW |