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

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

Issue 8417012: Refactor loading out of ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: finally 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
(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 registered component extensions.
25 void LoadAll();
26
27 // Loads and registers a component extension. If ExtensionService has been
28 // initialized, the extension is loaded; otherwise, the load is deferred
29 // until LoadAll is called.
30 const Extension* Add(const std::string& manifest,
31 const FilePath& root_directory);
32
33 // Unloads a component extension and removes it from the list of component
34 // extensions to be loaded.
35 void Remove(const std::string& manifest_str);
36
37 // Adds the default component extensions.
38 //
39 // 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
41 // following commands on a unixy system:
42 //
43 // 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
45 void AddDefaultComponentExtensions();
46
47 private:
48 // Information about a registered component extension.
49 struct ComponentExtensionInfo {
50 ComponentExtensionInfo(const std::string& manifest,
51 const FilePath& root_directory)
52 : manifest(manifest),
53 root_directory(root_directory) {
54 }
55
56 bool Equals(const ComponentExtensionInfo& other) const;
57
58 // The extension's manifest. This is required for component extensions so
59 // that ExtensionService doesn't need to go to disk to load them.
60 std::string manifest;
61
62 // Directory where the extension is stored.
63 FilePath root_directory;
64 };
65
66 // Loads a registered component extension.
67 const Extension* Load(const ComponentExtensionInfo& info);
68
69 // Registers an extension to be loaded as a component extension.
70 void Register(const ComponentExtensionInfo& info) {
71 component_extensions_.push_back(info);
72 }
73
74 // List of registered component extensions (see Extension::Location).
75 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions;
76 RegisteredComponentExtensions component_extensions_;
77
78 ExtensionService* extension_service_;
79 };
80
81 } // namespace extensions
82
83 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_crx_util.cc ('k') | chrome/browser/extensions/component_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698