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 // The Safe Browsing service is responsible for downloading anti-phishing and | 5 // The Safe Browsing service is responsible for downloading anti-phishing and |
6 // anti-malware tables and checking urls against them. | 6 // anti-malware tables and checking urls against them. |
7 | 7 |
8 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
9 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
10 | 10 |
11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
12 #include <string> | 13 #include <string> |
13 | 14 |
14 #include "base/callback.h" | 15 #include "base/callback.h" |
15 #include "base/callback_list.h" | 16 #include "base/callback_list.h" |
16 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | |
20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
21 #include "base/sequenced_task_runner_helpers.h" | 21 #include "base/sequenced_task_runner_helpers.h" |
22 #include "components/safe_browsing_db/util.h" | 22 #include "components/safe_browsing_db/util.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
25 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
26 | 26 |
27 #if defined(FULL_SAFE_BROWSING) | 27 #if defined(FULL_SAFE_BROWSING) |
28 #include "chrome/browser/safe_browsing/incident_reporting/delayed_analysis_callb
ack.h" | 28 #include "chrome/browser/safe_browsing/incident_reporting/delayed_analysis_callb
ack.h" |
29 #endif | 29 #endif |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager() const; | 141 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager() const; |
142 | 142 |
143 SafeBrowsingProtocolManager* protocol_manager() const; | 143 SafeBrowsingProtocolManager* protocol_manager() const; |
144 | 144 |
145 SafeBrowsingPingManager* ping_manager() const; | 145 SafeBrowsingPingManager* ping_manager() const; |
146 | 146 |
147 // Returns a preference validation delegate that adds incidents to the | 147 // Returns a preference validation delegate that adds incidents to the |
148 // incident reporting service for validation failures. Returns NULL if the | 148 // incident reporting service for validation failures. Returns NULL if the |
149 // service is not applicable for the given profile. | 149 // service is not applicable for the given profile. |
150 scoped_ptr<TrackedPreferenceValidationDelegate> | 150 std::unique_ptr<TrackedPreferenceValidationDelegate> |
151 CreatePreferenceValidationDelegate(Profile* profile) const; | 151 CreatePreferenceValidationDelegate(Profile* profile) const; |
152 | 152 |
153 #if defined(FULL_SAFE_BROWSING) | 153 #if defined(FULL_SAFE_BROWSING) |
154 // Registers |callback| to be run after some delay following process launch. | 154 // Registers |callback| to be run after some delay following process launch. |
155 // |callback| will be dropped if the service is not applicable for the | 155 // |callback| will be dropped if the service is not applicable for the |
156 // process. | 156 // process. |
157 void RegisterDelayedAnalysisCallback(const DelayedAnalysisCallback& callback); | 157 void RegisterDelayedAnalysisCallback(const DelayedAnalysisCallback& callback); |
158 void RegisterExtendedReportingOnlyDelayedAnalysisCallback( | 158 void RegisterExtendedReportingOnlyDelayedAnalysisCallback( |
159 const DelayedAnalysisCallback& callback); | 159 const DelayedAnalysisCallback& callback); |
160 #endif | 160 #endif |
161 | 161 |
162 // Adds |download_manager| to the set monitored by safe browsing. | 162 // Adds |download_manager| to the set monitored by safe browsing. |
163 void AddDownloadManager(content::DownloadManager* download_manager); | 163 void AddDownloadManager(content::DownloadManager* download_manager); |
164 | 164 |
165 // Observes resource requests made by the renderer and reports suspicious | 165 // Observes resource requests made by the renderer and reports suspicious |
166 // activity. | 166 // activity. |
167 void OnResourceRequest(const net::URLRequest* request); | 167 void OnResourceRequest(const net::URLRequest* request); |
168 | 168 |
169 // Type for subscriptions to SafeBrowsing service state. | 169 // Type for subscriptions to SafeBrowsing service state. |
170 typedef base::CallbackList<void(void)>::Subscription StateSubscription; | 170 typedef base::CallbackList<void(void)>::Subscription StateSubscription; |
171 | 171 |
172 // Adds a listener for when SafeBrowsing preferences might have changed. | 172 // Adds a listener for when SafeBrowsing preferences might have changed. |
173 // To get the current state, the callback should call enabled_by_prefs(). | 173 // To get the current state, the callback should call enabled_by_prefs(). |
174 // Should only be called on the UI thread. | 174 // Should only be called on the UI thread. |
175 scoped_ptr<StateSubscription> RegisterStateCallback( | 175 std::unique_ptr<StateSubscription> RegisterStateCallback( |
176 const base::Callback<void(void)>& callback); | 176 const base::Callback<void(void)>& callback); |
177 | 177 |
178 // Sends serialized download report to backend. | 178 // Sends serialized download report to backend. |
179 virtual void SendSerializedDownloadReport(const std::string& report); | 179 virtual void SendSerializedDownloadReport(const std::string& report); |
180 | 180 |
181 protected: | 181 protected: |
182 // Creates the safe browsing service. Need to initialize before using. | 182 // Creates the safe browsing service. Need to initialize before using. |
183 SafeBrowsingService(); | 183 SafeBrowsingService(); |
184 | 184 |
185 ~SafeBrowsingService() override; | 185 ~SafeBrowsingService() override; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // Used to track creation and destruction of profiles on the UI thread. | 282 // Used to track creation and destruction of profiles on the UI thread. |
283 content::NotificationRegistrar prefs_registrar_; | 283 content::NotificationRegistrar prefs_registrar_; |
284 | 284 |
285 // Callbacks when SafeBrowsing state might have changed. | 285 // Callbacks when SafeBrowsing state might have changed. |
286 // Should only be accessed on the UI thread. | 286 // Should only be accessed on the UI thread. |
287 base::CallbackList<void(void)> state_callback_list_; | 287 base::CallbackList<void(void)> state_callback_list_; |
288 | 288 |
289 // The ClientSideDetectionService is managed by the SafeBrowsingService, | 289 // The ClientSideDetectionService is managed by the SafeBrowsingService, |
290 // since its running state and lifecycle depends on SafeBrowsingService's. | 290 // since its running state and lifecycle depends on SafeBrowsingService's. |
291 // Accessed on UI thread. | 291 // Accessed on UI thread. |
292 scoped_ptr<ClientSideDetectionService> csd_service_; | 292 std::unique_ptr<ClientSideDetectionService> csd_service_; |
293 | 293 |
294 // The DownloadProtectionService is managed by the SafeBrowsingService, | 294 // The DownloadProtectionService is managed by the SafeBrowsingService, |
295 // since its running state and lifecycle depends on SafeBrowsingService's. | 295 // since its running state and lifecycle depends on SafeBrowsingService's. |
296 // Accessed on UI thread. | 296 // Accessed on UI thread. |
297 scoped_ptr<DownloadProtectionService> download_service_; | 297 std::unique_ptr<DownloadProtectionService> download_service_; |
298 | 298 |
299 #if defined(FULL_SAFE_BROWSING) | 299 #if defined(FULL_SAFE_BROWSING) |
300 scoped_ptr<IncidentReportingService> incident_service_; | 300 std::unique_ptr<IncidentReportingService> incident_service_; |
301 #endif | 301 #endif |
302 | 302 |
303 // The UI manager handles showing interstitials. Accessed on both UI and IO | 303 // The UI manager handles showing interstitials. Accessed on both UI and IO |
304 // thread. | 304 // thread. |
305 scoped_refptr<SafeBrowsingUIManager> ui_manager_; | 305 scoped_refptr<SafeBrowsingUIManager> ui_manager_; |
306 | 306 |
307 // The database manager handles the database and download logic. Accessed on | 307 // The database manager handles the database and download logic. Accessed on |
308 // both UI and IO thread. | 308 // both UI and IO thread. |
309 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; | 309 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |
310 | 310 |
311 #if defined(FULL_SAFE_BROWSING) | 311 #if defined(FULL_SAFE_BROWSING) |
312 scoped_ptr<ResourceRequestDetector> resource_request_detector_; | 312 std::unique_ptr<ResourceRequestDetector> resource_request_detector_; |
313 #endif | 313 #endif |
314 | 314 |
315 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); | 315 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); |
316 }; | 316 }; |
317 | 317 |
318 // Factory for creating SafeBrowsingService. Useful for tests. | 318 // Factory for creating SafeBrowsingService. Useful for tests. |
319 class SafeBrowsingServiceFactory { | 319 class SafeBrowsingServiceFactory { |
320 public: | 320 public: |
321 SafeBrowsingServiceFactory() { } | 321 SafeBrowsingServiceFactory() { } |
322 virtual ~SafeBrowsingServiceFactory() { } | 322 virtual ~SafeBrowsingServiceFactory() { } |
323 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; | 323 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; |
324 private: | 324 private: |
325 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); | 325 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); |
326 }; | 326 }; |
327 | 327 |
328 } // namespace safe_browsing | 328 } // namespace safe_browsing |
329 | 329 |
330 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 330 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
OLD | NEW |