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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 INVALID_URL, | 66 INVALID_URL, |
67 INVALID_TYPE, | 67 INVALID_TYPE, |
68 INVALID_CONTEXT, | 68 INVALID_CONTEXT, |
69 INVALID_LOCATION, | 69 INVALID_LOCATION, |
70 INVALID_PLATFORM, | 70 INVALID_PLATFORM, |
71 INVALID_MIN_MANIFEST_VERSION, | 71 INVALID_MIN_MANIFEST_VERSION, |
72 INVALID_MAX_MANIFEST_VERSION, | 72 INVALID_MAX_MANIFEST_VERSION, |
73 NOT_PRESENT, | 73 NOT_PRESENT, |
74 UNSUPPORTED_CHANNEL, | 74 UNSUPPORTED_CHANNEL, |
75 FOUND_IN_BLACKLIST, | 75 FOUND_IN_BLACKLIST, |
| 76 MISSING_COMMAND_LINE_SWITCH, |
76 }; | 77 }; |
77 | 78 |
78 // Container for AvailabiltyResult that also exposes a user-visible error | 79 // Container for AvailabiltyResult that also exposes a user-visible error |
79 // message in cases where the feature is not available. | 80 // message in cases where the feature is not available. |
80 class Availability { | 81 class Availability { |
81 public: | 82 public: |
82 AvailabilityResult result() const { return result_; } | 83 AvailabilityResult result() const { return result_; } |
83 bool is_available() const { return result_ == IS_AVAILABLE; } | 84 bool is_available() const { return result_ == IS_AVAILABLE; } |
84 const std::string& message() const { return message_; } | 85 const std::string& message() const { return message_; } |
85 | 86 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 virtual Availability IsAvailableToContext(const Extension* extension, | 143 virtual Availability IsAvailableToContext(const Extension* extension, |
143 Context context, | 144 Context context, |
144 const GURL& url, | 145 const GURL& url, |
145 Platform platform) const = 0; | 146 Platform platform) const = 0; |
146 | 147 |
147 virtual std::string GetAvailabilityMessage(AvailabilityResult result, | 148 virtual std::string GetAvailabilityMessage(AvailabilityResult result, |
148 Manifest::Type type, | 149 Manifest::Type type, |
149 const GURL& url, | 150 const GURL& url, |
150 Context context) const = 0; | 151 Context context) const = 0; |
151 | 152 |
| 153 // Returns true if the feature is available to the current environment, |
| 154 // without needing to know information about an Extension or any other |
| 155 // contextual information. Typically used when the Feature is purely |
| 156 // configured by command line flags and/or Chrome channel. |
| 157 // |
| 158 // Generally try not to use this function. Even if you don't think a Feature |
| 159 // relies on an Extension now - maybe it will, one day, so if there's an |
| 160 // Extension available (or a runtime context, etc) then use the more targeted |
| 161 // method instead. |
| 162 Availability IsAvailableToEnvironment() const; |
| 163 |
152 virtual bool IsIdInBlacklist(const std::string& extension_id) const = 0; | 164 virtual bool IsIdInBlacklist(const std::string& extension_id) const = 0; |
153 virtual bool IsIdInWhitelist(const std::string& extension_id) const = 0; | 165 virtual bool IsIdInWhitelist(const std::string& extension_id) const = 0; |
154 | 166 |
155 protected: | 167 protected: |
156 std::string name_; | 168 std::string name_; |
157 bool no_parent_; | 169 bool no_parent_; |
158 }; | 170 }; |
159 | 171 |
160 } // namespace extensions | 172 } // namespace extensions |
161 | 173 |
162 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_H_ | 174 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_H_ |
OLD | NEW |