| 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 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 namespace prefs { | 47 namespace prefs { |
| 48 namespace mojom { | 48 namespace mojom { |
| 49 class TrackedPreferenceValidationDelegate; | 49 class TrackedPreferenceValidationDelegate; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 namespace safe_browsing { | 53 namespace safe_browsing { |
| 54 class ClientSideDetectionService; | 54 class ClientSideDetectionService; |
| 55 class DownloadProtectionService; | 55 class DownloadProtectionService; |
| 56 class PasswordProtectionService; | 56 class PasswordProtectionService; |
| 57 class ChromePasswordProtectionService; |
| 57 struct ResourceRequestInfo; | 58 struct ResourceRequestInfo; |
| 58 struct SafeBrowsingProtocolConfig; | 59 struct SafeBrowsingProtocolConfig; |
| 59 class SafeBrowsingDatabaseManager; | 60 class SafeBrowsingDatabaseManager; |
| 60 class SafeBrowsingNavigationObserverManager; | 61 class SafeBrowsingNavigationObserverManager; |
| 61 class SafeBrowsingPingManager; | 62 class SafeBrowsingPingManager; |
| 62 class SafeBrowsingProtocolManager; | 63 class SafeBrowsingProtocolManager; |
| 63 class SafeBrowsingProtocolManagerDelegate; | 64 class SafeBrowsingProtocolManagerDelegate; |
| 64 class SafeBrowsingServiceFactory; | 65 class SafeBrowsingServiceFactory; |
| 65 class SafeBrowsingUIManager; | 66 class SafeBrowsingUIManager; |
| 66 class SafeBrowsingURLRequestContextGetter; | 67 class SafeBrowsingURLRequestContextGetter; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 navigation_observer_manager(); | 157 navigation_observer_manager(); |
| 157 | 158 |
| 158 SafeBrowsingProtocolManager* protocol_manager() const; | 159 SafeBrowsingProtocolManager* protocol_manager() const; |
| 159 | 160 |
| 160 SafeBrowsingPingManager* ping_manager() const; | 161 SafeBrowsingPingManager* ping_manager() const; |
| 161 | 162 |
| 162 // This may be NULL if v4 is not enabled by experiment. | 163 // This may be NULL if v4 is not enabled by experiment. |
| 163 const scoped_refptr<SafeBrowsingDatabaseManager>& v4_local_database_manager() | 164 const scoped_refptr<SafeBrowsingDatabaseManager>& v4_local_database_manager() |
| 164 const; | 165 const; |
| 165 | 166 |
| 166 PasswordProtectionService* password_protection_service(); | 167 // Gets PasswordProtectionService by profile. |
| 168 PasswordProtectionService* GetPasswordProtectionService( |
| 169 Profile* profile) const; |
| 167 | 170 |
| 168 // Returns a preference validation delegate that adds incidents to the | 171 // Returns a preference validation delegate that adds incidents to the |
| 169 // incident reporting service for validation failures. Returns NULL if the | 172 // incident reporting service for validation failures. Returns NULL if the |
| 170 // service is not applicable for the given profile. | 173 // service is not applicable for the given profile. |
| 171 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> | 174 std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> |
| 172 CreatePreferenceValidationDelegate(Profile* profile) const; | 175 CreatePreferenceValidationDelegate(Profile* profile) const; |
| 173 | 176 |
| 174 // Registers |callback| to be run after some delay following process launch. | 177 // Registers |callback| to be run after some delay following process launch. |
| 175 // |callback| will be dropped if the service is not applicable for the | 178 // |callback| will be dropped if the service is not applicable for the |
| 176 // process. | 179 // process. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 270 |
| 268 // Checks if any profile is currently using the safe browsing service, and | 271 // Checks if any profile is currently using the safe browsing service, and |
| 269 // starts or stops the service accordingly. | 272 // starts or stops the service accordingly. |
| 270 void RefreshState(); | 273 void RefreshState(); |
| 271 | 274 |
| 272 void OnSendSerializedDownloadReport(const std::string& report); | 275 void OnSendSerializedDownloadReport(const std::string& report); |
| 273 | 276 |
| 274 // Process the observed resource requests on the UI thread. | 277 // Process the observed resource requests on the UI thread. |
| 275 void ProcessResourceRequest(const ResourceRequestInfo& request); | 278 void ProcessResourceRequest(const ResourceRequestInfo& request); |
| 276 | 279 |
| 280 void CreatePasswordProtectionService(Profile* profile); |
| 281 |
| 282 void RemovePasswordProtectionService(Profile* profile); |
| 283 |
| 277 // The factory used to instantiate a SafeBrowsingService object. | 284 // The factory used to instantiate a SafeBrowsingService object. |
| 278 // Useful for tests, so they can provide their own implementation of | 285 // Useful for tests, so they can provide their own implementation of |
| 279 // SafeBrowsingService. | 286 // SafeBrowsingService. |
| 280 static SafeBrowsingServiceFactory* factory_; | 287 static SafeBrowsingServiceFactory* factory_; |
| 281 | 288 |
| 282 // The SafeBrowsingURLRequestContextGetter used to access | 289 // The SafeBrowsingURLRequestContextGetter used to access |
| 283 // |url_request_context_|. Accessed on UI thread. | 290 // |url_request_context_|. Accessed on UI thread. |
| 284 scoped_refptr<SafeBrowsingURLRequestContextGetter> | 291 scoped_refptr<SafeBrowsingURLRequestContextGetter> |
| 285 url_request_context_getter_; | 292 url_request_context_getter_; |
| 286 | 293 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 313 // |use_v4_only_| is true. | 320 // |use_v4_only_| is true. |
| 314 bool v4_enabled_; | 321 bool v4_enabled_; |
| 315 | 322 |
| 316 // Tracks existing PrefServices, and the safe browsing preference on each. | 323 // Tracks existing PrefServices, and the safe browsing preference on each. |
| 317 // This is used to determine if any profile is currently using the safe | 324 // This is used to determine if any profile is currently using the safe |
| 318 // browsing service, and to start it up or shut it down accordingly. | 325 // browsing service, and to start it up or shut it down accordingly. |
| 319 // Accessed on UI thread. | 326 // Accessed on UI thread. |
| 320 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_; | 327 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_; |
| 321 | 328 |
| 322 // Used to track creation and destruction of profiles on the UI thread. | 329 // Used to track creation and destruction of profiles on the UI thread. |
| 323 content::NotificationRegistrar prefs_registrar_; | 330 content::NotificationRegistrar profiles_registrar_; |
| 324 | 331 |
| 325 // Callbacks when SafeBrowsing state might have changed. | 332 // Callbacks when SafeBrowsing state might have changed. |
| 326 // Should only be accessed on the UI thread. | 333 // Should only be accessed on the UI thread. |
| 327 base::CallbackList<void(void)> state_callback_list_; | 334 base::CallbackList<void(void)> state_callback_list_; |
| 328 | 335 |
| 329 // Callbacks when SafeBrowsing service starts shutting down. | 336 // Callbacks when SafeBrowsing service starts shutting down. |
| 330 // Should only be accessed on the UI thread. | 337 // Should only be accessed on the UI thread. |
| 331 base::CallbackList<void(void)> shutdown_callback_list_; | 338 base::CallbackList<void(void)> shutdown_callback_list_; |
| 332 | 339 |
| 333 // The UI manager handles showing interstitials. Accessed on both UI and IO | 340 // The UI manager handles showing interstitials. Accessed on both UI and IO |
| 334 // thread. | 341 // thread. |
| 335 scoped_refptr<SafeBrowsingUIManager> ui_manager_; | 342 scoped_refptr<SafeBrowsingUIManager> ui_manager_; |
| 336 | 343 |
| 337 // The database manager handles the database and download logic. Accessed on | 344 // The database manager handles the database and download logic. Accessed on |
| 338 // both UI and IO thread. | 345 // both UI and IO thread. |
| 339 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; | 346 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |
| 340 | 347 |
| 341 // The navigation observer manager handles attribution of safe browsing | 348 // The navigation observer manager handles attribution of safe browsing |
| 342 // events. | 349 // events. |
| 343 scoped_refptr<SafeBrowsingNavigationObserverManager> | 350 scoped_refptr<SafeBrowsingNavigationObserverManager> |
| 344 navigation_observer_manager_; | 351 navigation_observer_manager_; |
| 345 | 352 |
| 346 // The password protection service detects and handles password related | 353 // Tracks existing Profiles, and their corresponding |
| 347 // incidents. | 354 // ChromePasswordProtectionService instances. |
| 348 std::unique_ptr<PasswordProtectionService> password_protection_service_; | 355 // Accessed on UI thread. |
| 356 std::map<Profile*, std::unique_ptr<ChromePasswordProtectionService>> |
| 357 password_protection_service_map_; |
| 349 | 358 |
| 350 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); | 359 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); |
| 351 }; | 360 }; |
| 352 | 361 |
| 353 // Factory for creating SafeBrowsingService. Useful for tests. | 362 // Factory for creating SafeBrowsingService. Useful for tests. |
| 354 class SafeBrowsingServiceFactory { | 363 class SafeBrowsingServiceFactory { |
| 355 public: | 364 public: |
| 356 SafeBrowsingServiceFactory() { } | 365 SafeBrowsingServiceFactory() { } |
| 357 virtual ~SafeBrowsingServiceFactory() { } | 366 virtual ~SafeBrowsingServiceFactory() { } |
| 358 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; | 367 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; |
| 359 private: | 368 private: |
| 360 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); | 369 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); |
| 361 }; | 370 }; |
| 362 | 371 |
| 363 } // namespace safe_browsing | 372 } // namespace safe_browsing |
| 364 | 373 |
| 365 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 374 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
| OLD | NEW |