OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_COMMON_FEATURE_SWITCH_H_ | 5 #ifndef EXTENSIONS_COMMON_FEATURE_SWITCH_H_ |
6 #define EXTENSIONS_COMMON_FEATURE_SWITCH_H_ | 6 #define EXTENSIONS_COMMON_FEATURE_SWITCH_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 | 11 |
| 12 namespace base { |
12 class CommandLine; | 13 class CommandLine; |
| 14 } |
13 | 15 |
14 namespace extensions { | 16 namespace extensions { |
15 | 17 |
16 // A switch that can turn a feature on or off. Typically controlled via | 18 // 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. | 19 // command-line switches but can be overridden, e.g., for testing. |
18 class FeatureSwitch { | 20 class FeatureSwitch { |
19 public: | 21 public: |
20 static FeatureSwitch* easy_off_store_install(); | 22 static FeatureSwitch* easy_off_store_install(); |
21 static FeatureSwitch* force_dev_mode_highlighting(); | 23 static FeatureSwitch* force_dev_mode_highlighting(); |
22 static FeatureSwitch* global_commands(); | 24 static FeatureSwitch* global_commands(); |
(...skipping 20 matching lines...) Expand all Loading... |
43 private: | 45 private: |
44 FeatureSwitch* feature_; | 46 FeatureSwitch* feature_; |
45 FeatureSwitch::OverrideValue previous_value_; | 47 FeatureSwitch::OverrideValue previous_value_; |
46 DISALLOW_COPY_AND_ASSIGN(ScopedOverride); | 48 DISALLOW_COPY_AND_ASSIGN(ScopedOverride); |
47 }; | 49 }; |
48 | 50 |
49 // |switch_name| can be NULL, in which case the feature is controlled solely | 51 // |switch_name| can be NULL, in which case the feature is controlled solely |
50 // by the default and override values. | 52 // by the default and override values. |
51 FeatureSwitch(const char* switch_name, | 53 FeatureSwitch(const char* switch_name, |
52 DefaultValue default_value); | 54 DefaultValue default_value); |
53 FeatureSwitch(const CommandLine* command_line, | 55 FeatureSwitch(const base::CommandLine* command_line, |
54 const char* switch_name, | 56 const char* switch_name, |
55 DefaultValue default_value); | 57 DefaultValue default_value); |
56 | 58 |
57 // Consider using ScopedOverride instead. | 59 // Consider using ScopedOverride instead. |
58 void SetOverrideValue(OverrideValue value); | 60 void SetOverrideValue(OverrideValue value); |
59 OverrideValue GetOverrideValue() const; | 61 OverrideValue GetOverrideValue() const; |
60 | 62 |
61 bool IsEnabled() const; | 63 bool IsEnabled() const; |
62 | 64 |
63 private: | 65 private: |
64 void Init(const CommandLine* command_line, | 66 void Init(const base::CommandLine* command_line, |
65 const char* switch_name, | 67 const char* switch_name, |
66 DefaultValue default_value); | 68 DefaultValue default_value); |
67 | 69 |
68 std::string GetLegacyEnableFlag() const; | 70 std::string GetLegacyEnableFlag() const; |
69 std::string GetLegacyDisableFlag() const; | 71 std::string GetLegacyDisableFlag() const; |
70 | 72 |
71 const CommandLine* command_line_; | 73 const base::CommandLine* command_line_; |
72 const char* switch_name_; | 74 const char* switch_name_; |
73 bool default_value_; | 75 bool default_value_; |
74 OverrideValue override_value_; | 76 OverrideValue override_value_; |
75 | 77 |
76 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); | 78 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); |
77 }; | 79 }; |
78 | 80 |
79 } // namespace extensions | 81 } // namespace extensions |
80 | 82 |
81 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_ | 83 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_ |
OLD | NEW |