Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: chrome/browser/extensions/component_loader.h

Issue 8477005: Add policies to specify an enterprise web store. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_
6 #define CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/values.h"
12 13
13 class Extension; 14 class Extension;
14 class ExtensionService; 15 class ExtensionService;
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 // For registering, loading, and unloading component extensions. 19 // For registering, loading, and unloading component extensions.
19 class ComponentLoader { 20 class ComponentLoader {
20 public: 21 public:
21 explicit ComponentLoader(ExtensionService* extension_service); 22 explicit ComponentLoader(ExtensionService* extension_service);
22 virtual ~ComponentLoader(); 23 virtual ~ComponentLoader();
23 24
24 // Loads any registered component extensions. 25 // Loads any registered component extensions.
25 void LoadAll(); 26 void LoadAll();
26 27
27 // Loads and registers a component extension. If ExtensionService has been 28 // Loads and registers a component extension. If ExtensionService has been
28 // initialized, the extension is loaded; otherwise, the load is deferred 29 // initialized, the extension is loaded; otherwise, the load is deferred
29 // until LoadAll is called. 30 // until LoadAll is called.
30 const Extension* Add(const std::string& manifest, 31 const Extension* Add(const std::string& manifest,
31 const FilePath& root_directory); 32 const FilePath& root_directory,
33 DictionaryValue* manifest_overrides);
34
35 const Extension* Add(const std::string& manifest,
36 const FilePath& root_directory) {
37 return Add(manifest, root_directory, NULL);
38 }
32 39
33 // Unloads a component extension and removes it from the list of component 40 // Unloads a component extension and removes it from the list of component
34 // extensions to be loaded. 41 // extensions to be loaded.
35 void Remove(const std::string& manifest_str); 42 void Remove(const std::string& manifest_str);
36 43
37 // Adds the default component extensions. 44 // Adds the default component extensions.
38 // 45 //
39 // Component extension manifests must contain a 'key' property with a unique 46 // Component extension manifests must contain a 'key' property with a unique
40 // public key, serialized in base64. You can create a suitable value with the 47 // public key, serialized in base64. You can create a suitable value with the
41 // following commands on a unixy system: 48 // following commands on a unixy system:
42 // 49 //
43 // ssh-keygen -t rsa -b 1024 -N '' -f /tmp/key.pem 50 // ssh-keygen -t rsa -b 1024 -N '' -f /tmp/key.pem
44 // openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0 51 // openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0
45 void AddDefaultComponentExtensions(); 52 void AddDefaultComponentExtensions();
46 53
47 private: 54 private:
48 // Information about a registered component extension. 55 // Information about a registered component extension.
49 struct ComponentExtensionInfo { 56 struct ComponentExtensionInfo {
50 ComponentExtensionInfo(const std::string& manifest, 57 ComponentExtensionInfo(const std::string& manifest,
51 const FilePath& root_directory) 58 const FilePath& root_directory,
59 DictionaryValue* manifest_overrides)
52 : manifest(manifest), 60 : manifest(manifest),
53 root_directory(root_directory) { 61 root_directory(root_directory),
62 manifest_overrides(manifest_overrides) {
54 } 63 }
55 64
56 bool Equals(const ComponentExtensionInfo& other) const; 65 bool Equals(const ComponentExtensionInfo& other) const;
57 66
58 // The extension's manifest. This is required for component extensions so 67 // The extension's manifest. This is required for component extensions so
59 // that ExtensionService doesn't need to go to disk to load them. 68 // that ExtensionService doesn't need to go to disk to load them.
60 std::string manifest; 69 std::string manifest;
61 70
62 // Directory where the extension is stored. 71 // Directory where the extension is stored.
63 FilePath root_directory; 72 FilePath root_directory;
73
74 // If non-NULL, contains values that should be used to override the values
75 // specified in the manifest.
76 DictionaryValue* manifest_overrides;
64 }; 77 };
65 78
66 // Loads a registered component extension. 79 // Loads a registered component extension.
67 const Extension* Load(const ComponentExtensionInfo& info); 80 const Extension* Load(const ComponentExtensionInfo& info);
68 81
69 // Registers an extension to be loaded as a component extension. 82 // Registers an extension to be loaded as a component extension.
70 void Register(const ComponentExtensionInfo& info) { 83 void Register(const ComponentExtensionInfo& info) {
71 component_extensions_.push_back(info); 84 component_extensions_.push_back(info);
72 } 85 }
73 86
74 // List of registered component extensions (see Extension::Location). 87 // List of registered component extensions (see Extension::Location).
75 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; 88 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions;
76 RegisteredComponentExtensions component_extensions_; 89 RegisteredComponentExtensions component_extensions_;
77 90
78 ExtensionService* extension_service_; 91 ExtensionService* extension_service_;
79 }; 92 };
80 93
81 } // namespace extensions 94 } // namespace extensions
82 95
83 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ 96 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698