Index: chrome/common/extensions/features/feature.cc |
diff --git a/chrome/common/extensions/features/feature.cc b/chrome/common/extensions/features/feature.cc |
index 1d65e572c2c93d312f036a6e2d265ae8f282fe59..bed065c9720babd1059adb85af9aee1520be7fe8 100644 |
--- a/chrome/common/extensions/features/feature.cc |
+++ b/chrome/common/extensions/features/feature.cc |
@@ -67,22 +67,24 @@ static bool g_channel_checking_enabled = false; |
class Channel { |
public: |
VersionInfo::Channel GetChannel() { |
- CHECK(g_channel_checking_enabled); |
- if (channel_for_testing_.get()) |
- return *channel_for_testing_; |
- return VersionInfo::GetChannel(); |
+ CHECK(channel_.get()); |
+ return *channel_; |
} |
- void SetChannelForTesting(VersionInfo::Channel channel_for_testing) { |
- channel_for_testing_.reset(new VersionInfo::Channel(channel_for_testing)); |
+ bool HasChannel() { |
+ return channel_.get(); |
} |
- void ResetChannelForTesting() { |
- channel_for_testing_.reset(); |
+ void SetChannel(VersionInfo::Channel channel) { |
+ channel_.reset(new VersionInfo::Channel(channel)); |
+ } |
+ |
+ void ClearChannel() { |
+ channel_.reset(); |
} |
private: |
- scoped_ptr<VersionInfo::Channel> channel_for_testing_; |
+ scoped_ptr<VersionInfo::Channel> channel_; |
}; |
static base::LazyInstance<Channel> g_channel = LAZY_INSTANCE_INITIALIZER; |
@@ -320,9 +322,11 @@ Feature::Availability Feature::IsAvailableToManifest( |
if (max_manifest_version_ != 0 && manifest_version > max_manifest_version_) |
return INVALID_MAX_MANIFEST_VERSION; |
- if (g_channel_checking_enabled) { |
+ if (g_channel.Get().HasChannel()) { |
if (channel_ < g_channel.Get().GetChannel()) |
return UNSUPPORTED_CHANNEL; |
+ } else { |
+ // Would warn here, but it'd be very spammy in tests. |
} |
return IS_AVAILABLE; |
@@ -350,30 +354,24 @@ Feature::Availability Feature::IsAvailableToContext( |
} |
// static |
-void Feature::SetChannelCheckingEnabled(bool enabled) { |
- g_channel_checking_enabled = enabled; |
+bool Feature::HasCurrentChannel() { |
+ return g_channel.Get().HasChannel(); |
} |
// static |
-void Feature::ResetChannelCheckingEnabled() { |
- g_channel_checking_enabled = false; |
-} |
- |
-// static |
-void Feature::SetChannelForTesting(VersionInfo::Channel channel) { |
- g_channel.Get().SetChannelForTesting(channel); |
+chrome::VersionInfo::Channel Feature::GetCurrentChannel() { |
+ CHECK(g_channel.Get().HasChannel()) << "No channel has been set."; |
+ return g_channel.Get().GetChannel(); |
} |
// static |
-void Feature::ResetChannelForTesting() { |
- g_channel.Get().ResetChannelForTesting(); |
+void Feature::SetCurrentChannel(VersionInfo::Channel channel) { |
+ g_channel.Get().SetChannel(channel); |
} |
// static |
-chrome::VersionInfo::Channel Feature::GetCurrentChannel() { |
- if (g_channel_checking_enabled) |
- return g_channel.Get().GetChannel(); |
- return chrome::VersionInfo::GetChannel(); |
+void Feature::ClearCurrentChannel() { |
+ g_channel.Get().ClearChannel(); |
} |
} // namespace |