diff options
Diffstat (limited to 'chrome/browser/safe_browsing/safe_browsing_service.h')
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_service.h | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h index b9633f9..abade47 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.h +++ b/chrome/browser/safe_browsing/safe_browsing_service.h @@ -44,18 +44,36 @@ class SafeBrowsingService URL_SAFE, URL_PHISHING, URL_MALWARE, + BINARY_MALWARE, // This binary is a malware. }; class Client { public: virtual ~Client() {} - // Called when the result of checking a URL is known. - virtual void OnUrlCheckResult(const GURL& url, UrlCheckResult result) = 0; + void OnSafeBrowsingResult(const GURL& url, UrlCheckResult result) { + OnBrowseUrlCheckResult(url, result); + OnDownloadUrlCheckResult(url, result); + // TODO(lzheng): This is not implemented yet. + // OnDownloadHashCheckResult(url, result); + } // Called when the user has made a decision about how to handle the // SafeBrowsing interstitial page. - virtual void OnBlockingPageComplete(bool proceed) = 0; + virtual void OnBlockingPageComplete(bool proceed) {} + + protected: + // Called when the result of checking a browse URL is known. + virtual void OnBrowseUrlCheckResult(const GURL& url, + UrlCheckResult result) {} + + // Called when the result of checking a download URL is known. + virtual void OnDownloadUrlCheckResult(const GURL& url, + UrlCheckResult result) {} + + // Called when the result of checking a download binary hash is known. + virtual void OnDownloadHashCheckResult(const GURL& url, + UrlCheckResult result) {} }; // Structure used to pass parameters between the IO and UI thread when @@ -112,7 +130,11 @@ class SafeBrowsingService // can synchronously determine that the url is safe, CheckUrl returns true. // Otherwise it returns false, and "client" is called asynchronously with the // result when it is ready. - virtual bool CheckUrl(const GURL& url, Client* client); + virtual bool CheckBrowseUrl(const GURL& url, Client* client); + + // Check if the prefix for |url| is in safebrowsing download add lists. + // Result will be passed to callback in |client|. + bool CheckDownloadUrl(const GURL& url, Client* client); // Called on the IO thread to cancel a pending check if the result is no // longer needed. @@ -299,6 +321,14 @@ class SafeBrowsingService bool is_subresource, UrlCheckResult threat_type); + // Invoked by CheckDownloadUrl. It checks the download URL on + // safe_browsing_thread_. + void CheckDownloadUrlOnSBThread(const GURL& url, Client* client); + + // Call the Client's callback in IO thread after CheckDownloadUrl finishes. + void CheckDownloadUrlDone(Client* client, const GURL& url, + UrlCheckResult result); + // The factory used to instanciate a SafeBrowsingService object. // Useful for tests, so they can provide their own implementation of // SafeBrowsingService. @@ -325,6 +355,10 @@ class SafeBrowsingService // on the IO thread during normal operations. bool enabled_; + // Indicate if download_protection is enabled by command switch + // so we allow this feature to be exersized. + bool enable_download_protection_; + // The SafeBrowsing thread that runs database operations. // // Note: Functions that run on this thread should run synchronously and return |