| 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 CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ |
| 9 #define CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 Client* client, | 60 Client* client, |
| 61 safe_browsing_util::ListType check_type, | 61 safe_browsing_util::ListType check_type, |
| 62 const std::vector<SBThreatType>& expected_threats); | 62 const std::vector<SBThreatType>& expected_threats); |
| 63 ~SafeBrowsingCheck(); | 63 ~SafeBrowsingCheck(); |
| 64 | 64 |
| 65 // Either |urls| or |full_hashes| is used to lookup database. |*_results| | 65 // Either |urls| or |full_hashes| is used to lookup database. |*_results| |
| 66 // are parallel vectors containing the results. They are initialized to | 66 // are parallel vectors containing the results. They are initialized to |
| 67 // contain SB_THREAT_TYPE_SAFE. | 67 // contain SB_THREAT_TYPE_SAFE. |
| 68 std::vector<GURL> urls; | 68 std::vector<GURL> urls; |
| 69 std::vector<SBThreatType> url_results; | 69 std::vector<SBThreatType> url_results; |
| 70 std::vector<std::string> url_metadata; |
| 70 std::vector<SBFullHash> full_hashes; | 71 std::vector<SBFullHash> full_hashes; |
| 71 std::vector<SBThreatType> full_hash_results; | 72 std::vector<SBThreatType> full_hash_results; |
| 72 | 73 |
| 73 Client* client; | 74 Client* client; |
| 74 bool need_get_hash; | 75 bool need_get_hash; |
| 75 base::TimeTicks start; // When check was sent to SB service. | 76 base::TimeTicks start; // When check was sent to SB service. |
| 76 safe_browsing_util::ListType check_type; // See comment in constructor. | 77 safe_browsing_util::ListType check_type; // See comment in constructor. |
| 77 std::vector<SBThreatType> expected_threats; | 78 std::vector<SBThreatType> expected_threats; |
| 78 std::vector<SBPrefix> prefix_hits; | 79 std::vector<SBPrefix> prefix_hits; |
| 79 std::vector<SBFullHashResult> cache_hits; | 80 std::vector<SBFullHashResult> cache_hits; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 | 94 |
| 94 class Client { | 95 class Client { |
| 95 public: | 96 public: |
| 96 void OnSafeBrowsingResult(const SafeBrowsingCheck& check); | 97 void OnSafeBrowsingResult(const SafeBrowsingCheck& check); |
| 97 | 98 |
| 98 protected: | 99 protected: |
| 99 virtual ~Client() {} | 100 virtual ~Client() {} |
| 100 | 101 |
| 101 // Called when the result of checking a browse URL is known. | 102 // Called when the result of checking a browse URL is known. |
| 102 virtual void OnCheckBrowseUrlResult(const GURL& url, | 103 virtual void OnCheckBrowseUrlResult(const GURL& url, |
| 103 SBThreatType threat_type) {} | 104 SBThreatType threat_type, |
| 105 const std::string& metadata) {} |
| 104 | 106 |
| 105 // Called when the result of checking a download URL is known. | 107 // Called when the result of checking a download URL is known. |
| 106 virtual void OnCheckDownloadUrlResult(const std::vector<GURL>& url_chain, | 108 virtual void OnCheckDownloadUrlResult(const std::vector<GURL>& url_chain, |
| 107 SBThreatType threat_type) {} | 109 SBThreatType threat_type) {} |
| 108 | 110 |
| 109 // Called when the result of checking a set of extensions is known. | 111 // Called when the result of checking a set of extensions is known. |
| 110 virtual void OnCheckExtensionsResult( | 112 virtual void OnCheckExtensionsResult( |
| 111 const std::set<std::string>& threats) {} | 113 const std::set<std::string>& threats) {} |
| 112 }; | 114 }; |
| 113 | 115 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // |hash|, or SAFE if none match. | 241 // |hash|, or SAFE if none match. |
| 240 static SBThreatType GetHashThreatType( | 242 static SBThreatType GetHashThreatType( |
| 241 const SBFullHash& hash, | 243 const SBFullHash& hash, |
| 242 const std::vector<SBFullHashResult>& full_hashes); | 244 const std::vector<SBFullHashResult>& full_hashes); |
| 243 | 245 |
| 244 // Given a URL, compare all the possible host + path full hashes to the set of | 246 // Given a URL, compare all the possible host + path full hashes to the set of |
| 245 // provided full hashes. Returns the threat type of the matching result from | 247 // provided full hashes. Returns the threat type of the matching result from |
| 246 // |full_hashes|, or SAFE if none match. | 248 // |full_hashes|, or SAFE if none match. |
| 247 static SBThreatType GetUrlThreatType( | 249 static SBThreatType GetUrlThreatType( |
| 248 const GURL& url, | 250 const GURL& url, |
| 249 const std::vector<SBFullHashResult>& full_hashes); | 251 const std::vector<SBFullHashResult>& full_hashes, |
| 252 size_t* index); |
| 250 | 253 |
| 251 // Called to stop operations on the io_thread. This may be called multiple | 254 // Called to stop operations on the io_thread. This may be called multiple |
| 252 // times during the life of the DatabaseManager. Should be called on IO | 255 // times during the life of the DatabaseManager. Should be called on IO |
| 253 // thread. | 256 // thread. |
| 254 void DoStopOnIOThread(); | 257 void DoStopOnIOThread(); |
| 255 | 258 |
| 256 // Returns whether |database_| exists and is accessible. | 259 // Returns whether |database_| exists and is accessible. |
| 257 bool DatabaseAvailable() const; | 260 bool DatabaseAvailable() const; |
| 258 | 261 |
| 259 // Called on the IO thread. If the database does not exist, queues up a call | 262 // Called on the IO thread. If the database does not exist, queues up a call |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 409 |
| 407 std::deque<QueuedCheck> queued_checks_; | 410 std::deque<QueuedCheck> queued_checks_; |
| 408 | 411 |
| 409 // Timeout to use for safe browsing checks. | 412 // Timeout to use for safe browsing checks. |
| 410 base::TimeDelta check_timeout_; | 413 base::TimeDelta check_timeout_; |
| 411 | 414 |
| 412 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseManager); | 415 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseManager); |
| 413 }; | 416 }; |
| 414 | 417 |
| 415 #endif // CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ | 418 #endif // CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ |
| OLD | NEW |