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

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

Issue 1410853003: [Safe Browsing] Only check main frame and iframe URLs on Mobile, for speed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rm unecessary thread restriction that interferes with tests Created 5 years, 2 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // The SafeBrowsingService owns both the UI and Database managers which do 69 // The SafeBrowsingService owns both the UI and Database managers which do
70 // the heavylifting of safebrowsing service. Both of these managers stay 70 // the heavylifting of safebrowsing service. Both of these managers stay
71 // alive until SafeBrowsingService is destroyed, however, they are disabled 71 // alive until SafeBrowsingService is destroyed, however, they are disabled
72 // permanently when Shutdown method is called. 72 // permanently when Shutdown method is called.
73 class SafeBrowsingService 73 class SafeBrowsingService
74 : public base::RefCountedThreadSafe< 74 : public base::RefCountedThreadSafe<
75 SafeBrowsingService, 75 SafeBrowsingService,
76 content::BrowserThread::DeleteOnUIThread>, 76 content::BrowserThread::DeleteOnUIThread>,
77 public content::NotificationObserver { 77 public content::NotificationObserver {
78 public: 78 public:
79 enum ResourceTypesToCheck {
80 CHECK_ALL_RESOURCE_TYPES,
81 CHECK_ONLY_DANGEROUS_TYPES,
82 };
83 79
84 // Makes the passed |factory| the factory used to instanciate 80 // Makes the passed |factory| the factory used to instanciate
85 // a SafeBrowsingService. Useful for tests. 81 // a SafeBrowsingService. Useful for tests.
86 static void RegisterFactory(SafeBrowsingServiceFactory* factory) { 82 static void RegisterFactory(SafeBrowsingServiceFactory* factory) {
87 factory_ = factory; 83 factory_ = factory;
88 } 84 }
89 85
90 static base::FilePath GetCookieFilePathForTesting(); 86 static base::FilePath GetCookieFilePathForTesting();
91 87
92 static base::FilePath GetBaseFilename(); 88 static base::FilePath GetBaseFilename();
93 89
94 // Create an instance of the safe browsing service. 90 // Create an instance of the safe browsing service.
95 static SafeBrowsingService* CreateSafeBrowsingService(); 91 static SafeBrowsingService* CreateSafeBrowsingService();
96 92
97 #if defined(SAFE_BROWSING_DB_REMOTE)
98 // Field trial for Android Safe Browsing. This is checked separately in
99 // SafeBrowsingFieldTrial.java for controlling the UI.
100 bool IsAndroidFieldTrialEnabled() const {
101 return is_android_field_trial_enabled_;
102 }
103
104 // Should we check all types, or just the dangerous ones?
105 // We can flip this with a field trial if a non-dangerous type
106 // starts getting exploited.
107 ResourceTypesToCheck GetResourceTypesToCheck() const {
108 return resource_types_to_check_;
109 }
110 #endif // defined(SAFE_BROWSING_DB_REMOTE)
111
112 // Called on the UI thread to initialize the service. 93 // Called on the UI thread to initialize the service.
113 void Initialize(); 94 void Initialize();
114 95
115 // Called on the main thread to let us know that the io_thread is going away. 96 // Called on the main thread to let us know that the io_thread is going away.
116 void ShutDown(); 97 void ShutDown();
117 98
118 // Called on UI thread to decide if the download file's sha256 hash 99 // Called on UI thread to decide if the download file's sha256 hash
119 // should be calculated for safebrowsing. 100 // should be calculated for safebrowsing.
120 bool DownloadBinHashNeeded() const; 101 bool DownloadBinHashNeeded() const;
121 102
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 SafeBrowsingPingManager* ping_manager_; 264 SafeBrowsingPingManager* ping_manager_;
284 265
285 // Whether the service is running. 'enabled_' is used by SafeBrowsingService 266 // Whether the service is running. 'enabled_' is used by SafeBrowsingService
286 // on the IO thread during normal operations. 267 // on the IO thread during normal operations.
287 bool enabled_; 268 bool enabled_;
288 269
289 // Whether SafeBrowsing is enabled by the current set of profiles. 270 // Whether SafeBrowsing is enabled by the current set of profiles.
290 // Accessed on UI thread. 271 // Accessed on UI thread.
291 bool enabled_by_prefs_; 272 bool enabled_by_prefs_;
292 273
293 #if defined(SAFE_BROWSING_DB_REMOTE)
294 bool is_android_field_trial_enabled_;
295 ResourceTypesToCheck resource_types_to_check_;
296 #endif // defined(SAFE_BROWSING_DB_REMOTE)
297
298 // Tracks existing PrefServices, and the safe browsing preference on each. 274 // Tracks existing PrefServices, and the safe browsing preference on each.
299 // This is used to determine if any profile is currently using the safe 275 // This is used to determine if any profile is currently using the safe
300 // browsing service, and to start it up or shut it down accordingly. 276 // browsing service, and to start it up or shut it down accordingly.
301 // Accessed on UI thread. 277 // Accessed on UI thread.
302 std::map<PrefService*, PrefChangeRegistrar*> prefs_map_; 278 std::map<PrefService*, PrefChangeRegistrar*> prefs_map_;
303 279
304 // Used to track creation and destruction of profiles on the UI thread. 280 // Used to track creation and destruction of profiles on the UI thread.
305 content::NotificationRegistrar prefs_registrar_; 281 content::NotificationRegistrar prefs_registrar_;
306 282
307 // Callbacks when SafeBrowsing state might have changed. 283 // Callbacks when SafeBrowsing state might have changed.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 class SafeBrowsingServiceFactory { 320 class SafeBrowsingServiceFactory {
345 public: 321 public:
346 SafeBrowsingServiceFactory() { } 322 SafeBrowsingServiceFactory() { }
347 virtual ~SafeBrowsingServiceFactory() { } 323 virtual ~SafeBrowsingServiceFactory() { }
348 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; 324 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0;
349 private: 325 private:
350 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); 326 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory);
351 }; 327 };
352 328
353 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ 329 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698