Index: extensions/common/features/simple_feature.h |
diff --git a/extensions/common/features/simple_feature.h b/extensions/common/features/simple_feature.h |
index e3884e014c73da53a6c994a45be303c964c50ddd..32892ed44ac8158e4f25f705672ec35f533378c8 100644 |
--- a/extensions/common/features/simple_feature.h |
+++ b/extensions/common/features/simple_feature.h |
@@ -10,6 +10,7 @@ |
#include <vector> |
#include "base/gtest_prod_util.h" |
+#include "base/lazy_instance.h" |
#include "base/memory/linked_ptr.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/values.h" |
@@ -39,21 +40,8 @@ class SimpleFeature : public Feature { |
// the error found, or an empty string on success. |
virtual std::string Parse(const base::DictionaryValue* value); |
- Location location() const { return location_; } |
- void set_location(Location location) { location_ = location; } |
- |
std::set<Platform>* platforms() { return &platforms_; } |
- int min_manifest_version() const { return min_manifest_version_; } |
- void set_min_manifest_version(int min_manifest_version) { |
- min_manifest_version_ = min_manifest_version; |
- } |
- |
- int max_manifest_version() const { return max_manifest_version_; } |
- void set_max_manifest_version(int max_manifest_version) { |
- max_manifest_version_ = max_manifest_version; |
- } |
- |
Availability IsAvailableToContext(const Extension* extension, |
Context context) const { |
return IsAvailableToContext(extension, context, GURL()); |
@@ -72,7 +60,7 @@ class SimpleFeature : public Feature { |
// extension::Feature: |
virtual Availability IsAvailableToManifest(const std::string& extension_id, |
Manifest::Type type, |
- Location location, |
+ Manifest::Location location, |
int manifest_version, |
Platform platform) const OVERRIDE; |
@@ -105,6 +93,29 @@ class SimpleFeature : public Feature { |
Context context) const; |
private: |
+ // Similar to Manifest::Location, these are the classes of locations |
+ // supported in feature files; "component" implies |
+ // COMPONENT/EXTERNAL_COMPONENT manifest location types, etc. |
+ enum Location { |
+ UNSPECIFIED_LOCATION, |
+ COMPONENT_LOCATION, |
+ POLICY_LOCATION, |
+ }; |
+ |
+ bool MatchesManifestLocation(Manifest::Location manifest_location) const; |
+ |
+ // Accessors defined for testing. |
+ Location location() const { return location_; } |
+ void set_location(Location location) { location_ = location; } |
+ int min_manifest_version() const { return min_manifest_version_; } |
+ void set_min_manifest_version(int min_manifest_version) { |
+ min_manifest_version_ = min_manifest_version; |
+ } |
+ int max_manifest_version() const { return max_manifest_version_; } |
+ void set_max_manifest_version(int max_manifest_version) { |
+ max_manifest_version_ = max_manifest_version; |
+ } |
+ |
// For clarity and consistency, we handle the default value of each of these |
// members the same way: it matches everything. It is up to the higher level |
// code that reads Features out of static data to validate that data and set |
@@ -113,7 +124,7 @@ class SimpleFeature : public Feature { |
std::set<Manifest::Type> extension_types_; |
std::set<Context> contexts_; |
URLPatternSet matches_; |
- Location location_; // we only care about component/not-component now |
+ Location location_; |
std::set<Platform> platforms_; |
int min_manifest_version_; |
int max_manifest_version_; |
@@ -122,7 +133,19 @@ class SimpleFeature : public Feature { |
typedef std::vector<linked_ptr<SimpleFeatureFilter> > FilterList; |
FilterList filters_; |
+ struct Mappings; |
+ static base::LazyInstance<Mappings> g_mappings; |
+ |
+ FRIEND_TEST_ALL_PREFIXES(ExtensionAPITest, DefaultConfigurationFeatures); |
FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context); |
+ FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Inheritance); |
+ FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Location); |
+ FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, ManifestVersion); |
+ FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, ParseLocation); |
+ FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, ParseNull); |
+ FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Version); |
+ FRIEND_TEST_ALL_PREFIXES(ManifestTest, Extension); |
+ |
DISALLOW_COPY_AND_ASSIGN(SimpleFeature); |
}; |