Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service.h

Issue 2675063002: Browser tests for using the new SafeBrowsing protocol (v4) (Closed)
Patch Set: shess@'s review Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 class SafeBrowsingDatabaseManager; 52 class SafeBrowsingDatabaseManager;
53 class SafeBrowsingNavigationObserverManager; 53 class SafeBrowsingNavigationObserverManager;
54 class SafeBrowsingPingManager; 54 class SafeBrowsingPingManager;
55 class SafeBrowsingProtocolManager; 55 class SafeBrowsingProtocolManager;
56 class SafeBrowsingProtocolManagerDelegate; 56 class SafeBrowsingProtocolManagerDelegate;
57 class SafeBrowsingServiceFactory; 57 class SafeBrowsingServiceFactory;
58 class SafeBrowsingUIManager; 58 class SafeBrowsingUIManager;
59 class SafeBrowsingURLRequestContextGetter; 59 class SafeBrowsingURLRequestContextGetter;
60 struct V4ProtocolConfig; 60 struct V4ProtocolConfig;
61 61
62 enum class V4UsageStatus { V4_DISABLED, V4_INSTANTIATED, V4_ONLY };
Nathan Parker 2017/02/08 01:22:43 Add a comment... could point to the v4_feature_lis
vakh (use Gerrit instead) 2017/02/09 03:30:27 Done.
63
62 // Construction needs to happen on the main thread. 64 // Construction needs to happen on the main thread.
63 // The SafeBrowsingService owns both the UI and Database managers which do 65 // The SafeBrowsingService owns both the UI and Database managers which do
64 // the heavylifting of safebrowsing service. Both of these managers stay 66 // the heavylifting of safebrowsing service. Both of these managers stay
65 // alive until SafeBrowsingService is destroyed, however, they are disabled 67 // alive until SafeBrowsingService is destroyed, however, they are disabled
66 // permanently when Shutdown method is called. 68 // permanently when Shutdown method is called.
67 class SafeBrowsingService : public base::RefCountedThreadSafe< 69 class SafeBrowsingService : public base::RefCountedThreadSafe<
68 SafeBrowsingService, 70 SafeBrowsingService,
69 content::BrowserThread::DeleteOnUIThread>, 71 content::BrowserThread::DeleteOnUIThread>,
70 public content::NotificationObserver { 72 public content::NotificationObserver {
71 public: 73 public:
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // The callbacks run on the UI thread, and give the subscribers an opportunity 192 // The callbacks run on the UI thread, and give the subscribers an opportunity
191 // to clean up any references they hold to SafeBrowsingService. 193 // to clean up any references they hold to SafeBrowsingService.
192 std::unique_ptr<ShutdownSubscription> RegisterShutdownCallback( 194 std::unique_ptr<ShutdownSubscription> RegisterShutdownCallback(
193 const base::Callback<void(void)>& callback); 195 const base::Callback<void(void)>& callback);
194 196
195 // Sends serialized download report to backend. 197 // Sends serialized download report to backend.
196 virtual void SendSerializedDownloadReport(const std::string& report); 198 virtual void SendSerializedDownloadReport(const std::string& report);
197 199
198 protected: 200 protected:
199 // Creates the safe browsing service. Need to initialize before using. 201 // Creates the safe browsing service. Need to initialize before using.
200 SafeBrowsingService(); 202 SafeBrowsingService(
203 V4UsageStatus v4_usage_status = V4UsageStatus::V4_DISABLED);
201 204
202 ~SafeBrowsingService() override; 205 ~SafeBrowsingService() override;
203 206
204 virtual SafeBrowsingDatabaseManager* CreateDatabaseManager(); 207 virtual SafeBrowsingDatabaseManager* CreateDatabaseManager();
205 208
206 virtual SafeBrowsingUIManager* CreateUIManager(); 209 virtual SafeBrowsingUIManager* CreateUIManager();
207 210
208 // Registers all the delayed analysis with the incident reporting service. 211 // Registers all the delayed analysis with the incident reporting service.
209 // This is where you register your process-wide, profile-independent analysis. 212 // This is where you register your process-wide, profile-independent analysis.
210 virtual void RegisterAllDelayedAnalysis(); 213 virtual void RegisterAllDelayedAnalysis();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // Whether the service is running. 'enabled_' is used by SafeBrowsingService 294 // Whether the service is running. 'enabled_' is used by SafeBrowsingService
292 // on the IO thread during normal operations. 295 // on the IO thread during normal operations.
293 bool enabled_; 296 bool enabled_;
294 297
295 // Whether SafeBrowsing is enabled by the current set of profiles. 298 // Whether SafeBrowsing is enabled by the current set of profiles.
296 // Accessed on UI thread. 299 // Accessed on UI thread.
297 bool enabled_by_prefs_; 300 bool enabled_by_prefs_;
298 301
299 // Whether SafeBrowsing needs to be enabled in V4Only mode. In this mode, all 302 // Whether SafeBrowsing needs to be enabled in V4Only mode. In this mode, all
300 // SafeBrowsing decisions are made using the PVer4 implementation. 303 // SafeBrowsing decisions are made using the PVer4 implementation.
301 bool enabled_v4_only_; 304 bool use_v4_only_;
305
306 // Whether the PVer4 implementation needs to be instantiated. Note that even
307 // if the PVer4 implementation has been instantiated, it is used only if
308 // |use_v4_only_| is true.
309 bool v4_enabled_;
302 310
303 // Tracks existing PrefServices, and the safe browsing preference on each. 311 // Tracks existing PrefServices, and the safe browsing preference on each.
304 // This is used to determine if any profile is currently using the safe 312 // This is used to determine if any profile is currently using the safe
305 // browsing service, and to start it up or shut it down accordingly. 313 // browsing service, and to start it up or shut it down accordingly.
306 // Accessed on UI thread. 314 // Accessed on UI thread.
307 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_; 315 std::map<PrefService*, std::unique_ptr<PrefChangeRegistrar>> prefs_map_;
308 316
309 // Used to track creation and destruction of profiles on the UI thread. 317 // Used to track creation and destruction of profiles on the UI thread.
310 content::NotificationRegistrar prefs_registrar_; 318 content::NotificationRegistrar prefs_registrar_;
311 319
(...skipping 26 matching lines...) Expand all
338 SafeBrowsingServiceFactory() { } 346 SafeBrowsingServiceFactory() { }
339 virtual ~SafeBrowsingServiceFactory() { } 347 virtual ~SafeBrowsingServiceFactory() { }
340 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; 348 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0;
341 private: 349 private:
342 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); 350 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory);
343 }; 351 };
344 352
345 } // namespace safe_browsing 353 } // namespace safe_browsing
346 354
347 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ 355 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698