Chromium Code Reviews| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 virtual bool IsMalwareKillSwitchOn() = 0; | 167 virtual bool IsMalwareKillSwitchOn() = 0; |
| 168 | 168 |
| 169 // Check if the CSD whitelist kill switch is turned on. | 169 // Check if the CSD whitelist kill switch is turned on. |
| 170 virtual bool IsCsdWhitelistKillSwitchOn() = 0; | 170 virtual bool IsCsdWhitelistKillSwitchOn() = 0; |
| 171 | 171 |
| 172 // Called on the IO thread to cancel a pending check if the result is no | 172 // Called on the IO thread to cancel a pending check if the result is no |
| 173 // longer needed. Also called after the result has been handled. Api checks | 173 // longer needed. Also called after the result has been handled. Api checks |
| 174 // are handled separately. To cancel an API check use CancelApiCheck. | 174 // are handled separately. To cancel an API check use CancelApiCheck. |
| 175 virtual void CancelCheck(Client* client) = 0; | 175 virtual void CancelCheck(Client* client) = 0; |
| 176 | 176 |
| 177 // TODO(kcarattini): Add a CancelApiCheck method. | 177 // Called on the IO thread to cancel a pending API check if the result is no |
| 178 // longer needed. Returns true if the client was found and the check | |
| 179 // successfully cancelled. | |
| 180 virtual bool CancelApiCheck(Client* client); | |
| 178 | 181 |
| 179 // Called on the IO thread to check if the given url has blacklisted APIs. | 182 // Called on the IO thread to check if the given url has blacklisted APIs. |
| 180 // "client" is called asynchronously with the result when it is ready. | 183 // "client" is called asynchronously with the result when it is ready. Clients |
| 184 // should wait for results before calling this method a second time. | |
|
Nathan Parker
2016/04/15 23:27:35
We probably want a dcheck to enforce that.
kcarattini
2016/04/18 03:00:09
Done.
| |
| 181 // This method has the same implementation for both the local and remote | 185 // This method has the same implementation for both the local and remote |
| 182 // database managers since it pings Safe Browsing servers directly without | 186 // database managers since it pings Safe Browsing servers directly without |
| 183 // accessing the database at all. Returns true if we can synchronously | 187 // accessing the database at all. Returns true if we can synchronously |
| 184 // determine that the url is safe. Otherwise it returns false, and "client" is | 188 // determine that the url is safe. Otherwise it returns false, and "client" is |
| 185 // called asynchronously with the result when it is ready. | 189 // called asynchronously with the result when it is ready. |
| 186 virtual bool CheckApiBlacklistUrl(const GURL& url, Client* client); | 190 virtual bool CheckApiBlacklistUrl(const GURL& url, Client* client); |
| 187 | 191 |
| 188 // Called on the IO thread wheh the SafeBrowsingProtocolManager has received | 192 // Called on the IO thread wheh the SafeBrowsingProtocolManager has received |
| 189 // the full hash and api results for prefixes of the |url| argument in | 193 // the full hash and api results for prefixes of the |url| argument in |
| 190 // CheckApiBlacklistUrl. | 194 // CheckApiBlacklistUrl. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 211 friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>; | 215 friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>; |
| 212 | 216 |
| 213 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, | 217 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 214 CheckApiBlacklistUrlPrefixes); | 218 CheckApiBlacklistUrlPrefixes); |
| 215 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, | 219 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 216 HandleGetHashesWithApisResults); | 220 HandleGetHashesWithApisResults); |
| 217 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, | 221 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 218 HandleGetHashesWithApisResultsNoMatch); | 222 HandleGetHashesWithApisResultsNoMatch); |
| 219 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, | 223 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, |
| 220 HandleGetHashesWithApisResultsMatches); | 224 HandleGetHashesWithApisResultsMatches); |
| 225 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseManagerTest, | |
| 226 CancelApiCheck); | |
| 227 | |
| 228 typedef std::set<std::shared_ptr<SafeBrowsingApiCheck> > CurrentApiChecks; | |
| 229 | |
| 230 // In-progress checks. | |
| 231 CurrentApiChecks api_checks_; | |
| 221 | 232 |
| 222 // Created and destroyed via StartOnIOThread/StopOnIOThread. | 233 // Created and destroyed via StartOnIOThread/StopOnIOThread. |
| 223 V4GetHashProtocolManager* v4_get_hash_protocol_manager_; | 234 V4GetHashProtocolManager* v4_get_hash_protocol_manager_; |
| 224 }; // class SafeBrowsingDatabaseManager | 235 }; // class SafeBrowsingDatabaseManager |
| 225 | 236 |
| 226 } // namespace safe_browsing | 237 } // namespace safe_browsing |
| 227 | 238 |
| 228 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ | 239 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ |
| OLD | NEW |