| Index: chrome/browser/extensions/user_script_master_manager.h
|
| diff --git a/chrome/browser/extensions/user_script_master_manager.h b/chrome/browser/extensions/user_script_master_manager.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..dfee8842242d7b5e21f2a366a50d6c51cdd21e8e
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/user_script_master_manager.h
|
| @@ -0,0 +1,75 @@
|
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_MANAGER_H_
|
| +#define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_MANAGER_H_
|
| +
|
| +#include "base/containers/scoped_ptr_hash_map.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/scoped_observer.h"
|
| +#include "chrome/browser/extensions/declarative_user_script_master.h"
|
| +#include "chrome/browser/extensions/user_script_master.h"
|
| +#include "extensions/browser/extension_registry.h"
|
| +#include "extensions/browser/extension_registry_observer.h"
|
| +#include "extensions/common/extension.h"
|
| +#include "extensions/common/user_script.h"
|
| +
|
| +namespace content {
|
| +
|
| +class BrowserContext;
|
| +
|
| +} // namespace content
|
| +
|
| +class Profile;
|
| +
|
| +namespace extensions {
|
| +
|
| +class UserScriptMasterManager : public ExtensionRegistryObserver {
|
| + public:
|
| + explicit UserScriptMasterManager(Profile* profile);
|
| + virtual ~UserScriptMasterManager();
|
| +
|
| + UserScriptMaster* shared_master() { return shared_master_.get(); }
|
| +
|
| + DeclarativeUserScriptMaster* GetDeclarativeMasterByExtension(
|
| + const ExtensionId& extension_id) {
|
| + if (!declarative_masters_.get(extension_id)) {
|
| + declarative_masters_.set(extension_id,
|
| + make_scoped_ptr(new DeclarativeUserScriptMaster(
|
| + profile_, extension_id)));
|
| + }
|
| + return declarative_masters_.get(extension_id);
|
| + }
|
| +
|
| + // 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;
|
| +
|
| + private:
|
| + Profile* profile_;
|
| +
|
| + // Shared memory region manager for scripts statically declared in extension
|
| + // manifests. This region is shared between all extensions.
|
| + scoped_ptr<UserScriptMaster> shared_master_;
|
| +
|
| + // Shared memory region manager for programmatically declared scripts, one per
|
| + // extension. Managers are instantiated the first time the declarative API is
|
| + // used by an extension to request content scripts.
|
| + base::ScopedPtrHashMap<ExtensionId, DeclarativeUserScriptMaster>
|
| + declarative_masters_;
|
| +
|
| + // Listen to extension load, unloaded notifications.
|
| + ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
|
| + extension_registry_observer_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(UserScriptMasterManager);
|
| +};
|
| +
|
| +} // namespace extensions
|
| +
|
| +#endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_MANAGER_H_
|
|
|