| 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 |
| 11 #include <deque> | 11 #include <deque> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 18 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 19 #include "content/public/common/resource_type.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 | 21 |
| 21 // Interface to either the locally-managed or a remotely-managed database. | 22 // Interface to either the locally-managed or a remotely-managed database. |
| 22 class SafeBrowsingDatabaseManager | 23 class SafeBrowsingDatabaseManager |
| 23 : public base::RefCountedThreadSafe<SafeBrowsingDatabaseManager> { | 24 : public base::RefCountedThreadSafe<SafeBrowsingDatabaseManager> { |
| 24 public: | 25 public: |
| 25 // Callers requesting a result should derive from this class. | 26 // Callers requesting a result should derive from this class. |
| 26 // The destructor should call db_manager->CancelCheck(client) if a | 27 // The destructor should call db_manager->CancelCheck(client) if a |
| 27 // request is still pending. | 28 // request is still pending. |
| 28 class Client { | 29 class Client { |
| 29 public: | 30 public: |
| 30 virtual ~Client() {} | 31 virtual ~Client() {} |
| 31 | 32 |
| 32 // Called when the result of checking a browse URL is known. | 33 // Called when the result of checking a browse URL is known. |
| 33 virtual void OnCheckBrowseUrlResult(const GURL& url, | 34 virtual void OnCheckBrowseUrlResult(const GURL& url, |
| 34 SBThreatType threat_type, | 35 SBThreatType threat_type, |
| 35 const std::string& metadata) {} | 36 const std::string& metadata) {} |
| 36 | 37 |
| 37 // Called when the result of checking a download URL is known. | 38 // Called when the result of checking a download URL is known. |
| 38 virtual void OnCheckDownloadUrlResult(const std::vector<GURL>& url_chain, | 39 virtual void OnCheckDownloadUrlResult(const std::vector<GURL>& url_chain, |
| 39 SBThreatType threat_type) {} | 40 SBThreatType threat_type) {} |
| 40 | 41 |
| 41 // Called when the result of checking a set of extensions is known. | 42 // Called when the result of checking a set of extensions is known. |
| 42 virtual void OnCheckExtensionsResult( | 43 virtual void OnCheckExtensionsResult( |
| 43 const std::set<std::string>& threats) {} | 44 const std::set<std::string>& threats) {} |
| 44 }; | 45 }; |
| 45 | 46 |
| 47 |
| 46 // Returns true if URL-checking is supported on this build+device. | 48 // Returns true if URL-checking is supported on this build+device. |
| 47 // If false, calls to CheckBrowseUrl may dcheck-fail. | 49 // If false, calls to CheckBrowseUrl may dcheck-fail. |
| 48 virtual bool IsSupported() const = 0; | 50 virtual bool IsSupported() const = 0; |
| 49 | 51 |
| 52 // Returns true if checks are never done synchronously, and therefore |
| 53 // always have some latency. |
| 54 virtual bool ChecksAreAlwaysAsync() const = 0; |
| 55 |
| 56 // Returns true if this resource type should be checked. |
| 57 virtual bool CanCheckResourceType( |
| 58 content::ResourceType resource_type) const = 0; |
| 59 |
| 50 // Returns true if the url's scheme can be checked. | 60 // Returns true if the url's scheme can be checked. |
| 51 virtual bool CanCheckUrl(const GURL& url) const = 0; | 61 virtual bool CanCheckUrl(const GURL& url) const = 0; |
| 52 | 62 |
| 53 // Returns whether download protection is enabled. | 63 // Returns whether download protection is enabled. |
| 54 virtual bool download_protection_enabled() const = 0; | 64 virtual bool download_protection_enabled() const = 0; |
| 55 | 65 |
| 56 // Called on the IO thread to check if the given url is safe or not. If we | 66 // Called on the IO thread to check if the given url is safe or not. If we |
| 57 // can synchronously determine that the url is safe, CheckUrl returns true. | 67 // can synchronously determine that the url is safe, CheckUrl returns true. |
| 58 // Otherwise it returns false, and "client" is called asynchronously with the | 68 // Otherwise it returns false, and "client" is called asynchronously with the |
| 59 // result when it is ready. | 69 // result when it is ready. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // on IO thread. If shutdown is true, the manager is disabled permanently. | 128 // on IO thread. If shutdown is true, the manager is disabled permanently. |
| 119 virtual void StopOnIOThread(bool shutdown) = 0; | 129 virtual void StopOnIOThread(bool shutdown) = 0; |
| 120 | 130 |
| 121 protected: | 131 protected: |
| 122 virtual ~SafeBrowsingDatabaseManager() {} | 132 virtual ~SafeBrowsingDatabaseManager() {} |
| 123 | 133 |
| 124 friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>; | 134 friend class base::RefCountedThreadSafe<SafeBrowsingDatabaseManager>; |
| 125 }; // class SafeBrowsingDatabaseManager | 135 }; // class SafeBrowsingDatabaseManager |
| 126 | 136 |
| 127 #endif // CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ | 137 #endif // CHROME_BROWSER_SAFE_BROWSING_DATABASE_MANAGER_H_ |
| OLD | NEW |