Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/file_path.h" | |
| 10 | |
| 11 class Extension; | |
| 12 class ExtensionService; | |
| 13 | |
| 14 // For registering, loading, and unloading component extensions. | |
| 15 class ComponentLoader { | |
| 16 public: | |
| 17 explicit ComponentLoader(ExtensionService* extension_service); | |
| 18 virtual ~ComponentLoader(); | |
| 19 | |
| 20 // Information about a registered component extension. | |
| 21 struct ComponentExtensionInfo { | |
| 22 ComponentExtensionInfo(const std::string& manifest, | |
| 23 const FilePath& root_directory) | |
| 24 : manifest(manifest), | |
| 25 root_directory(root_directory) { | |
| 26 } | |
| 27 | |
| 28 bool Equals(const ComponentExtensionInfo& other) const; | |
| 29 | |
| 30 // The extension's manifest. This is required for component extensions so | |
| 31 // that ExtensionService doesn't need to go to disk to load them. | |
| 32 std::string manifest; | |
| 33 | |
| 34 // Directory where the extension is stored. | |
| 35 FilePath root_directory; | |
| 36 }; | |
| 37 | |
| 38 // Loads any component extensions. | |
| 39 void LoadComponentExtensions(); | |
| 40 | |
| 41 // Loads particular component extension. | |
| 42 const Extension* LoadComponentExtension(const ComponentExtensionInfo& info); | |
| 43 | |
| 44 // Unloads particular component extension. | |
| 45 void UnloadComponentExtension(const ComponentExtensionInfo& info); | |
| 46 | |
| 47 // Register the component extensions. | |
| 48 // | |
| 49 // Component extension manifest must contain a 'key' property with a unique | |
| 50 // public key, serialized in base64. You can create a suitable value with the | |
| 51 // following commands on a unixy system: | |
| 52 // | |
| 53 // ssh-keygen -t rsa -b 1024 -N '' -f /tmp/key.pem | |
| 54 // openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0 | |
| 55 void RegisterDefaultComponentExtensions(); | |
| 56 | |
| 57 // Registers an extension to be loaded as a component extension. | |
| 58 void RegisterComponentExtension(const ComponentExtensionInfo& info) { | |
| 59 component_extension_manifests_.push_back(info); | |
| 60 } | |
| 61 | |
| 62 // Unregisters a component extension from the list of extensions to be loaded | |
| 63 void UnregisterComponentExtension(const ComponentExtensionInfo& info); | |
| 64 | |
| 65 // List of registered component extensions (see Extension::Location). | |
| 66 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; | |
| 67 RegisteredComponentExtensions component_extension_manifests_; | |
| 68 | |
| 69 private: | |
| 70 ExtensionService* extension_service_; | |
| 71 }; | |
| 72 | |
| 73 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ | |
| OLD | NEW |