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