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 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // Container for AvailabiltyResult that also exposes a user-visible error | 68 // Container for AvailabiltyResult that also exposes a user-visible error |
69 // message in cases where the feature is not available. | 69 // message in cases where the feature is not available. |
70 class Availability { | 70 class Availability { |
71 public: | 71 public: |
72 AvailabilityResult result() const { return result_; } | 72 AvailabilityResult result() const { return result_; } |
73 bool is_available() const { return result_ == IS_AVAILABLE; } | 73 bool is_available() const { return result_ == IS_AVAILABLE; } |
74 const std::string& message() const { return message_; } | 74 const std::string& message() const { return message_; } |
75 | 75 |
76 private: | 76 private: |
77 friend class SimpleFeature; | 77 friend class SimpleFeature; |
| 78 friend class Feature; |
78 | 79 |
79 // Instances should be created via Feature::CreateAvailability. | 80 // Instances should be created via Feature::CreateAvailability. |
80 Availability(AvailabilityResult result, const std::string& message) | 81 Availability(AvailabilityResult result, const std::string& message) |
81 : result_(result), message_(message) { } | 82 : result_(result), message_(message) { } |
82 | 83 |
83 const AvailabilityResult result_; | 84 const AvailabilityResult result_; |
84 const std::string message_; | 85 const std::string message_; |
85 }; | 86 }; |
86 | 87 |
87 virtual ~Feature(); | 88 virtual ~Feature(); |
88 | 89 |
| 90 // Used by ChromeV8Context until the feature system is fully functional. |
| 91 static Availability CreateAvailability(AvailabilityResult result, |
| 92 const std::string& message); |
| 93 |
89 // Gets the current channel as seen by the Feature system. | 94 // Gets the current channel as seen by the Feature system. |
90 static chrome::VersionInfo::Channel GetCurrentChannel(); | 95 static chrome::VersionInfo::Channel GetCurrentChannel(); |
91 | 96 |
92 // Sets the current channel as seen by the Feature system. In the browser | 97 // Sets the current channel as seen by the Feature system. In the browser |
93 // process this should be chrome::VersionInfo::GetChannel(), and in the | 98 // process this should be chrome::VersionInfo::GetChannel(), and in the |
94 // renderer this will need to come from an IPC. | 99 // renderer this will need to come from an IPC. |
95 static void SetCurrentChannel(chrome::VersionInfo::Channel channel); | 100 static void SetCurrentChannel(chrome::VersionInfo::Channel channel); |
96 | 101 |
97 // Gets the default channel as seen by the Feature system. | 102 // Gets the default channel as seen by the Feature system. |
98 static chrome::VersionInfo::Channel GetDefaultChannel(); | 103 static chrome::VersionInfo::Channel GetDefaultChannel(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 virtual std::string GetAvailabilityMessage( | 159 virtual std::string GetAvailabilityMessage( |
155 AvailabilityResult result, Manifest::Type type) const = 0; | 160 AvailabilityResult result, Manifest::Type type) const = 0; |
156 | 161 |
157 protected: | 162 protected: |
158 std::string name_; | 163 std::string name_; |
159 }; | 164 }; |
160 | 165 |
161 } // namespace extensions | 166 } // namespace extensions |
162 | 167 |
163 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ | 168 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ |
OLD | NEW |