| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_SERVICES_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SERVICES_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_SERVICES_DELEGATE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SERVICES_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "chrome/browser/safe_browsing/incident_reporting/delayed_analysis_callb
ack.h" | 10 #include "chrome/browser/safe_browsing/incident_reporting/delayed_analysis_callb
ack.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace safe_browsing { | 23 namespace safe_browsing { |
| 24 | 24 |
| 25 class ClientSideDetectionService; | 25 class ClientSideDetectionService; |
| 26 class DownloadProtectionService; | 26 class DownloadProtectionService; |
| 27 class IncidentReportingService; | 27 class IncidentReportingService; |
| 28 class ResourceRequestDetector; | 28 class ResourceRequestDetector; |
| 29 struct ResourceRequestInfo; | 29 struct ResourceRequestInfo; |
| 30 class SafeBrowsingService; | 30 class SafeBrowsingService; |
| 31 struct V4ProtocolConfig; |
| 31 | 32 |
| 32 // Abstraction to help organize code for mobile vs full safe browsing modes. | 33 // Abstraction to help organize code for mobile vs full safe browsing modes. |
| 33 // This helper class should be owned by a SafeBrowsingService, and it handles | 34 // This helper class should be owned by a SafeBrowsingService, and it handles |
| 34 // responsibilities for safe browsing service classes that may or may not exist | 35 // responsibilities for safe browsing service classes that may or may not exist |
| 35 // for a given build config. e.g. No DownloadProtectionService on mobile. | 36 // for a given build config. e.g. No DownloadProtectionService on mobile. |
| 36 // ServicesDelegate lives on the UI thread. | 37 // ServicesDelegate lives on the UI thread. |
| 37 class ServicesDelegate { | 38 class ServicesDelegate { |
| 38 public: | 39 public: |
| 39 // Used for tests to override service creation. If CanCreateFooService() | 40 // Used for tests to override service creation. If CanCreateFooService() |
| 40 // returns true, then ServicesDelegate will use the service created by | 41 // returns true, then ServicesDelegate will use the service created by |
| (...skipping 17 matching lines...) Expand all Loading... |
| 58 static std::unique_ptr<ServicesDelegate> Create( | 59 static std::unique_ptr<ServicesDelegate> Create( |
| 59 SafeBrowsingService* safe_browsing_service); | 60 SafeBrowsingService* safe_browsing_service); |
| 60 | 61 |
| 61 // Creates the ServicesDelegate using a custom ServicesCreator, for testing. | 62 // Creates the ServicesDelegate using a custom ServicesCreator, for testing. |
| 62 static std::unique_ptr<ServicesDelegate> CreateForTest( | 63 static std::unique_ptr<ServicesDelegate> CreateForTest( |
| 63 SafeBrowsingService* safe_browsing_service, | 64 SafeBrowsingService* safe_browsing_service, |
| 64 ServicesDelegate::ServicesCreator* services_creator); | 65 ServicesDelegate::ServicesCreator* services_creator); |
| 65 | 66 |
| 66 virtual ~ServicesDelegate() {} | 67 virtual ~ServicesDelegate() {} |
| 67 | 68 |
| 69 // Initializes internal state using the ServicesCreator. |
| 70 virtual void Initialize() = 0; |
| 71 |
| 68 // Creates the CSD service for the given |context_getter|. | 72 // Creates the CSD service for the given |context_getter|. |
| 69 virtual void InitializeCsdService( | 73 virtual void InitializeCsdService( |
| 70 net::URLRequestContextGetter* context_getter) = 0; | 74 net::URLRequestContextGetter* context_getter) = 0; |
| 71 | 75 |
| 72 // Initializes services using the ServicesCreator. | |
| 73 virtual void InitializeServices() = 0; | |
| 74 | |
| 75 // Shuts down the download service. | 76 // Shuts down the download service. |
| 76 virtual void ShutdownServices() = 0; | 77 virtual void ShutdownServices() = 0; |
| 77 | 78 |
| 78 // Handles SafeBrowsingService::RefreshState() for the provided services. | 79 // Handles SafeBrowsingService::RefreshState() for the provided services. |
| 79 virtual void RefreshState(bool enable) = 0; | 80 virtual void RefreshState(bool enable) = 0; |
| 80 | 81 |
| 81 // See the SafeBrowsingService methods of the same name. | 82 // See the SafeBrowsingService methods of the same name. |
| 82 virtual void ProcessResourceRequest(const ResourceRequestInfo* request) = 0; | 83 virtual void ProcessResourceRequest(const ResourceRequestInfo* request) = 0; |
| 83 virtual std::unique_ptr<TrackedPreferenceValidationDelegate> | 84 virtual std::unique_ptr<TrackedPreferenceValidationDelegate> |
| 84 CreatePreferenceValidationDelegate(Profile* profile) = 0; | 85 CreatePreferenceValidationDelegate(Profile* profile) = 0; |
| 85 virtual void RegisterDelayedAnalysisCallback( | 86 virtual void RegisterDelayedAnalysisCallback( |
| 86 const DelayedAnalysisCallback& callback) = 0; | 87 const DelayedAnalysisCallback& callback) = 0; |
| 87 virtual void RegisterExtendedReportingOnlyDelayedAnalysisCallback( | 88 virtual void RegisterExtendedReportingOnlyDelayedAnalysisCallback( |
| 88 const DelayedAnalysisCallback& callback) = 0; | 89 const DelayedAnalysisCallback& callback) = 0; |
| 89 virtual void AddDownloadManager( | 90 virtual void AddDownloadManager( |
| 90 content::DownloadManager* download_manager) = 0; | 91 content::DownloadManager* download_manager) = 0; |
| 91 | 92 |
| 92 // Returns nullptr for any service that is not available. | 93 // Returns nullptr for any service that is not available. |
| 93 virtual ClientSideDetectionService* GetCsdService() = 0; | 94 virtual ClientSideDetectionService* GetCsdService() = 0; |
| 94 virtual DownloadProtectionService* GetDownloadService() = 0; | 95 virtual DownloadProtectionService* GetDownloadService() = 0; |
| 96 |
| 97 virtual void StartOnIOThread( |
| 98 net::URLRequestContextGetter* url_request_context_getter, |
| 99 const V4ProtocolConfig& v4_config) = 0; |
| 100 virtual void StopOnIOThread(bool shutdown) = 0; |
| 95 }; | 101 }; |
| 96 | 102 |
| 97 } // namespace safe_browsing | 103 } // namespace safe_browsing |
| 98 | 104 |
| 99 #endif // CHROME_BROWSER_SAFE_BROWSING_SERVICES_DELEGATE_H_ | 105 #endif // CHROME_BROWSER_SAFE_BROWSING_SERVICES_DELEGATE_H_ |
| OLD | NEW |