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 |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <unordered_set> | 13 #include <unordered_set> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "components/safe_browsing_db/hit_report.h" | 19 #include "components/safe_browsing_db/hit_report.h" |
| 20 #include "components/safe_browsing_db/util.h" | 20 #include "components/safe_browsing_db/util.h" |
| 21 #include "content/public/common/resource_type.h" | 21 #include "content/public/common/resource_type.h" |
| 22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 class URLRequestContextGetter; | 25 class URLRequestContextGetter; |
| 26 } // namespace net | 26 } // namespace net |
| 27 | 27 |
| 28 namespace safe_browsing { | 28 namespace safe_browsing { |
| 29 | 29 |
| 30 // Value returned by some Check*Whitelist() calls that may or may not have an | |
| 31 // immediate answer. | |
| 32 enum class AsyncMatch { | |
| 33 ASYNC, // No answer yet -- Client will get a callback | |
| 34 MATCH, // URL matches the list. No callback. | |
| 35 NO_MATCH, // URL doesn't match. No callback. | |
| 36 }; | |
| 37 | |
| 30 struct V4ProtocolConfig; | 38 struct V4ProtocolConfig; |
| 31 class V4GetHashProtocolManager; | 39 class V4GetHashProtocolManager; |
| 32 | 40 |
| 33 // Base class to either the locally-managed or a remotely-managed database. | 41 // Base class to either the locally-managed or a remotely-managed database. |
| 34 class SafeBrowsingDatabaseManager | 42 class SafeBrowsingDatabaseManager |
| 35 : public base::RefCountedThreadSafe<SafeBrowsingDatabaseManager> { | 43 : public base::RefCountedThreadSafe<SafeBrowsingDatabaseManager> { |
| 36 public: | 44 public: |
| 37 // Callers requesting a result should derive from this class. | 45 // Callers requesting a result should derive from this class. |
| 38 // The destructor should call db_manager->CancelCheck(client) if a | 46 // The destructor should call db_manager->CancelCheck(client) if a |
| 39 // request is still pending. | 47 // request is still pending. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 57 SBThreatType threat_type) {} | 65 SBThreatType threat_type) {} |
| 58 | 66 |
| 59 // Called when the result of checking a set of extensions is known. | 67 // Called when the result of checking a set of extensions is known. |
| 60 virtual void OnCheckExtensionsResult( | 68 virtual void OnCheckExtensionsResult( |
| 61 const std::set<std::string>& threats) {} | 69 const std::set<std::string>& threats) {} |
| 62 | 70 |
| 63 // Called when the result of checking the resource blacklist is known. | 71 // Called when the result of checking the resource blacklist is known. |
| 64 virtual void OnCheckResourceUrlResult(const GURL& url, | 72 virtual void OnCheckResourceUrlResult(const GURL& url, |
| 65 SBThreatType threat_type, | 73 SBThreatType threat_type, |
| 66 const std::string& threat_hash) {} | 74 const std::string& threat_hash) {} |
| 75 | |
| 76 // Called when the result of checking the CSD whitelist is known. | |
| 77 virtual void OnCheckWhitelistUrlResult(bool is_whitelisted) {} | |
|
vakh (use Gerrit instead)
2017/05/24 16:01:17
The comment is CSD specific but the method name is
Nathan Parker
2017/05/31 23:40:11
Done.
| |
| 67 }; | 78 }; |
| 68 | 79 |
| 69 // | 80 // |
| 70 // Methods called by the client to cancel pending checks. | 81 // Methods called by the client to cancel pending checks. |
| 71 // | 82 // |
| 72 | 83 |
| 73 // Called on the IO thread to cancel a pending API check if the result is no | 84 // Called on the IO thread to cancel a pending API check if the result is no |
| 74 // longer needed. Returns true if the client was found and the check | 85 // longer needed. Returns true if the client was found and the check |
| 75 // successfully cancelled. | 86 // successfully cancelled. |
| 76 virtual bool CancelApiCheck(Client* client); | 87 virtual bool CancelApiCheck(Client* client); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 156 |
| 146 // | 157 // |
| 147 // Methods to synchronously check whether a URL, or full hash, or IP address | 158 // Methods to synchronously check whether a URL, or full hash, or IP address |
| 148 // or a DLL file is safe. | 159 // or a DLL file is safe. |
| 149 // | 160 // |
| 150 | 161 |
| 151 // Check if the |url| matches any of the full-length hashes from the client- | 162 // Check if the |url| matches any of the full-length hashes from the client- |
| 152 // side phishing detection whitelist. Returns true if there was a match and | 163 // side phishing detection whitelist. Returns true if there was a match and |
| 153 // false otherwise. To make sure we are conservative we will return true if | 164 // false otherwise. To make sure we are conservative we will return true if |
| 154 // an error occurs. This method must be called on the IO thread. | 165 // an error occurs. This method must be called on the IO thread. |
| 166 // | |
| 167 // DEPRECATED. ref: http://crbug.com/714300 | |
| 155 virtual bool MatchCsdWhitelistUrl(const GURL& url) = 0; | 168 virtual bool MatchCsdWhitelistUrl(const GURL& url) = 0; |
| 156 | 169 |
| 170 // Check if the |url| matches any of the full-length hashes from the client- | |
| 171 // side phishing detection whitelist. The 3-state return value indicates | |
| 172 // the result or that the Client will get a callback later with the result. | |
| 173 virtual AsyncMatch CheckCsdWhitelistUrl(const GURL& url, Client* client) = 0; | |
|
vakh (use Gerrit instead)
2017/05/24 16:01:16
Please move this declaration above to keep it sort
Nathan Parker
2017/05/31 23:40:11
Done.
| |
| 174 | |
| 157 // Check if |str| matches any of the full-length hashes from the download | 175 // Check if |str| matches any of the full-length hashes from the download |
| 158 // whitelist. Returns true if there was a match and false otherwise. To make | 176 // whitelist. Returns true if there was a match and false otherwise. To make |
| 159 // sure we are conservative we will return true if an error occurs. This | 177 // sure we are conservative we will return true if an error occurs. This |
| 160 // method must be called on the IO thread. | 178 // method must be called on the IO thread. |
| 161 virtual bool MatchDownloadWhitelistString(const std::string& str) = 0; | 179 virtual bool MatchDownloadWhitelistString(const std::string& str) = 0; |
| 162 | 180 |
| 163 // Check if the |url| matches any of the full-length hashes from the download | 181 // Check if the |url| matches any of the full-length hashes from the download |
| 164 // whitelist. Returns true if there was a match and false otherwise. To make | 182 // whitelist. Returns true if there was a match and false otherwise. To make |
| 165 // sure we are conservative we will return true if an error occurs. This | 183 // sure we are conservative we will return true if an error occurs. This |
| 166 // method must be called on the IO thread. | 184 // method must be called on the IO thread. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 std::unique_ptr<V4GetHashProtocolManager> v4_get_hash_protocol_manager_; | 302 std::unique_ptr<V4GetHashProtocolManager> v4_get_hash_protocol_manager_; |
| 285 | 303 |
| 286 private: | 304 private: |
| 287 // Returns an iterator to the pending API check with the given |client|. | 305 // Returns an iterator to the pending API check with the given |client|. |
| 288 ApiCheckSet::iterator FindClientApiCheck(Client* client); | 306 ApiCheckSet::iterator FindClientApiCheck(Client* client); |
| 289 }; // class SafeBrowsingDatabaseManager | 307 }; // class SafeBrowsingDatabaseManager |
| 290 | 308 |
| 291 } // namespace safe_browsing | 309 } // namespace safe_browsing |
| 292 | 310 |
| 293 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ | 311 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ |
| OLD | NEW |