| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_COMMON_EXTENSIONS_FEATURE_SWITCH_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_FEATURE_SWITCH_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 |
| 10 class CommandLine; |
| 11 |
| 12 namespace extensions { |
| 13 |
| 14 // A switch that can turn a feature on or off. Typically controlled via |
| 15 // command-line switches but can be overridden, e.g., for testing. |
| 16 class FeatureSwitch { |
| 17 public: |
| 18 static FeatureSwitch* GetScriptBubble(); |
| 19 |
| 20 // A temporary override for the switch value. |
| 21 class ScopedOverride { |
| 22 public: |
| 23 ScopedOverride(FeatureSwitch* feature, bool override_value); |
| 24 ~ScopedOverride(); |
| 25 private: |
| 26 friend FeatureSwitch; |
| 27 FeatureSwitch* feature_; |
| 28 bool previous_value_; |
| 29 DISALLOW_COPY_AND_ASSIGN(ScopedOverride); |
| 30 }; |
| 31 |
| 32 enum DefaultValue { |
| 33 DEFAULT_ENABLED, |
| 34 DEFAULT_DISABLED |
| 35 }; |
| 36 |
| 37 FeatureSwitch(const CommandLine* command_line, |
| 38 const char* switch_name, |
| 39 DefaultValue default_value); |
| 40 |
| 41 bool IsEnabled() const; |
| 42 |
| 43 private: |
| 44 enum OverrideValue { |
| 45 OVERRIDE_NONE, |
| 46 OVERRIDE_ENABLED, |
| 47 OVERRIDE_DISABLED |
| 48 }; |
| 49 |
| 50 void SetOverrideValue(OverrideValue value); |
| 51 |
| 52 const CommandLine* command_line_; |
| 53 const char* switch_name_; |
| 54 bool default_value_; |
| 55 OverrideValue override_value_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); |
| 58 }; |
| 59 |
| 60 } // namespace extensions |
| 61 |
| 62 #endif // CHROME_COMMON_EXTENSIONS_FEATURE_SWITCH_H_ |
| OLD | NEW |