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 f9b2c6cbfaf34b1a7284470fbcb3e1b68758b571..6dbcdc0b638e804e6636fd2c4e601c155bb73ca8 100644 |
--- a/chrome/browser/safe_browsing/safe_browsing_service.h |
+++ b/chrome/browser/safe_browsing/safe_browsing_service.h |
@@ -18,6 +18,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" |
@@ -106,6 +107,22 @@ class SafeBrowsingService |
DISALLOW_COPY_AND_ASSIGN(SafeBrowsingCheck); |
}; |
+ // Observer class can be used to get notified when a SafeBrowsing hit |
+ // was found. |
+ class Observer { |
+ public: |
+ // 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; |
+ |
+ protected: |
+ Observer() {} |
+ virtual ~Observer() {} |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(Observer); |
+ }; |
+ |
class Client { |
public: |
virtual ~Client() {} |
@@ -130,7 +147,6 @@ class SafeBrowsingService |
UrlCheckResult result) {} |
}; |
- |
// Makes the passed |factory| the factory used to instanciate |
// a SafeBrowsingService. Useful for tests. |
static void RegisterFactory(SafeBrowsingServiceFactory* factory) { |
@@ -261,6 +277,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(); |
@@ -489,6 +509,8 @@ class SafeBrowsingService |
// Similar to |download_urlcheck_timeout_ms_|, but for download hash checks. |
int64 download_hashcheck_timeout_ms_; |
+ ObserverList<Observer> observer_list_; |
+ |
// Used to track purge memory notifications. Lives on the IO thread. |
NotificationRegistrar registrar_; |