Chromium Code Reviews| Index: chrome/browser/extensions/shared_user_script_master.h |
| diff --git a/chrome/browser/extensions/shared_user_script_master.h b/chrome/browser/extensions/shared_user_script_master.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ab4a0f3d3fa33d517abda2d60150049fb3dd37f9 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/shared_user_script_master.h |
| @@ -0,0 +1,70 @@ |
| +// Copyright 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_SHARED_USER_SCRIPT_MASTER_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ |
| + |
| +#include <set> |
| + |
| +#include "base/scoped_observer.h" |
| +#include "chrome/browser/extensions/user_script_loader.h" |
| +#include "content/public/browser/notification_observer.h" |
|
Devlin
2014/08/04 18:33:24
don't need either of the notification_*.h
Mark Dittmer
2014/08/05 20:33:18
Done.
|
| +#include "content/public/browser/notification_registrar.h" |
| +#include "extensions/browser/extension_registry.h" |
|
Devlin
2014/08/04 18:33:24
forward-declare ExtensionRegistry.
Mark Dittmer
2014/08/05 20:33:18
Done.
|
| +#include "extensions/browser/extension_registry_observer.h" |
| +#include "extensions/common/extension.h" |
| +#include "extensions/common/user_script.h" |
| + |
| +namespace content { |
|
Devlin
2014/08/04 18:33:24
nit:
namespace content {
class BrowserContext;
}
Mark Dittmer
2014/08/05 20:33:18
Done.
|
| + |
| +class BrowserContext; |
| + |
| +} // namespace content |
| + |
| +class Profile; |
| + |
| +namespace extensions { |
| + |
| +class SharedUserScriptMaster : public ExtensionRegistryObserver { |
|
Devlin
2014/08/04 18:33:25
class comments
Mark Dittmer
2014/08/05 20:33:18
Done.
|
| + public: |
| + explicit SharedUserScriptMaster(Profile* profile); |
| + virtual ~SharedUserScriptMaster(); |
| + |
| + // ExtensionRegistryObserver implementation. |
| + virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
|
Devlin
2014/08/04 18:33:24
privatize.
Mark Dittmer
2014/08/05 20:33:18
Done.
|
| + const Extension* extension) OVERRIDE; |
| + virtual void OnExtensionUnloaded( |
| + content::BrowserContext* browser_context, |
| + const Extension* extension, |
| + UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| + |
| + // Provides access to loader state method: ScriptsReady(). |
| + bool ScriptsReady() const { return loader_.ScriptsReady(); } |
| + |
| + private: |
| + // Gets an extension's scripts' metadata; i.e., gets a list of UserScript |
| + // objects that contains script info, but not the contents of the scripts. |
| + const std::set<UserScript>& GetScriptsMetadata(const Extension* extension); |
| + |
| + // Map of extension ID -> list of script metadata for currently-loaded |
| + // extensions. |
| + std::map<ExtensionId, std::set<UserScript> > scripts_metadata_; |
| + |
| + // Script loader that handles loading contents of scripts into shared memory |
| + // and notifying renderers of scripts in shared memory. |
| + UserScriptLoader loader_; |
| + |
| + // The profile for which the scripts managed here are installed. |
| + Profile* profile_; |
| + |
| + // Listen to extension load, unloaded notifications. |
| + ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| + extension_registry_observer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SharedUserScriptMaster); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ |