diff options
Diffstat (limited to 'extensions/common')
-rw-r--r-- | extensions/common/features/feature_provider.cc | 16 | ||||
-rw-r--r-- | extensions/common/features/feature_provider.h | 5 | ||||
-rw-r--r-- | extensions/common/manifest.cc | 11 |
3 files changed, 27 insertions, 5 deletions
diff --git a/extensions/common/features/feature_provider.cc b/extensions/common/features/feature_provider.cc index 8e15d4b..d5357f1 100644 --- a/extensions/common/features/feature_provider.cc +++ b/extensions/common/features/feature_provider.cc @@ -9,8 +9,24 @@ namespace extensions { +// static FeatureProvider* FeatureProvider::GetByName(const std::string& name) { return ExtensionsClient::Get()->GetFeatureProviderByName(name); } +// static +FeatureProvider* FeatureProvider::GetAPIFeatures() { + return GetByName("api"); +} + +// static +FeatureProvider* FeatureProvider::GetManifestFeatures() { + return GetByName("manifest"); +} + +// static +FeatureProvider* FeatureProvider::GetPermissionFeatures() { + return GetByName("permission"); +} + } // namespace extensions diff --git a/extensions/common/features/feature_provider.h b/extensions/common/features/feature_provider.h index c20e5d1..a295fe0 100644 --- a/extensions/common/features/feature_provider.h +++ b/extensions/common/features/feature_provider.h @@ -29,6 +29,11 @@ class FeatureProvider { // Gets a feature provider for a specific feature type, like "permission". static FeatureProvider* GetByName(const std::string& name); + + // Directly access the common feature types. + static FeatureProvider* GetAPIFeatures(); + static FeatureProvider* GetManifestFeatures(); + static FeatureProvider* GetPermissionFeatures(); }; } // namespace extensions diff --git a/extensions/common/manifest.cc b/extensions/common/manifest.cc index 39e6920..bbd8c32 100644 --- a/extensions/common/manifest.cc +++ b/extensions/common/manifest.cc @@ -145,9 +145,10 @@ bool Manifest::ValidateManifest( // TODO(aa): Consider having an error here in the case of strict error // checking to let developers know when they screw up. - FeatureProvider* provider = FeatureProvider::GetByName("manifest"); + FeatureProvider* manifest_feature_provider = + FeatureProvider::GetManifestFeatures(); const std::vector<std::string>& feature_names = - provider->GetAllFeatureNames(); + manifest_feature_provider->GetAllFeatureNames(); for (std::vector<std::string>::const_iterator feature_name = feature_names.begin(); feature_name != feature_names.end(); ++feature_name) { @@ -155,7 +156,7 @@ bool Manifest::ValidateManifest( if (!value_->Get(*feature_name, NULL)) continue; - Feature* feature = provider->GetFeature(*feature_name); + Feature* feature = manifest_feature_provider->GetFeature(*feature_name); Feature::Availability result = feature->IsAvailableToManifest( extension_id_, type_, Feature::ConvertLocation(location_), GetManifestVersion()); @@ -166,7 +167,7 @@ bool Manifest::ValidateManifest( // Also generate warnings for keys that are not features. for (base::DictionaryValue::Iterator it(*value_); !it.IsAtEnd(); it.Advance()) { - if (!provider->GetFeature(it.key())) { + if (!manifest_feature_provider->GetFeature(it.key())) { warnings->push_back(InstallWarning( ErrorUtils::FormatErrorMessage( manifest_errors::kUnrecognizedManifestKey, it.key()), @@ -253,7 +254,7 @@ bool Manifest::CanAccessPath(const std::string& path) const { } bool Manifest::CanAccessKey(const std::string& key) const { - Feature* feature = FeatureProvider::GetByName("manifest")->GetFeature(key); + Feature* feature = FeatureProvider::GetManifestFeatures()->GetFeature(key); if (!feature) return true; |