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

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

Issue 9664053: Re-land 125247: Better error messages when using unsupported manifest features. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/manifest.h ('k') | chrome/common/extensions/manifest_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/manifest.cc
diff --git a/chrome/common/extensions/manifest.cc b/chrome/common/extensions/manifest.cc
index d462bb85bd9d48860fc3953f2e100a9ddc9390cc..0cf2ef275985c66ad0ef040cd2ceed232fd5dcc5 100644
--- a/chrome/common/extensions/manifest.cc
+++ b/chrome/common/extensions/manifest.cc
@@ -28,18 +28,24 @@ Manifest::~Manifest() {
bool Manifest::ValidateManifest(string16* error) const {
for (DictionaryValue::key_iterator key = value_->begin_keys();
key != value_->end_keys(); ++key) {
- bool was_known = false;
- if (!CanAccessKey(*key, &was_known)) {
+ scoped_ptr<Feature> feature =
+ ManifestFeatureProvider::GetDefaultInstance()->GetFeature(*key);
+ if (!feature.get()) {
// When validating the extension manifests, we ignore keys that are not
// recognized for forward compatibility.
- if (!was_known) {
- // TODO(aa): Consider having an error here in the case of strict error
- // checking to let developers know when they screw up.
- continue;
- }
+ // TODO(aa): Consider having an error here in the case of strict error
+ // checking to let developers know when they screw up.
+ continue;
+ }
+ Feature::Availability result = feature->IsAvailable(
+ extension_id_, GetType(), Feature::ConvertLocation(location_),
+ GetManifestVersion());
+ if (result != Feature::IS_AVAILABLE) {
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
- errors::kFeatureNotAllowed, *key);
+ errors::kFeatureNotAllowed,
+ *key,
+ feature->GetErrorMessage(result));
return false;
}
}
@@ -48,7 +54,7 @@ bool Manifest::ValidateManifest(string16* error) const {
}
bool Manifest::HasKey(const std::string& key) const {
- return CanAccessKey(key, NULL) && value_->HasKey(key);
+ return CanAccessKey(key) && value_->HasKey(key);
}
bool Manifest::Get(
@@ -140,22 +146,18 @@ bool Manifest::IsHostedApp() const {
bool Manifest::CanAccessPath(const std::string& path) const {
std::vector<std::string> components;
base::SplitString(path, '.', &components);
- return CanAccessKey(components[0], NULL);
+ return CanAccessKey(components[0]);
}
-bool Manifest::CanAccessKey(const std::string& key, bool *was_known) const {
+bool Manifest::CanAccessKey(const std::string& key) const {
scoped_ptr<Feature> feature =
ManifestFeatureProvider::GetDefaultInstance()->GetFeature(key);
if (!feature.get())
return false;
- if (was_known)
- *was_known = true;
-
- return feature->IsAvailable(extension_id_,
- GetType(),
- Feature::ConvertLocation(location_),
- GetManifestVersion());
+ return Feature::IS_AVAILABLE == feature->IsAvailable(
+ extension_id_, GetType(), Feature::ConvertLocation(location_),
+ GetManifestVersion());
}
} // namespace extensions
« no previous file with comments | « chrome/common/extensions/manifest.h ('k') | chrome/common/extensions/manifest_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698