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"
16 namespace extensions
{
18 // A switch that can turn a feature on or off. Typically controlled via
19 // command-line switches but can be overridden, e.g., for testing.
22 static FeatureSwitch
* easy_off_store_install();
23 static FeatureSwitch
* force_dev_mode_highlighting();
24 static FeatureSwitch
* prompt_for_external_extensions();
25 static FeatureSwitch
* error_console();
26 static FeatureSwitch
* enable_override_bookmarks_ui();
27 static FeatureSwitch
* extension_action_redesign();
28 static FeatureSwitch
* scripts_require_action();
29 static FeatureSwitch
* embedded_extension_options();
30 static FeatureSwitch
* app_view();
43 // A temporary override for the switch value.
44 class ScopedOverride
{
46 ScopedOverride(FeatureSwitch
* feature
, bool override_value
);
49 FeatureSwitch
* feature_
;
50 FeatureSwitch::OverrideValue previous_value_
;
51 DISALLOW_COPY_AND_ASSIGN(ScopedOverride
);
54 // |switch_name| can be NULL, in which case the feature is controlled solely
55 // by the default and override values.
56 FeatureSwitch(const char* switch_name
,
57 DefaultValue default_value
);
58 FeatureSwitch(const base::CommandLine
* command_line
,
59 const char* switch_name
,
60 DefaultValue default_value
);
62 // Consider using ScopedOverride instead.
63 void SetOverrideValue(OverrideValue value
);
64 OverrideValue
GetOverrideValue() const;
66 bool IsEnabled() const;
69 void Init(const base::CommandLine
* command_line
,
70 const char* switch_name
,
71 DefaultValue default_value
);
73 std::string
GetLegacyEnableFlag() const;
74 std::string
GetLegacyDisableFlag() const;
76 const base::CommandLine
* command_line_
;
77 const char* switch_name_
;
79 OverrideValue override_value_
;
81 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch
);
84 } // namespace extensions
86 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_