Chromium Code Reviews| Index: chrome/common/extensions/feature.cc |
| diff --git a/chrome/common/extensions/feature.cc b/chrome/common/extensions/feature.cc |
| index 9f7543574dd9dc8e6acd70cd5a137d28b62d4418..70dfc8328c2356eb8f59e9d1cd9f50765c66a93d 100644 |
| --- a/chrome/common/extensions/feature.cc |
| +++ b/chrome/common/extensions/feature.cc |
| @@ -11,6 +11,8 @@ |
| #include "base/stringprintf.h" |
| #include "chrome/common/chrome_switches.h" |
| +using chrome::VersionInfo; |
| + |
| namespace { |
| struct Mappings { |
| @@ -31,12 +33,18 @@ struct Mappings { |
| locations["component"] = extensions::Feature::COMPONENT_LOCATION; |
| platforms["chromeos"] = extensions::Feature::CHROMEOS_PLATFORM; |
| + channels["trunk"] = VersionInfo::CHANNEL_UNKNOWN; |
|
Aaron Boodman
2012/04/11 23:35:53
.insert("\n")
not at google - send to devlin
2012/04/12 00:05:21
Done.
|
| + channels["canary"] = VersionInfo::CHANNEL_CANARY; |
| + channels["dev"] = VersionInfo::CHANNEL_DEV; |
| + channels["beta"] = VersionInfo::CHANNEL_BETA; |
| + channels["stable"] = VersionInfo::CHANNEL_STABLE; |
| } |
| std::map<std::string, Extension::Type> extension_types; |
| std::map<std::string, extensions::Feature::Context> contexts; |
| std::map<std::string, extensions::Feature::Location> locations; |
| std::map<std::string, extensions::Feature::Platform> platforms; |
| + std::map<std::string, VersionInfo::Channel> channels; |
| }; |
| static base::LazyInstance<Mappings> g_mappings = |
| @@ -120,7 +128,9 @@ Feature::Feature() |
| : location_(UNSPECIFIED_LOCATION), |
| platform_(UNSPECIFIED_PLATFORM), |
| min_manifest_version_(0), |
| - max_manifest_version_(0) { |
| + max_manifest_version_(0), |
| + channel_(VersionInfo::GetChannel()), |
| + supported_channel_(VersionInfo::CHANNEL_STABLE) { |
| } |
| Feature::Feature(const Feature& other) |
| @@ -130,7 +140,9 @@ Feature::Feature(const Feature& other) |
| location_(other.location_), |
| platform_(other.platform_), |
| min_manifest_version_(other.min_manifest_version_), |
| - max_manifest_version_(other.max_manifest_version_) { |
| + max_manifest_version_(other.max_manifest_version_), |
| + channel_(other.channel_), |
| + supported_channel_(other.supported_channel_) { |
| } |
| Feature::~Feature() { |
| @@ -143,7 +155,9 @@ bool Feature::Equals(const Feature& other) const { |
| location_ == other.location_ && |
| platform_ == other.platform_ && |
| min_manifest_version_ == other.min_manifest_version_ && |
| - max_manifest_version_ == other.max_manifest_version_; |
| + max_manifest_version_ == other.max_manifest_version_ && |
| + channel_ == other.channel_ && |
| + supported_channel_ == other.supported_channel_; |
| } |
| // static |
| @@ -175,6 +189,9 @@ void Feature::Parse(const DictionaryValue* value) { |
| g_mappings.Get().platforms); |
| value->GetInteger("min_manifest_version", &min_manifest_version_); |
| value->GetInteger("max_manifest_version", &max_manifest_version_); |
| + ParseEnum<VersionInfo::Channel>( |
| + value, "supported_channel", &supported_channel_, |
| + g_mappings.Get().channels); |
| } |
| std::string Feature::GetErrorMessage(Feature::Availability result) { |
| @@ -198,10 +215,12 @@ std::string Feature::GetErrorMessage(Feature::Availability result) { |
| case INVALID_MAX_MANIFEST_VERSION: |
| return base::StringPrintf("Requires manifest version of %d or lower.", |
| max_manifest_version_); |
| - default: |
| - CHECK(false); |
| - return ""; |
|
not at google - send to devlin
2012/04/11 23:05:54
Unrelated cleanup, but clang won't compile if ther
Aaron Boodman
2012/04/11 23:35:53
Neat. Thanks for the info.
|
| + case UNSUPPORTED_CHANNEL: |
| + return base::StringPrintf("Channel %d is unsupported.", |
| + supported_channel_); |
| } |
| + |
| + return ""; |
| } |
| Feature::Availability Feature::IsAvailableToManifest( |
| @@ -247,6 +266,9 @@ Feature::Availability Feature::IsAvailableToManifest( |
| if (max_manifest_version_ != 0 && manifest_version > max_manifest_version_) |
| return INVALID_MAX_MANIFEST_VERSION; |
| + if (supported_channel_ < channel_) |
| + return UNSUPPORTED_CHANNEL; |
| + |
| return IS_AVAILABLE; |
| } |
| @@ -271,4 +293,8 @@ Feature::Availability Feature::IsAvailableToContext( |
| return IS_AVAILABLE; |
| } |
| +void Feature::SetChannelForTesting(VersionInfo::Channel channel) { |
| + channel_ = channel; |
| +} |
| + |
| } // namespace |