| 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" | |
| 13 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 14 #include "chrome/common/extensions/manifest.h" | 13 #include "chrome/common/extensions/manifest.h" |
| 15 | 14 |
| 16 class GURL; | 15 class GURL; |
| 17 | 16 |
| 18 namespace extensions { | 17 namespace extensions { |
| 19 | 18 |
| 20 // Represents a single feature accessible to an extension developer, such as a | 19 // Represents a single feature accessible to an extension developer, such as a |
| 21 // top-level manifest key, a permission, or a programmatic API. A feature can | 20 // top-level manifest key, a permission, or a programmatic API. A feature can |
| 22 // express requirements for where it can be accessed, and supports testing | 21 // express requirements for where it can be accessed, and supports testing |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 const std::string message_; | 87 const std::string message_; |
| 89 }; | 88 }; |
| 90 | 89 |
| 91 Feature(); | 90 Feature(); |
| 92 virtual ~Feature(); | 91 virtual ~Feature(); |
| 93 | 92 |
| 94 // Used by ChromeV8Context until the feature system is fully functional. | 93 // Used by ChromeV8Context until the feature system is fully functional. |
| 95 static Availability CreateAvailability(AvailabilityResult result, | 94 static Availability CreateAvailability(AvailabilityResult result, |
| 96 const std::string& message); | 95 const std::string& message); |
| 97 | 96 |
| 98 // Gets the current channel as seen by the Feature system. | |
| 99 static chrome::VersionInfo::Channel GetCurrentChannel(); | |
| 100 | |
| 101 // Sets the current channel as seen by the Feature system. In the browser | |
| 102 // process this should be chrome::VersionInfo::GetChannel(), and in the | |
| 103 // renderer this will need to come from an IPC. | |
| 104 static void SetCurrentChannel(chrome::VersionInfo::Channel channel); | |
| 105 | |
| 106 // Gets the default channel as seen by the Feature system. | |
| 107 static chrome::VersionInfo::Channel GetDefaultChannel(); | |
| 108 | |
| 109 // Scoped channel setter. Use for tests. | |
| 110 class ScopedCurrentChannel { | |
| 111 public: | |
| 112 explicit ScopedCurrentChannel(chrome::VersionInfo::Channel channel) | |
| 113 : original_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { | |
| 114 original_channel_ = GetCurrentChannel(); | |
| 115 SetCurrentChannel(channel); | |
| 116 } | |
| 117 | |
| 118 ~ScopedCurrentChannel() { | |
| 119 SetCurrentChannel(original_channel_); | |
| 120 } | |
| 121 | |
| 122 private: | |
| 123 chrome::VersionInfo::Channel original_channel_; | |
| 124 }; | |
| 125 | |
| 126 const std::string& name() const { return name_; } | 97 const std::string& name() const { return name_; } |
| 127 void set_name(const std::string& name) { name_ = name; } | 98 void set_name(const std::string& name) { name_ = name; } |
| 128 const std::set<std::string>& dependencies() { return dependencies_; } | 99 const std::set<std::string>& dependencies() { return dependencies_; } |
| 129 bool no_parent() const { return no_parent_; } | 100 bool no_parent() const { return no_parent_; } |
| 130 | 101 |
| 131 // Gets the platform the code is currently running on. | 102 // Gets the platform the code is currently running on. |
| 132 static Platform GetCurrentPlatform(); | 103 static Platform GetCurrentPlatform(); |
| 133 | 104 |
| 134 // Gets the Feature::Location value for the specified Manifest::Location. | 105 // Gets the Feature::Location value for the specified Manifest::Location. |
| 135 static Location ConvertLocation(Manifest::Location extension_location); | 106 static Location ConvertLocation(Manifest::Location extension_location); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 145 |
| 175 protected: | 146 protected: |
| 176 std::string name_; | 147 std::string name_; |
| 177 std::set<std::string> dependencies_; | 148 std::set<std::string> dependencies_; |
| 178 bool no_parent_; | 149 bool no_parent_; |
| 179 }; | 150 }; |
| 180 | 151 |
| 181 } // namespace extensions | 152 } // namespace extensions |
| 182 | 153 |
| 183 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ | 154 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ |
| OLD | NEW |