Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: extensions/common/feature_switch.h

Issue 1680823004: [Feature Switch][Media Router] Add required field trials to MR switch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
9 10
10 #include "base/macros.h" 11 #include "base/macros.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.
21 // A note about priority: 22 // A note about priority:
22 // 1. If an override is present, the override state will be used. 23 // 1. If an override is present, the override state will be used.
23 // 2. If there is no switch name, the default value will be used. This is 24 // 2. If there is no switch name, the default value will be used. This is
24 // because certain features are specifically designed *not* to be able to 25 // because certain features are specifically designed *not* to be able to
25 // be turned off via command-line, so we can't consult it (or, by extension, 26 // be turned off via command-line, so we can't consult it (or, by extension,
26 // the finch config). 27 // the finch config).
27 // 3. If there is a switch name, and the switch is present in the command line, 28 // 3. If there is a switch name, and the switch is present in the command line,
28 // the command line value will be used. 29 // the command line value will be used.
29 // 4. If there is a finch experiment associated and applicable to the machine, 30 // 4. If there is a finch experiment associated and applicable to the machine,
30 // the finch value will be used. 31 // the finch value will be used. In order for the feature to be enabled by
32 // finch experiment, the machine must be in the "Enabled" group for the
33 // experiment and all dependent experiments.
31 // 5. Otherwise, the default value is used. 34 // 5. Otherwise, the default value is used.
32 class FeatureSwitch { 35 class FeatureSwitch {
33 public: 36 public:
34 static FeatureSwitch* easy_off_store_install(); 37 static FeatureSwitch* easy_off_store_install();
35 static FeatureSwitch* force_dev_mode_highlighting(); 38 static FeatureSwitch* force_dev_mode_highlighting();
36 static FeatureSwitch* prompt_for_external_extensions(); 39 static FeatureSwitch* prompt_for_external_extensions();
37 static FeatureSwitch* error_console(); 40 static FeatureSwitch* error_console();
38 static FeatureSwitch* enable_override_bookmarks_ui(); 41 static FeatureSwitch* enable_override_bookmarks_ui();
39 static FeatureSwitch* extension_action_redesign(); 42 static FeatureSwitch* extension_action_redesign();
40 static FeatureSwitch* scripts_require_action(); 43 static FeatureSwitch* scripts_require_action();
(...skipping 24 matching lines...) Expand all
65 DISALLOW_COPY_AND_ASSIGN(ScopedOverride); 68 DISALLOW_COPY_AND_ASSIGN(ScopedOverride);
66 }; 69 };
67 70
68 // |switch_name| can be null, in which case the feature is controlled solely 71 // |switch_name| can be null, in which case the feature is controlled solely
69 // by the default and override values. 72 // by the default and override values.
70 FeatureSwitch(const char* switch_name, 73 FeatureSwitch(const char* switch_name,
71 DefaultValue default_value); 74 DefaultValue default_value);
72 FeatureSwitch(const char* switch_name, 75 FeatureSwitch(const char* switch_name,
73 const char* field_trial_name, 76 const char* field_trial_name,
74 DefaultValue default_value); 77 DefaultValue default_value);
78 FeatureSwitch(const char* switch_name,
79 const char* field_trial_name,
80 const std::vector<const char*>& dependent_field_trials,
Devlin 2016/02/09 18:45:14 "dependent" is the wrong word here - it should pro
imcheng 2016/02/09 21:35:39 Done.
81 DefaultValue default_value);
75 FeatureSwitch(const base::CommandLine* command_line, 82 FeatureSwitch(const base::CommandLine* command_line,
76 const char* switch_name, 83 const char* switch_name,
77 DefaultValue default_value); 84 DefaultValue default_value);
78 FeatureSwitch(const base::CommandLine* command_line, 85 FeatureSwitch(const base::CommandLine* command_line,
79 const char* switch_name, 86 const char* switch_name,
80 const char* field_trial_name, 87 const char* field_trial_name,
88 const std::vector<const char*>& dependent_field_trials,
81 DefaultValue default_value); 89 DefaultValue default_value);
90 ~FeatureSwitch();
82 91
83 // Consider using ScopedOverride instead. 92 // Consider using ScopedOverride instead.
84 void SetOverrideValue(OverrideValue value); 93 void SetOverrideValue(OverrideValue value);
85 OverrideValue GetOverrideValue() const; 94 OverrideValue GetOverrideValue() const;
86 95
87 bool IsEnabled() const; 96 bool IsEnabled() const;
88 97
89 private: 98 private:
90 std::string GetLegacyEnableFlag() const; 99 std::string GetLegacyEnableFlag() const;
91 std::string GetLegacyDisableFlag() const; 100 std::string GetLegacyDisableFlag() const;
101 bool DependentFieldTrialsEnabled() const;
92 102
93 const base::CommandLine* command_line_; 103 const base::CommandLine* command_line_;
94 const char* switch_name_; 104 const char* switch_name_;
95 const char* field_trial_name_; 105 const char* field_trial_name_;
106 std::vector<const char*> dependent_field_trials_;
Devlin 2016/02/09 18:45:14 this should probably just be std::vector<std::stri
imcheng 2016/02/09 21:35:39 Done.
96 bool default_value_; 107 bool default_value_;
97 OverrideValue override_value_; 108 OverrideValue override_value_;
98 109
99 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch); 110 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch);
100 }; 111 };
101 112
102 } // namespace extensions 113 } // namespace extensions
103 114
104 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_ 115 #endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698