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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_COMMON_FEATURE_SWITCH_H_
6 #define EXTENSIONS_COMMON_FEATURE_SWITCH_H_
10 #include "base/basictypes.h"
14 namespace extensions
{
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.
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();
38 // A temporary override for the switch value.
39 class ScopedOverride
{
41 ScopedOverride(FeatureSwitch
* feature
, bool override_value
);
44 FeatureSwitch
* feature_
;
45 FeatureSwitch::OverrideValue previous_value_
;
46 DISALLOW_COPY_AND_ASSIGN(ScopedOverride
);
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
);
55 // Consider using ScopedOverride instead.
56 void SetOverrideValue(OverrideValue value
);
57 OverrideValue
GetOverrideValue() const;
59 bool IsEnabled() const;
61 std::string
GetLegacyEnableFlag() const;
62 std::string
GetLegacyDisableFlag() const;
65 void Init(const CommandLine
* command_line
,
66 const char* switch_name
,
67 DefaultValue default_value
);
69 const CommandLine
* command_line_
;
70 const char* switch_name_
;
72 OverrideValue override_value_
;
74 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch
);
77 } // namespace extensions
79 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_