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 #include "chrome/common/extensions/manifest.h" |
15 | 15 |
| 16 class GURL; |
| 17 |
16 namespace extensions { | 18 namespace extensions { |
17 | 19 |
18 // Represents a single feature accessible to an extension developer, such as a | 20 // Represents a single feature accessible to an extension developer, such as a |
19 // top-level manifest key, a permission, or a programmatic API. A feature can | 21 // top-level manifest key, a permission, or a programmatic API. A feature can |
20 // express requirements for where it can be accessed, and supports testing | 22 // express requirements for where it can be accessed, and supports testing |
21 // support for those requirements. | 23 // support for those requirements. |
22 class Feature { | 24 class Feature { |
23 public: | 25 public: |
24 // The JavaScript contexts the feature is supported in. | 26 // The JavaScript contexts the feature is supported in. |
25 enum Context { | 27 enum Context { |
(...skipping 22 matching lines...) Expand all Loading... |
48 enum Platform { | 50 enum Platform { |
49 UNSPECIFIED_PLATFORM, | 51 UNSPECIFIED_PLATFORM, |
50 CHROMEOS_PLATFORM | 52 CHROMEOS_PLATFORM |
51 }; | 53 }; |
52 | 54 |
53 // Whether a feature is available in a given situation or not, and if not, | 55 // Whether a feature is available in a given situation or not, and if not, |
54 // why not. | 56 // why not. |
55 enum AvailabilityResult { | 57 enum AvailabilityResult { |
56 IS_AVAILABLE, | 58 IS_AVAILABLE, |
57 NOT_FOUND_IN_WHITELIST, | 59 NOT_FOUND_IN_WHITELIST, |
| 60 INVALID_URL, |
58 INVALID_TYPE, | 61 INVALID_TYPE, |
59 INVALID_CONTEXT, | 62 INVALID_CONTEXT, |
60 INVALID_LOCATION, | 63 INVALID_LOCATION, |
61 INVALID_PLATFORM, | 64 INVALID_PLATFORM, |
62 INVALID_MIN_MANIFEST_VERSION, | 65 INVALID_MIN_MANIFEST_VERSION, |
63 INVALID_MAX_MANIFEST_VERSION, | 66 INVALID_MAX_MANIFEST_VERSION, |
64 NOT_PRESENT, | 67 NOT_PRESENT, |
65 UNSUPPORTED_CHANNEL, | 68 UNSUPPORTED_CHANNEL, |
66 }; | 69 }; |
67 | 70 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 145 } |
143 virtual Availability IsAvailableToManifest(const std::string& extension_id, | 146 virtual Availability IsAvailableToManifest(const std::string& extension_id, |
144 Manifest::Type type, | 147 Manifest::Type type, |
145 Location location, | 148 Location location, |
146 int manifest_version, | 149 int manifest_version, |
147 Platform platform) const = 0; | 150 Platform platform) const = 0; |
148 | 151 |
149 // Returns true if the feature is available to be used in the specified | 152 // Returns true if the feature is available to be used in the specified |
150 // extension and context. | 153 // extension and context. |
151 Availability IsAvailableToContext(const Extension* extension, | 154 Availability IsAvailableToContext(const Extension* extension, |
152 Context context) const { | 155 Context context, |
153 return IsAvailableToContext(extension, context, GetCurrentPlatform()); | 156 const GURL& url) const { |
| 157 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); |
154 } | 158 } |
155 virtual Availability IsAvailableToContext(const Extension* extension, | 159 virtual Availability IsAvailableToContext(const Extension* extension, |
156 Context context, | 160 Context context, |
| 161 const GURL& url, |
157 Platform platform) const = 0; | 162 Platform platform) const = 0; |
158 | 163 |
159 virtual std::string GetAvailabilityMessage( | 164 virtual std::string GetAvailabilityMessage(AvailabilityResult result, |
160 AvailabilityResult result, Manifest::Type type) const = 0; | 165 Manifest::Type type, |
| 166 const GURL& url) const = 0; |
161 | 167 |
162 protected: | 168 protected: |
163 std::string name_; | 169 std::string name_; |
164 }; | 170 }; |
165 | 171 |
166 } // namespace extensions | 172 } // namespace extensions |
167 | 173 |
168 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ | 174 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ |
OLD | NEW |