OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ | 5 #ifndef EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ |
6 #define EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ | 6 #define EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // Adds a filter to this feature. The feature takes ownership of the filter. | 33 // Adds a filter to this feature. The feature takes ownership of the filter. |
34 void AddFilter(scoped_ptr<SimpleFeatureFilter> filter); | 34 void AddFilter(scoped_ptr<SimpleFeatureFilter> filter); |
35 | 35 |
36 // Parses the JSON representation of a feature into the fields of this object. | 36 // Parses the JSON representation of a feature into the fields of this object. |
37 // Unspecified values in the JSON are not modified in the object. This allows | 37 // Unspecified values in the JSON are not modified in the object. This allows |
38 // us to implement inheritance by parsing one value after another. Returns | 38 // us to implement inheritance by parsing one value after another. Returns |
39 // the error found, or an empty string on success. | 39 // the error found, or an empty string on success. |
40 virtual std::string Parse(const base::DictionaryValue* value); | 40 virtual std::string Parse(const base::DictionaryValue* value); |
41 | 41 |
42 Location location() const { return location_; } | 42 std::set<Manifest::Location>* locations() { return &locations_; } |
43 void set_location(Location location) { location_ = location; } | |
44 | 43 |
45 std::set<Platform>* platforms() { return &platforms_; } | 44 std::set<Platform>* platforms() { return &platforms_; } |
46 | 45 |
47 int min_manifest_version() const { return min_manifest_version_; } | 46 int min_manifest_version() const { return min_manifest_version_; } |
48 void set_min_manifest_version(int min_manifest_version) { | 47 void set_min_manifest_version(int min_manifest_version) { |
49 min_manifest_version_ = min_manifest_version; | 48 min_manifest_version_ = min_manifest_version; |
50 } | 49 } |
51 | 50 |
52 int max_manifest_version() const { return max_manifest_version_; } | 51 int max_manifest_version() const { return max_manifest_version_; } |
53 void set_max_manifest_version(int max_manifest_version) { | 52 void set_max_manifest_version(int max_manifest_version) { |
(...skipping 11 matching lines...) Expand all Loading... |
65 } | 64 } |
66 Availability IsAvailableToContext(const Extension* extension, | 65 Availability IsAvailableToContext(const Extension* extension, |
67 Context context, | 66 Context context, |
68 const GURL& url) const { | 67 const GURL& url) const { |
69 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); | 68 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); |
70 } | 69 } |
71 | 70 |
72 // extension::Feature: | 71 // extension::Feature: |
73 virtual Availability IsAvailableToManifest(const std::string& extension_id, | 72 virtual Availability IsAvailableToManifest(const std::string& extension_id, |
74 Manifest::Type type, | 73 Manifest::Type type, |
75 Location location, | 74 Manifest::Location location, |
76 int manifest_version, | 75 int manifest_version, |
77 Platform platform) const OVERRIDE; | 76 Platform platform) const OVERRIDE; |
78 | 77 |
79 virtual Availability IsAvailableToContext(const Extension* extension, | 78 virtual Availability IsAvailableToContext(const Extension* extension, |
80 Context context, | 79 Context context, |
81 const GURL& url, | 80 const GURL& url, |
82 Platform platform) const OVERRIDE; | 81 Platform platform) const OVERRIDE; |
83 | 82 |
84 virtual std::string GetAvailabilityMessage(AvailabilityResult result, | 83 virtual std::string GetAvailabilityMessage(AvailabilityResult result, |
85 Manifest::Type type, | 84 Manifest::Type type, |
(...skipping 20 matching lines...) Expand all Loading... |
106 | 105 |
107 private: | 106 private: |
108 // For clarity and consistency, we handle the default value of each of these | 107 // For clarity and consistency, we handle the default value of each of these |
109 // members the same way: it matches everything. It is up to the higher level | 108 // members the same way: it matches everything. It is up to the higher level |
110 // code that reads Features out of static data to validate that data and set | 109 // code that reads Features out of static data to validate that data and set |
111 // sensible defaults. | 110 // sensible defaults. |
112 std::set<std::string> whitelist_; | 111 std::set<std::string> whitelist_; |
113 std::set<Manifest::Type> extension_types_; | 112 std::set<Manifest::Type> extension_types_; |
114 std::set<Context> contexts_; | 113 std::set<Context> contexts_; |
115 URLPatternSet matches_; | 114 URLPatternSet matches_; |
116 Location location_; // we only care about component/not-component now | 115 std::set<Manifest::Location> locations_; |
117 std::set<Platform> platforms_; | 116 std::set<Platform> platforms_; |
118 int min_manifest_version_; | 117 int min_manifest_version_; |
119 int max_manifest_version_; | 118 int max_manifest_version_; |
120 bool has_parent_; | 119 bool has_parent_; |
121 | 120 |
122 typedef std::vector<linked_ptr<SimpleFeatureFilter> > FilterList; | 121 typedef std::vector<linked_ptr<SimpleFeatureFilter> > FilterList; |
123 FilterList filters_; | 122 FilterList filters_; |
124 | 123 |
125 FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context); | 124 FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context); |
126 DISALLOW_COPY_AND_ASSIGN(SimpleFeature); | 125 DISALLOW_COPY_AND_ASSIGN(SimpleFeature); |
127 }; | 126 }; |
128 | 127 |
129 } // namespace extensions | 128 } // namespace extensions |
130 | 129 |
131 #endif // EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ | 130 #endif // EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ |
OLD | NEW |