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

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

Issue 7583007: Add "enabled" state to the ClientSideDetectionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 10 #pragma once
(...skipping 24 matching lines...) Expand all
35 class SafeBrowsingServiceFactory; 35 class SafeBrowsingServiceFactory;
36 36
37 namespace base { 37 namespace base {
38 class Thread; 38 class Thread;
39 } 39 }
40 40
41 namespace net { 41 namespace net {
42 class URLRequestContextGetter; 42 class URLRequestContextGetter;
43 } 43 }
44 44
45 namespace safe_browsing {
46 class ClientSideDetectionService;
47 }
48
45 // Construction needs to happen on the main thread. 49 // Construction needs to happen on the main thread.
46 class SafeBrowsingService 50 class SafeBrowsingService
47 : public base::RefCountedThreadSafe<SafeBrowsingService>, 51 : public base::RefCountedThreadSafe<SafeBrowsingService>,
48 public NotificationObserver { 52 public NotificationObserver {
49 public: 53 public:
50 class Client; 54 class Client;
51 // Users of this service implement this interface to be notified 55 // Users of this service implement this interface to be notified
52 // asynchronously of the result. 56 // asynchronously of the result.
53 enum UrlCheckResult { 57 enum UrlCheckResult {
54 SAFE, 58 SAFE,
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // updated MAC keys. 248 // updated MAC keys.
245 void OnNewMacKeys(const std::string& client_key, 249 void OnNewMacKeys(const std::string& client_key,
246 const std::string& wrapped_key); 250 const std::string& wrapped_key);
247 251
248 bool enabled() const { return enabled_; } 252 bool enabled() const { return enabled_; }
249 253
250 bool download_protection_enabled() const { 254 bool download_protection_enabled() const {
251 return enabled_ && enable_download_protection_; 255 return enabled_ && enable_download_protection_;
252 } 256 }
253 257
258 safe_browsing::ClientSideDetectionService*
259 safe_browsing_detection_service() const {
260 return csd_service_.get();
261 }
262
254 // Preference handling. 263 // Preference handling.
255 static void RegisterPrefs(PrefService* prefs); 264 static void RegisterPrefs(PrefService* prefs);
256 265
257 // Called on the IO thread to reset the database. 266 // Called on the IO thread to reset the database.
258 void ResetDatabase(); 267 void ResetDatabase();
259 268
260 // Log the user perceived delay caused by SafeBrowsing. This delay is the time 269 // Log the user perceived delay caused by SafeBrowsing. This delay is the time
261 // delta starting from when we would have started reading data from the 270 // delta starting from when we would have started reading data from the
262 // network, and ending when the SafeBrowsing check completes indicating that 271 // network, and ending when the SafeBrowsing check completes indicating that
263 // the current page is 'safe'. 272 // the current page is 'safe'.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 375
367 void NotifyClientBlockingComplete(Client* client, bool proceed); 376 void NotifyClientBlockingComplete(Client* client, bool proceed);
368 377
369 void DatabaseUpdateFinished(bool update_succeeded); 378 void DatabaseUpdateFinished(bool update_succeeded);
370 379
371 // Start up SafeBrowsing objects. This can be called at browser start, or when 380 // Start up SafeBrowsing objects. This can be called at browser start, or when
372 // the user checks the "Enable SafeBrowsing" option in the Advanced options 381 // the user checks the "Enable SafeBrowsing" option in the Advanced options
373 // UI. 382 // UI.
374 void Start(); 383 void Start();
375 384
385 // Stops the SafeBrowsingService. This can be called when the safe browsing
386 // preference is disabled.
387 void Stop();
388
376 // Called on the db thread to close the database. See CloseDatabase(). 389 // Called on the db thread to close the database. See CloseDatabase().
377 void OnCloseDatabase(); 390 void OnCloseDatabase();
378 391
379 // Runs on the db thread to reset the database. We assume that resetting the 392 // Runs on the db thread to reset the database. We assume that resetting the
380 // database is a synchronous operation. 393 // database is a synchronous operation.
381 void OnResetDatabase(); 394 void OnResetDatabase();
382 395
383 // Store in-memory the GetHash response. Runs on the database thread. 396 // Store in-memory the GetHash response. Runs on the database thread.
384 void CacheHashResults(const std::vector<SBPrefix>& prefixes, 397 void CacheHashResults(const std::vector<SBPrefix>& prefixes,
385 const std::vector<SBFullHashResult>& full_hashes); 398 const std::vector<SBFullHashResult>& full_hashes);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 NotificationRegistrar registrar_; 528 NotificationRegistrar registrar_;
516 529
517 // Tracks existing PrefServices, and the safe browsing preference on each. 530 // Tracks existing PrefServices, and the safe browsing preference on each.
518 // This is used to determine if any profile is currently using the safe 531 // This is used to determine if any profile is currently using the safe
519 // browsing service, and to start it up or shut it down accordingly. 532 // browsing service, and to start it up or shut it down accordingly.
520 std::map<PrefService*, PrefChangeRegistrar*> prefs_map_; 533 std::map<PrefService*, PrefChangeRegistrar*> prefs_map_;
521 534
522 // Used to track creation and destruction of profiles on the UI thread. 535 // Used to track creation and destruction of profiles on the UI thread.
523 NotificationRegistrar prefs_registrar_; 536 NotificationRegistrar prefs_registrar_;
524 537
538 // The ClientSideDetectionService is managed by the SafeBrowsingService,
539 // since its running state and lifecycle depends on SafeBrowsingService's.
540 scoped_ptr<safe_browsing::ClientSideDetectionService> csd_service_;
541
525 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); 542 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService);
526 }; 543 };
527 544
528 // Factory for creating SafeBrowsingService. Useful for tests. 545 // Factory for creating SafeBrowsingService. Useful for tests.
529 class SafeBrowsingServiceFactory { 546 class SafeBrowsingServiceFactory {
530 public: 547 public:
531 SafeBrowsingServiceFactory() { } 548 SafeBrowsingServiceFactory() { }
532 virtual ~SafeBrowsingServiceFactory() { } 549 virtual ~SafeBrowsingServiceFactory() { }
533 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; 550 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0;
534 private: 551 private:
535 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); 552 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory);
536 }; 553 };
537 554
538 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ 555 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698