Chromium Code Reviews| 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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 static FeatureSwitch* force_dev_mode_highlighting(); | 34 static FeatureSwitch* force_dev_mode_highlighting(); |
| 35 static FeatureSwitch* prompt_for_external_extensions(); | 35 static FeatureSwitch* prompt_for_external_extensions(); |
| 36 static FeatureSwitch* error_console(); | 36 static FeatureSwitch* error_console(); |
| 37 static FeatureSwitch* enable_override_bookmarks_ui(); | 37 static FeatureSwitch* enable_override_bookmarks_ui(); |
| 38 static FeatureSwitch* extension_action_redesign(); | 38 static FeatureSwitch* extension_action_redesign(); |
| 39 static FeatureSwitch* scripts_require_action(); | 39 static FeatureSwitch* scripts_require_action(); |
| 40 static FeatureSwitch* embedded_extension_options(); | 40 static FeatureSwitch* embedded_extension_options(); |
| 41 static FeatureSwitch* trace_app_source(); | 41 static FeatureSwitch* trace_app_source(); |
| 42 static FeatureSwitch* load_media_router_component_extension(); | 42 static FeatureSwitch* load_media_router_component_extension(); |
| 43 static FeatureSwitch* native_crx_bindings(); | 43 static FeatureSwitch* native_crx_bindings(); |
| 44 static FeatureSwitch* yield_between_content_script_runs(); | |
| 44 | 45 |
| 45 enum DefaultValue { | 46 enum DefaultValue { |
| 46 DEFAULT_ENABLED, | 47 DEFAULT_ENABLED, |
| 47 DEFAULT_DISABLED | 48 DEFAULT_DISABLED |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 enum OverrideValue { | 51 enum OverrideValue { |
| 51 OVERRIDE_NONE, | 52 OVERRIDE_NONE, |
| 52 OVERRIDE_ENABLED, | 53 OVERRIDE_ENABLED, |
| 53 OVERRIDE_DISABLED | 54 OVERRIDE_DISABLED |
| 54 }; | 55 }; |
| 55 | 56 |
| 57 enum CachedValue { | |
| 58 NOT_CACHED, | |
| 59 CACHED_ENABLED, | |
| 60 CACHED_DISABLED | |
| 61 }; | |
| 62 | |
| 56 // A temporary override for the switch value. | 63 // A temporary override for the switch value. |
| 57 class ScopedOverride { | 64 class ScopedOverride { |
| 58 public: | 65 public: |
| 59 ScopedOverride(FeatureSwitch* feature, bool override_value); | 66 ScopedOverride(FeatureSwitch* feature, bool override_value); |
| 60 ~ScopedOverride(); | 67 ~ScopedOverride(); |
| 61 private: | 68 private: |
| 62 FeatureSwitch* feature_; | 69 FeatureSwitch* feature_; |
| 63 FeatureSwitch::OverrideValue previous_value_; | 70 FeatureSwitch::OverrideValue previous_value_; |
| 64 DISALLOW_COPY_AND_ASSIGN(ScopedOverride); | 71 DISALLOW_COPY_AND_ASSIGN(ScopedOverride); |
| 65 }; | 72 }; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 81 | 88 |
| 82 // Consider using ScopedOverride instead. | 89 // Consider using ScopedOverride instead. |
| 83 void SetOverrideValue(OverrideValue value); | 90 void SetOverrideValue(OverrideValue value); |
| 84 OverrideValue GetOverrideValue() const; | 91 OverrideValue GetOverrideValue() const; |
| 85 | 92 |
| 86 bool IsEnabled() const; | 93 bool IsEnabled() const; |
| 87 | 94 |
| 88 private: | 95 private: |
| 89 std::string GetLegacyEnableFlag() const; | 96 std::string GetLegacyEnableFlag() const; |
| 90 std::string GetLegacyDisableFlag() const; | 97 std::string GetLegacyDisableFlag() const; |
| 98 bool ComputeValue() const; | |
| 91 | 99 |
| 92 const base::CommandLine* command_line_; | 100 const base::CommandLine* command_line_; |
| 93 const char* switch_name_; | 101 const char* switch_name_; |
| 94 const char* field_trial_name_; | 102 const char* field_trial_name_; |
| 95 bool default_value_; | 103 bool default_value_; |
| 96 OverrideValue override_value_; | 104 OverrideValue override_value_; |
| 105 mutable CachedValue cached_value_; | |
|
Devlin
2017/03/10 03:18:45
nit: maybe use a base::Optional<bool> here?
Kunihiko Sakamoto
2017/03/10 07:07:28
Done.
| |
| 97 | 106 |
| 98 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); | 107 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); |
| 99 }; | 108 }; |
| 100 | 109 |
| 101 } // namespace extensions | 110 } // namespace extensions |
| 102 | 111 |
| 103 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_ | 112 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_ |
| OLD | NEW |