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

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

Issue 9360005: Handle termination/crashes of an extension hosted in the ExtensionDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 months 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
« no previous file with comments | « no previous file | chrome/browser/extensions/component_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const FilePath& root_directory); 42 const FilePath& root_directory);
43 43
44 // Convenience method for registering a component extension by resource id. 44 // Convenience method for registering a component extension by resource id.
45 const Extension* Add(int manifest_resource_id, 45 const Extension* Add(int manifest_resource_id,
46 const FilePath& root_directory); 46 const FilePath& root_directory);
47 47
48 // Loads a component extension from file system. Replaces previously added 48 // Loads a component extension from file system. Replaces previously added
49 // extension with the same ID. 49 // extension with the same ID.
50 const Extension* AddOrReplace(const FilePath& path); 50 const Extension* AddOrReplace(const FilePath& path);
51 51
52 // Returns true if an extension with the specified id has been added.
53 bool Exists(const std::string& id) const;
54
52 // Unloads a component extension and removes it from the list of component 55 // Unloads a component extension and removes it from the list of component
53 // extensions to be loaded. 56 // extensions to be loaded.
54 void Remove(const FilePath& root_directory); 57 void Remove(const FilePath& root_directory);
55 void Remove(const std::string& id); 58 void Remove(const std::string& id);
56 59
57 // Adds the default component extensions. 60 // Adds the default component extensions.
58 // 61 //
59 // Component extension manifests must contain a 'key' property with a unique 62 // Component extension manifests must contain a 'key' property with a unique
60 // public key, serialized in base64. You can create a suitable value with the 63 // public key, serialized in base64. You can create a suitable value with the
61 // following commands on a unixy system: 64 // following commands on a unixy system:
62 // 65 //
63 // ssh-keygen -t rsa -b 1024 -N '' -f /tmp/key.pem 66 // ssh-keygen -t rsa -b 1024 -N '' -f /tmp/key.pem
64 // openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0 67 // openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0
65 void AddDefaultComponentExtensions(); 68 void AddDefaultComponentExtensions();
66 69
67 // content::NotificationObserver implementation 70 // content::NotificationObserver implementation
68 virtual void Observe(int type, 71 virtual void Observe(int type,
69 const content::NotificationSource& source, 72 const content::NotificationSource& source,
70 const content::NotificationDetails& details) OVERRIDE; 73 const content::NotificationDetails& details) OVERRIDE;
71 74
72 static void RegisterUserPrefs(PrefService* prefs); 75 static void RegisterUserPrefs(PrefService* prefs);
73 76
74 // Parse the given JSON manifest. Returns NULL if it cannot be parsed, or if 77 // Parse the given JSON manifest. Returns NULL if it cannot be parsed, or if
75 // if the result is not a DictionaryValue. 78 // if the result is not a DictionaryValue.
76 DictionaryValue* ParseManifest(const std::string& manifest_contents) const; 79 DictionaryValue* ParseManifest(const std::string& manifest_contents) const;
77 80
78 // Clear the list of registered extensions. 81 // Clear the list of registered extensions.
79 void ClearAllRegistered(); 82 void ClearAllRegistered();
80 83
84 // Reloads a registered component extension.
85 void Reload(const std::string& extension_id);
86
81 private: 87 private:
82 // Information about a registered component extension. 88 // Information about a registered component extension.
83 struct ComponentExtensionInfo { 89 struct ComponentExtensionInfo {
84 ComponentExtensionInfo(const DictionaryValue* manifest, 90 ComponentExtensionInfo(const DictionaryValue* manifest,
85 const FilePath& root_directory) 91 const FilePath& root_directory)
86 : manifest(manifest), 92 : manifest(manifest),
87 root_directory(root_directory) { 93 root_directory(root_directory) {
88 } 94 }
89 95
90 // The parsed contents of the extensions's manifest file. 96 // The parsed contents of the extensions's manifest file.
91 const DictionaryValue* manifest; 97 const DictionaryValue* manifest;
92 98
93 // Directory where the extension is stored. 99 // Directory where the extension is stored.
94 FilePath root_directory; 100 FilePath root_directory;
95 }; 101 };
96 102
97 const Extension* Add(const DictionaryValue* parsed_manifest, 103 const Extension* Add(const DictionaryValue* parsed_manifest,
98 const FilePath& root_directory); 104 const FilePath& root_directory);
99 105
100 // Loads a registered component extension. 106 // Loads a registered component extension.
101 const Extension* Load(const ComponentExtensionInfo& info); 107 const Extension* Load(const ComponentExtensionInfo& info);
102 108
103 void AddFileManagerExtension(); 109 void AddFileManagerExtension();
104 110
105 // Add the enterprise webstore extension, or reload it if already loaded. 111 // Add the enterprise webstore extension, or reload it if already loaded.
106 void AddOrReloadEnterpriseWebStore(); 112 void AddOrReloadEnterpriseWebStore();
107 113
108 // Returns true if an extension with the specified id has been added.
109 bool Exists(const std::string& id) const;
110
111 // Determine the extension id. 114 // Determine the extension id.
112 static std::string GenerateId(const base::DictionaryValue* manifest); 115 static std::string GenerateId(const base::DictionaryValue* manifest);
113 116
114 PrefService* prefs_; 117 PrefService* prefs_;
115 PrefService* local_state_; 118 PrefService* local_state_;
116 119
117 ExtensionServiceInterface* extension_service_; 120 ExtensionServiceInterface* extension_service_;
118 121
119 // List of registered component extensions (see Extension::Location). 122 // List of registered component extensions (see Extension::Location).
120 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions; 123 typedef std::vector<ComponentExtensionInfo> RegisteredComponentExtensions;
121 RegisteredComponentExtensions component_extensions_; 124 RegisteredComponentExtensions component_extensions_;
122 125
123 PrefChangeRegistrar pref_change_registrar_; 126 PrefChangeRegistrar pref_change_registrar_;
124 }; 127 };
125 128
126 } // namespace extensions 129 } // namespace extensions
127 130
128 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_ 131 #endif // CHROME_BROWSER_EXTENSIONS_COMPONENT_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/component_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698