| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 10 #pragma once |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 260 |
| 261 bool download_protection_enabled() const { | 261 bool download_protection_enabled() const { |
| 262 return enabled_ && enable_download_protection_; | 262 return enabled_ && enable_download_protection_; |
| 263 } | 263 } |
| 264 | 264 |
| 265 safe_browsing::ClientSideDetectionService* | 265 safe_browsing::ClientSideDetectionService* |
| 266 safe_browsing_detection_service() const { | 266 safe_browsing_detection_service() const { |
| 267 return csd_service_.get(); | 267 return csd_service_.get(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 // The DownloadProtectionService is not valid after the SafeBrowsingService |
| 271 // is destroyed. |
| 270 safe_browsing::DownloadProtectionService* | 272 safe_browsing::DownloadProtectionService* |
| 271 download_protection_service() const { | 273 download_protection_service() const { |
| 272 return download_service_.get(); | 274 return download_service_.get(); |
| 273 } | 275 } |
| 274 | 276 |
| 275 // Preference handling. | 277 // Preference handling. |
| 276 static void RegisterPrefs(PrefService* prefs); | 278 static void RegisterPrefs(PrefService* prefs); |
| 277 | 279 |
| 278 // Called on the IO thread to reset the database. | 280 // Called on the IO thread to reset the database. |
| 279 void ResetDatabase(); | 281 void ResetDatabase(); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 // Starts following the safe browsing preference on |pref_service|. | 467 // Starts following the safe browsing preference on |pref_service|. |
| 466 void AddPrefService(PrefService* pref_service); | 468 void AddPrefService(PrefService* pref_service); |
| 467 | 469 |
| 468 // Stop following the safe browsing preference on |pref_service|. | 470 // Stop following the safe browsing preference on |pref_service|. |
| 469 void RemovePrefService(PrefService* pref_service); | 471 void RemovePrefService(PrefService* pref_service); |
| 470 | 472 |
| 471 // Checks if any profile is currently using the safe browsing service, and | 473 // Checks if any profile is currently using the safe browsing service, and |
| 472 // starts or stops the service accordingly. | 474 // starts or stops the service accordingly. |
| 473 void RefreshState(); | 475 void RefreshState(); |
| 474 | 476 |
| 477 // Arranges to delete |download_service_| on the IO thread, and sets |
| 478 // the pointer to NULL. |
| 479 void ShutDownDownloadService(); |
| 480 |
| 475 // The factory used to instanciate a SafeBrowsingService object. | 481 // The factory used to instanciate a SafeBrowsingService object. |
| 476 // Useful for tests, so they can provide their own implementation of | 482 // Useful for tests, so they can provide their own implementation of |
| 477 // SafeBrowsingService. | 483 // SafeBrowsingService. |
| 478 static SafeBrowsingServiceFactory* factory_; | 484 static SafeBrowsingServiceFactory* factory_; |
| 479 | 485 |
| 480 CurrentChecks checks_; | 486 CurrentChecks checks_; |
| 481 | 487 |
| 482 // Used for issuing only one GetHash request for a given prefix. | 488 // Used for issuing only one GetHash request for a given prefix. |
| 483 GetHashRequests gethash_requests_; | 489 GetHashRequests gethash_requests_; |
| 484 | 490 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 | 555 |
| 550 // Used to track creation and destruction of profiles on the UI thread. | 556 // Used to track creation and destruction of profiles on the UI thread. |
| 551 content::NotificationRegistrar prefs_registrar_; | 557 content::NotificationRegistrar prefs_registrar_; |
| 552 | 558 |
| 553 // The ClientSideDetectionService is managed by the SafeBrowsingService, | 559 // The ClientSideDetectionService is managed by the SafeBrowsingService, |
| 554 // since its running state and lifecycle depends on SafeBrowsingService's. | 560 // since its running state and lifecycle depends on SafeBrowsingService's. |
| 555 scoped_ptr<safe_browsing::ClientSideDetectionService> csd_service_; | 561 scoped_ptr<safe_browsing::ClientSideDetectionService> csd_service_; |
| 556 | 562 |
| 557 // The DownloadProtectionService is managed by the SafeBrowsingService, | 563 // The DownloadProtectionService is managed by the SafeBrowsingService, |
| 558 // since its running state and lifecycle depends on SafeBrowsingService's. | 564 // since its running state and lifecycle depends on SafeBrowsingService's. |
| 559 scoped_refptr<safe_browsing::DownloadProtectionService> download_service_; | 565 scoped_ptr<safe_browsing::DownloadProtectionService> download_service_; |
| 560 | 566 |
| 561 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); | 567 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); |
| 562 }; | 568 }; |
| 563 | 569 |
| 564 // Factory for creating SafeBrowsingService. Useful for tests. | 570 // Factory for creating SafeBrowsingService. Useful for tests. |
| 565 class SafeBrowsingServiceFactory { | 571 class SafeBrowsingServiceFactory { |
| 566 public: | 572 public: |
| 567 SafeBrowsingServiceFactory() { } | 573 SafeBrowsingServiceFactory() { } |
| 568 virtual ~SafeBrowsingServiceFactory() { } | 574 virtual ~SafeBrowsingServiceFactory() { } |
| 569 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; | 575 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; |
| 570 private: | 576 private: |
| 571 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); | 577 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); |
| 572 }; | 578 }; |
| 573 | 579 |
| 574 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 580 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
| OLD | NEW |