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