| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 ClientSideDetectionService* safe_browsing_detection_service() const { | 114 ClientSideDetectionService* safe_browsing_detection_service() const { |
| 115 return services_delegate_->GetCsdService(); | 115 return services_delegate_->GetCsdService(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // The DownloadProtectionService is not valid after the SafeBrowsingService | 118 // The DownloadProtectionService is not valid after the SafeBrowsingService |
| 119 // is destroyed. | 119 // is destroyed. |
| 120 DownloadProtectionService* download_protection_service() const { | 120 DownloadProtectionService* download_protection_service() const { |
| 121 return services_delegate_->GetDownloadService(); | 121 return services_delegate_->GetDownloadService(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 net::URLRequestContextGetter* url_request_context(); | 124 scoped_refptr<net::URLRequestContextGetter> url_request_context(); |
| 125 | 125 |
| 126 const scoped_refptr<SafeBrowsingUIManager>& ui_manager() const; | 126 const scoped_refptr<SafeBrowsingUIManager>& ui_manager() const; |
| 127 | 127 |
| 128 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager() const; | 128 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager() const; |
| 129 | 129 |
| 130 SafeBrowsingProtocolManager* protocol_manager() const; | 130 SafeBrowsingProtocolManager* protocol_manager() const; |
| 131 | 131 |
| 132 SafeBrowsingPingManager* ping_manager() const; | 132 SafeBrowsingPingManager* ping_manager() const; |
| 133 | 133 |
| 134 const scoped_refptr<V4LocalDatabaseManager>& v4_local_database_manager() | 134 const scoped_refptr<V4LocalDatabaseManager>& v4_local_database_manager() |
| (...skipping 14 matching lines...) Expand all Loading... |
| 149 | 149 |
| 150 // Adds |download_manager| to the set monitored by safe browsing. | 150 // Adds |download_manager| to the set monitored by safe browsing. |
| 151 void AddDownloadManager(content::DownloadManager* download_manager); | 151 void AddDownloadManager(content::DownloadManager* download_manager); |
| 152 | 152 |
| 153 // Observes resource requests made by the renderer and reports suspicious | 153 // Observes resource requests made by the renderer and reports suspicious |
| 154 // activity. | 154 // activity. |
| 155 void OnResourceRequest(const net::URLRequest* request); | 155 void OnResourceRequest(const net::URLRequest* request); |
| 156 | 156 |
| 157 // Type for subscriptions to SafeBrowsing service state. | 157 // Type for subscriptions to SafeBrowsing service state. |
| 158 typedef base::CallbackList<void(void)>::Subscription StateSubscription; | 158 typedef base::CallbackList<void(void)>::Subscription StateSubscription; |
| 159 typedef base::CallbackList<void(void)>::Subscription ShutdownSubscription; |
| 159 | 160 |
| 160 // Adds a listener for when SafeBrowsing preferences might have changed. | 161 // Adds a listener for when SafeBrowsing preferences might have changed. |
| 161 // To get the current state, the callback should call enabled_by_prefs(). | 162 // To get the current state, the callback should call enabled_by_prefs(). |
| 162 // Should only be called on the UI thread. | 163 // Should only be called on the UI thread. |
| 163 std::unique_ptr<StateSubscription> RegisterStateCallback( | 164 std::unique_ptr<StateSubscription> RegisterStateCallback( |
| 164 const base::Callback<void(void)>& callback); | 165 const base::Callback<void(void)>& callback); |
| 166 std::unique_ptr<ShutdownSubscription> RegisterShutdownCallback( |
| 167 const base::Callback<void(void)>& callback); |
| 165 | 168 |
| 166 // Sends serialized download report to backend. | 169 // Sends serialized download report to backend. |
| 167 virtual void SendSerializedDownloadReport(const std::string& report); | 170 virtual void SendSerializedDownloadReport(const std::string& report); |
| 168 | 171 |
| 169 protected: | 172 protected: |
| 170 // Creates the safe browsing service. Need to initialize before using. | 173 // Creates the safe browsing service. Need to initialize before using. |
| 171 SafeBrowsingService(); | 174 SafeBrowsingService(); |
| 172 | 175 |
| 173 ~SafeBrowsingService() override; | 176 ~SafeBrowsingService() override; |
| 174 | 177 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // browsing service, and to start it up or shut it down accordingly. | 271 // browsing service, and to start it up or shut it down accordingly. |
| 269 // Accessed on UI thread. | 272 // Accessed on UI thread. |
| 270 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_; | 273 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_; |
| 271 | 274 |
| 272 // Used to track creation and destruction of profiles on the UI thread. | 275 // Used to track creation and destruction of profiles on the UI thread. |
| 273 content::NotificationRegistrar prefs_registrar_; | 276 content::NotificationRegistrar prefs_registrar_; |
| 274 | 277 |
| 275 // Callbacks when SafeBrowsing state might have changed. | 278 // Callbacks when SafeBrowsing state might have changed. |
| 276 // Should only be accessed on the UI thread. | 279 // Should only be accessed on the UI thread. |
| 277 base::CallbackList<void(void)> state_callback_list_; | 280 base::CallbackList<void(void)> state_callback_list_; |
| 281 base::CallbackList<void(void)> shutdown_callback_list_; |
| 278 | 282 |
| 279 // The UI manager handles showing interstitials. Accessed on both UI and IO | 283 // The UI manager handles showing interstitials. Accessed on both UI and IO |
| 280 // thread. | 284 // thread. |
| 281 scoped_refptr<SafeBrowsingUIManager> ui_manager_; | 285 scoped_refptr<SafeBrowsingUIManager> ui_manager_; |
| 282 | 286 |
| 283 // The database manager handles the database and download logic. Accessed on | 287 // The database manager handles the database and download logic. Accessed on |
| 284 // both UI and IO thread. | 288 // both UI and IO thread. |
| 285 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; | 289 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |
| 286 | 290 |
| 287 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); | 291 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); |
| 288 }; | 292 }; |
| 289 | 293 |
| 290 // Factory for creating SafeBrowsingService. Useful for tests. | 294 // Factory for creating SafeBrowsingService. Useful for tests. |
| 291 class SafeBrowsingServiceFactory { | 295 class SafeBrowsingServiceFactory { |
| 292 public: | 296 public: |
| 293 SafeBrowsingServiceFactory() { } | 297 SafeBrowsingServiceFactory() { } |
| 294 virtual ~SafeBrowsingServiceFactory() { } | 298 virtual ~SafeBrowsingServiceFactory() { } |
| 295 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; | 299 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; |
| 296 private: | 300 private: |
| 297 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); | 301 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); |
| 298 }; | 302 }; |
| 299 | 303 |
| 300 } // namespace safe_browsing | 304 } // namespace safe_browsing |
| 301 | 305 |
| 302 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 306 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
| OLD | NEW |