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 |