| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_FEATURE_H_ | 5 #ifndef EXTENSIONS_COMMON_FEATURES_FEATURE_H_ |
| 6 #define EXTENSIONS_COMMON_FEATURES_FEATURE_H_ | 6 #define EXTENSIONS_COMMON_FEATURES_FEATURE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // A normal web page. This should have an associated URL matching pattern. | 40 // A normal web page. This should have an associated URL matching pattern. |
| 41 WEB_PAGE_CONTEXT, | 41 WEB_PAGE_CONTEXT, |
| 42 | 42 |
| 43 // A web page context which has been blessed by the user. Typically this | 43 // A web page context which has been blessed by the user. Typically this |
| 44 // will be via the installation of a hosted app, so this may host an | 44 // will be via the installation of a hosted app, so this may host an |
| 45 // extension. This is not affected by the URL matching pattern. | 45 // extension. This is not affected by the URL matching pattern. |
| 46 BLESSED_WEB_PAGE_CONTEXT, | 46 BLESSED_WEB_PAGE_CONTEXT, |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // The location required of extensions the feature is supported in. | |
| 50 enum Location { | |
| 51 UNSPECIFIED_LOCATION, | |
| 52 COMPONENT_LOCATION | |
| 53 }; | |
| 54 | |
| 55 // The platforms the feature is supported in. | 49 // The platforms the feature is supported in. |
| 56 enum Platform { | 50 enum Platform { |
| 57 UNSPECIFIED_PLATFORM, | 51 UNSPECIFIED_PLATFORM, |
| 58 CHROMEOS_PLATFORM, | 52 CHROMEOS_PLATFORM, |
| 59 LINUX_PLATFORM, | 53 LINUX_PLATFORM, |
| 60 MACOSX_PLATFORM, | 54 MACOSX_PLATFORM, |
| 61 WIN_PLATFORM | 55 WIN_PLATFORM |
| 62 }; | 56 }; |
| 63 | 57 |
| 64 // Whether a feature is available in a given situation or not, and if not, | 58 // Whether a feature is available in a given situation or not, and if not, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 94 : result_(result), message_(message) { } | 88 : result_(result), message_(message) { } |
| 95 | 89 |
| 96 const AvailabilityResult result_; | 90 const AvailabilityResult result_; |
| 97 const std::string message_; | 91 const std::string message_; |
| 98 }; | 92 }; |
| 99 | 93 |
| 100 Feature(); | 94 Feature(); |
| 101 virtual ~Feature(); | 95 virtual ~Feature(); |
| 102 | 96 |
| 103 // Used by ChromeV8Context until the feature system is fully functional. | 97 // Used by ChromeV8Context until the feature system is fully functional. |
| 98 // TODO(kalman): This is no longer used by ChromeV8Context, so what is the |
| 99 // comment trying to say? |
| 104 static Availability CreateAvailability(AvailabilityResult result, | 100 static Availability CreateAvailability(AvailabilityResult result, |
| 105 const std::string& message); | 101 const std::string& message); |
| 106 | 102 |
| 107 const std::string& name() const { return name_; } | 103 const std::string& name() const { return name_; } |
| 108 void set_name(const std::string& name) { name_ = name; } | 104 void set_name(const std::string& name) { name_ = name; } |
| 109 const std::set<std::string>& dependencies() const { return dependencies_; } | 105 const std::set<std::string>& dependencies() const { return dependencies_; } |
| 110 bool no_parent() const { return no_parent_; } | 106 bool no_parent() const { return no_parent_; } |
| 111 | 107 |
| 112 // Gets the platform the code is currently running on. | 108 // Gets the platform the code is currently running on. |
| 113 static Platform GetCurrentPlatform(); | 109 static Platform GetCurrentPlatform(); |
| 114 | 110 |
| 115 // Gets the Feature::Location value for the specified Manifest::Location. | |
| 116 static Location ConvertLocation(Manifest::Location extension_location); | |
| 117 | |
| 118 virtual std::set<Context>* GetContexts() = 0; | 111 virtual std::set<Context>* GetContexts() = 0; |
| 119 | 112 |
| 120 // Tests whether this is an internal API or not. | 113 // Tests whether this is an internal API or not. |
| 121 virtual bool IsInternal() const = 0; | 114 virtual bool IsInternal() const = 0; |
| 122 | 115 |
| 123 // Returns True for features excluded from service worker backed contexts. | 116 // Returns True for features excluded from service worker backed contexts. |
| 124 virtual bool IsBlockedInServiceWorker() const = 0; | 117 virtual bool IsBlockedInServiceWorker() const = 0; |
| 125 | 118 |
| 126 // Returns true if the feature is available to be parsed into a new extension | 119 // Returns true if the feature is available to be parsed into a new extension |
| 127 // manifest. | 120 // manifest. |
| 128 Availability IsAvailableToManifest(const std::string& extension_id, | 121 Availability IsAvailableToManifest(const std::string& extension_id, |
| 129 Manifest::Type type, | 122 Manifest::Type type, |
| 130 Location location, | 123 Manifest::Location location, |
| 131 int manifest_version) const { | 124 int manifest_version) const { |
| 132 return IsAvailableToManifest(extension_id, type, location, manifest_version, | 125 return IsAvailableToManifest(extension_id, type, location, manifest_version, |
| 133 GetCurrentPlatform()); | 126 GetCurrentPlatform()); |
| 134 } | 127 } |
| 135 virtual Availability IsAvailableToManifest(const std::string& extension_id, | 128 virtual Availability IsAvailableToManifest(const std::string& extension_id, |
| 136 Manifest::Type type, | 129 Manifest::Type type, |
| 137 Location location, | 130 Manifest::Location location, |
| 138 int manifest_version, | 131 int manifest_version, |
| 139 Platform platform) const = 0; | 132 Platform platform) const = 0; |
| 140 | 133 |
| 134 // Returns true if the feature is available to |extension|. |
| 135 Availability IsAvailableToExtension(const Extension* extension); |
| 136 |
| 141 // Returns true if the feature is available to be used in the specified | 137 // Returns true if the feature is available to be used in the specified |
| 142 // extension and context. | 138 // extension and context. |
| 143 Availability IsAvailableToContext(const Extension* extension, | 139 Availability IsAvailableToContext(const Extension* extension, |
| 144 Context context, | 140 Context context, |
| 145 const GURL& url) const { | 141 const GURL& url) const { |
| 146 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); | 142 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); |
| 147 } | 143 } |
| 148 virtual Availability IsAvailableToContext(const Extension* extension, | 144 virtual Availability IsAvailableToContext(const Extension* extension, |
| 149 Context context, | 145 Context context, |
| 150 const GURL& url, | 146 const GURL& url, |
| 151 Platform platform) const = 0; | 147 Platform platform) const = 0; |
| 152 | 148 |
| 153 virtual std::string GetAvailabilityMessage(AvailabilityResult result, | 149 virtual std::string GetAvailabilityMessage(AvailabilityResult result, |
| 154 Manifest::Type type, | 150 Manifest::Type type, |
| 155 const GURL& url, | 151 const GURL& url, |
| 156 Context context) const = 0; | 152 Context context) const = 0; |
| 157 | 153 |
| 158 virtual bool IsIdInWhitelist(const std::string& extension_id) const = 0; | 154 virtual bool IsIdInWhitelist(const std::string& extension_id) const = 0; |
| 159 | 155 |
| 160 protected: | 156 protected: |
| 161 std::string name_; | 157 std::string name_; |
| 162 std::set<std::string> dependencies_; | 158 std::set<std::string> dependencies_; |
| 163 bool no_parent_; | 159 bool no_parent_; |
| 164 }; | 160 }; |
| 165 | 161 |
| 166 } // namespace extensions | 162 } // namespace extensions |
| 167 | 163 |
| 168 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_H_ | 164 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_H_ |
| OLD | NEW |