OLD | NEW |
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 Loading... |
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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 int64 timeout_ms); | 479 int64 timeout_ms); |
478 | 480 |
479 // Adds the given entry to the whitelist. Called on the UI thread. | 481 // Adds the given entry to the whitelist. Called on the UI thread. |
480 void UpdateWhitelist(const UnsafeResource& resource); | 482 void UpdateWhitelist(const UnsafeResource& resource); |
481 | 483 |
482 // content::NotificationObserver override | 484 // content::NotificationObserver override |
483 virtual void Observe(int type, | 485 virtual void Observe(int type, |
484 const content::NotificationSource& source, | 486 const content::NotificationSource& source, |
485 const content::NotificationDetails& details) OVERRIDE; | 487 const content::NotificationDetails& details) OVERRIDE; |
486 | 488 |
| 489 // PrefObserver override |
| 490 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 491 const std::string& pref_name) OVERRIDE; |
| 492 |
487 // Starts following the safe browsing preference on |pref_service|. | 493 // Starts following the safe browsing preference on |pref_service|. |
488 void AddPrefService(PrefService* pref_service); | 494 void AddPrefService(PrefService* pref_service); |
489 | 495 |
490 // Stop following the safe browsing preference on |pref_service|. | 496 // Stop following the safe browsing preference on |pref_service|. |
491 void RemovePrefService(PrefService* pref_service); | 497 void RemovePrefService(PrefService* pref_service); |
492 | 498 |
493 // Checks if any profile is currently using the safe browsing service, and | 499 // Checks if any profile is currently using the safe browsing service, and |
494 // starts or stops the service accordingly. | 500 // starts or stops the service accordingly. |
495 void RefreshState(); | 501 void RefreshState(); |
496 | 502 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 class SafeBrowsingServiceFactory { | 601 class SafeBrowsingServiceFactory { |
596 public: | 602 public: |
597 SafeBrowsingServiceFactory() { } | 603 SafeBrowsingServiceFactory() { } |
598 virtual ~SafeBrowsingServiceFactory() { } | 604 virtual ~SafeBrowsingServiceFactory() { } |
599 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; | 605 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; |
600 private: | 606 private: |
601 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); | 607 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); |
602 }; | 608 }; |
603 | 609 |
604 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 610 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
OLD | NEW |