summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_file_util.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 21:28:19 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 21:28:19 +0000
commitf6f5b8bdad700644866d1097cf20807732aaf62b (patch)
tree43df29dce8655135ae179bd46ced2e92020ab7a3 /chrome/browser/extensions/extension_file_util.cc
parentef8413855c5e505d12843fc31eb69e4b5bead560 (diff)
downloadchromium_src-f6f5b8bdad700644866d1097cf20807732aaf62b.zip
chromium_src-f6f5b8bdad700644866d1097cf20807732aaf62b.tar.gz
chromium_src-f6f5b8bdad700644866d1097cf20807732aaf62b.tar.bz2
Improve error messages when a manifest is not readable or not valid JSON.
Review URL: http://codereview.chromium.org/251003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28601 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_file_util.cc')
-rw-r--r--chrome/browser/extensions/extension_file_util.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extension_file_util.cc b/chrome/browser/extensions/extension_file_util.cc
index 32c4819..1b6f474 100644
--- a/chrome/browser/extensions/extension_file_util.cc
+++ b/chrome/browser/extensions/extension_file_util.cc
@@ -101,14 +101,26 @@ Extension* LoadExtension(const FilePath& extension_path,
FilePath manifest_path =
extension_path.AppendASCII(Extension::kManifestFilename);
if (!file_util::PathExists(manifest_path)) {
- *error = extension_manifest_errors::kInvalidManifest;
+ *error = extension_manifest_errors::kManifestUnreadable;
return NULL;
}
JSONFileValueSerializer serializer(manifest_path);
scoped_ptr<Value> root(serializer.Deserialize(error));
- if (!root.get())
+ if (!root.get()) {
+ if (error->empty()) {
+ // If |error| is empty, than the file could not be read.
+ // 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 = extension_manifest_errors::kManifestUnreadable;
+ } else {
+ *error = StringPrintf("%s %s",
+ extension_manifest_errors::kManifestParseError,
+ error->c_str());
+ }
return NULL;
+ }
if (!root->IsType(Value::TYPE_DICTIONARY)) {
*error = extension_manifest_errors::kInvalidManifest;