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 #pragma once | 10 #pragma once |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 DownloadInfo(); | 52 DownloadInfo(); |
53 ~DownloadInfo(); | 53 ~DownloadInfo(); |
54 std::string DebugString() const; | 54 std::string DebugString() const; |
55 // Creates a DownloadInfo from a DownloadItem object. | 55 // Creates a DownloadInfo from a DownloadItem object. |
56 static DownloadInfo FromDownloadItem(const content::DownloadItem& item); | 56 static DownloadInfo FromDownloadItem(const content::DownloadItem& item); |
57 }; | 57 }; |
58 | 58 |
59 enum DownloadCheckResult { | 59 enum DownloadCheckResult { |
60 SAFE, | 60 SAFE, |
61 DANGEROUS, | 61 DANGEROUS, |
62 // In the future we may introduce a third category which corresponds to | 62 UNCOMMON, |
63 // suspicious downloads that are not known to be malicious. | |
64 }; | 63 }; |
65 | 64 |
66 // Callback type which is invoked once the download request is done. | 65 // Callback type which is invoked once the download request is done. |
67 typedef base::Callback<void(DownloadCheckResult)> CheckDownloadCallback; | 66 typedef base::Callback<void(DownloadCheckResult)> CheckDownloadCallback; |
68 | 67 |
69 // Creates a download service. The service is initially disabled. You need | 68 // Creates a download service. The service is initially disabled. You need |
70 // to call SetEnabled() to start it. |sb_service| owns this object; we | 69 // to call SetEnabled() to start it. |sb_service| owns this object; we |
71 // keep a reference to |request_context_getter|. | 70 // keep a reference to |request_context_getter|. |
72 DownloadProtectionService( | 71 DownloadProtectionService( |
73 SafeBrowsingService* sb_service, | 72 SafeBrowsingService* sb_service, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 REASON_INVALID_RESPONSE_PROTO, | 128 REASON_INVALID_RESPONSE_PROTO, |
130 REASON_NOT_BINARY_FILE, | 129 REASON_NOT_BINARY_FILE, |
131 REASON_REQUEST_CANCELED, | 130 REASON_REQUEST_CANCELED, |
132 REASON_DOWNLOAD_DANGEROUS, | 131 REASON_DOWNLOAD_DANGEROUS, |
133 REASON_DOWNLOAD_SAFE, | 132 REASON_DOWNLOAD_SAFE, |
134 REASON_EMPTY_URL_CHAIN, | 133 REASON_EMPTY_URL_CHAIN, |
135 REASON_HTTPS_URL, | 134 REASON_HTTPS_URL, |
136 REASON_PING_DISABLED, | 135 REASON_PING_DISABLED, |
137 REASON_TRUSTED_EXECUTABLE, | 136 REASON_TRUSTED_EXECUTABLE, |
138 REASON_OS_NOT_SUPPORTED, | 137 REASON_OS_NOT_SUPPORTED, |
| 138 REASON_DOWNLOAD_UNCOMMON, |
139 REASON_MAX // Always add new values before this one. | 139 REASON_MAX // Always add new values before this one. |
140 }; | 140 }; |
141 | 141 |
142 private: | 142 private: |
143 class CheckClientDownloadRequest; // Per-request state | 143 class CheckClientDownloadRequest; // Per-request state |
144 friend class DownloadProtectionServiceTest; | 144 friend class DownloadProtectionServiceTest; |
145 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest, | 145 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest, |
146 CheckClientDownloadValidateRequest); | 146 CheckClientDownloadValidateRequest); |
147 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest, | 147 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest, |
148 CheckClientDownloadSuccess); | 148 CheckClientDownloadSuccess); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // SignatureUtil object, may be overridden for testing. | 186 // SignatureUtil object, may be overridden for testing. |
187 scoped_refptr<SignatureUtil> signature_util_; | 187 scoped_refptr<SignatureUtil> signature_util_; |
188 | 188 |
189 int64 download_request_timeout_ms_; | 189 int64 download_request_timeout_ms_; |
190 | 190 |
191 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); | 191 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); |
192 }; | 192 }; |
193 } // namespace safe_browsing | 193 } // namespace safe_browsing |
194 | 194 |
195 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 195 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
OLD | NEW |