| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 virtual bool CheckExtensionIDs(const std::set<std::string>& extension_ids, | 142 virtual bool CheckExtensionIDs(const std::set<std::string>& extension_ids, |
| 143 Client* client); | 143 Client* client); |
| 144 | 144 |
| 145 // Check if the given url is on the side-effect free whitelist. | 145 // Check if the given url is on the side-effect free whitelist. |
| 146 // Can be called on any thread. Returns false if the check cannot be performed | 146 // Can be called on any thread. Returns false if the check cannot be performed |
| 147 // (e.g. because we are disabled or because of an invalid scheme in the URL). | 147 // (e.g. because we are disabled or because of an invalid scheme in the URL). |
| 148 // Otherwise, returns true if the URL is on the whitelist based on matching | 148 // Otherwise, returns true if the URL is on the whitelist based on matching |
| 149 // the hash prefix only (so there may be false positives). | 149 // the hash prefix only (so there may be false positives). |
| 150 virtual bool CheckSideEffectFreeWhitelistUrl(const GURL& url); | 150 virtual bool CheckSideEffectFreeWhitelistUrl(const GURL& url); |
| 151 | 151 |
| 152 // Check if the |url| matches any of the full-length hashes from the | 152 // Check if the |url| matches any of the full-length hashes from the client- |
| 153 // client-side phishing detection whitelist. Returns true if there was a | 153 // side phishing detection whitelist. Returns true if there was a match and |
| 154 // match and false otherwise. To make sure we are conservative we will return | 154 // false otherwise. To make sure we are conservative we will return true if |
| 155 // true if an error occurs. This method is expected to be called on the IO | 155 // an error occurs. This method must be called on the IO thread. |
| 156 // thread. | |
| 157 virtual bool MatchCsdWhitelistUrl(const GURL& url); | 156 virtual bool MatchCsdWhitelistUrl(const GURL& url); |
| 158 | 157 |
| 159 // Check if the given IP address (either IPv4 or IPv6) matches the malware | 158 // Check if the given IP address (either IPv4 or IPv6) matches the malware |
| 160 // IP blacklist. | 159 // IP blacklist. |
| 161 virtual bool MatchMalwareIP(const std::string& ip_address); | 160 virtual bool MatchMalwareIP(const std::string& ip_address); |
| 162 | 161 |
| 163 // Check if the |url| matches any of the full-length hashes from the | 162 // Check if the |url| matches any of the full-length hashes from the download |
| 164 // download whitelist. Returns true if there was a match and false otherwise. | 163 // whitelist. Returns true if there was a match and false otherwise. To make |
| 165 // To make sure we are conservative we will return true if an error occurs. | 164 // sure we are conservative we will return true if an error occurs. This |
| 166 // This method is expected to be called on the IO thread. | 165 // method must be called on the IO thread. |
| 167 virtual bool MatchDownloadWhitelistUrl(const GURL& url); | 166 virtual bool MatchDownloadWhitelistUrl(const GURL& url); |
| 168 | 167 |
| 169 // Check if |str| matches any of the full-length hashes from the download | 168 // Check if |str| matches any of the full-length hashes from the download |
| 170 // whitelist. Returns true if there was a match and false otherwise. | 169 // whitelist. Returns true if there was a match and false otherwise. To make |
| 171 // To make sure we are conservative we will return true if an error occurs. | 170 // sure we are conservative we will return true if an error occurs. This |
| 172 // This method is expected to be called on the IO thread. | 171 // method must be called on the IO thread. |
| 173 virtual bool MatchDownloadWhitelistString(const std::string& str); | 172 virtual bool MatchDownloadWhitelistString(const std::string& str); |
| 174 | 173 |
| 174 // Check if the |url| matches any of the full-length hashes from the off- |
| 175 // domain inclusion whitelist. Returns true if there was a match and false |
| 176 // otherwise. To make sure we are conservative, we will return true if an |
| 177 // error occurs. This method must be called on the IO thread. |
| 178 virtual bool MatchInclusionWhitelistUrl(const GURL& url); |
| 179 |
| 175 // Check if the CSD malware IP matching kill switch is turned on. | 180 // Check if the CSD malware IP matching kill switch is turned on. |
| 176 virtual bool IsMalwareKillSwitchOn(); | 181 virtual bool IsMalwareKillSwitchOn(); |
| 177 | 182 |
| 178 // Check if the CSD whitelist kill switch is turned on. | 183 // Check if the CSD whitelist kill switch is turned on. |
| 179 virtual bool IsCsdWhitelistKillSwitchOn(); | 184 virtual bool IsCsdWhitelistKillSwitchOn(); |
| 180 | 185 |
| 181 // Called on the IO thread to cancel a pending check if the result is no | 186 // Called on the IO thread to cancel a pending check if the result is no |
| 182 // longer needed. | 187 // longer needed. |
| 183 void CancelCheck(Client* client); | 188 void CancelCheck(Client* client); |
| 184 | 189 |
| 185 // Called on the IO thread when the SafeBrowsingProtocolManager has received | 190 // Called on the IO thread when the SafeBrowsingProtocolManager has received |
| 186 // the full hash results for prefix hits detected in the database. | 191 // the full hash results for prefix hits detected in the database. |
| 187 void HandleGetHashResults(SafeBrowsingCheck* check, | 192 void HandleGetHashResults(SafeBrowsingCheck* check, |
| 188 const std::vector<SBFullHashResult>& full_hashes, | 193 const std::vector<SBFullHashResult>& full_hashes, |
| 189 const base::TimeDelta& cache_lifetime); | 194 const base::TimeDelta& cache_lifetime); |
| 190 | 195 |
| 191 // Called to initialize objects that are used on the io_thread. This may be | 196 // Called to initialize objects that are used on the io_thread. This may be |
| 192 // called multiple times during the life of the DatabaseManager. Should be | 197 // called multiple times during the life of the DatabaseManager. Must be |
| 193 // called on IO thread. | 198 // called on IO thread. |
| 194 void StartOnIOThread(); | 199 void StartOnIOThread(); |
| 195 | 200 |
| 196 // Called to stop or shutdown operations on the io_thread. This may be called | 201 // Called to stop or shutdown operations on the io_thread. This may be called |
| 197 // multiple times during the life of the DatabaseManager. Should be called | 202 // multiple times during the life of the DatabaseManager. Must be called |
| 198 // on IO thread. If shutdown is true, the manager is disabled permanently. | 203 // on IO thread. If shutdown is true, the manager is disabled permanently. |
| 199 void StopOnIOThread(bool shutdown); | 204 void StopOnIOThread(bool shutdown); |
| 200 | 205 |
| 201 protected: | 206 protected: |
| 202 ~SafeBrowsingDatabaseManager() override; | 207 ~SafeBrowsingDatabaseManager() override; |
| 203 | 208 |
| 204 // protected for tests. | 209 // protected for tests. |
| 205 void NotifyDatabaseUpdateFinished(bool update_succeeded); | 210 void NotifyDatabaseUpdateFinished(bool update_succeeded); |
| 206 | 211 |
| 207 private: | 212 private: |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 412 |
| 408 std::deque<QueuedCheck> queued_checks_; | 413 std::deque<QueuedCheck> queued_checks_; |
| 409 | 414 |
| 410 // Timeout to use for safe browsing checks. | 415 // Timeout to use for safe browsing checks. |
| 411 base::TimeDelta check_timeout_; | 416 base::TimeDelta check_timeout_; |
| 412 | 417 |
| 413 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseManager); | 418 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseManager); |
| 414 }; | 419 }; |
| 415 | 420 |
| 416 #endif // CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ | 421 #endif // CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ |
| OLD | NEW |