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> | 11 #include <stdint.h> |
12 | 12 |
| 13 #include <memory> |
13 #include <set> | 14 #include <set> |
14 #include <string> | 15 #include <string> |
15 #include <vector> | 16 #include <vector> |
16 | 17 |
17 #include "base/callback.h" | 18 #include "base/callback.h" |
18 #include "base/callback_list.h" | 19 #include "base/callback_list.h" |
19 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
20 #include "base/gtest_prod_util.h" | 21 #include "base/gtest_prod_util.h" |
21 #include "base/macros.h" | 22 #include "base/macros.h" |
22 #include "base/memory/ref_counted.h" | 23 #include "base/memory/ref_counted.h" |
23 #include "base/memory/scoped_ptr.h" | |
24 #include "chrome/browser/safe_browsing/ui_manager.h" | 24 #include "chrome/browser/safe_browsing/ui_manager.h" |
25 #include "components/safe_browsing_db/database_manager.h" | 25 #include "components/safe_browsing_db/database_manager.h" |
26 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
28 | 28 |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 class DownloadItem; | 31 class DownloadItem; |
32 class PageNavigator; | 32 class PageNavigator; |
33 } | 33 } |
(...skipping 29 matching lines...) Expand all Loading... |
63 typedef base::Callback<void(content::DownloadItem*, | 63 typedef base::Callback<void(content::DownloadItem*, |
64 const ClientDownloadRequest*)> | 64 const ClientDownloadRequest*)> |
65 ClientDownloadRequestCallback; | 65 ClientDownloadRequestCallback; |
66 | 66 |
67 // A list of ClientDownloadRequest callbacks. | 67 // A list of ClientDownloadRequest callbacks. |
68 typedef base::CallbackList<void(content::DownloadItem*, | 68 typedef base::CallbackList<void(content::DownloadItem*, |
69 const ClientDownloadRequest*)> | 69 const ClientDownloadRequest*)> |
70 ClientDownloadRequestCallbackList; | 70 ClientDownloadRequestCallbackList; |
71 | 71 |
72 // A subscription to a registered ClientDownloadRequest callback. | 72 // A subscription to a registered ClientDownloadRequest callback. |
73 typedef scoped_ptr<ClientDownloadRequestCallbackList::Subscription> | 73 typedef std::unique_ptr<ClientDownloadRequestCallbackList::Subscription> |
74 ClientDownloadRequestSubscription; | 74 ClientDownloadRequestSubscription; |
75 | 75 |
76 // Creates a download service. The service is initially disabled. You need | 76 // Creates a download service. The service is initially disabled. You need |
77 // to call SetEnabled() to start it. |sb_service| owns this object; we | 77 // to call SetEnabled() to start it. |sb_service| owns this object; we |
78 // keep a reference to |request_context_getter|. | 78 // keep a reference to |request_context_getter|. |
79 DownloadProtectionService( | 79 DownloadProtectionService( |
80 SafeBrowsingService* sb_service, | 80 SafeBrowsingService* sb_service, |
81 net::URLRequestContextGetter* request_context_getter); | 81 net::URLRequestContextGetter* request_context_getter); |
82 | 82 |
83 virtual ~DownloadProtectionService(); | 83 virtual ~DownloadProtectionService(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 std::set<scoped_refptr<CheckClientDownloadRequest> > download_requests_; | 232 std::set<scoped_refptr<CheckClientDownloadRequest> > download_requests_; |
233 | 233 |
234 // Keeps track of the state of the service. | 234 // Keeps track of the state of the service. |
235 bool enabled_; | 235 bool enabled_; |
236 | 236 |
237 // BinaryFeatureExtractor object, may be overridden for testing. | 237 // BinaryFeatureExtractor object, may be overridden for testing. |
238 scoped_refptr<BinaryFeatureExtractor> binary_feature_extractor_; | 238 scoped_refptr<BinaryFeatureExtractor> binary_feature_extractor_; |
239 | 239 |
240 int64_t download_request_timeout_ms_; | 240 int64_t download_request_timeout_ms_; |
241 | 241 |
242 scoped_ptr<DownloadFeedbackService> feedback_service_; | 242 std::unique_ptr<DownloadFeedbackService> feedback_service_; |
243 | 243 |
244 // 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 |
245 // ClientDownloadRequest has been formed. | 245 // ClientDownloadRequest has been formed. |
246 ClientDownloadRequestCallbackList client_download_request_callbacks_; | 246 ClientDownloadRequestCallbackList client_download_request_callbacks_; |
247 | 247 |
248 // List of 8-byte hashes that are blacklisted manually by flag. | 248 // List of 8-byte hashes that are blacklisted manually by flag. |
249 // Normally empty. | 249 // Normally empty. |
250 std::set<std::string> manual_blacklist_hashes_; | 250 std::set<std::string> manual_blacklist_hashes_; |
251 | 251 |
252 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); | 252 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); |
253 }; | 253 }; |
254 } // namespace safe_browsing | 254 } // namespace safe_browsing |
255 | 255 |
256 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 256 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
OLD | NEW |