OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ |
6 #define CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ | 6 #define CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/common/chrome_version_info.h" | 12 #include "chrome/common/chrome_version_info.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
| 14 #include "chrome/common/extensions/manifest.h" |
14 | 15 |
15 namespace extensions { | 16 namespace extensions { |
16 | 17 |
17 // Represents a single feature accessible to an extension developer, such as a | 18 // Represents a single feature accessible to an extension developer, such as a |
18 // top-level manifest key, a permission, or a programmatic API. A feature can | 19 // top-level manifest key, a permission, or a programmatic API. A feature can |
19 // express requirements for where it can be accessed, and supports testing | 20 // express requirements for where it can be accessed, and supports testing |
20 // support for those requirements. | 21 // support for those requirements. |
21 class Feature { | 22 class Feature { |
22 public: | 23 public: |
23 // The JavaScript contexts the feature is supported in. | 24 // The JavaScript contexts the feature is supported in. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 private: | 113 private: |
113 chrome::VersionInfo::Channel original_channel_; | 114 chrome::VersionInfo::Channel original_channel_; |
114 }; | 115 }; |
115 | 116 |
116 const std::string& name() const { return name_; } | 117 const std::string& name() const { return name_; } |
117 void set_name(const std::string& name) { name_ = name; } | 118 void set_name(const std::string& name) { name_ = name; } |
118 | 119 |
119 // Gets the platform the code is currently running on. | 120 // Gets the platform the code is currently running on. |
120 static Platform GetCurrentPlatform(); | 121 static Platform GetCurrentPlatform(); |
121 | 122 |
122 // Gets the Feature::Location value for the specified Extension::Location. | 123 // Gets the Feature::Location value for the specified Manifest::Location. |
123 static Location ConvertLocation(Extension::Location extension_location); | 124 static Location ConvertLocation(Manifest::Location extension_location); |
124 | 125 |
125 // TODO(justinlin): Remove and move to APIFeature when it exists. | 126 // TODO(justinlin): Remove and move to APIFeature when it exists. |
126 virtual std::set<Context>* GetContexts() = 0; | 127 virtual std::set<Context>* GetContexts() = 0; |
127 | 128 |
128 // Returns true if the feature is available to be parsed into a new extension | 129 // Returns true if the feature is available to be parsed into a new extension |
129 // manifest. | 130 // manifest. |
130 Availability IsAvailableToManifest(const std::string& extension_id, | 131 Availability IsAvailableToManifest(const std::string& extension_id, |
131 Extension::Type type, | 132 Manifest::Type type, |
132 Location location, | 133 Location location, |
133 int manifest_version) const { | 134 int manifest_version) const { |
134 return IsAvailableToManifest(extension_id, type, location, manifest_version, | 135 return IsAvailableToManifest(extension_id, type, location, manifest_version, |
135 GetCurrentPlatform()); | 136 GetCurrentPlatform()); |
136 } | 137 } |
137 virtual Availability IsAvailableToManifest(const std::string& extension_id, | 138 virtual Availability IsAvailableToManifest(const std::string& extension_id, |
138 Extension::Type type, | 139 Manifest::Type type, |
139 Location location, | 140 Location location, |
140 int manifest_version, | 141 int manifest_version, |
141 Platform platform) const = 0; | 142 Platform platform) const = 0; |
142 | 143 |
143 // Returns true if the feature is available to be used in the specified | 144 // Returns true if the feature is available to be used in the specified |
144 // extension and context. | 145 // extension and context. |
145 Availability IsAvailableToContext(const Extension* extension, | 146 Availability IsAvailableToContext(const Extension* extension, |
146 Context context) const { | 147 Context context) const { |
147 return IsAvailableToContext(extension, context, GetCurrentPlatform()); | 148 return IsAvailableToContext(extension, context, GetCurrentPlatform()); |
148 } | 149 } |
149 virtual Availability IsAvailableToContext(const Extension* extension, | 150 virtual Availability IsAvailableToContext(const Extension* extension, |
150 Context context, | 151 Context context, |
151 Platform platform) const = 0; | 152 Platform platform) const = 0; |
152 | 153 |
153 virtual std::string GetAvailabilityMessage( | 154 virtual std::string GetAvailabilityMessage( |
154 AvailabilityResult result, Extension::Type type) const = 0; | 155 AvailabilityResult result, Manifest::Type type) const = 0; |
155 | 156 |
156 protected: | 157 protected: |
157 std::string name_; | 158 std::string name_; |
158 }; | 159 }; |
159 | 160 |
160 } // namespace extensions | 161 } // namespace extensions |
161 | 162 |
162 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ | 163 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ |
OLD | NEW |