Index: chrome/common/extensions/features/feature.h |
diff --git a/chrome/common/extensions/features/feature.h b/chrome/common/extensions/features/feature.h |
index 2683d5b8f999dcb592f80f5606ff7495f27af845..bf315acac6ef6f1e793f39224dbfd530a84dd96c 100644 |
--- a/chrome/common/extensions/features/feature.h |
+++ b/chrome/common/extensions/features/feature.h |
@@ -68,23 +68,44 @@ class Feature { |
Feature(const Feature& other); |
virtual ~Feature(); |
- // (Re)Sets whether checking against "channel" should be done. This must only |
- // be called on the browser process, since the check involves accessing the |
- // filesystem. |
- // See http://crbug.com/126535. |
- static void SetChannelCheckingEnabled(bool enabled); |
- static void ResetChannelCheckingEnabled(); |
- |
- // (Re)Sets the Channel to for all Features to compare against. This is |
- // usually chrome::VersionInfo::GetChannel(), but for tests allow this to be |
- // overridden. |
- static void SetChannelForTesting(chrome::VersionInfo::Channel channel); |
- static void ResetChannelForTesting(); |
- |
- // Returns the current channel as seen by the Feature system (i.e. the |
- // ChannelForTesting if one is set, otherwise the actual channel). |
+ // Returns true if a channel has been set. |
+ static bool HasCurrentChannel(); |
+ |
+ // Gets the current channel as seen by the Feature system. |
+ // SetCurrentChannel() must have already been called. |
static chrome::VersionInfo::Channel GetCurrentChannel(); |
+ // Sets the current channel as seen by the Feature system. In the browser |
+ // process this should be chrome::VersionInfo::GetChannel(), and in the |
+ // renderer this will need to come from an IPC. |
+ static void SetCurrentChannel(chrome::VersionInfo::Channel channel); |
+ |
+ // Clears the current channel as seen by the Feature system. |
+ static void ClearCurrentChannel(); |
+ |
+ // Scoped channel setter. Use for tests. |
+ class ScopedCurrentChannel { |
+ public: |
+ explicit ScopedCurrentChannel(chrome::VersionInfo::Channel channel) |
+ : has_original_channel_(false), |
+ original_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { |
+ if (HasCurrentChannel()) { |
+ has_original_channel_ = true; |
+ original_channel_ = GetCurrentChannel(); |
+ } |
+ SetCurrentChannel(channel); |
+ } |
+ |
+ ~ScopedCurrentChannel() { |
+ if (has_original_channel_) |
+ SetCurrentChannel(original_channel_); |
Matt Perry
2012/08/08 19:17:26
else: ClearCurrentChannel?
not at google - send to devlin
2012/08/09 00:14:37
Oops. Thanks.
|
+ } |
+ |
+ private: |
+ bool has_original_channel_; |
+ chrome::VersionInfo::Channel original_channel_; |
+ }; |
+ |
const std::string& name() const { return name_; } |
void set_name(const std::string& name) { name_ = name; } |