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 |
| 11 #include <stdint.h> |
| 12 |
11 #include <set> | 13 #include <set> |
12 #include <string> | 14 #include <string> |
13 #include <vector> | 15 #include <vector> |
14 | 16 |
15 #include "base/basictypes.h" | |
16 #include "base/callback.h" | 17 #include "base/callback.h" |
17 #include "base/callback_list.h" | 18 #include "base/callback_list.h" |
18 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
19 #include "base/gtest_prod_util.h" | 20 #include "base/gtest_prod_util.h" |
| 21 #include "base/macros.h" |
20 #include "base/memory/ref_counted.h" | 22 #include "base/memory/ref_counted.h" |
21 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
22 #include "chrome/browser/safe_browsing/database_manager.h" | 24 #include "chrome/browser/safe_browsing/database_manager.h" |
23 #include "chrome/browser/safe_browsing/ui_manager.h" | 25 #include "chrome/browser/safe_browsing/ui_manager.h" |
24 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
25 #include "url/gurl.h" | 27 #include "url/gurl.h" |
26 | 28 |
27 | 29 |
28 namespace content { | 30 namespace content { |
29 class DownloadItem; | 31 class DownloadItem; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // SafeBrowsingService, which tracks whether any profile uses these services | 120 // SafeBrowsingService, which tracks whether any profile uses these services |
119 // at all. Disabling causes any pending and future requests to have their | 121 // at all. Disabling causes any pending and future requests to have their |
120 // callbacks called with "UNKNOWN" results. | 122 // callbacks called with "UNKNOWN" results. |
121 void SetEnabled(bool enabled); | 123 void SetEnabled(bool enabled); |
122 | 124 |
123 bool enabled() const { | 125 bool enabled() const { |
124 return enabled_; | 126 return enabled_; |
125 } | 127 } |
126 | 128 |
127 // Returns the timeout that is used by CheckClientDownload(). | 129 // Returns the timeout that is used by CheckClientDownload(). |
128 int64 download_request_timeout_ms() const { | 130 int64_t download_request_timeout_ms() const { |
129 return download_request_timeout_ms_; | 131 return download_request_timeout_ms_; |
130 } | 132 } |
131 | 133 |
132 DownloadFeedbackService* feedback_service() { | 134 DownloadFeedbackService* feedback_service() { |
133 return feedback_service_.get(); | 135 return feedback_service_.get(); |
134 } | 136 } |
135 | 137 |
136 // Registers a callback that will be run when a ClientDownloadRequest has | 138 // Registers a callback that will be run when a ClientDownloadRequest has |
137 // been formed. | 139 // been formed. |
138 ClientDownloadRequestSubscription RegisterClientDownloadRequestCallback( | 140 ClientDownloadRequestSubscription RegisterClientDownloadRequestCallback( |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 // has to be invoked when the request is done. This map contains all | 230 // has to be invoked when the request is done. This map contains all |
229 // pending server requests. | 231 // pending server requests. |
230 std::set<scoped_refptr<CheckClientDownloadRequest> > download_requests_; | 232 std::set<scoped_refptr<CheckClientDownloadRequest> > download_requests_; |
231 | 233 |
232 // Keeps track of the state of the service. | 234 // Keeps track of the state of the service. |
233 bool enabled_; | 235 bool enabled_; |
234 | 236 |
235 // BinaryFeatureExtractor object, may be overridden for testing. | 237 // BinaryFeatureExtractor object, may be overridden for testing. |
236 scoped_refptr<BinaryFeatureExtractor> binary_feature_extractor_; | 238 scoped_refptr<BinaryFeatureExtractor> binary_feature_extractor_; |
237 | 239 |
238 int64 download_request_timeout_ms_; | 240 int64_t download_request_timeout_ms_; |
239 | 241 |
240 scoped_ptr<DownloadFeedbackService> feedback_service_; | 242 scoped_ptr<DownloadFeedbackService> feedback_service_; |
241 | 243 |
242 // A list of callbacks to be run on the main thread when a | 244 // A list of callbacks to be run on the main thread when a |
243 // ClientDownloadRequest has been formed. | 245 // ClientDownloadRequest has been formed. |
244 ClientDownloadRequestCallbackList client_download_request_callbacks_; | 246 ClientDownloadRequestCallbackList client_download_request_callbacks_; |
245 | 247 |
246 // List of 8-byte hashes that are blacklisted manually by flag. | 248 // List of 8-byte hashes that are blacklisted manually by flag. |
247 // Normally empty. | 249 // Normally empty. |
248 std::set<std::string> manual_blacklist_hashes_; | 250 std::set<std::string> manual_blacklist_hashes_; |
249 | 251 |
250 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); | 252 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); |
251 }; | 253 }; |
252 } // namespace safe_browsing | 254 } // namespace safe_browsing |
253 | 255 |
254 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 256 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
OLD | NEW |