| 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" |
| 11 #include "base/optional.h" |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 class CommandLine; | 14 class CommandLine; |
| 14 } | 15 } |
| 15 | 16 |
| 16 namespace extensions { | 17 namespace extensions { |
| 17 | 18 |
| 18 // A switch that can turn a feature on or off. Typically controlled via | 19 // 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 // command-line switches but can be overridden, e.g., for testing. |
| 20 // Can also integrate with Finch's field trials. | 21 // Can also integrate with Finch's field trials. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 34 static FeatureSwitch* force_dev_mode_highlighting(); | 35 static FeatureSwitch* force_dev_mode_highlighting(); |
| 35 static FeatureSwitch* prompt_for_external_extensions(); | 36 static FeatureSwitch* prompt_for_external_extensions(); |
| 36 static FeatureSwitch* error_console(); | 37 static FeatureSwitch* error_console(); |
| 37 static FeatureSwitch* enable_override_bookmarks_ui(); | 38 static FeatureSwitch* enable_override_bookmarks_ui(); |
| 38 static FeatureSwitch* extension_action_redesign(); | 39 static FeatureSwitch* extension_action_redesign(); |
| 39 static FeatureSwitch* scripts_require_action(); | 40 static FeatureSwitch* scripts_require_action(); |
| 40 static FeatureSwitch* embedded_extension_options(); | 41 static FeatureSwitch* embedded_extension_options(); |
| 41 static FeatureSwitch* trace_app_source(); | 42 static FeatureSwitch* trace_app_source(); |
| 42 static FeatureSwitch* load_media_router_component_extension(); | 43 static FeatureSwitch* load_media_router_component_extension(); |
| 43 static FeatureSwitch* native_crx_bindings(); | 44 static FeatureSwitch* native_crx_bindings(); |
| 45 static FeatureSwitch* yield_between_content_script_runs(); |
| 44 | 46 |
| 45 enum DefaultValue { | 47 enum DefaultValue { |
| 46 DEFAULT_ENABLED, | 48 DEFAULT_ENABLED, |
| 47 DEFAULT_DISABLED | 49 DEFAULT_DISABLED |
| 48 }; | 50 }; |
| 49 | 51 |
| 50 enum OverrideValue { | 52 enum OverrideValue { |
| 51 OVERRIDE_NONE, | 53 OVERRIDE_NONE, |
| 52 OVERRIDE_ENABLED, | 54 OVERRIDE_ENABLED, |
| 53 OVERRIDE_DISABLED | 55 OVERRIDE_DISABLED |
| (...skipping 27 matching lines...) Expand all Loading... |
| 81 | 83 |
| 82 // Consider using ScopedOverride instead. | 84 // Consider using ScopedOverride instead. |
| 83 void SetOverrideValue(OverrideValue value); | 85 void SetOverrideValue(OverrideValue value); |
| 84 OverrideValue GetOverrideValue() const; | 86 OverrideValue GetOverrideValue() const; |
| 85 | 87 |
| 86 bool IsEnabled() const; | 88 bool IsEnabled() const; |
| 87 | 89 |
| 88 private: | 90 private: |
| 89 std::string GetLegacyEnableFlag() const; | 91 std::string GetLegacyEnableFlag() const; |
| 90 std::string GetLegacyDisableFlag() const; | 92 std::string GetLegacyDisableFlag() const; |
| 93 bool ComputeValue() const; |
| 91 | 94 |
| 92 const base::CommandLine* command_line_; | 95 const base::CommandLine* command_line_; |
| 93 const char* switch_name_; | 96 const char* switch_name_; |
| 94 const char* field_trial_name_; | 97 const char* field_trial_name_; |
| 95 bool default_value_; | 98 bool default_value_; |
| 96 OverrideValue override_value_; | 99 OverrideValue override_value_; |
| 100 mutable base::Optional<bool> cached_value_; |
| 97 | 101 |
| 98 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); | 102 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); |
| 99 }; | 103 }; |
| 100 | 104 |
| 101 } // namespace extensions | 105 } // namespace extensions |
| 102 | 106 |
| 103 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_ | 107 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_ |
| OLD | NEW |