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

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: Use a comma-separated list of types 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 SafeBrowsingPingManager* ping_manager_; 259 SafeBrowsingPingManager* ping_manager_;
279 260
280 // Whether the service is running. 'enabled_' is used by SafeBrowsingService 261 // Whether the service is running. 'enabled_' is used by SafeBrowsingService
281 // on the IO thread during normal operations. 262 // on the IO thread during normal operations.
282 bool enabled_; 263 bool enabled_;
283 264
284 // Whether SafeBrowsing is enabled by the current set of profiles. 265 // Whether SafeBrowsing is enabled by the current set of profiles.
285 // Accessed on UI thread. 266 // Accessed on UI thread.
286 bool enabled_by_prefs_; 267 bool enabled_by_prefs_;
287 268
288 #if defined(SAFE_BROWSING_DB_REMOTE)
289 bool is_android_field_trial_enabled_;
290 ResourceTypesToCheck resource_types_to_check_;
291 #endif // defined(SAFE_BROWSING_DB_REMOTE)
292
293 // Tracks existing PrefServices, and the safe browsing preference on each. 269 // Tracks existing PrefServices, and the safe browsing preference on each.
294 // This is used to determine if any profile is currently using the safe 270 // This is used to determine if any profile is currently using the safe
295 // 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.
296 // Accessed on UI thread. 272 // Accessed on UI thread.
297 std::map<PrefService*, PrefChangeRegistrar*> prefs_map_; 273 std::map<PrefService*, PrefChangeRegistrar*> prefs_map_;
298 274
299 // 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.
300 content::NotificationRegistrar prefs_registrar_; 276 content::NotificationRegistrar prefs_registrar_;
301 277
302 // Callbacks when SafeBrowsing state might have changed. 278 // Callbacks when SafeBrowsing state might have changed.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 class SafeBrowsingServiceFactory { 315 class SafeBrowsingServiceFactory {
340 public: 316 public:
341 SafeBrowsingServiceFactory() { } 317 SafeBrowsingServiceFactory() { }
342 virtual ~SafeBrowsingServiceFactory() { } 318 virtual ~SafeBrowsingServiceFactory() { }
343 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; 319 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0;
344 private: 320 private:
345 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); 321 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory);
346 }; 322 };
347 323
348 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ 324 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698