summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_file_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common/extensions/extension_file_util.cc')
-rw-r--r--chrome/common/extensions/extension_file_util.cc29
1 files changed, 12 insertions, 17 deletions
diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc
index d530357..c7be522 100644
--- a/chrome/common/extensions/extension_file_util.cc
+++ b/chrome/common/extensions/extension_file_util.cc
@@ -81,15 +81,14 @@ void UninstallExtension(const FilePath& extensions_dir,
file_util::Delete(extensions_dir.AppendASCII(id), true); // recursive.
}
-Extension* LoadExtension(const FilePath& extension_path,
- Extension::Location location,
- bool require_key,
- std::string* error) {
+scoped_refptr<Extension> LoadExtension(const FilePath& extension_path,
+ Extension::Location location,
+ bool require_key,
+ std::string* error) {
FilePath manifest_path =
extension_path.Append(Extension::kManifestFilename);
if (!file_util::PathExists(manifest_path)) {
- *error =
- l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE);
+ *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE);
return NULL;
}
@@ -101,8 +100,7 @@ Extension* LoadExtension(const FilePath& extension_path,
// It would be cleaner to have the JSON reader give a specific error
// in this case, but other code tests for a file error with
// error->empty(). For now, be consistent.
- *error =
- l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE);
+ *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE);
} else {
*error = StringPrintf("%s %s",
errors::kManifestParseError,
@@ -112,26 +110,23 @@ Extension* LoadExtension(const FilePath& extension_path,
}
if (!root->IsType(Value::TYPE_DICTIONARY)) {
- *error =
- l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID);
+ *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID);
return NULL;
}
DictionaryValue* manifest = static_cast<DictionaryValue*>(root.get());
-
- scoped_ptr<Extension> extension(new Extension(extension_path));
- extension->set_location(location);
-
- if (!extension_l10n_util::LocalizeExtension(extension.get(), manifest, error))
+ if (!extension_l10n_util::LocalizeExtension(extension_path, manifest, error))
return NULL;
- if (!extension->InitFromValue(*manifest, require_key, error))
+ scoped_refptr<Extension> extension(Extension::Create(
+ extension_path, location, *manifest, require_key, error));
+ if (!extension.get())
return NULL;
if (!ValidateExtension(extension.get(), error))
return NULL;
- return extension.release();
+ return extension;
}
bool ValidateExtension(Extension* extension, std::string* error) {