| 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 // Helper class which handles communication with the SafeBrowsing servers for | 5 // Helper class which handles communication with the SafeBrowsing servers for |
| 6 // improved binary download protection. | 6 // improved binary download protection. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
| 9 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 SAFE, | 51 SAFE, |
| 52 DANGEROUS, | 52 DANGEROUS, |
| 53 UNCOMMON, | 53 UNCOMMON, |
| 54 DANGEROUS_HOST, | 54 DANGEROUS_HOST, |
| 55 POTENTIALLY_UNWANTED | 55 POTENTIALLY_UNWANTED |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // Callback type which is invoked once the download request is done. | 58 // Callback type which is invoked once the download request is done. |
| 59 typedef base::Callback<void(DownloadCheckResult)> CheckDownloadCallback; | 59 typedef base::Callback<void(DownloadCheckResult)> CheckDownloadCallback; |
| 60 | 60 |
| 61 // Callback type which is invoked once the download content check is done. |
| 62 typedef base::Callback<void(DownloadCheckResult, const std::string& token)> |
| 63 CheckDownloadContentCallback; |
| 64 |
| 61 // A type of callback run on the main thread when a ClientDownloadRequest has | 65 // A type of callback run on the main thread when a ClientDownloadRequest has |
| 62 // been formed for a download, or when one has not been formed for a supported | 66 // been formed for a download, or when one has not been formed for a supported |
| 63 // download. | 67 // download. |
| 64 typedef base::Callback<void(content::DownloadItem*, | 68 typedef base::Callback<void(content::DownloadItem*, |
| 65 const ClientDownloadRequest*)> | 69 const ClientDownloadRequest*)> |
| 66 ClientDownloadRequestCallback; | 70 ClientDownloadRequestCallback; |
| 67 | 71 |
| 68 // A list of ClientDownloadRequest callbacks. | 72 // A list of ClientDownloadRequest callbacks. |
| 69 typedef base::CallbackList<void(content::DownloadItem*, | 73 typedef base::CallbackList<void(content::DownloadItem*, |
| 70 const ClientDownloadRequest*)> | 74 const ClientDownloadRequest*)> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 85 virtual void ParseManualBlacklistFlag(); | 89 virtual void ParseManualBlacklistFlag(); |
| 86 | 90 |
| 87 // Return true if this hash value is blacklisted via flag (for testing). | 91 // Return true if this hash value is blacklisted via flag (for testing). |
| 88 virtual bool IsHashManuallyBlacklisted(const std::string& sha256_hash) const; | 92 virtual bool IsHashManuallyBlacklisted(const std::string& sha256_hash) const; |
| 89 | 93 |
| 90 // Checks whether the given client download is likely to be malicious or not. | 94 // Checks whether the given client download is likely to be malicious or not. |
| 91 // The result is delivered asynchronously via the given callback. This | 95 // The result is delivered asynchronously via the given callback. This |
| 92 // method must be called on the UI thread, and the callback will also be | 96 // method must be called on the UI thread, and the callback will also be |
| 93 // invoked on the UI thread. This method must be called once the download | 97 // invoked on the UI thread. This method must be called once the download |
| 94 // is finished and written to disk. | 98 // is finished and written to disk. |
| 95 virtual void CheckClientDownload(content::DownloadItem* item, | 99 virtual void CheckClientDownload( |
| 96 const CheckDownloadCallback& callback); | 100 content::DownloadItem* item, |
| 101 const CheckDownloadContentCallback& callback); |
| 97 | 102 |
| 98 // Checks whether any of the URLs in the redirect chain of the | 103 // Checks whether any of the URLs in the redirect chain of the |
| 99 // download match the SafeBrowsing bad binary URL list. The result is | 104 // download match the SafeBrowsing bad binary URL list. The result is |
| 100 // delivered asynchronously via the given callback. This method must be | 105 // delivered asynchronously via the given callback. This method must be |
| 101 // called on the UI thread, and the callback will also be invoked on the UI | 106 // called on the UI thread, and the callback will also be invoked on the UI |
| 102 // thread. Pre-condition: !info.download_url_chain.empty(). | 107 // thread. Pre-condition: !info.download_url_chain.empty(). |
| 103 virtual void CheckDownloadUrl(const content::DownloadItem& item, | 108 virtual void CheckDownloadUrl(const content::DownloadItem& item, |
| 104 const CheckDownloadCallback& callback); | 109 const CheckDownloadCallback& callback); |
| 105 | 110 |
| 106 // Returns true iff the download specified by |info| should be scanned by | 111 // Returns true iff the download specified by |info| should be scanned by |
| 107 // CheckClientDownload() for malicious content. | 112 // CheckClientDownload() for malicious content. |
| 108 virtual bool IsSupportedDownload(const content::DownloadItem& item, | 113 virtual bool IsSupportedDownload(const content::DownloadItem& item, |
| 109 const base::FilePath& target_path) const; | 114 const base::FilePath& target_path) const; |
| 110 | 115 |
| 111 virtual void CheckPPAPIDownloadRequest( | 116 virtual void CheckPPAPIDownloadRequest( |
| 112 const GURL& requestor_url, | 117 const GURL& requestor_url, |
| 113 const base::FilePath& default_file_path, | 118 const base::FilePath& default_file_path, |
| 114 const std::vector<base::FilePath::StringType>& alternate_extensions, | 119 const std::vector<base::FilePath::StringType>& alternate_extensions, |
| 115 const CheckDownloadCallback& callback); | 120 const CheckDownloadContentCallback& callback); |
| 116 | 121 |
| 117 // Display more information to the user regarding the download specified by | 122 // Display more information to the user regarding the download specified by |
| 118 // |info|. This method is invoked when the user requests more information | 123 // |info|. This method is invoked when the user requests more information |
| 119 // about a download that was marked as malicious. | 124 // about a download that was marked as malicious. |
| 120 void ShowDetailsForDownload(const content::DownloadItem& item, | 125 void ShowDetailsForDownload(const content::DownloadItem& item, |
| 121 content::PageNavigator* navigator); | 126 content::PageNavigator* navigator); |
| 122 | 127 |
| 123 // Enables or disables the service. This is usually called by the | 128 // Enables or disables the service. This is usually called by the |
| 124 // SafeBrowsingService, which tracks whether any profile uses these services | 129 // SafeBrowsingService, which tracks whether any profile uses these services |
| 125 // at all. Disabling causes any pending and future requests to have their | 130 // at all. Disabling causes any pending and future requests to have their |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 std::set<std::string> manual_blacklist_hashes_; | 276 std::set<std::string> manual_blacklist_hashes_; |
| 272 | 277 |
| 273 // Rate of whitelisted downloads we sample to send out download ping. | 278 // Rate of whitelisted downloads we sample to send out download ping. |
| 274 double whitelist_sample_rate_; | 279 double whitelist_sample_rate_; |
| 275 | 280 |
| 276 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); | 281 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); |
| 277 }; | 282 }; |
| 278 } // namespace safe_browsing | 283 } // namespace safe_browsing |
| 279 | 284 |
| 280 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 285 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
| OLD | NEW |