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