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 // This returns either the v3 or the v4 database manager, depending on | 128 // This returns either the v3 or the v4 database manager, depending on |
129 // the experiment settings. | 129 // the experiment settings. |
130 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager() const; | 130 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager() const; |
131 | 131 |
132 SafeBrowsingProtocolManager* protocol_manager() const; | 132 SafeBrowsingProtocolManager* protocol_manager() const; |
133 | 133 |
134 SafeBrowsingPingManager* ping_manager() const; | 134 SafeBrowsingPingManager* ping_manager() const; |
(...skipping 17 matching lines...) Expand all Loading... | |
152 | 152 |
153 // Adds |download_manager| to the set monitored by safe browsing. | 153 // Adds |download_manager| to the set monitored by safe browsing. |
154 void AddDownloadManager(content::DownloadManager* download_manager); | 154 void AddDownloadManager(content::DownloadManager* download_manager); |
155 | 155 |
156 // Observes resource requests made by the renderer and reports suspicious | 156 // Observes resource requests made by the renderer and reports suspicious |
157 // activity. | 157 // activity. |
158 void OnResourceRequest(const net::URLRequest* request); | 158 void OnResourceRequest(const net::URLRequest* request); |
159 | 159 |
160 // Type for subscriptions to SafeBrowsing service state. | 160 // Type for subscriptions to SafeBrowsing service state. |
161 typedef base::CallbackList<void(void)>::Subscription StateSubscription; | 161 typedef base::CallbackList<void(void)>::Subscription StateSubscription; |
162 typedef base::CallbackList<void(void)>::Subscription ShutdownSubscription; | |
162 | 163 |
163 // Adds a listener for when SafeBrowsing preferences might have changed. | 164 // Adds a listener for when SafeBrowsing preferences might have changed. |
164 // To get the current state, the callback should call enabled_by_prefs(). | 165 // To get the current state, the callback should call enabled_by_prefs(). |
165 // Should only be called on the UI thread. | 166 // Should only be called on the UI thread. |
166 std::unique_ptr<StateSubscription> RegisterStateCallback( | 167 std::unique_ptr<StateSubscription> RegisterStateCallback( |
167 const base::Callback<void(void)>& callback); | 168 const base::Callback<void(void)>& callback); |
169 std::unique_ptr<ShutdownSubscription> RegisterShutdownCallback( | |
Jialiu Lin
2016/12/16 01:55:24
Could you add some comments on what thread these w
meacer
2016/12/16 20:26:36
Done.
| |
170 const base::Callback<void(void)>& callback); | |
168 | 171 |
169 // Sends serialized download report to backend. | 172 // Sends serialized download report to backend. |
170 virtual void SendSerializedDownloadReport(const std::string& report); | 173 virtual void SendSerializedDownloadReport(const std::string& report); |
171 | 174 |
172 protected: | 175 protected: |
173 // Creates the safe browsing service. Need to initialize before using. | 176 // Creates the safe browsing service. Need to initialize before using. |
174 SafeBrowsingService(); | 177 SafeBrowsingService(); |
175 | 178 |
176 ~SafeBrowsingService() override; | 179 ~SafeBrowsingService() override; |
177 | 180 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 // browsing service, and to start it up or shut it down accordingly. | 278 // browsing service, and to start it up or shut it down accordingly. |
276 // Accessed on UI thread. | 279 // Accessed on UI thread. |
277 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_; | 280 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_; |
278 | 281 |
279 // Used to track creation and destruction of profiles on the UI thread. | 282 // Used to track creation and destruction of profiles on the UI thread. |
280 content::NotificationRegistrar prefs_registrar_; | 283 content::NotificationRegistrar prefs_registrar_; |
281 | 284 |
282 // Callbacks when SafeBrowsing state might have changed. | 285 // Callbacks when SafeBrowsing state might have changed. |
283 // Should only be accessed on the UI thread. | 286 // Should only be accessed on the UI thread. |
284 base::CallbackList<void(void)> state_callback_list_; | 287 base::CallbackList<void(void)> state_callback_list_; |
288 base::CallbackList<void(void)> shutdown_callback_list_; | |
285 | 289 |
286 // The UI manager handles showing interstitials. Accessed on both UI and IO | 290 // The UI manager handles showing interstitials. Accessed on both UI and IO |
287 // thread. | 291 // thread. |
288 scoped_refptr<SafeBrowsingUIManager> ui_manager_; | 292 scoped_refptr<SafeBrowsingUIManager> ui_manager_; |
289 | 293 |
290 // The database manager handles the database and download logic. Accessed on | 294 // The database manager handles the database and download logic. Accessed on |
291 // both UI and IO thread. | 295 // both UI and IO thread. |
292 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; | 296 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |
293 | 297 |
294 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); | 298 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); |
295 }; | 299 }; |
296 | 300 |
297 // Factory for creating SafeBrowsingService. Useful for tests. | 301 // Factory for creating SafeBrowsingService. Useful for tests. |
298 class SafeBrowsingServiceFactory { | 302 class SafeBrowsingServiceFactory { |
299 public: | 303 public: |
300 SafeBrowsingServiceFactory() { } | 304 SafeBrowsingServiceFactory() { } |
301 virtual ~SafeBrowsingServiceFactory() { } | 305 virtual ~SafeBrowsingServiceFactory() { } |
302 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; | 306 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; |
303 private: | 307 private: |
304 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); | 308 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); |
305 }; | 309 }; |
306 | 310 |
307 } // namespace safe_browsing | 311 } // namespace safe_browsing |
308 | 312 |
309 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 313 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
OLD | NEW |