Index: chrome/browser/safe_browsing/safe_browsing_service.h |
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h |
index 90199377d5423df4e5b981c8e12fecb9fbbe34f2..6c66eb1ae06dc4acbbd011c705aed1ec1102d8c4 100644 |
--- a/chrome/browser/safe_browsing/safe_browsing_service.h |
+++ b/chrome/browser/safe_browsing/safe_browsing_service.h |
@@ -17,6 +17,7 @@ |
#include "base/hash_tables.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/observer_list.h" |
#include "base/synchronization/lock.h" |
#include "base/task.h" |
#include "base/time.h" |
@@ -104,6 +105,20 @@ class SafeBrowsingService |
DISALLOW_COPY_AND_ASSIGN(SafeBrowsingCheck); |
}; |
+ // Observer class can be used to get notified when a SafeBrowsing hit |
+ // was found. |
+ class Observer { |
+ public: |
+ Observer() {} |
Brian Ryner
2011/07/19 21:27:10
Since this should always be subclassed, make the c
noelutz
2011/07/19 22:28:08
Done.
|
+ virtual ~Observer() {} |
+ // The |resource| must not be accessed after OnSafeBrowsingHit returns. |
+ // This method will be called on the UI thread. |
+ virtual void OnSafeBrowsingHit(const UnsafeResource& resource) = 0; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(Observer); |
+ }; |
+ |
class Client { |
public: |
virtual ~Client() {} |
@@ -128,7 +143,6 @@ class SafeBrowsingService |
UrlCheckResult result) {} |
}; |
- |
// Makes the passed |factory| the factory used to instanciate |
// a SafeBrowsingService. Useful for tests. |
static void RegisterFactory(SafeBrowsingServiceFactory* factory) { |
@@ -262,6 +276,10 @@ class SafeBrowsingService |
UrlCheckResult threat_type, |
const std::string& post_data); |
+ // Add and remove observers. These methods must be invoked on the UI thread. |
+ void AddObserver(Observer* observer); |
+ void RemoveObserver(Observer* remove); |
+ |
protected: |
// Creates the safe browsing service. Need to initialize before using. |
SafeBrowsingService(); |
@@ -480,6 +498,7 @@ class SafeBrowsingService |
// Similar to |download_urlcheck_timeout_ms_|, but for download hash checks. |
int64 download_hashcheck_timeout_ms_; |
+ ObserverList<Observer> observer_list_; |
NotificationRegistrar registrar_; |
DISALLOW_COPY_AND_ASSIGN(SafeBrowsingService); |