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 <memory> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/callback_list.h" | 16 #include "base/callback_list.h" |
17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.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 "chrome/browser/safe_browsing/services_delegate.h" | 22 #include "chrome/browser/safe_browsing/services_delegate.h" |
23 #include "components/safe_browsing_db/safe_browsing_prefs.h" | 23 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
24 #include "components/safe_browsing_db/util.h" | 24 #include "components/safe_browsing_db/util.h" |
25 #include "components/safe_browsing_db/v4_feature_list.h" | |
26 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
28 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
29 | 28 |
30 #if defined(FULL_SAFE_BROWSING) | 29 #if defined(FULL_SAFE_BROWSING) |
31 #include "chrome/browser/safe_browsing/incident_reporting/delayed_analysis_callb
ack.h" | 30 #include "chrome/browser/safe_browsing/incident_reporting/delayed_analysis_callb
ack.h" |
32 #endif | 31 #endif |
33 | 32 |
34 class PrefChangeRegistrar; | 33 class PrefChangeRegistrar; |
35 class PrefService; | 34 class PrefService; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 // The callbacks run on the UI thread, and give the subscribers an opportunity | 190 // The callbacks run on the UI thread, and give the subscribers an opportunity |
192 // to clean up any references they hold to SafeBrowsingService. | 191 // to clean up any references they hold to SafeBrowsingService. |
193 std::unique_ptr<ShutdownSubscription> RegisterShutdownCallback( | 192 std::unique_ptr<ShutdownSubscription> RegisterShutdownCallback( |
194 const base::Callback<void(void)>& callback); | 193 const base::Callback<void(void)>& callback); |
195 | 194 |
196 // Sends serialized download report to backend. | 195 // Sends serialized download report to backend. |
197 virtual void SendSerializedDownloadReport(const std::string& report); | 196 virtual void SendSerializedDownloadReport(const std::string& report); |
198 | 197 |
199 protected: | 198 protected: |
200 // Creates the safe browsing service. Need to initialize before using. | 199 // Creates the safe browsing service. Need to initialize before using. |
201 SafeBrowsingService(V4FeatureList::V4UsageStatus v4_usage_status = | 200 SafeBrowsingService(); |
202 V4FeatureList::V4UsageStatus::V4_DISABLED); | |
203 | 201 |
204 ~SafeBrowsingService() override; | 202 ~SafeBrowsingService() override; |
205 | 203 |
206 virtual SafeBrowsingDatabaseManager* CreateDatabaseManager(); | 204 virtual SafeBrowsingDatabaseManager* CreateDatabaseManager(); |
207 | 205 |
208 virtual SafeBrowsingUIManager* CreateUIManager(); | 206 virtual SafeBrowsingUIManager* CreateUIManager(); |
209 | 207 |
210 // Registers all the delayed analysis with the incident reporting service. | 208 // Registers all the delayed analysis with the incident reporting service. |
211 // This is where you register your process-wide, profile-independent analysis. | 209 // This is where you register your process-wide, profile-independent analysis. |
212 virtual void RegisterAllDelayedAnalysis(); | 210 virtual void RegisterAllDelayedAnalysis(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // Whether the service is running. 'enabled_' is used by SafeBrowsingService | 291 // Whether the service is running. 'enabled_' is used by SafeBrowsingService |
294 // on the IO thread during normal operations. | 292 // on the IO thread during normal operations. |
295 bool enabled_; | 293 bool enabled_; |
296 | 294 |
297 // Whether SafeBrowsing is enabled by the current set of profiles. | 295 // Whether SafeBrowsing is enabled by the current set of profiles. |
298 // Accessed on UI thread. | 296 // Accessed on UI thread. |
299 bool enabled_by_prefs_; | 297 bool enabled_by_prefs_; |
300 | 298 |
301 // Whether SafeBrowsing needs to be enabled in V4Only mode. In this mode, all | 299 // Whether SafeBrowsing needs to be enabled in V4Only mode. In this mode, all |
302 // SafeBrowsing decisions are made using the PVer4 implementation. | 300 // SafeBrowsing decisions are made using the PVer4 implementation. |
303 bool use_v4_only_; | 301 bool enabled_v4_only_; |
304 | |
305 // Whether the PVer4 implementation needs to be instantiated. Note that even | |
306 // if the PVer4 implementation has been instantiated, it is used only if | |
307 // |use_v4_only_| is true. | |
308 bool v4_enabled_; | |
309 | 302 |
310 // Tracks existing PrefServices, and the safe browsing preference on each. | 303 // Tracks existing PrefServices, and the safe browsing preference on each. |
311 // This is used to determine if any profile is currently using the safe | 304 // This is used to determine if any profile is currently using the safe |
312 // browsing service, and to start it up or shut it down accordingly. | 305 // browsing service, and to start it up or shut it down accordingly. |
313 // Accessed on UI thread. | 306 // Accessed on UI thread. |
314 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_; | 307 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_; |
315 | 308 |
316 // Used to track creation and destruction of profiles on the UI thread. | 309 // Used to track creation and destruction of profiles on the UI thread. |
317 content::NotificationRegistrar prefs_registrar_; | 310 content::NotificationRegistrar prefs_registrar_; |
318 | 311 |
(...skipping 26 matching lines...) Expand all Loading... |
345 SafeBrowsingServiceFactory() { } | 338 SafeBrowsingServiceFactory() { } |
346 virtual ~SafeBrowsingServiceFactory() { } | 339 virtual ~SafeBrowsingServiceFactory() { } |
347 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; | 340 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; |
348 private: | 341 private: |
349 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); | 342 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); |
350 }; | 343 }; |
351 | 344 |
352 } // namespace safe_browsing | 345 } // namespace safe_browsing |
353 | 346 |
354 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 347 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
OLD | NEW |