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

Side by Side Diff: chrome/browser/about_flags.cc

Issue 1159433002: Switch nomenclature in about_flags.cc to not use "Experiments". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 7 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
« no previous file with comments | « chrome/browser/about_flags.h ('k') | chrome/browser/about_flags_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/about_flags.h" 5 #include "chrome/browser/about_flags.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #endif 70 #endif
71 71
72 #if defined(USE_OZONE) 72 #if defined(USE_OZONE)
73 #include "ui/ozone/public/ozone_switches.h" 73 #include "ui/ozone/public/ozone_switches.h"
74 #endif 74 #endif
75 75
76 namespace about_flags { 76 namespace about_flags {
77 77
78 // Macros to simplify specifying the type. 78 // Macros to simplify specifying the type.
79 #define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \ 79 #define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
80 Experiment::SINGLE_VALUE, \ 80 Entry::SINGLE_VALUE, \
81 command_line_switch, switch_value, NULL, NULL, NULL, 0 81 command_line_switch, switch_value, NULL, NULL, NULL, 0
82 #define SINGLE_VALUE_TYPE(command_line_switch) \ 82 #define SINGLE_VALUE_TYPE(command_line_switch) \
83 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "") 83 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
84 #define ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(enable_switch, enable_value, \ 84 #define ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(enable_switch, enable_value, \
85 disable_switch, disable_value) \ 85 disable_switch, disable_value) \
86 Experiment::ENABLE_DISABLE_VALUE, enable_switch, enable_value, \ 86 Entry::ENABLE_DISABLE_VALUE, enable_switch, enable_value, \
87 disable_switch, disable_value, NULL, 3 87 disable_switch, disable_value, NULL, 3
88 #define ENABLE_DISABLE_VALUE_TYPE(enable_switch, disable_switch) \ 88 #define ENABLE_DISABLE_VALUE_TYPE(enable_switch, disable_switch) \
89 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(enable_switch, "", disable_switch, "") 89 ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(enable_switch, "", disable_switch, "")
90 #define MULTI_VALUE_TYPE(choices) \ 90 #define MULTI_VALUE_TYPE(choices) \
91 Experiment::MULTI_VALUE, NULL, NULL, NULL, NULL, choices, arraysize(choices) 91 Entry::MULTI_VALUE, NULL, NULL, NULL, NULL, choices, arraysize(choices)
92 92
93 namespace { 93 namespace {
94 94
95 // Enumeration of OSs. 95 // Enumeration of OSs.
96 enum { 96 enum {
97 kOsMac = 1 << 0, 97 kOsMac = 1 << 0,
98 kOsWin = 1 << 1, 98 kOsWin = 1 << 1,
99 kOsLinux = 1 << 2, 99 kOsLinux = 1 << 2,
100 kOsCrOS = 1 << 3, 100 kOsCrOS = 1 << 3,
101 kOsAndroid = 1 << 4, 101 kOsAndroid = 1 << 4,
102 kOsCrOSOwnerOnly = 1 << 5 102 kOsCrOSOwnerOnly = 1 << 5
103 }; 103 };
104 104
105 const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS | kOsAndroid; 105 const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS | kOsAndroid;
106 const unsigned kOsDesktop = kOsMac | kOsWin | kOsLinux | kOsCrOS; 106 const unsigned kOsDesktop = kOsMac | kOsWin | kOsLinux | kOsCrOS;
107 107
108 // Adds a |StringValue| to |list| for each platform where |bitmask| indicates 108 // Adds a |StringValue| to |list| for each platform where |bitmask| indicates
109 // whether the experiment is available on that platform. 109 // whether the entry is available on that platform.
110 void AddOsStrings(unsigned bitmask, base::ListValue* list) { 110 void AddOsStrings(unsigned bitmask, base::ListValue* list) {
111 struct { 111 struct {
112 unsigned bit; 112 unsigned bit;
113 const char* const name; 113 const char* const name;
114 } kBitsToOs[] = { 114 } kBitsToOs[] = {
115 {kOsMac, "Mac"}, 115 {kOsMac, "Mac"},
116 {kOsWin, "Windows"}, 116 {kOsWin, "Windows"},
117 {kOsLinux, "Linux"}, 117 {kOsLinux, "Linux"},
118 {kOsCrOS, "Chrome OS"}, 118 {kOsCrOS, "Chrome OS"},
119 {kOsAndroid, "Android"}, 119 {kOsAndroid, "Android"},
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 first = std::find(cmdline.argv().begin(), cmdline.argv().end(), 151 first = std::find(cmdline.argv().begin(), cmdline.argv().end(),
152 GetSwitchString(chromeos::switches::kPolicySwitchesBegin)); 152 GetSwitchString(chromeos::switches::kPolicySwitchesBegin));
153 last = std::find(cmdline.argv().begin(), cmdline.argv().end(), 153 last = std::find(cmdline.argv().begin(), cmdline.argv().end(),
154 GetSwitchString(chromeos::switches::kPolicySwitchesEnd)); 154 GetSwitchString(chromeos::switches::kPolicySwitchesEnd));
155 if (first != cmdline.argv().end() && last != cmdline.argv().end()) 155 if (first != cmdline.argv().end() && last != cmdline.argv().end())
156 flags.insert(first + 1, last); 156 flags.insert(first + 1, last);
157 #endif 157 #endif
158 return flags; 158 return flags;
159 } 159 }
160 160
161 const Experiment::Choice kTouchEventsChoices[] = { 161 const Entry::Choice kTouchEventsChoices[] = {
162 { IDS_GENERIC_EXPERIMENT_CHOICE_AUTOMATIC, "", "" }, 162 { IDS_GENERIC_EXPERIMENT_CHOICE_AUTOMATIC, "", "" },
163 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, 163 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
164 switches::kTouchEvents, 164 switches::kTouchEvents,
165 switches::kTouchEventsEnabled }, 165 switches::kTouchEventsEnabled },
166 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 166 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
167 switches::kTouchEvents, 167 switches::kTouchEvents,
168 switches::kTouchEventsDisabled } 168 switches::kTouchEventsDisabled }
169 }; 169 };
170 170
171 #if defined(USE_AURA) 171 #if defined(USE_AURA)
172 const Experiment::Choice kOverscrollHistoryNavigationChoices[] = { 172 const Entry::Choice kOverscrollHistoryNavigationChoices[] = {
173 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, "", "" }, 173 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, "", "" },
174 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 174 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
175 switches::kOverscrollHistoryNavigation, 175 switches::kOverscrollHistoryNavigation,
176 "0" }, 176 "0" },
177 { IDS_OVERSCROLL_HISTORY_NAVIGATION_SIMPLE_UI, 177 { IDS_OVERSCROLL_HISTORY_NAVIGATION_SIMPLE_UI,
178 switches::kOverscrollHistoryNavigation, 178 switches::kOverscrollHistoryNavigation,
179 "2" } 179 "2" }
180 }; 180 };
181 #endif 181 #endif
182 182
183 const Experiment::Choice kTouchTextSelectionStrategyChoices[] = { 183 const Entry::Choice kTouchTextSelectionStrategyChoices[] = {
184 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 184 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
185 { IDS_TOUCH_SELECTION_STRATEGY_CHARACTER, 185 { IDS_TOUCH_SELECTION_STRATEGY_CHARACTER,
186 switches::kTouchTextSelectionStrategy, 186 switches::kTouchTextSelectionStrategy,
187 "character" }, 187 "character" },
188 { IDS_TOUCH_SELECTION_STRATEGY_DIRECTION, 188 { IDS_TOUCH_SELECTION_STRATEGY_DIRECTION,
189 switches::kTouchTextSelectionStrategy, 189 switches::kTouchTextSelectionStrategy,
190 "direction" } 190 "direction" }
191 }; 191 };
192 192
193 #if !defined(DISABLE_NACL) 193 #if !defined(DISABLE_NACL)
194 const Experiment::Choice kNaClDebugMaskChoices[] = { 194 const Entry::Choice kNaClDebugMaskChoices[] = {
195 // Secure shell can be used on ChromeOS for forwarding the TCP port opened by 195 // Secure shell can be used on ChromeOS for forwarding the TCP port opened by
196 // debug stub to a remote machine. Since secure shell uses NaCl, we usually 196 // debug stub to a remote machine. Since secure shell uses NaCl, we usually
197 // want to avoid debugging that. The PNaCl translator is also a NaCl module, 197 // want to avoid debugging that. The PNaCl translator is also a NaCl module,
198 // so by default we want to avoid debugging that. 198 // so by default we want to avoid debugging that.
199 // NOTE: As the default value must be the empty string, the mask excluding 199 // NOTE: As the default value must be the empty string, the mask excluding
200 // the PNaCl translator and secure shell is substituted elsewhere. 200 // the PNaCl translator and secure shell is substituted elsewhere.
201 { IDS_NACL_DEBUG_MASK_CHOICE_EXCLUDE_UTILS_PNACL, "", "" }, 201 { IDS_NACL_DEBUG_MASK_CHOICE_EXCLUDE_UTILS_PNACL, "", "" },
202 { IDS_NACL_DEBUG_MASK_CHOICE_DEBUG_ALL, switches::kNaClDebugMask, "*://*" }, 202 { IDS_NACL_DEBUG_MASK_CHOICE_DEBUG_ALL, switches::kNaClDebugMask, "*://*" },
203 { IDS_NACL_DEBUG_MASK_CHOICE_INCLUDE_DEBUG, 203 { IDS_NACL_DEBUG_MASK_CHOICE_INCLUDE_DEBUG,
204 switches::kNaClDebugMask, "*://*/*debug.nmf" } 204 switches::kNaClDebugMask, "*://*/*debug.nmf" }
205 }; 205 };
206 #endif 206 #endif
207 207
208 const Experiment::Choice kMarkNonSecureAsChoices[] = { 208 const Entry::Choice kMarkNonSecureAsChoices[] = {
209 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 209 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
210 { IDS_MARK_NON_SECURE_AS_NEUTRAL, 210 { IDS_MARK_NON_SECURE_AS_NEUTRAL,
211 switches::kMarkNonSecureAs, switches::kMarkNonSecureAsNeutral}, 211 switches::kMarkNonSecureAs, switches::kMarkNonSecureAsNeutral},
212 { IDS_MARK_NON_SECURE_AS_NON_SECURE, 212 { IDS_MARK_NON_SECURE_AS_NON_SECURE,
213 switches::kMarkNonSecureAs, switches::kMarkNonSecureAsNonSecure}, 213 switches::kMarkNonSecureAs, switches::kMarkNonSecureAsNonSecure},
214 { IDS_MARK_NON_SECURE_AS_DUBIOUS, 214 { IDS_MARK_NON_SECURE_AS_DUBIOUS,
215 switches::kMarkNonSecureAs, switches::kMarkNonSecureAsDubious} 215 switches::kMarkNonSecureAs, switches::kMarkNonSecureAsDubious}
216 }; 216 };
217 217
218 const Experiment::Choice kShowSavedCopyChoices[] = { 218 const Entry::Choice kShowSavedCopyChoices[] = {
219 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 219 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
220 { IDS_FLAGS_ENABLE_SHOW_SAVED_COPY_PRIMARY, 220 { IDS_FLAGS_ENABLE_SHOW_SAVED_COPY_PRIMARY,
221 switches::kShowSavedCopy, switches::kEnableShowSavedCopyPrimary }, 221 switches::kShowSavedCopy, switches::kEnableShowSavedCopyPrimary },
222 { IDS_FLAGS_ENABLE_SHOW_SAVED_COPY_SECONDARY, 222 { IDS_FLAGS_ENABLE_SHOW_SAVED_COPY_SECONDARY,
223 switches::kShowSavedCopy, switches::kEnableShowSavedCopySecondary }, 223 switches::kShowSavedCopy, switches::kEnableShowSavedCopySecondary },
224 { IDS_FLAGS_DISABLE_SHOW_SAVED_COPY, 224 { IDS_FLAGS_DISABLE_SHOW_SAVED_COPY,
225 switches::kShowSavedCopy, switches::kDisableShowSavedCopy } 225 switches::kShowSavedCopy, switches::kDisableShowSavedCopy }
226 }; 226 };
227 227
228 const Experiment::Choice kDefaultTileWidthChoices[] = { 228 const Entry::Choice kDefaultTileWidthChoices[] = {
229 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 229 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
230 { IDS_FLAGS_DEFAULT_TILE_WIDTH_SHORT, 230 { IDS_FLAGS_DEFAULT_TILE_WIDTH_SHORT,
231 switches::kDefaultTileWidth, "128"}, 231 switches::kDefaultTileWidth, "128"},
232 { IDS_FLAGS_DEFAULT_TILE_WIDTH_TALL, 232 { IDS_FLAGS_DEFAULT_TILE_WIDTH_TALL,
233 switches::kDefaultTileWidth, "256"}, 233 switches::kDefaultTileWidth, "256"},
234 { IDS_FLAGS_DEFAULT_TILE_WIDTH_GRANDE, 234 { IDS_FLAGS_DEFAULT_TILE_WIDTH_GRANDE,
235 switches::kDefaultTileWidth, "512"}, 235 switches::kDefaultTileWidth, "512"},
236 { IDS_FLAGS_DEFAULT_TILE_WIDTH_VENTI, 236 { IDS_FLAGS_DEFAULT_TILE_WIDTH_VENTI,
237 switches::kDefaultTileWidth, "1024"} 237 switches::kDefaultTileWidth, "1024"}
238 }; 238 };
239 239
240 const Experiment::Choice kDefaultTileHeightChoices[] = { 240 const Entry::Choice kDefaultTileHeightChoices[] = {
241 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 241 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
242 { IDS_FLAGS_DEFAULT_TILE_HEIGHT_SHORT, 242 { IDS_FLAGS_DEFAULT_TILE_HEIGHT_SHORT,
243 switches::kDefaultTileHeight, "128"}, 243 switches::kDefaultTileHeight, "128"},
244 { IDS_FLAGS_DEFAULT_TILE_HEIGHT_TALL, 244 { IDS_FLAGS_DEFAULT_TILE_HEIGHT_TALL,
245 switches::kDefaultTileHeight, "256"}, 245 switches::kDefaultTileHeight, "256"},
246 { IDS_FLAGS_DEFAULT_TILE_HEIGHT_GRANDE, 246 { IDS_FLAGS_DEFAULT_TILE_HEIGHT_GRANDE,
247 switches::kDefaultTileHeight, "512"}, 247 switches::kDefaultTileHeight, "512"},
248 { IDS_FLAGS_DEFAULT_TILE_HEIGHT_VENTI, 248 { IDS_FLAGS_DEFAULT_TILE_HEIGHT_VENTI,
249 switches::kDefaultTileHeight, "1024"} 249 switches::kDefaultTileHeight, "1024"}
250 }; 250 };
251 251
252 const Experiment::Choice kSimpleCacheBackendChoices[] = { 252 const Entry::Choice kSimpleCacheBackendChoices[] = {
253 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 253 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
254 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 254 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
255 switches::kUseSimpleCacheBackend, "off" }, 255 switches::kUseSimpleCacheBackend, "off" },
256 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, 256 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
257 switches::kUseSimpleCacheBackend, "on"} 257 switches::kUseSimpleCacheBackend, "on"}
258 }; 258 };
259 259
260 #if defined(USE_AURA) 260 #if defined(USE_AURA)
261 const Experiment::Choice kTabCaptureUpscaleQualityChoices[] = { 261 const Entry::Choice kTabCaptureUpscaleQualityChoices[] = {
262 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 262 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
263 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_FAST, 263 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_FAST,
264 switches::kTabCaptureUpscaleQuality, "fast" }, 264 switches::kTabCaptureUpscaleQuality, "fast" },
265 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_GOOD, 265 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_GOOD,
266 switches::kTabCaptureUpscaleQuality, "good" }, 266 switches::kTabCaptureUpscaleQuality, "good" },
267 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_BEST, 267 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_BEST,
268 switches::kTabCaptureUpscaleQuality, "best" }, 268 switches::kTabCaptureUpscaleQuality, "best" },
269 }; 269 };
270 270
271 const Experiment::Choice kTabCaptureDownscaleQualityChoices[] = { 271 const Entry::Choice kTabCaptureDownscaleQualityChoices[] = {
272 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 272 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
273 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_FAST, 273 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_FAST,
274 switches::kTabCaptureDownscaleQuality, "fast" }, 274 switches::kTabCaptureDownscaleQuality, "fast" },
275 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_GOOD, 275 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_GOOD,
276 switches::kTabCaptureDownscaleQuality, "good" }, 276 switches::kTabCaptureDownscaleQuality, "good" },
277 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_BEST, 277 { IDS_FLAGS_TAB_CAPTURE_SCALE_QUALITY_BEST,
278 switches::kTabCaptureDownscaleQuality, "best" }, 278 switches::kTabCaptureDownscaleQuality, "best" },
279 }; 279 };
280 #endif 280 #endif
281 281
282 #if defined(OS_ANDROID) 282 #if defined(OS_ANDROID)
283 const Experiment::Choice kZeroSuggestExperimentsChoices[] = { 283 const Entry::Choice kZeroSuggestExperimentsChoices[] = {
284 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 284 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
285 { IDS_FLAGS_ZERO_SUGGEST_MOST_VISITED, 285 { IDS_FLAGS_ZERO_SUGGEST_MOST_VISITED,
286 switches::kEnableZeroSuggestMostVisited, ""}, 286 switches::kEnableZeroSuggestMostVisited, ""},
287 { IDS_FLAGS_ZERO_SUGGEST_MOST_VISITED_WITHOUT_SERP, 287 { IDS_FLAGS_ZERO_SUGGEST_MOST_VISITED_WITHOUT_SERP,
288 switches::kEnableZeroSuggestMostVisitedWithoutSerp, ""}, 288 switches::kEnableZeroSuggestMostVisitedWithoutSerp, ""},
289 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 289 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
290 switches::kDisableZeroSuggest, ""} 290 switches::kDisableZeroSuggest, ""}
291 }; 291 };
292 292
293 const Experiment::Choice kReaderModeHeuristicsChoices[] = { 293 const Entry::Choice kReaderModeHeuristicsChoices[] = {
294 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", ""}, 294 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", ""},
295 { IDS_FLAGS_READER_MODE_HEURISTICS_MARKUP, 295 { IDS_FLAGS_READER_MODE_HEURISTICS_MARKUP,
296 switches::kReaderModeHeuristics, 296 switches::kReaderModeHeuristics,
297 switches::reader_mode_heuristics::kOGArticle }, 297 switches::reader_mode_heuristics::kOGArticle },
298 { IDS_FLAGS_READER_MODE_HEURISTICS_ADABOOST, 298 { IDS_FLAGS_READER_MODE_HEURISTICS_ADABOOST,
299 switches::kReaderModeHeuristics, 299 switches::kReaderModeHeuristics,
300 switches::reader_mode_heuristics::kAdaBoost }, 300 switches::reader_mode_heuristics::kAdaBoost },
301 { IDS_FLAGS_READER_MODE_HEURISTICS_ALWAYS_ON, 301 { IDS_FLAGS_READER_MODE_HEURISTICS_ALWAYS_ON,
302 switches::kReaderModeHeuristics, 302 switches::kReaderModeHeuristics,
303 switches::reader_mode_heuristics::kAlwaysTrue }, 303 switches::reader_mode_heuristics::kAlwaysTrue },
304 { IDS_FLAGS_READER_MODE_HEURISTICS_ALWAYS_OFF, 304 { IDS_FLAGS_READER_MODE_HEURISTICS_ALWAYS_OFF,
305 switches::kReaderModeHeuristics, 305 switches::kReaderModeHeuristics,
306 switches::reader_mode_heuristics::kNone }, 306 switches::reader_mode_heuristics::kNone },
307 }; 307 };
308 #endif 308 #endif
309 309
310 const Experiment::Choice kNumRasterThreadsChoices[] = { 310 const Entry::Choice kNumRasterThreadsChoices[] = {
311 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 311 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
312 { IDS_FLAGS_NUM_RASTER_THREADS_ONE, switches::kNumRasterThreads, "1" }, 312 { IDS_FLAGS_NUM_RASTER_THREADS_ONE, switches::kNumRasterThreads, "1" },
313 { IDS_FLAGS_NUM_RASTER_THREADS_TWO, switches::kNumRasterThreads, "2" }, 313 { IDS_FLAGS_NUM_RASTER_THREADS_TWO, switches::kNumRasterThreads, "2" },
314 { IDS_FLAGS_NUM_RASTER_THREADS_THREE, switches::kNumRasterThreads, "3" }, 314 { IDS_FLAGS_NUM_RASTER_THREADS_THREE, switches::kNumRasterThreads, "3" },
315 { IDS_FLAGS_NUM_RASTER_THREADS_FOUR, switches::kNumRasterThreads, "4" } 315 { IDS_FLAGS_NUM_RASTER_THREADS_FOUR, switches::kNumRasterThreads, "4" }
316 }; 316 };
317 317
318 const Experiment::Choice kGpuRasterizationMSAASampleCountChoices[] = { 318 const Entry::Choice kGpuRasterizationMSAASampleCountChoices[] = {
319 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, 319 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT,
320 "", 320 "",
321 "" }, 321 "" },
322 { IDS_FLAGS_GPU_RASTERIZATION_MSAA_SAMPLE_COUNT_ZERO, 322 { IDS_FLAGS_GPU_RASTERIZATION_MSAA_SAMPLE_COUNT_ZERO,
323 switches::kGpuRasterizationMSAASampleCount, "0" }, 323 switches::kGpuRasterizationMSAASampleCount, "0" },
324 { IDS_FLAGS_GPU_RASTERIZATION_MSAA_SAMPLE_COUNT_TWO, 324 { IDS_FLAGS_GPU_RASTERIZATION_MSAA_SAMPLE_COUNT_TWO,
325 switches::kGpuRasterizationMSAASampleCount, "2" }, 325 switches::kGpuRasterizationMSAASampleCount, "2" },
326 { IDS_FLAGS_GPU_RASTERIZATION_MSAA_SAMPLE_COUNT_FOUR, 326 { IDS_FLAGS_GPU_RASTERIZATION_MSAA_SAMPLE_COUNT_FOUR,
327 switches::kGpuRasterizationMSAASampleCount, "4" }, 327 switches::kGpuRasterizationMSAASampleCount, "4" },
328 { IDS_FLAGS_GPU_RASTERIZATION_MSAA_SAMPLE_COUNT_EIGHT, 328 { IDS_FLAGS_GPU_RASTERIZATION_MSAA_SAMPLE_COUNT_EIGHT,
329 switches::kGpuRasterizationMSAASampleCount, "8" }, 329 switches::kGpuRasterizationMSAASampleCount, "8" },
330 { IDS_FLAGS_GPU_RASTERIZATION_MSAA_SAMPLE_COUNT_SIXTEEN, 330 { IDS_FLAGS_GPU_RASTERIZATION_MSAA_SAMPLE_COUNT_SIXTEEN,
331 switches::kGpuRasterizationMSAASampleCount, "16" }, 331 switches::kGpuRasterizationMSAASampleCount, "16" },
332 }; 332 };
333 333
334 const Experiment::Choice kEnableGpuRasterizationChoices[] = { 334 const Entry::Choice kEnableGpuRasterizationChoices[] = {
335 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 335 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
336 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, 336 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
337 switches::kEnableGpuRasterization, "" }, 337 switches::kEnableGpuRasterization, "" },
338 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 338 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
339 switches::kDisableGpuRasterization, "" }, 339 switches::kDisableGpuRasterization, "" },
340 { IDS_FLAGS_FORCE_GPU_RASTERIZATION, 340 { IDS_FLAGS_FORCE_GPU_RASTERIZATION,
341 switches::kForceGpuRasterization, "" }, 341 switches::kForceGpuRasterization, "" },
342 }; 342 };
343 343
344 #if defined(OS_CHROMEOS) 344 #if defined(OS_CHROMEOS)
345 const Experiment::Choice kMemoryPressureThresholdChoices[] = { 345 const Entry::Choice kMemoryPressureThresholdChoices[] = {
346 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 346 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
347 { IDS_FLAGS_CONSERVATIVE_THRESHOLDS, 347 { IDS_FLAGS_CONSERVATIVE_THRESHOLDS,
348 chromeos::switches::kMemoryPressureThresholds, 348 chromeos::switches::kMemoryPressureThresholds,
349 chromeos::switches::kConservativeThreshold }, 349 chromeos::switches::kConservativeThreshold },
350 { IDS_FLAGS_AGGRESSIVE_CACHE_DISCARD_THRESHOLDS, 350 { IDS_FLAGS_AGGRESSIVE_CACHE_DISCARD_THRESHOLDS,
351 chromeos::switches::kMemoryPressureThresholds, 351 chromeos::switches::kMemoryPressureThresholds,
352 chromeos::switches::kAggressiveCacheDiscardThreshold }, 352 chromeos::switches::kAggressiveCacheDiscardThreshold },
353 { IDS_FLAGS_AGGRESSIVE_TAB_DISCARD_THRESHOLDS, 353 { IDS_FLAGS_AGGRESSIVE_TAB_DISCARD_THRESHOLDS,
354 chromeos::switches::kMemoryPressureThresholds, 354 chromeos::switches::kMemoryPressureThresholds,
355 chromeos::switches::kAggressiveTabDiscardThreshold }, 355 chromeos::switches::kAggressiveTabDiscardThreshold },
356 { IDS_FLAGS_AGGRESSIVE_THRESHOLDS, 356 { IDS_FLAGS_AGGRESSIVE_THRESHOLDS,
357 chromeos::switches::kMemoryPressureThresholds, 357 chromeos::switches::kMemoryPressureThresholds,
358 chromeos::switches::kAggressiveThreshold }, 358 chromeos::switches::kAggressiveThreshold },
359 }; 359 };
360 #endif 360 #endif
361 361
362 const Experiment::Choice kExtensionContentVerificationChoices[] = { 362 const Entry::Choice kExtensionContentVerificationChoices[] = {
363 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 363 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
364 { IDS_FLAGS_EXTENSION_CONTENT_VERIFICATION_BOOTSTRAP, 364 { IDS_FLAGS_EXTENSION_CONTENT_VERIFICATION_BOOTSTRAP,
365 switches::kExtensionContentVerification, 365 switches::kExtensionContentVerification,
366 switches::kExtensionContentVerificationBootstrap }, 366 switches::kExtensionContentVerificationBootstrap },
367 { IDS_FLAGS_EXTENSION_CONTENT_VERIFICATION_ENFORCE, 367 { IDS_FLAGS_EXTENSION_CONTENT_VERIFICATION_ENFORCE,
368 switches::kExtensionContentVerification, 368 switches::kExtensionContentVerification,
369 switches::kExtensionContentVerificationEnforce }, 369 switches::kExtensionContentVerificationEnforce },
370 { IDS_FLAGS_EXTENSION_CONTENT_VERIFICATION_ENFORCE_STRICT, 370 { IDS_FLAGS_EXTENSION_CONTENT_VERIFICATION_ENFORCE_STRICT,
371 switches::kExtensionContentVerification, 371 switches::kExtensionContentVerification,
372 switches::kExtensionContentVerificationEnforceStrict }, 372 switches::kExtensionContentVerificationEnforceStrict },
373 }; 373 };
374 374
375 // Note that the value is specified in seconds (where 0 is equivalent to 375 // Note that the value is specified in seconds (where 0 is equivalent to
376 // disabled). 376 // disabled).
377 const Experiment::Choice kRememberCertificateErrorDecisionsChoices[] = { 377 const Entry::Choice kRememberCertificateErrorDecisionsChoices[] = {
378 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 378 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
379 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 379 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
380 switches::kRememberCertErrorDecisions, 380 switches::kRememberCertErrorDecisions,
381 "-1" }, 381 "-1" },
382 { IDS_REMEMBER_CERTIFICATE_ERROR_DECISION_CHOICE_ONE_DAY, 382 { IDS_REMEMBER_CERTIFICATE_ERROR_DECISION_CHOICE_ONE_DAY,
383 switches::kRememberCertErrorDecisions, 383 switches::kRememberCertErrorDecisions,
384 "86400" }, 384 "86400" },
385 { IDS_REMEMBER_CERTIFICATE_ERROR_DECISION_CHOICE_THREE_DAYS, 385 { IDS_REMEMBER_CERTIFICATE_ERROR_DECISION_CHOICE_THREE_DAYS,
386 switches::kRememberCertErrorDecisions, 386 switches::kRememberCertErrorDecisions,
387 "259200" }, 387 "259200" },
388 { IDS_REMEMBER_CERTIFICATE_ERROR_DECISION_CHOICE_ONE_WEEK, 388 { IDS_REMEMBER_CERTIFICATE_ERROR_DECISION_CHOICE_ONE_WEEK,
389 switches::kRememberCertErrorDecisions, 389 switches::kRememberCertErrorDecisions,
390 "604800" }, 390 "604800" },
391 { IDS_REMEMBER_CERTIFICATE_ERROR_DECISION_CHOICE_ONE_MONTH, 391 { IDS_REMEMBER_CERTIFICATE_ERROR_DECISION_CHOICE_ONE_MONTH,
392 switches::kRememberCertErrorDecisions, 392 switches::kRememberCertErrorDecisions,
393 "2592000" }, 393 "2592000" },
394 { IDS_REMEMBER_CERTIFICATE_ERROR_DECISION_CHOICE_THREE_MONTHS, 394 { IDS_REMEMBER_CERTIFICATE_ERROR_DECISION_CHOICE_THREE_MONTHS,
395 switches::kRememberCertErrorDecisions, 395 switches::kRememberCertErrorDecisions,
396 "7776000" }, 396 "7776000" },
397 }; 397 };
398 398
399 const Experiment::Choice kAutofillSyncCredentialChoices[] = { 399 const Entry::Choice kAutofillSyncCredentialChoices[] = {
400 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", ""}, 400 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", ""},
401 { IDS_ALLOW_AUTOFILL_SYNC_CREDENTIAL, 401 { IDS_ALLOW_AUTOFILL_SYNC_CREDENTIAL,
402 password_manager::switches::kAllowAutofillSyncCredential, ""}, 402 password_manager::switches::kAllowAutofillSyncCredential, ""},
403 { IDS_DISALLOW_AUTOFILL_SYNC_CREDENTIAL_FOR_REAUTH, 403 { IDS_DISALLOW_AUTOFILL_SYNC_CREDENTIAL_FOR_REAUTH,
404 password_manager::switches::kDisallowAutofillSyncCredentialForReauth, ""}, 404 password_manager::switches::kDisallowAutofillSyncCredentialForReauth, ""},
405 { IDS_DISALLOW_AUTOFILL_SYNC_CREDENTIAL, 405 { IDS_DISALLOW_AUTOFILL_SYNC_CREDENTIAL,
406 password_manager::switches::kDisallowAutofillSyncCredential, ""}, 406 password_manager::switches::kDisallowAutofillSyncCredential, ""},
407 }; 407 };
408 408
409 const Experiment::Choice kSSLVersionMinChoices[] = { 409 const Entry::Choice kSSLVersionMinChoices[] = {
410 { IDS_FLAGS_SSL_VERSION_DEFAULT, "", "" }, 410 { IDS_FLAGS_SSL_VERSION_DEFAULT, "", "" },
411 { IDS_FLAGS_SSL_VERSION_TLSV1, switches::kSSLVersionMin, 411 { IDS_FLAGS_SSL_VERSION_TLSV1, switches::kSSLVersionMin,
412 switches::kSSLVersionTLSv1 }, 412 switches::kSSLVersionTLSv1 },
413 { IDS_FLAGS_SSL_VERSION_TLSV11, switches::kSSLVersionMin, 413 { IDS_FLAGS_SSL_VERSION_TLSV11, switches::kSSLVersionMin,
414 switches::kSSLVersionTLSv11 }, 414 switches::kSSLVersionTLSv11 },
415 { IDS_FLAGS_SSL_VERSION_TLSV12, switches::kSSLVersionMin, 415 { IDS_FLAGS_SSL_VERSION_TLSV12, switches::kSSLVersionMin,
416 switches::kSSLVersionTLSv12 }, 416 switches::kSSLVersionTLSv12 },
417 }; 417 };
418 418
419 const Experiment::Choice kFillOnAccountSelectChoices[] = { 419 const Entry::Choice kFillOnAccountSelectChoices[] = {
420 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 420 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
421 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 421 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
422 autofill::switches::kDisableFillOnAccountSelect, "" }, 422 autofill::switches::kDisableFillOnAccountSelect, "" },
423 { IDS_FLAGS_FILL_ON_ACCOUNT_SELECT_ENABLE_HIGHLIGHTING, 423 { IDS_FLAGS_FILL_ON_ACCOUNT_SELECT_ENABLE_HIGHLIGHTING,
424 autofill::switches::kEnableFillOnAccountSelect, "" }, 424 autofill::switches::kEnableFillOnAccountSelect, "" },
425 { IDS_FLAGS_FILL_ON_ACCOUNT_SELECT_ENABLE_NO_HIGHLIGHTING, 425 { IDS_FLAGS_FILL_ON_ACCOUNT_SELECT_ENABLE_NO_HIGHLIGHTING,
426 autofill::switches::kEnableFillOnAccountSelectNoHighlighting, "" }, 426 autofill::switches::kEnableFillOnAccountSelectNoHighlighting, "" },
427 }; 427 };
428 428
429 #if defined(USE_ASH) 429 #if defined(USE_ASH)
430 const Experiment::Choice kAshScreenRotationAnimationChoices[] = { 430 const Entry::Choice kAshScreenRotationAnimationChoices[] = {
431 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 431 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
432 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 432 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
433 ash::switches::kAshEnableScreenRotationAnimation, 433 ash::switches::kAshEnableScreenRotationAnimation,
434 "none" }, 434 "none" },
435 { IDS_ASH_SCREEN_ROTATION_ANIMATION_PARTIAL_ROTATION, 435 { IDS_ASH_SCREEN_ROTATION_ANIMATION_PARTIAL_ROTATION,
436 ash::switches::kAshEnableScreenRotationAnimation, 436 ash::switches::kAshEnableScreenRotationAnimation,
437 "partial-rotation" }, 437 "partial-rotation" },
438 { IDS_ASH_SCREEN_ROTATION_ANIMATION_FULL_ROTATION, 438 { IDS_ASH_SCREEN_ROTATION_ANIMATION_FULL_ROTATION,
439 ash::switches::kAshEnableScreenRotationAnimation, 439 ash::switches::kAshEnableScreenRotationAnimation,
440 "full-rotation" } 440 "full-rotation" }
441 }; 441 };
442 #endif 442 #endif
443 443
444 #if defined(OS_CHROMEOS) 444 #if defined(OS_CHROMEOS)
445 const Experiment::Choice kDataSaverPromptChoices[] = { 445 const Entry::Choice kDataSaverPromptChoices[] = {
446 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 446 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
447 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 447 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
448 chromeos::switches::kDisableDataSaverPrompt, "" }, 448 chromeos::switches::kDisableDataSaverPrompt, "" },
449 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, 449 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
450 chromeos::switches::kEnableDataSaverPrompt, "" }, 450 chromeos::switches::kEnableDataSaverPrompt, "" },
451 { IDS_FLAGS_DATASAVER_PROMPT_DEMO_MODE, 451 { IDS_FLAGS_DATASAVER_PROMPT_DEMO_MODE,
452 chromeos::switches::kEnableDataSaverPrompt, 452 chromeos::switches::kEnableDataSaverPrompt,
453 chromeos::switches::kDataSaverPromptDemoMode }, 453 chromeos::switches::kDataSaverPromptDemoMode },
454 }; 454 };
455 455
456 const Experiment::Choice kFloatingVirtualKeyboardChoices[] = { 456 const Entry::Choice kFloatingVirtualKeyboardChoices[] = {
457 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 457 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
458 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 458 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
459 keyboard::switches::kFloatingVirtualKeyboard, 459 keyboard::switches::kFloatingVirtualKeyboard,
460 keyboard::switches::kFloatingVirtualKeyboardDisabled}, 460 keyboard::switches::kFloatingVirtualKeyboardDisabled},
461 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, 461 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
462 keyboard::switches::kFloatingVirtualKeyboard, 462 keyboard::switches::kFloatingVirtualKeyboard,
463 keyboard::switches::kFloatingVirtualKeyboardEnabled}, 463 keyboard::switches::kFloatingVirtualKeyboardEnabled},
464 }; 464 };
465 465
466 const Experiment::Choice kGestureTypingChoices[] = { 466 const Entry::Choice kGestureTypingChoices[] = {
467 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 467 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
468 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 468 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
469 keyboard::switches::kGestureTyping, 469 keyboard::switches::kGestureTyping,
470 keyboard::switches::kGestureTypingDisabled}, 470 keyboard::switches::kGestureTypingDisabled},
471 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, 471 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
472 keyboard::switches::kGestureTyping, 472 keyboard::switches::kGestureTyping,
473 keyboard::switches::kGestureTypingEnabled}, 473 keyboard::switches::kGestureTypingEnabled},
474 }; 474 };
475 475
476 const Experiment::Choice kGestureEditingChoices[] = { 476 const Entry::Choice kGestureEditingChoices[] = {
477 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 477 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
478 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 478 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
479 keyboard::switches::kGestureEditing, 479 keyboard::switches::kGestureEditing,
480 keyboard::switches::kGestureEditingDisabled}, 480 keyboard::switches::kGestureEditingDisabled},
481 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, 481 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
482 keyboard::switches::kGestureEditing, 482 keyboard::switches::kGestureEditing,
483 keyboard::switches::kGestureEditingEnabled}, 483 keyboard::switches::kGestureEditingEnabled},
484 }; 484 };
485 #endif 485 #endif
486 486
487 const Experiment::Choice kSupervisedUserSafeSitesChoices[] = { 487 const Entry::Choice kSupervisedUserSafeSitesChoices[] = {
488 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" }, 488 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
489 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, 489 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
490 switches::kSupervisedUserSafeSites, 490 switches::kSupervisedUserSafeSites,
491 "enabled" }, 491 "enabled" },
492 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 492 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
493 switches::kSupervisedUserSafeSites, 493 switches::kSupervisedUserSafeSites,
494 "disabled" }, 494 "disabled" },
495 { IDS_SUPERVISED_USER_SAFESITES_BLACKLIST_ONLY, 495 { IDS_SUPERVISED_USER_SAFESITES_BLACKLIST_ONLY,
496 switches::kSupervisedUserSafeSites, 496 switches::kSupervisedUserSafeSites,
497 "blacklist-only" }, 497 "blacklist-only" },
498 { IDS_SUPERVISED_USER_SAFESITES_ONLINE_CHECK_ONLY, 498 { IDS_SUPERVISED_USER_SAFESITES_ONLINE_CHECK_ONLY,
499 switches::kSupervisedUserSafeSites, 499 switches::kSupervisedUserSafeSites,
500 "online-check-only" } 500 "online-check-only" }
501 }; 501 };
502 502
503 // RECORDING USER METRICS FOR FLAGS: 503 // RECORDING USER METRICS FOR FLAGS:
504 // ----------------------------------------------------------------------------- 504 // -----------------------------------------------------------------------------
505 // The first line of the experiment is the internal name. If you'd like to 505 // The first line of the entry is the internal name. If you'd like to gather
506 // gather statistics about the usage of your flag, you should append a marker 506 // statistics about the usage of your flag, you should append a marker comment
507 // comment to the end of the feature name, like so: 507 // to the end of the feature name, like so:
508 // "my-special-feature", // FLAGS:RECORD_UMA 508 // "my-special-feature", // FLAGS:RECORD_UMA
509 // 509 //
510 // After doing that, run 510 // After doing that, run
511 // tools/metrics/actions/extract_actions.py 511 // tools/metrics/actions/extract_actions.py
512 // to add the metric to actions.xml (which will enable UMA to record your 512 // to add the metric to actions.xml (which will enable UMA to record your
513 // feature flag), then update the <owner>s and <description> sections. Make sure 513 // feature flag), then update the <owner>s and <description> sections. Make sure
514 // to include the actions.xml file when you upload your code for review! 514 // to include the actions.xml file when you upload your code for review!
515 // 515 //
516 // After your feature has shipped under a flag, you can locate the metrics under 516 // After your feature has shipped under a flag, you can locate the metrics under
517 // the action name AboutFlags_internal-action-name. Actions are recorded once 517 // the action name AboutFlags_internal-action-name. Actions are recorded once
518 // per startup, so you should divide this number by AboutFlags_StartupTick to 518 // per startup, so you should divide this number by AboutFlags_StartupTick to
519 // get a sense of usage. Note that this will not be the same as number of users 519 // get a sense of usage. Note that this will not be the same as number of users
520 // with a given feature enabled because users can quit and relaunch the 520 // with a given feature enabled because users can quit and relaunch the
521 // application multiple times over a given time interval. The dashboard also 521 // application multiple times over a given time interval. The dashboard also
522 // shows you how many (metrics reporting) users have enabled the flag over the 522 // shows you how many (metrics reporting) users have enabled the flag over the
523 // last seven days. However, note that this is not the same as the number of 523 // last seven days. However, note that this is not the same as the number of
524 // users who have the flag enabled, since enabling the flag happens once, 524 // users who have the flag enabled, since enabling the flag happens once,
525 // whereas running with the flag enabled happens until the user flips the flag 525 // whereas running with the flag enabled happens until the user flips the flag
526 // again. 526 // again.
527 527
528 // To add a new experiment add to the end of kExperiments. There are two 528 // To add a new entry, add to the end of kEntries. There are two
529 // distinct types of experiments: 529 // distinct types of entries:
530 // . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE 530 // . SINGLE_VALUE: entry is either on or off. Use the SINGLE_VALUE_TYPE
531 // macro for this type supplying the command line to the macro. 531 // macro for this type supplying the command line to the macro.
532 // . MULTI_VALUE: a list of choices, the first of which should correspond to a 532 // . MULTI_VALUE: a list of choices, the first of which should correspond to a
533 // deactivated state for this lab (i.e. no command line option). To specify 533 // deactivated state for this lab (i.e. no command line option). To specify
534 // this type of experiment use the macro MULTI_VALUE_TYPE supplying it the 534 // this type of entry use the macro MULTI_VALUE_TYPE supplying it the
535 // array of choices. 535 // array of choices.
536 // See the documentation of Experiment for details on the fields. 536 // See the documentation of Entry for details on the fields.
537 // 537 //
538 // Command-line switches must have entries in enum "LoginCustomFlags" in 538 // Command-line switches must have entries in enum "LoginCustomFlags" in
539 // histograms.xml. See note in histograms.xml and don't forget to run 539 // histograms.xml. See note in histograms.xml and don't forget to run
540 // AboutFlagsHistogramTest unit test to calculate and verify checksum. 540 // AboutFlagsHistogramTest unit test to calculate and verify checksum.
541 // 541 //
542 // When adding a new choice, add it to the end of the list. 542 // When adding a new choice, add it to the end of the list.
543 const Experiment kExperiments[] = { 543 const Entry kEntries[] = {
544 { 544 {
545 "ignore-gpu-blacklist", 545 "ignore-gpu-blacklist",
546 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME, 546 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
547 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION, 547 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
548 kOsAll, 548 kOsAll,
549 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist) 549 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
550 }, 550 },
551 #if defined(OS_WIN) 551 #if defined(OS_WIN)
552 { 552 {
553 "disable-direct-write", 553 "disable-direct-write",
(...skipping 1896 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 IDS_FLAGS_EMPHASIZE_TITLES_IN_OMNIBOX_DROPDOWN_NAME, 2450 IDS_FLAGS_EMPHASIZE_TITLES_IN_OMNIBOX_DROPDOWN_NAME,
2451 IDS_FLAGS_EMPHASIZE_TITLES_IN_OMNIBOX_DROPDOWN_DESCRIPTION, 2451 IDS_FLAGS_EMPHASIZE_TITLES_IN_OMNIBOX_DROPDOWN_DESCRIPTION,
2452 kOsAll, 2452 kOsAll,
2453 SINGLE_VALUE_TYPE(switches::kEmphasizeTitlesInOmniboxDropdown) 2453 SINGLE_VALUE_TYPE(switches::kEmphasizeTitlesInOmniboxDropdown)
2454 }, 2454 },
2455 // NOTE: Adding new command-line switches requires adding corresponding 2455 // NOTE: Adding new command-line switches requires adding corresponding
2456 // entries to enum "LoginCustomFlags" in histograms.xml. See note in 2456 // entries to enum "LoginCustomFlags" in histograms.xml. See note in
2457 // histograms.xml and don't forget to run AboutFlagsHistogramTest unit test. 2457 // histograms.xml and don't forget to run AboutFlagsHistogramTest unit test.
2458 }; 2458 };
2459 2459
2460 const Experiment* experiments = kExperiments; 2460 const Entry* entries = kEntries;
2461 size_t num_experiments = arraysize(kExperiments); 2461 size_t num_entries = arraysize(kEntries);
2462 2462
2463 // Stores and encapsulates the little state that about:flags has. 2463 // Stores and encapsulates the little state that about:flags has.
2464 class FlagsState { 2464 class FlagsState {
2465 public: 2465 public:
2466 FlagsState() : needs_restart_(false) {} 2466 FlagsState() : needs_restart_(false) {}
2467 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, 2467 void ConvertFlagsToSwitches(FlagsStorage* flags_storage,
2468 base::CommandLine* command_line, 2468 base::CommandLine* command_line,
2469 SentinelsMode sentinels); 2469 SentinelsMode sentinels);
2470 bool IsRestartNeededToCommitChanges(); 2470 bool IsRestartNeededToCommitChanges();
2471 void SetExperimentEnabled( 2471 void SetEntryEnabled(
2472 FlagsStorage* flags_storage, 2472 FlagsStorage* flags_storage,
2473 const std::string& internal_name, 2473 const std::string& internal_name,
2474 bool enable); 2474 bool enable);
2475 void RemoveFlagsSwitches( 2475 void RemoveFlagsSwitches(
2476 std::map<std::string, base::CommandLine::StringType>* switch_list); 2476 std::map<std::string, base::CommandLine::StringType>* switch_list);
2477 void ResetAllFlags(FlagsStorage* flags_storage); 2477 void ResetAllFlags(FlagsStorage* flags_storage);
2478 void reset(); 2478 void reset();
2479 2479
2480 // Returns the singleton instance of this class 2480 // Returns the singleton instance of this class
2481 static FlagsState* GetInstance() { 2481 static FlagsState* GetInstance() {
2482 return Singleton<FlagsState>::get(); 2482 return Singleton<FlagsState>::get();
2483 } 2483 }
2484 2484
2485 private: 2485 private:
2486 bool needs_restart_; 2486 bool needs_restart_;
2487 std::map<std::string, std::string> flags_switches_; 2487 std::map<std::string, std::string> flags_switches_;
2488 2488
2489 DISALLOW_COPY_AND_ASSIGN(FlagsState); 2489 DISALLOW_COPY_AND_ASSIGN(FlagsState);
2490 }; 2490 };
2491 2491
2492 // Adds the internal names for the specified experiment to |names|. 2492 // Adds the internal names for the specified entry to |names|.
2493 void AddInternalName(const Experiment& e, std::set<std::string>* names) { 2493 void AddInternalName(const Entry& e, std::set<std::string>* names) {
2494 if (e.type == Experiment::SINGLE_VALUE) { 2494 if (e.type == Entry::SINGLE_VALUE) {
2495 names->insert(e.internal_name); 2495 names->insert(e.internal_name);
2496 } else { 2496 } else {
2497 DCHECK(e.type == Experiment::MULTI_VALUE || 2497 DCHECK(e.type == Entry::MULTI_VALUE ||
2498 e.type == Experiment::ENABLE_DISABLE_VALUE); 2498 e.type == Entry::ENABLE_DISABLE_VALUE);
2499 for (int i = 0; i < e.num_choices; ++i) 2499 for (int i = 0; i < e.num_choices; ++i)
2500 names->insert(e.NameForChoice(i)); 2500 names->insert(e.NameForChoice(i));
2501 } 2501 }
2502 } 2502 }
2503 2503
2504 // Confirms that an experiment is valid, used in a DCHECK in 2504 // Confirms that an entry is valid, used in a DCHECK in SanitizeList below.
2505 // SanitizeList below. 2505 bool ValidateEntry(const Entry& e) {
2506 bool ValidateExperiment(const Experiment& e) {
2507 switch (e.type) { 2506 switch (e.type) {
2508 case Experiment::SINGLE_VALUE: 2507 case Entry::SINGLE_VALUE:
2509 DCHECK_EQ(0, e.num_choices); 2508 DCHECK_EQ(0, e.num_choices);
2510 DCHECK(!e.choices); 2509 DCHECK(!e.choices);
2511 break; 2510 break;
2512 case Experiment::MULTI_VALUE: 2511 case Entry::MULTI_VALUE:
2513 DCHECK_GT(e.num_choices, 0); 2512 DCHECK_GT(e.num_choices, 0);
2514 DCHECK(e.choices); 2513 DCHECK(e.choices);
2515 DCHECK(e.choices[0].command_line_switch); 2514 DCHECK(e.choices[0].command_line_switch);
2516 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]); 2515 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
2517 break; 2516 break;
2518 case Experiment::ENABLE_DISABLE_VALUE: 2517 case Entry::ENABLE_DISABLE_VALUE:
2519 DCHECK_EQ(3, e.num_choices); 2518 DCHECK_EQ(3, e.num_choices);
2520 DCHECK(!e.choices); 2519 DCHECK(!e.choices);
2521 DCHECK(e.command_line_switch); 2520 DCHECK(e.command_line_switch);
2522 DCHECK(e.command_line_value); 2521 DCHECK(e.command_line_value);
2523 DCHECK(e.disable_command_line_switch); 2522 DCHECK(e.disable_command_line_switch);
2524 DCHECK(e.disable_command_line_value); 2523 DCHECK(e.disable_command_line_value);
2525 break; 2524 break;
2526 default: 2525 default:
2527 NOTREACHED(); 2526 NOTREACHED();
2528 } 2527 }
2529 return true; 2528 return true;
2530 } 2529 }
2531 2530
2532 // Removes all experiments from prefs::kEnabledLabsExperiments that are 2531 // Removes all entries from prefs::kEnabledLabsExperiments that are unknown, to
2533 // unknown, to prevent this list to become very long as experiments are added 2532 // prevent this list to become very long as entries are added and removed.
2534 // and removed.
2535 void SanitizeList(FlagsStorage* flags_storage) { 2533 void SanitizeList(FlagsStorage* flags_storage) {
2536 std::set<std::string> known_experiments; 2534 std::set<std::string> known_entries;
2537 for (size_t i = 0; i < num_experiments; ++i) { 2535 for (size_t i = 0; i < num_entries; ++i) {
2538 DCHECK(ValidateExperiment(experiments[i])); 2536 DCHECK(ValidateEntry(entries[i]));
2539 AddInternalName(experiments[i], &known_experiments); 2537 AddInternalName(entries[i], &known_entries);
2540 } 2538 }
2541 2539
2542 std::set<std::string> enabled_experiments = flags_storage->GetFlags(); 2540 std::set<std::string> enabled_entries = flags_storage->GetFlags();
2543 2541
2544 std::set<std::string> new_enabled_experiments = 2542 std::set<std::string> new_enabled_entries =
2545 base::STLSetIntersection<std::set<std::string> >( 2543 base::STLSetIntersection<std::set<std::string> >(
2546 known_experiments, enabled_experiments); 2544 known_entries, enabled_entries);
2547 2545
2548 if (new_enabled_experiments != enabled_experiments) 2546 if (new_enabled_entries != enabled_entries)
2549 flags_storage->SetFlags(new_enabled_experiments); 2547 flags_storage->SetFlags(new_enabled_entries);
2550 } 2548 }
2551 2549
2552 void GetSanitizedEnabledFlags( 2550 void GetSanitizedEnabledFlags(FlagsStorage* flags_storage,
2553 FlagsStorage* flags_storage, std::set<std::string>* result) { 2551 std::set<std::string>* result) {
2554 SanitizeList(flags_storage); 2552 SanitizeList(flags_storage);
2555 *result = flags_storage->GetFlags(); 2553 *result = flags_storage->GetFlags();
2556 } 2554 }
2557 2555
2558 bool SkipConditionalExperiment(const Experiment& experiment, 2556 bool SkipConditionalEntry(const Entry& entry, FlagsStorage* flags_storage) {
2559 FlagsStorage* flags_storage) {
2560 #if defined(OS_ANDROID) || defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) 2557 #if defined(OS_ANDROID) || defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
2561 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 2558 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
2562 #endif 2559 #endif
2563 2560
2564 #if defined(OS_ANDROID) 2561 #if defined(OS_ANDROID)
2565 // enable-data-reduction-proxy-dev is only available for the Dev/Beta channel. 2562 // enable-data-reduction-proxy-dev is only available for the Dev/Beta channel.
2566 if (!strcmp("enable-data-reduction-proxy-dev", experiment.internal_name) && 2563 if (!strcmp("enable-data-reduction-proxy-dev", entry.internal_name) &&
2567 channel != chrome::VersionInfo::CHANNEL_BETA && 2564 channel != chrome::VersionInfo::CHANNEL_BETA &&
2568 channel != chrome::VersionInfo::CHANNEL_DEV) { 2565 channel != chrome::VersionInfo::CHANNEL_DEV) {
2569 return true; 2566 return true;
2570 } 2567 }
2571 // enable-data-reduction-proxy-alt is only available for the Dev channel. 2568 // enable-data-reduction-proxy-alt is only available for the Dev channel.
2572 if (!strcmp("enable-data-reduction-proxy-alt", experiment.internal_name) && 2569 if (!strcmp("enable-data-reduction-proxy-alt", entry.internal_name) &&
2573 channel != chrome::VersionInfo::CHANNEL_DEV) { 2570 channel != chrome::VersionInfo::CHANNEL_DEV) {
2574 return true; 2571 return true;
2575 } 2572 }
2576 // enable-data-reduction-proxy-lo-fi is only available for Chromium builds and 2573 // enable-data-reduction-proxy-lo-fi is only available for Chromium builds and
2577 // the Canary/Dev channel. 2574 // the Canary/Dev channel.
2578 if (!strcmp("enable-data-reduction-proxy-lo-fi", experiment.internal_name) && 2575 if (!strcmp("enable-data-reduction-proxy-lo-fi", entry.internal_name) &&
2579 channel != chrome::VersionInfo::CHANNEL_DEV && 2576 channel != chrome::VersionInfo::CHANNEL_DEV &&
2580 channel != chrome::VersionInfo::CHANNEL_CANARY && 2577 channel != chrome::VersionInfo::CHANNEL_CANARY &&
2581 channel != chrome::VersionInfo::CHANNEL_UNKNOWN) { 2578 channel != chrome::VersionInfo::CHANNEL_UNKNOWN) {
2582 return true; 2579 return true;
2583 } 2580 }
2584 #endif 2581 #endif
2585 2582
2586 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) 2583 #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
2587 // enable-data-reduction-proxy-bypass-warning is only available for Chromium 2584 // enable-data-reduction-proxy-bypass-warning is only available for Chromium
2588 // builds and Canary/Dev channel. 2585 // builds and Canary/Dev channel.
2589 if (!strcmp("enable-data-reduction-proxy-bypass-warnings", 2586 if (!strcmp("enable-data-reduction-proxy-bypass-warnings",
2590 experiment.internal_name) && 2587 entry.internal_name) &&
2591 channel != chrome::VersionInfo::CHANNEL_UNKNOWN && 2588 channel != chrome::VersionInfo::CHANNEL_UNKNOWN &&
2592 channel != chrome::VersionInfo::CHANNEL_CANARY && 2589 channel != chrome::VersionInfo::CHANNEL_CANARY &&
2593 channel != chrome::VersionInfo::CHANNEL_DEV) { 2590 channel != chrome::VersionInfo::CHANNEL_DEV) {
2594 return true; 2591 return true;
2595 } 2592 }
2596 #endif 2593 #endif
2597 2594
2598 return false; 2595 return false;
2599 } 2596 }
2600 2597
2601 2598
2602 // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't 2599 // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
2603 // enabled on the current platform. 2600 // enabled on the current platform.
2604 void GetSanitizedEnabledFlagsForCurrentPlatform( 2601 void GetSanitizedEnabledFlagsForCurrentPlatform(
2605 FlagsStorage* flags_storage, std::set<std::string>* result) { 2602 FlagsStorage* flags_storage, std::set<std::string>* result) {
2606 GetSanitizedEnabledFlags(flags_storage, result); 2603 GetSanitizedEnabledFlags(flags_storage, result);
2607 2604
2608 // Filter out any experiments that aren't enabled on the current platform. We 2605 // Filter out any entries that aren't enabled on the current platform. We
2609 // don't remove these from prefs else syncing to a platform with a different 2606 // don't remove these from prefs else syncing to a platform with a different
2610 // set of experiments would be lossy. 2607 // set of entries would be lossy.
2611 std::set<std::string> platform_experiments; 2608 std::set<std::string> platform_entries;
2612 int current_platform = GetCurrentPlatform(); 2609 int current_platform = GetCurrentPlatform();
2613 for (size_t i = 0; i < num_experiments; ++i) { 2610 for (size_t i = 0; i < num_entries; ++i) {
2614 if (experiments[i].supported_platforms & current_platform) 2611 if (entries[i].supported_platforms & current_platform)
2615 AddInternalName(experiments[i], &platform_experiments); 2612 AddInternalName(entries[i], &platform_entries);
2616 #if defined(OS_CHROMEOS) 2613 #if defined(OS_CHROMEOS)
2617 if (experiments[i].supported_platforms & kOsCrOSOwnerOnly) 2614 if (entries[i].supported_platforms & kOsCrOSOwnerOnly)
2618 AddInternalName(experiments[i], &platform_experiments); 2615 AddInternalName(entries[i], &platform_entries);
2619 #endif 2616 #endif
2620 } 2617 }
2621 2618
2622 std::set<std::string> new_enabled_experiments = 2619 std::set<std::string> new_enabled_entries =
2623 base::STLSetIntersection<std::set<std::string> >( 2620 base::STLSetIntersection<std::set<std::string> >(
2624 platform_experiments, *result); 2621 platform_entries, *result);
2625 2622
2626 result->swap(new_enabled_experiments); 2623 result->swap(new_enabled_entries);
2627 } 2624 }
2628 2625
2629 // Returns the Value representing the choice data in the specified experiment. 2626 // Returns the Value representing the choice data in the specified entry.
2630 base::Value* CreateChoiceData( 2627 base::Value* CreateChoiceData(
2631 const Experiment& experiment, 2628 const Entry& entry,
2632 const std::set<std::string>& enabled_experiments) { 2629 const std::set<std::string>& enabled_entries) {
2633 DCHECK(experiment.type == Experiment::MULTI_VALUE || 2630 DCHECK(entry.type == Entry::MULTI_VALUE ||
2634 experiment.type == Experiment::ENABLE_DISABLE_VALUE); 2631 entry.type == Entry::ENABLE_DISABLE_VALUE);
2635 base::ListValue* result = new base::ListValue; 2632 base::ListValue* result = new base::ListValue;
2636 for (int i = 0; i < experiment.num_choices; ++i) { 2633 for (int i = 0; i < entry.num_choices; ++i) {
2637 base::DictionaryValue* value = new base::DictionaryValue; 2634 base::DictionaryValue* value = new base::DictionaryValue;
2638 const std::string name = experiment.NameForChoice(i); 2635 const std::string name = entry.NameForChoice(i);
2639 value->SetString("internal_name", name); 2636 value->SetString("internal_name", name);
2640 value->SetString("description", experiment.DescriptionForChoice(i)); 2637 value->SetString("description", entry.DescriptionForChoice(i));
2641 value->SetBoolean("selected", enabled_experiments.count(name) > 0); 2638 value->SetBoolean("selected", enabled_entries.count(name) > 0);
2642 result->Append(value); 2639 result->Append(value);
2643 } 2640 }
2644 return result; 2641 return result;
2645 } 2642 }
2646 2643
2647 } // namespace 2644 } // namespace
2648 2645
2649 std::string Experiment::NameForChoice(int index) const { 2646 std::string Entry::NameForChoice(int index) const {
2650 DCHECK(type == Experiment::MULTI_VALUE || 2647 DCHECK(type == Entry::MULTI_VALUE ||
2651 type == Experiment::ENABLE_DISABLE_VALUE); 2648 type == Entry::ENABLE_DISABLE_VALUE);
2652 DCHECK_LT(index, num_choices); 2649 DCHECK_LT(index, num_choices);
2653 return std::string(internal_name) + testing::kMultiSeparator + 2650 return std::string(internal_name) + testing::kMultiSeparator +
2654 base::IntToString(index); 2651 base::IntToString(index);
2655 } 2652 }
2656 2653
2657 base::string16 Experiment::DescriptionForChoice(int index) const { 2654 base::string16 Entry::DescriptionForChoice(int index) const {
2658 DCHECK(type == Experiment::MULTI_VALUE || 2655 DCHECK(type == Entry::MULTI_VALUE ||
2659 type == Experiment::ENABLE_DISABLE_VALUE); 2656 type == Entry::ENABLE_DISABLE_VALUE);
2660 DCHECK_LT(index, num_choices); 2657 DCHECK_LT(index, num_choices);
2661 int description_id; 2658 int description_id;
2662 if (type == Experiment::ENABLE_DISABLE_VALUE) { 2659 if (type == Entry::ENABLE_DISABLE_VALUE) {
2663 const int kEnableDisableDescriptionIds[] = { 2660 const int kEnableDisableDescriptionIds[] = {
2664 IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, 2661 IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT,
2665 IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, 2662 IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
2666 IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED, 2663 IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
2667 }; 2664 };
2668 description_id = kEnableDisableDescriptionIds[index]; 2665 description_id = kEnableDisableDescriptionIds[index];
2669 } else { 2666 } else {
2670 description_id = choices[index].description_id; 2667 description_id = choices[index].description_id;
2671 } 2668 }
2672 return l10n_util::GetStringUTF16(description_id); 2669 return l10n_util::GetStringUTF16(description_id);
(...skipping 28 matching lines...) Expand all
2701 new_flags.begin(), 2698 new_flags.begin(),
2702 new_flags.end(), 2699 new_flags.end(),
2703 active_flags.begin(), 2700 active_flags.begin(),
2704 active_flags.end(), 2701 active_flags.end(),
2705 std::inserter(*out_difference, out_difference->begin())); 2702 std::inserter(*out_difference, out_difference->begin()));
2706 } 2703 }
2707 2704
2708 return result; 2705 return result;
2709 } 2706 }
2710 2707
2711 void GetFlagsExperimentsData(FlagsStorage* flags_storage, 2708 void GetFlagsEntryData(FlagsStorage* flags_storage,
2712 FlagAccess access, 2709 FlagAccess access,
2713 base::ListValue* supported_experiments, 2710 base::ListValue* supported_entries,
2714 base::ListValue* unsupported_experiments) { 2711 base::ListValue* unsupported_entries) {
2715 std::set<std::string> enabled_experiments; 2712 std::set<std::string> enabled_entries;
2716 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); 2713 GetSanitizedEnabledFlags(flags_storage, &enabled_entries);
2717 2714
2718 int current_platform = GetCurrentPlatform(); 2715 int current_platform = GetCurrentPlatform();
2719 2716
2720 for (size_t i = 0; i < num_experiments; ++i) { 2717 for (size_t i = 0; i < num_entries; ++i) {
2721 const Experiment& experiment = experiments[i]; 2718 const Entry& entry = entries[i];
2722 if (SkipConditionalExperiment(experiment, flags_storage)) 2719 if (SkipConditionalEntry(entry, flags_storage))
2723 continue; 2720 continue;
2724 2721
2725 base::DictionaryValue* data = new base::DictionaryValue(); 2722 base::DictionaryValue* data = new base::DictionaryValue();
2726 data->SetString("internal_name", experiment.internal_name); 2723 data->SetString("internal_name", entry.internal_name);
2727 data->SetString("name", 2724 data->SetString("name",
2728 l10n_util::GetStringUTF16(experiment.visible_name_id)); 2725 l10n_util::GetStringUTF16(entry.visible_name_id));
2729 data->SetString("description", 2726 data->SetString("description",
2730 l10n_util::GetStringUTF16( 2727 l10n_util::GetStringUTF16(entry.visible_description_id));
2731 experiment.visible_description_id));
2732 2728
2733 base::ListValue* supported_platforms = new base::ListValue(); 2729 base::ListValue* supported_platforms = new base::ListValue();
2734 AddOsStrings(experiment.supported_platforms, supported_platforms); 2730 AddOsStrings(entry.supported_platforms, supported_platforms);
2735 data->Set("supported_platforms", supported_platforms); 2731 data->Set("supported_platforms", supported_platforms);
2736 2732
2737 switch (experiment.type) { 2733 switch (entry.type) {
2738 case Experiment::SINGLE_VALUE: 2734 case Entry::SINGLE_VALUE:
2739 data->SetBoolean( 2735 data->SetBoolean("enabled",
2740 "enabled", 2736 enabled_entries.count(entry.internal_name) > 0);
2741 enabled_experiments.count(experiment.internal_name) > 0);
2742 break; 2737 break;
2743 case Experiment::MULTI_VALUE: 2738 case Entry::MULTI_VALUE:
2744 case Experiment::ENABLE_DISABLE_VALUE: 2739 case Entry::ENABLE_DISABLE_VALUE:
2745 data->Set("choices", CreateChoiceData(experiment, enabled_experiments)); 2740 data->Set("choices", CreateChoiceData(entry, enabled_entries));
2746 break; 2741 break;
2747 default: 2742 default:
2748 NOTREACHED(); 2743 NOTREACHED();
2749 } 2744 }
2750 2745
2751 bool supported = (experiment.supported_platforms & current_platform) != 0; 2746 bool supported = (entry.supported_platforms & current_platform) != 0;
2752 #if defined(OS_CHROMEOS) 2747 #if defined(OS_CHROMEOS)
2753 if (access == kOwnerAccessToFlags && 2748 if (access == kOwnerAccessToFlags &&
2754 (experiment.supported_platforms & kOsCrOSOwnerOnly) != 0) { 2749 (entry.supported_platforms & kOsCrOSOwnerOnly) != 0) {
2755 supported = true; 2750 supported = true;
2756 } 2751 }
2757 #endif 2752 #endif
2758 if (supported) 2753 if (supported)
2759 supported_experiments->Append(data); 2754 supported_entries->Append(data);
2760 else 2755 else
2761 unsupported_experiments->Append(data); 2756 unsupported_entries->Append(data);
2762 } 2757 }
2763 } 2758 }
2764 2759
2765 bool IsRestartNeededToCommitChanges() { 2760 bool IsRestartNeededToCommitChanges() {
2766 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges(); 2761 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
2767 } 2762 }
2768 2763
2769 void SetExperimentEnabled(FlagsStorage* flags_storage, 2764 void SetEntryEnabled(FlagsStorage* flags_storage,
2770 const std::string& internal_name, 2765 const std::string& internal_name,
2771 bool enable) { 2766 bool enable) {
2772 FlagsState::GetInstance()->SetExperimentEnabled(flags_storage, 2767 FlagsState::GetInstance()->SetEntryEnabled(flags_storage, internal_name,
2773 internal_name, enable); 2768 enable);
2774 } 2769 }
2775 2770
2776 void RemoveFlagsSwitches( 2771 void RemoveFlagsSwitches(
2777 std::map<std::string, base::CommandLine::StringType>* switch_list) { 2772 std::map<std::string, base::CommandLine::StringType>* switch_list) {
2778 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list); 2773 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
2779 } 2774 }
2780 2775
2781 void ResetAllFlags(FlagsStorage* flags_storage) { 2776 void ResetAllFlags(FlagsStorage* flags_storage) {
2782 FlagsState::GetInstance()->ResetAllFlags(flags_storage); 2777 FlagsState::GetInstance()->ResetAllFlags(flags_storage);
2783 } 2778 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 DCHECK(name_to_switch_map->end() == name_to_switch_map->find(key)); 2854 DCHECK(name_to_switch_map->end() == name_to_switch_map->find(key));
2860 (*name_to_switch_map)[key] = std::make_pair(switch_name, switch_value); 2855 (*name_to_switch_map)[key] = std::make_pair(switch_name, switch_value);
2861 } 2856 }
2862 2857
2863 void FlagsState::ConvertFlagsToSwitches(FlagsStorage* flags_storage, 2858 void FlagsState::ConvertFlagsToSwitches(FlagsStorage* flags_storage,
2864 base::CommandLine* command_line, 2859 base::CommandLine* command_line,
2865 SentinelsMode sentinels) { 2860 SentinelsMode sentinels) {
2866 if (command_line->HasSwitch(switches::kNoExperiments)) 2861 if (command_line->HasSwitch(switches::kNoExperiments))
2867 return; 2862 return;
2868 2863
2869 std::set<std::string> enabled_experiments; 2864 std::set<std::string> enabled_entries;
2870 2865
2871 GetSanitizedEnabledFlagsForCurrentPlatform(flags_storage, 2866 GetSanitizedEnabledFlagsForCurrentPlatform(flags_storage,
2872 &enabled_experiments); 2867 &enabled_entries);
2873 2868
2874 NameToSwitchAndValueMap name_to_switch_map; 2869 NameToSwitchAndValueMap name_to_switch_map;
2875 for (size_t i = 0; i < num_experiments; ++i) { 2870 for (size_t i = 0; i < num_entries; ++i) {
2876 const Experiment& e = experiments[i]; 2871 const Entry& e = entries[i];
2877 if (e.type == Experiment::SINGLE_VALUE) { 2872 if (e.type == Entry::SINGLE_VALUE) {
2878 SetFlagToSwitchMapping(e.internal_name, e.command_line_switch, 2873 SetFlagToSwitchMapping(e.internal_name, e.command_line_switch,
2879 e.command_line_value, &name_to_switch_map); 2874 e.command_line_value, &name_to_switch_map);
2880 } else if (e.type == Experiment::MULTI_VALUE) { 2875 } else if (e.type == Entry::MULTI_VALUE) {
2881 for (int j = 0; j < e.num_choices; ++j) { 2876 for (int j = 0; j < e.num_choices; ++j) {
2882 SetFlagToSwitchMapping(e.NameForChoice(j), 2877 SetFlagToSwitchMapping(e.NameForChoice(j),
2883 e.choices[j].command_line_switch, 2878 e.choices[j].command_line_switch,
2884 e.choices[j].command_line_value, 2879 e.choices[j].command_line_value,
2885 &name_to_switch_map); 2880 &name_to_switch_map);
2886 } 2881 }
2887 } else { 2882 } else {
2888 DCHECK_EQ(e.type, Experiment::ENABLE_DISABLE_VALUE); 2883 DCHECK_EQ(e.type, Entry::ENABLE_DISABLE_VALUE);
2889 SetFlagToSwitchMapping(e.NameForChoice(0), std::string(), std::string(), 2884 SetFlagToSwitchMapping(e.NameForChoice(0), std::string(), std::string(),
2890 &name_to_switch_map); 2885 &name_to_switch_map);
2891 SetFlagToSwitchMapping(e.NameForChoice(1), e.command_line_switch, 2886 SetFlagToSwitchMapping(e.NameForChoice(1), e.command_line_switch,
2892 e.command_line_value, &name_to_switch_map); 2887 e.command_line_value, &name_to_switch_map);
2893 SetFlagToSwitchMapping(e.NameForChoice(2), e.disable_command_line_switch, 2888 SetFlagToSwitchMapping(e.NameForChoice(2), e.disable_command_line_switch,
2894 e.disable_command_line_value, &name_to_switch_map); 2889 e.disable_command_line_value, &name_to_switch_map);
2895 } 2890 }
2896 } 2891 }
2897 2892
2898 if (sentinels == kAddSentinels) { 2893 if (sentinels == kAddSentinels) {
2899 command_line->AppendSwitch(switches::kFlagSwitchesBegin); 2894 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
2900 flags_switches_.insert( 2895 flags_switches_.insert(
2901 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin, 2896 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
2902 std::string())); 2897 std::string()));
2903 } 2898 }
2904 for (const std::string& experiment_name : enabled_experiments) { 2899 for (const std::string& entry_name : enabled_entries) {
2905 NameToSwitchAndValueMap::const_iterator name_to_switch_it = 2900 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
2906 name_to_switch_map.find(experiment_name); 2901 name_to_switch_map.find(entry_name);
2907 if (name_to_switch_it == name_to_switch_map.end()) { 2902 if (name_to_switch_it == name_to_switch_map.end()) {
2908 NOTREACHED(); 2903 NOTREACHED();
2909 continue; 2904 continue;
2910 } 2905 }
2911 2906
2912 const std::pair<std::string, std::string>& 2907 const std::pair<std::string, std::string>&
2913 switch_and_value_pair = name_to_switch_it->second; 2908 switch_and_value_pair = name_to_switch_it->second;
2914 2909
2915 CHECK(!switch_and_value_pair.first.empty()); 2910 CHECK(!switch_and_value_pair.first.empty());
2916 command_line->AppendSwitchASCII(switch_and_value_pair.first, 2911 command_line->AppendSwitchASCII(switch_and_value_pair.first,
2917 switch_and_value_pair.second); 2912 switch_and_value_pair.second);
2918 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second; 2913 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
2919 } 2914 }
2920 if (sentinels == kAddSentinels) { 2915 if (sentinels == kAddSentinels) {
2921 command_line->AppendSwitch(switches::kFlagSwitchesEnd); 2916 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
2922 flags_switches_.insert( 2917 flags_switches_.insert(
2923 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd, 2918 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
2924 std::string())); 2919 std::string()));
2925 } 2920 }
2926 } 2921 }
2927 2922
2928 bool FlagsState::IsRestartNeededToCommitChanges() { 2923 bool FlagsState::IsRestartNeededToCommitChanges() {
2929 return needs_restart_; 2924 return needs_restart_;
2930 } 2925 }
2931 2926
2932 void FlagsState::SetExperimentEnabled(FlagsStorage* flags_storage, 2927 void FlagsState::SetEntryEnabled(FlagsStorage* flags_storage,
2933 const std::string& internal_name, 2928 const std::string& internal_name,
2934 bool enable) { 2929 bool enable) {
2935 size_t at_index = internal_name.find(testing::kMultiSeparator); 2930 size_t at_index = internal_name.find(testing::kMultiSeparator);
2936 if (at_index != std::string::npos) { 2931 if (at_index != std::string::npos) {
2937 DCHECK(enable); 2932 DCHECK(enable);
2938 // We're being asked to enable a multi-choice experiment. Disable the 2933 // We're being asked to enable a multi-choice entry. Disable the currently
2939 // currently selected choice. 2934 // selected choice.
2940 DCHECK_NE(at_index, 0u); 2935 DCHECK_NE(at_index, 0u);
2941 const std::string experiment_name = internal_name.substr(0, at_index); 2936 const std::string entry_name = internal_name.substr(0, at_index);
2942 SetExperimentEnabled(flags_storage, experiment_name, false); 2937 SetEntryEnabled(flags_storage, entry_name, false);
2943 2938
2944 // And enable the new choice, if it is not the default first choice. 2939 // And enable the new choice, if it is not the default first choice.
2945 if (internal_name != experiment_name + "@0") { 2940 if (internal_name != entry_name + "@0") {
2946 std::set<std::string> enabled_experiments; 2941 std::set<std::string> enabled_entries;
2947 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); 2942 GetSanitizedEnabledFlags(flags_storage, &enabled_entries);
2948 needs_restart_ |= enabled_experiments.insert(internal_name).second; 2943 needs_restart_ |= enabled_entries.insert(internal_name).second;
2949 flags_storage->SetFlags(enabled_experiments); 2944 flags_storage->SetFlags(enabled_entries);
2950 } 2945 }
2951 return; 2946 return;
2952 } 2947 }
2953 2948
2954 std::set<std::string> enabled_experiments; 2949 std::set<std::string> enabled_entries;
2955 GetSanitizedEnabledFlags(flags_storage, &enabled_experiments); 2950 GetSanitizedEnabledFlags(flags_storage, &enabled_entries);
2956 2951
2957 const Experiment* e = NULL; 2952 const Entry* e = NULL;
2958 for (size_t i = 0; i < num_experiments; ++i) { 2953 for (size_t i = 0; i < num_entries; ++i) {
2959 if (experiments[i].internal_name == internal_name) { 2954 if (entries[i].internal_name == internal_name) {
2960 e = experiments + i; 2955 e = entries + i;
2961 break; 2956 break;
2962 } 2957 }
2963 } 2958 }
2964 DCHECK(e); 2959 DCHECK(e);
2965 2960
2966 if (e->type == Experiment::SINGLE_VALUE) { 2961 if (e->type == Entry::SINGLE_VALUE) {
2967 if (enable) 2962 if (enable)
2968 needs_restart_ |= enabled_experiments.insert(internal_name).second; 2963 needs_restart_ |= enabled_entries.insert(internal_name).second;
2969 else 2964 else
2970 needs_restart_ |= (enabled_experiments.erase(internal_name) > 0); 2965 needs_restart_ |= (enabled_entries.erase(internal_name) > 0);
2971 } else { 2966 } else {
2972 if (enable) { 2967 if (enable) {
2973 // Enable the first choice. 2968 // Enable the first choice.
2974 needs_restart_ |= enabled_experiments.insert(e->NameForChoice(0)).second; 2969 needs_restart_ |= enabled_entries.insert(e->NameForChoice(0)).second;
2975 } else { 2970 } else {
2976 // Find the currently enabled choice and disable it. 2971 // Find the currently enabled choice and disable it.
2977 for (int i = 0; i < e->num_choices; ++i) { 2972 for (int i = 0; i < e->num_choices; ++i) {
2978 std::string choice_name = e->NameForChoice(i); 2973 std::string choice_name = e->NameForChoice(i);
2979 if (enabled_experiments.find(choice_name) != 2974 if (enabled_entries.find(choice_name) != enabled_entries.end()) {
2980 enabled_experiments.end()) {
2981 needs_restart_ = true; 2975 needs_restart_ = true;
2982 enabled_experiments.erase(choice_name); 2976 enabled_entries.erase(choice_name);
2983 // Continue on just in case there's a bug and more than one 2977 // Continue on just in case there's a bug and more than one entry for
2984 // experiment for this choice was enabled. 2978 // this choice was enabled.
2985 } 2979 }
2986 } 2980 }
2987 } 2981 }
2988 } 2982 }
2989 2983
2990 flags_storage->SetFlags(enabled_experiments); 2984 flags_storage->SetFlags(enabled_entries);
2991 } 2985 }
2992 2986
2993 void FlagsState::RemoveFlagsSwitches( 2987 void FlagsState::RemoveFlagsSwitches(
2994 std::map<std::string, base::CommandLine::StringType>* switch_list) { 2988 std::map<std::string, base::CommandLine::StringType>* switch_list) {
2995 for (const auto& entry : flags_switches_) 2989 for (const auto& entry : flags_switches_)
2996 switch_list->erase(entry.first); 2990 switch_list->erase(entry.first);
2997 } 2991 }
2998 2992
2999 void FlagsState::ResetAllFlags(FlagsStorage* flags_storage) { 2993 void FlagsState::ResetAllFlags(FlagsStorage* flags_storage) {
3000 needs_restart_ = true; 2994 needs_restart_ = true;
3001 2995
3002 std::set<std::string> no_experiments; 2996 std::set<std::string> no_entries;
3003 flags_storage->SetFlags(no_experiments); 2997 flags_storage->SetFlags(no_entries);
3004 } 2998 }
3005 2999
3006 void FlagsState::reset() { 3000 void FlagsState::reset() {
3007 needs_restart_ = false; 3001 needs_restart_ = false;
3008 flags_switches_.clear(); 3002 flags_switches_.clear();
3009 } 3003 }
3010 3004
3011 } // namespace 3005 } // namespace
3012 3006
3013 namespace testing { 3007 namespace testing {
3014 3008
3015 // WARNING: '@' is also used in the html file. If you update this constant you 3009 // WARNING: '@' is also used in the html file. If you update this constant you
3016 // also need to update the html file. 3010 // also need to update the html file.
3017 const char kMultiSeparator[] = "@"; 3011 const char kMultiSeparator[] = "@";
3018 3012
3019 const base::HistogramBase::Sample kBadSwitchFormatHistogramId = 0; 3013 const base::HistogramBase::Sample kBadSwitchFormatHistogramId = 0;
3020 3014
3021 void ClearState() { 3015 void ClearState() {
3022 FlagsState::GetInstance()->reset(); 3016 FlagsState::GetInstance()->reset();
3023 } 3017 }
3024 3018
3025 void SetExperiments(const Experiment* e, size_t count) { 3019 void SetEntries(const Entry* e, size_t count) {
3026 if (!e) { 3020 if (!e) {
3027 experiments = kExperiments; 3021 entries = kEntries;
3028 num_experiments = arraysize(kExperiments); 3022 num_entries = arraysize(kEntries);
3029 } else { 3023 } else {
3030 experiments = e; 3024 entries = e;
3031 num_experiments = count; 3025 num_entries = count;
3032 } 3026 }
3033 } 3027 }
3034 3028
3035 const Experiment* GetExperiments(size_t* count) { 3029 const Entry* GetEntries(size_t* count) {
3036 *count = num_experiments; 3030 *count = num_entries;
3037 return experiments; 3031 return entries;
3038 } 3032 }
3039 3033
3040 } // namespace testing 3034 } // namespace testing
3041 3035
3042 } // namespace about_flags 3036 } // namespace about_flags
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.h ('k') | chrome/browser/about_flags_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698