diff options
Diffstat (limited to 'extensions/browser/user_script_loader.h')
-rw-r--r-- | extensions/browser/user_script_loader.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/extensions/browser/user_script_loader.h b/extensions/browser/user_script_loader.h index 1eeea31..c1f10ac 100644 --- a/extensions/browser/user_script_loader.h +++ b/extensions/browser/user_script_loader.h @@ -12,6 +12,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/shared_memory.h" #include "base/memory/weak_ptr.h" +#include "base/observer_list.h" #include "base/scoped_observer.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" @@ -41,6 +42,11 @@ class UserScriptLoader : public content::NotificationObserver { using LoadScriptsCallback = base::Callback<void(scoped_ptr<UserScriptList>, scoped_ptr<base::SharedMemory>)>; + class Observer { + public: + virtual void OnScriptsLoaded(UserScriptLoader* loader) = 0; + virtual void OnUserScriptLoaderDestroyed(UserScriptLoader* loader) = 0; + }; // Parses the includes out of |script| and returns them in |includes|. static bool ParseMetadataHeader(const base::StringPiece& script_text, @@ -79,6 +85,10 @@ class UserScriptLoader : public content::NotificationObserver { static scoped_ptr<base::SharedMemory> Serialize( const extensions::UserScriptList& scripts); + // Adds or removes observers. + void AddObserver(Observer* observer); + void RemoveObserver(Observer* observer); + protected: // Allows the derived classes have different ways to load user scripts. virtual void LoadScripts(scoped_ptr<UserScriptList> user_scripts, @@ -164,6 +174,9 @@ class UserScriptLoader : public content::NotificationObserver { // non-empty value for declarative user script shared memory regions. HostID host_id_; + // The associated observers. + ObserverList<Observer> observers_; + base::WeakPtrFactory<UserScriptLoader> weak_factory_; DISALLOW_COPY_AND_ASSIGN(UserScriptLoader); |