[Android] Lint pylib/host_driven.
[chromium-blink-merge.git] / extensions / common / feature_switch.h
blobbbfd2c7a69b2c3f8cb8e30e52f33c84adacf8e70
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 class CommandLine;
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.
18 class FeatureSwitch {
19 public:
20 static FeatureSwitch* easy_off_store_install();
21 static FeatureSwitch* force_dev_mode_highlighting();
22 static FeatureSwitch* global_commands();
23 static FeatureSwitch* prompt_for_external_extensions();
24 static FeatureSwitch* error_console();
25 static FeatureSwitch* enable_override_bookmarks_ui();
27 enum DefaultValue {
28 DEFAULT_ENABLED,
29 DEFAULT_DISABLED
32 enum OverrideValue {
33 OVERRIDE_NONE,
34 OVERRIDE_ENABLED,
35 OVERRIDE_DISABLED
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);
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;
64 private:
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_;
71 bool default_value_;
72 OverrideValue override_value_;
74 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch);
77 } // namespace extensions
79 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_