| Index: chrome/browser/extensions/user_script_master.h
|
| diff --git a/chrome/browser/extensions/user_script_master.h b/chrome/browser/extensions/user_script_master.h
|
| index 3252a8417fc1a998064890b729fedc9db2b538b2..a41562a08b6e9b91ab2821202c83f27ba22c7acc 100644
|
| --- a/chrome/browser/extensions/user_script_master.h
|
| +++ b/chrome/browser/extensions/user_script_master.h
|
| @@ -11,11 +11,7 @@
|
| #include "base/compiler_specific.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| -#include "base/scoped_observer.h"
|
| #include "content/public/browser/browser_thread.h"
|
| -#include "content/public/browser/notification_observer.h"
|
| -#include "content/public/browser/notification_registrar.h"
|
| -#include "extensions/browser/extension_registry_observer.h"
|
| #include "extensions/common/extension_messages.h"
|
| #include "extensions/common/extension_set.h"
|
| #include "extensions/common/user_script.h"
|
| @@ -40,8 +36,7 @@ typedef std::map<std::string, ExtensionSet::ExtensionPathAndDefaultLocale>
|
|
|
| // Manages a segment of shared memory that contains the user scripts the user
|
| // has installed. Lives on the UI thread.
|
| -class UserScriptMaster : public content::NotificationObserver,
|
| - public ExtensionRegistryObserver {
|
| +class UserScriptMaster {
|
| public:
|
| // Parses the includes out of |script| and returns them in |includes|.
|
| static bool ParseMetadataHeader(const base::StringPiece& script_text,
|
| @@ -56,7 +51,7 @@ class UserScriptMaster : public content::NotificationObserver,
|
|
|
| // Kicks off a process on the file thread to reload scripts from disk
|
| // into a new chunk of shared memory and notify renderers.
|
| - virtual void StartLoad();
|
| + virtual void StartLoad() = 0;
|
|
|
| // Gets the segment of shared memory for the scripts.
|
| base::SharedMemory* GetSharedMemory() const {
|
| @@ -66,24 +61,27 @@ class UserScriptMaster : public content::NotificationObserver,
|
| // Return true if we have any scripts ready.
|
| bool ScriptsReady() const { return shared_memory_.get() != NULL; }
|
|
|
| - private:
|
| - // content::NotificationObserver implementation.
|
| - virtual void Observe(int type,
|
| - const content::NotificationSource& source,
|
| - const content::NotificationDetails& details) OVERRIDE;
|
| -
|
| - // ExtensionRegistryObserver implementation.
|
| - virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
|
| - const Extension* extension) OVERRIDE;
|
| - virtual void OnExtensionUnloaded(
|
| - content::BrowserContext* browser_context,
|
| - const Extension* extension,
|
| - UnloadedExtensionInfo::Reason reason) OVERRIDE;
|
| -
|
| // Called once we have finished loading the scripts on the file thread.
|
| void OnScriptsLoaded(scoped_ptr<UserScriptList> user_scripts,
|
| scoped_ptr<base::SharedMemory> shared_memory);
|
|
|
| + protected:
|
| + typedef base::Callback<
|
| + void(scoped_ptr<UserScriptList>, scoped_ptr<base::SharedMemory>)>
|
| + LoadScriptsCallback;
|
| +
|
| + static void LoadScriptsOnFileThread(
|
| + scoped_ptr<UserScriptList> user_scripts,
|
| + const ExtensionsInfo& extensions_info,
|
| + const std::set<std::string>& new_extensions,
|
| + scoped_refptr<ContentVerifier> verifier,
|
| + LoadScriptsCallback callback);
|
| +
|
| + bool is_loading() const {
|
| + // Ownership of |user_scripts_| is passed to the file thread when loading.
|
| + return user_scripts_.get() == NULL;
|
| + }
|
| +
|
| // Sends the renderer process a new set of user scripts. If
|
| // |changed_extensions| is not empty, this signals that only the scripts from
|
| // those extensions should be updated. Otherwise, all extensions will be
|
| @@ -92,17 +90,6 @@ class UserScriptMaster : public content::NotificationObserver,
|
| base::SharedMemory* shared_memory,
|
| const std::set<std::string>& changed_extensions);
|
|
|
| - bool is_loading() const {
|
| - // Ownership of |user_scripts_| is passed to the file thread when loading.
|
| - return user_scripts_.get() == NULL;
|
| - }
|
| -
|
| - // Manages our notification registrations.
|
| - content::NotificationRegistrar registrar_;
|
| -
|
| - // Contains the scripts that were found the last time scripts were updated.
|
| - scoped_ptr<base::SharedMemory> shared_memory_;
|
| -
|
| // List of scripts from currently-installed extensions we should load.
|
| scoped_ptr<UserScriptList> user_scripts_;
|
|
|
| @@ -127,18 +114,23 @@ class UserScriptMaster : public content::NotificationObserver,
|
| // finishes. This boolean tracks whether another load is pending.
|
| bool pending_load_;
|
|
|
| - // Whether or not we are currently loading.
|
| - bool is_loading_;
|
| -
|
| // The profile for which the scripts managed here are installed.
|
| Profile* profile_;
|
|
|
| - // Listen to extension load, unloaded notifications.
|
| - ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
|
| - extension_registry_observer_;
|
| -
|
| base::WeakPtrFactory<UserScriptMaster> weak_factory_;
|
|
|
| + // ID of extension that owns this region, if any. This is the empty string in
|
| + // the case of the memory region for statically declared content scripts,
|
| + // which is shared between extensions.
|
| + ExtensionId owner_extension_id_;
|
| +
|
| + private:
|
| + // Contains the scripts that were found the last time scripts were updated.
|
| + scoped_ptr<base::SharedMemory> shared_memory_;
|
| +
|
| + // Whether or not we are currently loading.
|
| + bool is_loading_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(UserScriptMaster);
|
| };
|
|
|
|
|