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

Unified Diff: chrome/common/extensions/extension_file_util.cc

Issue 8659002: Adding the --load-component-extension flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding comment to ScopedAllowIO.wq Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/extension_file_util.cc
diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc
index b54bd62da2aaaf617859248eb67ccbb64f664775..b0a1935bb9f749de15896982b0e65ae3f39efb05 100644
--- a/chrome/common/extensions/extension_file_util.cc
+++ b/chrome/common/extensions/extension_file_util.cc
@@ -93,6 +93,30 @@ scoped_refptr<Extension> LoadExtension(const FilePath& extension_path,
Extension::Location location,
int flags,
std::string* error) {
+ scoped_ptr<DictionaryValue> manifest(LoadManifest(extension_path, error));
+ if (!manifest.get())
+ return NULL;
+ if (!extension_l10n_util::LocalizeExtension(extension_path, manifest.get(),
+ error))
+ return NULL;
+
+ scoped_refptr<Extension> extension(Extension::Create(
+ extension_path,
+ location,
+ *manifest,
+ flags,
+ error));
+ if (!extension.get())
+ return NULL;
+
+ if (!ValidateExtension(extension.get(), error))
+ return NULL;
+
+ return extension;
+}
+
+DictionaryValue* LoadManifest(const FilePath& extension_path,
+ std::string* error) {
FilePath manifest_path =
extension_path.Append(Extension::kManifestFilename);
if (!file_util::PathExists(manifest_path)) {
@@ -122,23 +146,7 @@ scoped_refptr<Extension> LoadExtension(const FilePath& extension_path,
return NULL;
}
- DictionaryValue* manifest = static_cast<DictionaryValue*>(root.get());
- if (!extension_l10n_util::LocalizeExtension(extension_path, manifest, error))
- return NULL;
-
- scoped_refptr<Extension> extension(Extension::Create(
- extension_path,
- location,
- *manifest,
- flags,
- error));
- if (!extension.get())
- return NULL;
-
- if (!ValidateExtension(extension.get(), error))
- return NULL;
-
- return extension;
+ return static_cast<DictionaryValue*>(root.release());
}
bool ValidateExtension(const Extension* extension, std::string* error) {
« no previous file with comments | « chrome/common/extensions/extension_file_util.h ('k') | chrome/test/data/extensions/override_component_extension/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698