| 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 <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 | |
| 12 class CommandLine; | |
| 13 | |
| 14 namespace extensions { | |
| 15 | |
| 16 // A switch that can turn a feature on or off. Typically controlled via | |
| 17 // command-line switches but can be overridden, e.g., for testing. | |
| 18 class FeatureSwitch { | |
| 19 public: | |
| 20 static FeatureSwitch* easy_off_store_install(); | |
| 21 static FeatureSwitch* global_commands(); | |
| 22 static FeatureSwitch* script_badges(); | |
| 23 static FeatureSwitch* script_bubble(); | |
| 24 static FeatureSwitch* prompt_for_external_extensions(); | |
| 25 static FeatureSwitch* error_console(); | |
| 26 | |
| 27 enum DefaultValue { | |
| 28 DEFAULT_ENABLED, | |
| 29 DEFAULT_DISABLED | |
| 30 }; | |
| 31 | |
| 32 enum OverrideValue { | |
| 33 OVERRIDE_NONE, | |
| 34 OVERRIDE_ENABLED, | |
| 35 OVERRIDE_DISABLED | |
| 36 }; | |
| 37 | |
| 38 // A temporary override for the switch value. | |
| 39 class ScopedOverride { | |
| 40 public: | |
| 41 ScopedOverride(FeatureSwitch* feature, bool override_value); | |
| 42 ~ScopedOverride(); | |
| 43 private: | |
| 44 FeatureSwitch* feature_; | |
| 45 FeatureSwitch::OverrideValue previous_value_; | |
| 46 DISALLOW_COPY_AND_ASSIGN(ScopedOverride); | |
| 47 }; | |
| 48 | |
| 49 FeatureSwitch(const char* switch_name, | |
| 50 DefaultValue default_value); | |
| 51 FeatureSwitch(const CommandLine* command_line, | |
| 52 const char* switch_name, | |
| 53 DefaultValue default_value); | |
| 54 | |
| 55 // Consider using ScopedOverride instead. | |
| 56 void SetOverrideValue(OverrideValue value); | |
| 57 OverrideValue GetOverrideValue() const; | |
| 58 | |
| 59 bool IsEnabled() const; | |
| 60 | |
| 61 std::string GetLegacyEnableFlag() const; | |
| 62 std::string GetLegacyDisableFlag() const; | |
| 63 | |
| 64 private: | |
| 65 void Init(const CommandLine* command_line, | |
| 66 const char* switch_name, | |
| 67 DefaultValue default_value); | |
| 68 | |
| 69 const CommandLine* command_line_; | |
| 70 const char* switch_name_; | |
| 71 bool default_value_; | |
| 72 OverrideValue override_value_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); | |
| 75 }; | |
| 76 | |
| 77 } // namespace extensions | |
| 78 | |
| 79 #endif // CHROME_COMMON_EXTENSIONS_FEATURE_SWITCH_H_ | |
| OLD | NEW |