| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
| 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
| 7 | 7 |
| 8 // A class that provides the interface between the SafeBrowsing protocol manager | 8 // A class that provides the interface between the SafeBrowsing protocol manager |
| 9 // and database that holds the downloaded updates. | 9 // and database that holds the downloaded updates. |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 using content::ResourceType; | 21 using content::ResourceType; |
| 22 | 22 |
| 23 namespace safe_browsing { | 23 namespace safe_browsing { |
| 24 | 24 |
| 25 typedef unsigned ThreatSeverity; | 25 typedef unsigned ThreatSeverity; |
| 26 | 26 |
| 27 // Manages the local, on-disk database of updates downloaded from the | 27 // Manages the local, on-disk database of updates downloaded from the |
| 28 // SafeBrowsing service and interfaces with the protocol manager. | 28 // SafeBrowsing service and interfaces with the protocol manager. |
| 29 class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { | 29 class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { |
| 30 public: | 30 public: |
| 31 enum class ClientCallbackType { | 31 // Create and return an instance of V4LocalDatabaseManager, if Finch trial |
| 32 // This represents the case when we're trying to determine if a URL is | 32 // allows it; nullptr otherwise. |
| 33 // unsafe from the following perspectives: Malware, Phishing, UwS. | 33 static scoped_refptr<V4LocalDatabaseManager> Create( |
| 34 CHECK_BROWSE_URL = 0, | 34 const base::FilePath& base_path); |
| 35 | |
| 36 // This should always be the last value. | |
| 37 CHECK_MAX | |
| 38 }; | |
| 39 | |
| 40 // Construct V4LocalDatabaseManager. | |
| 41 // Must be initialized by calling StartOnIOThread() before using. | |
| 42 V4LocalDatabaseManager(const base::FilePath& base_path); | |
| 43 | 35 |
| 44 // | 36 // |
| 45 // SafeBrowsingDatabaseManager implementation | 37 // SafeBrowsingDatabaseManager implementation |
| 46 // | 38 // |
| 47 | 39 |
| 48 void CancelCheck(Client* client) override; | 40 void CancelCheck(Client* client) override; |
| 49 bool CanCheckResourceType(content::ResourceType resource_type) const override; | 41 bool CanCheckResourceType(content::ResourceType resource_type) const override; |
| 50 bool CanCheckUrl(const GURL& url) const override; | 42 bool CanCheckUrl(const GURL& url) const override; |
| 51 bool ChecksAreAlwaysAsync() const override; | 43 bool ChecksAreAlwaysAsync() const override; |
| 52 bool CheckBrowseUrl(const GURL& url, Client* client) override; | 44 bool CheckBrowseUrl(const GURL& url, Client* client) override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 67 bool IsSupported() const override; | 59 bool IsSupported() const override; |
| 68 void StartOnIOThread(net::URLRequestContextGetter* request_context_getter, | 60 void StartOnIOThread(net::URLRequestContextGetter* request_context_getter, |
| 69 const V4ProtocolConfig& config) override; | 61 const V4ProtocolConfig& config) override; |
| 70 void StopOnIOThread(bool shutdown) override; | 62 void StopOnIOThread(bool shutdown) override; |
| 71 | 63 |
| 72 // | 64 // |
| 73 // End: SafeBrowsingDatabaseManager implementation | 65 // End: SafeBrowsingDatabaseManager implementation |
| 74 // | 66 // |
| 75 | 67 |
| 76 protected: | 68 protected: |
| 69 // Construct V4LocalDatabaseManager. |
| 70 // Must be initialized by calling StartOnIOThread() before using. |
| 71 V4LocalDatabaseManager(const base::FilePath& base_path); |
| 72 |
| 73 enum class ClientCallbackType { |
| 74 // This represents the case when we're trying to determine if a URL is |
| 75 // unsafe from the following perspectives: Malware, Phishing, UwS. |
| 76 CHECK_BROWSE_URL = 0, |
| 77 |
| 78 // This should always be the last value. |
| 79 CHECK_MAX |
| 80 }; |
| 81 |
| 77 // The information we need to process a URL safety reputation request and | 82 // The information we need to process a URL safety reputation request and |
| 78 // respond to the SafeBrowsing client that asked for it. | 83 // respond to the SafeBrowsing client that asked for it. |
| 79 // TODO(vakh): In its current form, it only includes information for | 84 // TODO(vakh): In its current form, it only includes information for |
| 80 // |CheckBrowseUrl| method. Extend it to serve other methods on |client|. | 85 // |CheckBrowseUrl| method. Extend it to serve other methods on |client|. |
| 81 struct PendingCheck { | 86 struct PendingCheck { |
| 82 PendingCheck(Client* client, | 87 PendingCheck(Client* client, |
| 83 ClientCallbackType client_callback_type, | 88 ClientCallbackType client_callback_type, |
| 84 const StoresToCheck& stores_to_check, | 89 const StoresToCheck& stores_to_check, |
| 85 const GURL& url); | 90 const GURL& url); |
| 86 | 91 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // The protocol manager that downloads the hash prefix updates. | 227 // The protocol manager that downloads the hash prefix updates. |
| 223 std::unique_ptr<V4UpdateProtocolManager> v4_update_protocol_manager_; | 228 std::unique_ptr<V4UpdateProtocolManager> v4_update_protocol_manager_; |
| 224 | 229 |
| 225 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; | 230 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; |
| 226 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); | 231 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); |
| 227 }; // class V4LocalDatabaseManager | 232 }; // class V4LocalDatabaseManager |
| 228 | 233 |
| 229 } // namespace safe_browsing | 234 } // namespace safe_browsing |
| 230 | 235 |
| 231 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ | 236 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
| OLD | NEW |