Renamed NQP to EEPAndroid
[chromium-blink-merge.git] / extensions / common / feature_switch.h
blobf54d2d4c298a8ba61d999622203134b544d88367
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_
8 #include <string>
10 #include "base/basictypes.h"
12 namespace base {
13 class CommandLine;
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.
20 class FeatureSwitch {
21 public:
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* trace_app_source();
32 enum DefaultValue {
33 DEFAULT_ENABLED,
34 DEFAULT_DISABLED
37 enum OverrideValue {
38 OVERRIDE_NONE,
39 OVERRIDE_ENABLED,
40 OVERRIDE_DISABLED
43 // A temporary override for the switch value.
44 class ScopedOverride {
45 public:
46 ScopedOverride(FeatureSwitch* feature, bool override_value);
47 ~ScopedOverride();
48 private:
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;
68 private:
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_;
78 bool default_value_;
79 OverrideValue override_value_;
81 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch);
84 } // namespace extensions
86 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_