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

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

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 8 years, 1 month 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) 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
11 #include <deque> 11 #include <deque>
12 #include <map> 12 #include <map>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/file_path.h" 18 #include "base/file_path.h"
19 #include "base/hash_tables.h" 19 #include "base/hash_tables.h"
20 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
21 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
22 #include "base/observer_list.h" 22 #include "base/observer_list.h"
23 #include "base/prefs/public/pref_observer.h"
23 #include "base/sequenced_task_runner_helpers.h" 24 #include "base/sequenced_task_runner_helpers.h"
24 #include "base/synchronization/lock.h" 25 #include "base/synchronization/lock.h"
25 #include "base/time.h" 26 #include "base/time.h"
26 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 27 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/notification_observer.h" 29 #include "content/public/browser/notification_observer.h"
29 #include "content/public/browser/notification_registrar.h" 30 #include "content/public/browser/notification_registrar.h"
30 #include "googleurl/src/gurl.h" 31 #include "googleurl/src/gurl.h"
31 32
32 class MalwareDetails; 33 class MalwareDetails;
(...skipping 15 matching lines...) Expand all
48 49
49 namespace safe_browsing { 50 namespace safe_browsing {
50 class ClientSideDetectionService; 51 class ClientSideDetectionService;
51 class DownloadProtectionService; 52 class DownloadProtectionService;
52 } 53 }
53 54
54 // Construction needs to happen on the main thread. 55 // Construction needs to happen on the main thread.
55 class SafeBrowsingService 56 class SafeBrowsingService
56 : public base::RefCountedThreadSafe< 57 : public base::RefCountedThreadSafe<
57 SafeBrowsingService, content::BrowserThread::DeleteOnUIThread>, 58 SafeBrowsingService, content::BrowserThread::DeleteOnUIThread>,
58 public content::NotificationObserver { 59 public content::NotificationObserver,
60 public PrefObserver {
59 public: 61 public:
60 class Client; 62 class Client;
61 // Users of this service implement this interface to be notified 63 // Users of this service implement this interface to be notified
62 // asynchronously of the result. 64 // asynchronously of the result.
63 enum UrlCheckResult { 65 enum UrlCheckResult {
64 SAFE, 66 SAFE,
65 URL_PHISHING, 67 URL_PHISHING,
66 URL_MALWARE, 68 URL_MALWARE,
67 BINARY_MALWARE_URL, // Binary url leads to a malware. 69 BINARY_MALWARE_URL, // Binary url leads to a malware.
68 BINARY_MALWARE_HASH, // Binary hash indicates this is a malware. 70 BINARY_MALWARE_HASH, // Binary hash indicates this is a malware.
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 int64 timeout_ms); 481 int64 timeout_ms);
480 482
481 // Adds the given entry to the whitelist. Called on the UI thread. 483 // Adds the given entry to the whitelist. Called on the UI thread.
482 void UpdateWhitelist(const UnsafeResource& resource); 484 void UpdateWhitelist(const UnsafeResource& resource);
483 485
484 // content::NotificationObserver override 486 // content::NotificationObserver override
485 virtual void Observe(int type, 487 virtual void Observe(int type,
486 const content::NotificationSource& source, 488 const content::NotificationSource& source,
487 const content::NotificationDetails& details) OVERRIDE; 489 const content::NotificationDetails& details) OVERRIDE;
488 490
491 // PrefObserver override
492 virtual void OnPreferenceChanged(PrefServiceBase* service,
493 const std::string& pref_name) OVERRIDE;
494
489 // Starts following the safe browsing preference on |pref_service|. 495 // Starts following the safe browsing preference on |pref_service|.
490 void AddPrefService(PrefService* pref_service); 496 void AddPrefService(PrefService* pref_service);
491 497
492 // Stop following the safe browsing preference on |pref_service|. 498 // Stop following the safe browsing preference on |pref_service|.
493 void RemovePrefService(PrefService* pref_service); 499 void RemovePrefService(PrefService* pref_service);
494 500
495 // Checks if any profile is currently using the safe browsing service, and 501 // Checks if any profile is currently using the safe browsing service, and
496 // starts or stops the service accordingly. 502 // starts or stops the service accordingly.
497 void RefreshState(); 503 void RefreshState();
498 504
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 class SafeBrowsingServiceFactory { 603 class SafeBrowsingServiceFactory {
598 public: 604 public:
599 SafeBrowsingServiceFactory() { } 605 SafeBrowsingServiceFactory() { }
600 virtual ~SafeBrowsingServiceFactory() { } 606 virtual ~SafeBrowsingServiceFactory() { }
601 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; 607 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0;
602 private: 608 private:
603 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); 609 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory);
604 }; 610 };
605 611
606 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ 612 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698