Chromium Code Reviews| Index: chrome/browser/extensions/component_loader.h |
| diff --git a/chrome/browser/extensions/component_loader.h b/chrome/browser/extensions/component_loader.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3d2f5c85532a97d0ba1f1fa48880bcb18dd6d06c |
| --- /dev/null |
| +++ b/chrome/browser/extensions/component_loader.h |
| @@ -0,0 +1,73 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
|
Aaron Boodman
2011/10/28 22:21:58
What about this idea for a simplification:
class
Yoyo Zhou
2011/10/31 21:58:15
Yeah, this is unnecessary. I'll get rid of this ri
Aaron Boodman
2011/10/31 22:33:25
I think it needs to be a property of ES, at least
Yoyo Zhou
2011/11/01 21:50:57
You can't do this if it's a property of ExtensionS
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |
| +#pragma once |
| + |
| +#include "base/file_path.h" |
| + |
| +class Extension; |
| +class ExtensionService; |
| + |
| +// For registering, loading, and unloading component extensions. |
| +class ComponentLoader { |
| + public: |
| + explicit ComponentLoader(ExtensionService* extension_service); |
| + virtual ~ComponentLoader(); |
| + |
| + // Information about a registered component extension. |
| + struct ComponentExtensionInfo { |
| + ComponentExtensionInfo(const std::string& manifest, |
| + const FilePath& root_directory) |
| + : manifest(manifest), |
| + root_directory(root_directory) { |
| + } |
| + |
| + bool Equals(const ComponentExtensionInfo& other) const; |
| + |
| + // The extension's manifest. This is required for component extensions so |
| + // that ExtensionService doesn't need to go to disk to load them. |
| + std::string manifest; |
| + |
| + // Directory where the extension is stored. |
| + FilePath root_directory; |
| + }; |
| + |
| + // Loads any component extensions. |
| + void LoadComponentExtensions(); |
| + |
| + // Loads particular component extension. |
| + const Extension* LoadComponentExtension(const ComponentExtensionInfo& info); |
| + |
| + // Unloads particular component extension. |
| + void UnloadComponentExtension(const ComponentExtensionInfo& info); |
| + |
| + // Register the component extensions. |
| + // |
| + // Component extension manifest must contain a 'key' property with a unique |
| + // public key, serialized in base64. You can create a suitable value with the |
| + // following commands on a unixy system: |
| + // |
| + // ssh-keygen -t rsa -b 1024 -N '' -f /tmp/key.pem |
| + // openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0 |
| + void RegisterDefaultComponentExtensions(); |
| + |
| + // Registers an extension to be loaded as a component extension. |
| + void RegisterComponentExtension(const ComponentExtensionInfo& info) { |
| + component_extension_manifests_.push_back(info); |
| + } |
| + |
| + // Unregisters a component extension from the list of extensions to be loaded |
| + void UnregisterComponentExtension(const ComponentExtensionInfo& info); |
| + |
| + // List of registered component extensions (see Extension::Location). |
| + typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; |
| + RegisteredComponentExtensions component_extension_manifests_; |
| + |
| + private: |
| + ExtensionService* extension_service_; |
| +}; |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ |