| 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 #include <vector> | |
| 10 | 9 |
| 11 #include "base/macros.h" | 10 #include "base/macros.h" |
| 12 | 11 |
| 13 namespace base { | 12 namespace base { |
| 14 class CommandLine; | 13 class CommandLine; |
| 15 } | 14 } |
| 16 | 15 |
| 17 namespace extensions { | 16 namespace extensions { |
| 18 | 17 |
| 19 // A switch that can turn a feature on or off. Typically controlled via | 18 // A switch that can turn a feature on or off. Typically controlled via |
| 20 // command-line switches but can be overridden, e.g., for testing. | 19 // command-line switches but can be overridden, e.g., for testing. |
| 21 // Can also integrate with Finch's field trials. | 20 // Can also integrate with Finch's field trials. |
| 22 // A note about priority: | 21 // A note about priority: |
| 23 // 1. If an override is present, the override state will be used. | 22 // 1. If an override is present, the override state will be used. |
| 24 // 2. If there is no switch name, the default value will be used. This is | 23 // 2. If there is no switch name, the default value will be used. This is |
| 25 // because certain features are specifically designed *not* to be able to | 24 // because certain features are specifically designed *not* to be able to |
| 26 // be turned off via command-line, so we can't consult it (or, by extension, | 25 // be turned off via command-line, so we can't consult it (or, by extension, |
| 27 // the finch config). | 26 // the finch config). |
| 28 // 3. If there is a switch name, and the switch is present in the command line, | 27 // 3. If there is a switch name, and the switch is present in the command line, |
| 29 // the command line value will be used. | 28 // the command line value will be used. |
| 30 // 4. If there are field trials associated with the feature, and the machine | 29 // 4. If there is a finch experiment associated and applicable to the machine, |
| 31 // is in the "Enabled" group for all field trials, then the feature is | 30 // the finch value will be used. |
| 32 // enabled. If the machine is in the "Disabled" group for any field trials, | |
| 33 // the feature is disabled. | |
| 34 // 5. Otherwise, the default value is used. | 31 // 5. Otherwise, the default value is used. |
| 35 class FeatureSwitch { | 32 class FeatureSwitch { |
| 36 public: | 33 public: |
| 37 static FeatureSwitch* easy_off_store_install(); | 34 static FeatureSwitch* easy_off_store_install(); |
| 38 static FeatureSwitch* force_dev_mode_highlighting(); | 35 static FeatureSwitch* force_dev_mode_highlighting(); |
| 39 static FeatureSwitch* prompt_for_external_extensions(); | 36 static FeatureSwitch* prompt_for_external_extensions(); |
| 40 static FeatureSwitch* error_console(); | 37 static FeatureSwitch* error_console(); |
| 41 static FeatureSwitch* enable_override_bookmarks_ui(); | 38 static FeatureSwitch* enable_override_bookmarks_ui(); |
| 42 static FeatureSwitch* extension_action_redesign(); | 39 static FeatureSwitch* extension_action_redesign(); |
| 43 static FeatureSwitch* scripts_require_action(); | 40 static FeatureSwitch* scripts_require_action(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 68 DISALLOW_COPY_AND_ASSIGN(ScopedOverride); | 65 DISALLOW_COPY_AND_ASSIGN(ScopedOverride); |
| 69 }; | 66 }; |
| 70 | 67 |
| 71 // |switch_name| can be null, in which case the feature is controlled solely | 68 // |switch_name| can be null, in which case the feature is controlled solely |
| 72 // by the default and override values. | 69 // by the default and override values. |
| 73 FeatureSwitch(const char* switch_name, | 70 FeatureSwitch(const char* switch_name, |
| 74 DefaultValue default_value); | 71 DefaultValue default_value); |
| 75 FeatureSwitch(const char* switch_name, | 72 FeatureSwitch(const char* switch_name, |
| 76 const char* field_trial_name, | 73 const char* field_trial_name, |
| 77 DefaultValue default_value); | 74 DefaultValue default_value); |
| 78 FeatureSwitch(const char* switch_name, | |
| 79 const std::vector<std::string>& required_field_trials, | |
| 80 DefaultValue default_value); | |
| 81 FeatureSwitch(const base::CommandLine* command_line, | 75 FeatureSwitch(const base::CommandLine* command_line, |
| 82 const char* switch_name, | 76 const char* switch_name, |
| 83 DefaultValue default_value); | 77 DefaultValue default_value); |
| 84 FeatureSwitch(const base::CommandLine* command_line, | 78 FeatureSwitch(const base::CommandLine* command_line, |
| 85 const char* switch_name, | 79 const char* switch_name, |
| 86 const std::vector<std::string>& required_field_trials, | 80 const char* field_trial_name, |
| 87 DefaultValue default_value); | 81 DefaultValue default_value); |
| 88 ~FeatureSwitch(); | |
| 89 | 82 |
| 90 // Consider using ScopedOverride instead. | 83 // Consider using ScopedOverride instead. |
| 91 void SetOverrideValue(OverrideValue value); | 84 void SetOverrideValue(OverrideValue value); |
| 92 OverrideValue GetOverrideValue() const; | 85 OverrideValue GetOverrideValue() const; |
| 93 | 86 |
| 94 bool IsEnabled() const; | 87 bool IsEnabled() const; |
| 95 | 88 |
| 96 private: | 89 private: |
| 97 std::string GetLegacyEnableFlag() const; | 90 std::string GetLegacyEnableFlag() const; |
| 98 std::string GetLegacyDisableFlag() const; | 91 std::string GetLegacyDisableFlag() const; |
| 99 | 92 |
| 100 const base::CommandLine* command_line_; | 93 const base::CommandLine* command_line_; |
| 101 const char* switch_name_; | 94 const char* switch_name_; |
| 102 std::vector<std::string> required_field_trials_; | 95 const char* field_trial_name_; |
| 103 bool default_value_; | 96 bool default_value_; |
| 104 OverrideValue override_value_; | 97 OverrideValue override_value_; |
| 105 | 98 |
| 106 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); | 99 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); |
| 107 }; | 100 }; |
| 108 | 101 |
| 109 } // namespace extensions | 102 } // namespace extensions |
| 110 | 103 |
| 111 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_ | 104 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_ |
| OLD | NEW |