blob: 43e0c46e7bd02e6a633383402d2aaeccf7f9860f [file] [log] [blame]
[email protected]9c66adc2012-01-05 02:10:161// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ad2a3ded2010-08-27 13:19:052// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]1a47d7e2010-10-15 00:37:245#include "chrome/browser/about_flags.h"
[email protected]ad2a3ded2010-08-27 13:19:056
7#include <algorithm>
8#include <iterator>
9#include <map>
10#include <set>
11
[email protected]ad2a3ded2010-08-27 13:19:0512#include "base/command_line.h"
[email protected]3b63f8f42011-03-28 01:54:1513#include "base/memory/singleton.h"
[email protected]8a6ff28d2010-12-02 16:35:1914#include "base/string_number_conversions.h"
[email protected]d208f4d82011-05-23 21:52:0315#include "base/utf_string_conversions.h"
[email protected]ad2a3ded2010-08-27 13:19:0516#include "base/values.h"
[email protected]ad2a3ded2010-08-27 13:19:0517#include "chrome/browser/prefs/pref_service.h"
[email protected]1bc78422011-03-31 08:41:3818#include "chrome/browser/prefs/scoped_user_pref_update.h"
[email protected]d208f4d82011-05-23 21:52:0319#include "chrome/common/chrome_content_client.h"
[email protected]ad2a3ded2010-08-27 13:19:0520#include "chrome/common/chrome_switches.h"
21#include "chrome/common/pref_names.h"
[email protected]7f6f44c2011-12-14 13:23:3822#include "content/public/browser/user_metrics.h"
[email protected]ad2a3ded2010-08-27 13:19:0523#include "grit/generated_resources.h"
[email protected]c051a1b2011-01-21 23:30:1724#include "ui/base/l10n/l10n_util.h"
[email protected]c9c73ad42012-04-18 03:35:5925#include "ui/base/ui_base_switches.h"
[email protected]c9e2cbbb2012-05-12 21:17:2726#include "ui/gl/gl_switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0527
[email protected]dc04be7c2012-03-15 23:57:4928#if defined(USE_ASH)
[email protected]b65bdda2011-12-23 23:35:3129#include "ash/ash_switches.h"
[email protected]dc04be7c2012-03-15 23:57:4930#endif
31
32#if defined(USE_AURA)
[email protected]308aaa32012-03-12 13:14:5033#include "ui/aura/aura_switches.h"
[email protected]8cc10df2011-11-03 23:57:5034#endif
35
[email protected]7f6f44c2011-12-14 13:23:3836using content::UserMetricsAction;
37
[email protected]1a47d7e2010-10-15 00:37:2438namespace about_flags {
[email protected]ad2a3ded2010-08-27 13:19:0539
[email protected]8a6ff28d2010-12-02 16:35:1940// Macros to simplify specifying the type.
[email protected]a82744532011-02-11 16:15:5341#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
42 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0
43#define SINGLE_VALUE_TYPE(command_line_switch) \
44 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
45#define MULTI_VALUE_TYPE(choices) \
[email protected]0e6f56d2011-02-12 23:45:1546 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices)
[email protected]8a6ff28d2010-12-02 16:35:1947
[email protected]e2ddbc92010-10-15 20:02:0748namespace {
49
[email protected]9c7453d2012-01-21 00:45:4050const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS | kOsAndroid;
[email protected]ad2a3ded2010-08-27 13:19:0551
[email protected]cc3e2052011-12-20 01:01:4052// Adds a |StringValue| to |list| for each platform where |bitmask| indicates
53// whether the experiment is available on that platform.
54void AddOsStrings(unsigned bitmask, ListValue* list) {
55 struct {
56 unsigned bit;
57 const char* const name;
58 } kBitsToOs[] = {
59 {kOsMac, "Mac"},
60 {kOsWin, "Windows"},
61 {kOsLinux, "Linux"},
62 {kOsCrOS, "Chrome OS"},
63 };
64 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i)
65 if (bitmask & kBitsToOs[i].bit)
66 list->Append(new StringValue(kBitsToOs[i].name));
67}
68
[email protected]ba8164242010-11-16 21:31:0069// Names for former Chrome OS Labs experiments, shared with prefs migration
70// code.
71const char kMediaPlayerExperimentName[] = "media-player";
72const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
73const char kVerticalTabsExperimentName[] = "vertical-tabs";
74
[email protected]68317802012-06-07 19:13:2375const Experiment::Choice kOmniboxHistoryQuickProviderNewScoringChoices[] = {
76 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_AUTOMATIC, "", "" },
77 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_ENABLED,
78 switches::kOmniboxHistoryQuickProviderNewScoring,
79 switches::kOmniboxHistoryQuickProviderNewScoringEnabled },
80 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DISABLED,
81 switches::kOmniboxHistoryQuickProviderNewScoring,
82 switches::kOmniboxHistoryQuickProviderNewScoringDisabled }
83};
84
[email protected]b1c4de4c2012-06-08 00:04:5685const Experiment::Choice kBrowserPluginChoices[] = {
86 { IDS_FLAGS_BROWSER_PLUGIN_DISABLED, "", "" },
87 { IDS_FLAGS_BROWSER_PLUGIN_PLATFORM_APPS,
88 switches::kBrowserPlugin,
89 switches::kBrowserPluginPlatformApps },
90 { IDS_FLAGS_BROWSER_PLUGIN_ENABLED,
91 switches::kBrowserPlugin,
92 switches::kBrowserPluginEnabled },
93};
94
[email protected]032d5e6c2012-02-17 17:53:5595const Experiment::Choice kOmniboxInlineHistoryQuickProviderChoices[] = {
96 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_AUTOMATIC, "", "" },
97 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_ALLOWED,
98 switches::kOmniboxInlineHistoryQuickProvider,
99 switches::kOmniboxInlineHistoryQuickProviderAllowed },
100 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_PROHIBITED,
101 switches::kOmniboxInlineHistoryQuickProvider,
102 switches::kOmniboxInlineHistoryQuickProviderProhibited }
103};
104
[email protected]9b19cf82012-06-13 06:23:23105const Experiment::Choice kForceCompositingModeChoices[] = {
106 { IDS_FLAGS_FORCE_COMPOSITING_MODE_DEFAULT, "", "" },
107 { IDS_FLAGS_FORCE_COMPOSITING_MODE_ENABLED,
108 switches::kForceCompositingMode, ""},
109 { IDS_FLAGS_FORCE_COMPOSITING_MODE_DISABLED,
110 switches::kDisableForceCompositingMode, ""}
111};
112
[email protected]72787e392012-03-23 05:55:43113const Experiment::Choice kThreadedCompositingModeChoices[] = {
114 { IDS_FLAGS_THREADED_COMPOSITING_MODE_DEFAULT, "", "" },
115 { IDS_FLAGS_THREADED_COMPOSITING_MODE_DISABLED,
116 switches::kDisableThreadedCompositing, ""},
117 { IDS_FLAGS_THREADED_COMPOSITING_MODE_ENABLED,
118 switches::kEnableThreadedCompositing, ""}
119};
120
[email protected]347a0c72012-05-14 20:28:06121const Experiment::Choice kTouchOptimizedUIChoices[] = {
122 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_AUTOMATIC, "", "" },
123 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_ENABLED,
124 switches::kTouchOptimizedUI,
125 switches::kTouchOptimizedUIEnabled },
126 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_DISABLED,
127 switches::kTouchOptimizedUI,
128 switches::kTouchOptimizedUIDisabled }
129};
130
131
[email protected]4bc5050c2010-11-18 17:55:54132// RECORDING USER METRICS FOR FLAGS:
133// -----------------------------------------------------------------------------
134// The first line of the experiment is the internal name. If you'd like to
135// gather statistics about the usage of your flag, you should append a marker
136// comment to the end of the feature name, like so:
137// "my-special-feature", // FLAGS:RECORD_UMA
138//
139// After doing that, run //chrome/tools/extract_actions.py (see instructions at
140// the top of that file for details) to update the chromeactions.txt file, which
141// will enable UMA to record your feature flag.
142//
143// After your feature has shipped under a flag, you can locate the metrics
144// under the action name AboutFlags_internal-action-name. Actions are recorded
145// once per startup, so you should divide this number by AboutFlags_StartupTick
146// to get a sense of usage. Note that this will not be the same as number of
147// users with a given feature enabled because users can quit and relaunch
148// the application multiple times over a given time interval.
149// TODO(rsesek): See if there's a way to count per-user, rather than
150// per-startup.
151
[email protected]8a6ff28d2010-12-02 16:35:19152// To add a new experiment add to the end of kExperiments. There are two
153// distinct types of experiments:
154// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
155// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:22156// . MULTI_VALUE: a list of choices, the first of which should correspond to a
157// deactivated state for this lab (i.e. no command line option). To specify
158// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
159// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:19160// See the documentation of Experiment for details on the fields.
161//
162// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:05163const Experiment kExperiments[] = {
164 {
[email protected]aac169d2011-03-18 19:53:03165 "expose-for-tabs", // FLAGS:RECORD_UMA
166 IDS_FLAGS_TABPOSE_NAME,
167 IDS_FLAGS_TABPOSE_DESCRIPTION,
168 kOsMac,
169#if defined(OS_MACOSX)
170 // The switch exists only on OS X.
171 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
172#else
173 SINGLE_VALUE_TYPE("")
174#endif
175 },
176 {
[email protected]4bc5050c2010-11-18 17:55:54177 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05178 IDS_FLAGS_CONFLICTS_CHECK_NAME,
179 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
180 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19181 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05182 },
183 {
[email protected]4bc5050c2010-11-18 17:55:54184 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]dae7325b2011-12-21 20:56:54185 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME,
186 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45187 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22188 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31189 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22190 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
191 // always have PDF rasterization available, so no flag needed there.
192#if !defined(GOOGLE_CHROME_BUILD)
193 kOsWin,
194#else
195 0,
[email protected]fa6d2a2f2010-11-30 21:47:19196#endif
[email protected]8a6ff28d2010-12-02 16:35:19197 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42198 },
[email protected]580939a2010-10-12 18:54:37199 {
[email protected]bb461532010-11-26 21:50:23200 "crxless-web-apps",
201 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
202 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
203 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19204 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23205 },
206 {
[email protected]96c6f4c2011-05-18 19:36:22207 "ignore-gpu-blacklist",
208 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
209 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
210 kOsAll,
211 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
212 },
213 {
[email protected]0110cf112011-07-02 00:39:43214 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22215 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
216 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
[email protected]9b19cf82012-06-13 06:23:23217 kOsMac | kOsWin | kOsLinux,
218 MULTI_VALUE_TYPE(kForceCompositingModeChoices)
[email protected]96c6f4c2011-05-18 19:36:22219 },
220 {
[email protected]72787e392012-03-23 05:55:43221 "threaded-compositing-mode",
222 IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME,
223 IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59224 kOsAll,
[email protected]72787e392012-03-23 05:55:43225 MULTI_VALUE_TYPE(kThreadedCompositingModeChoices)
[email protected]644a1072012-03-16 09:29:59226 },
227 {
[email protected]81c64af62012-06-06 20:15:52228 "disable-accelerated-2d-canvas",
229 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_NAME,
230 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_DESCRIPTION,
231 kOsAll,
232 SINGLE_VALUE_TYPE(switches::kDisableAccelerated2dCanvas)
233 },
234 {
[email protected]2cd73322012-05-30 13:15:49235 "disable-deferred-2d-canvas",
236 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_NAME,
237 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_DESCRIPTION,
238 kOsAll,
239 SINGLE_VALUE_TYPE(switches::kDisableDeferred2dCanvas)
240 },
241 {
[email protected]efcde132012-05-30 01:05:18242 "disable-threaded-animation",
243 IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME,
244 IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59245 kOsAll,
[email protected]efcde132012-05-30 01:05:18246 SINGLE_VALUE_TYPE(switches::kDisableThreadedAnimation)
[email protected]644a1072012-03-16 09:29:59247 },
248 {
[email protected]5963b772011-02-09 22:55:38249 "composited-layer-borders",
250 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
251 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
252 kOsAll,
253 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
254 },
255 {
[email protected]a8f1eaa2011-03-07 19:00:58256 "show-fps-counter",
257 IDS_FLAGS_SHOW_FPS_COUNTER,
258 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
259 kOsAll,
260 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
261 },
[email protected]8ff7f342011-05-25 01:49:47262 {
[email protected]70c98a332011-12-21 20:51:52263 "accelerated-filters",
264 IDS_FLAGS_ACCELERATED_FILTERS,
265 IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION,
266 kOsAll,
267 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters)
268 },
269 {
[email protected]8ff7f342011-05-25 01:49:47270 "disable-gpu-vsync",
271 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
272 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
273 kOsAll,
274 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
275 },
[email protected]deaba6d52011-09-23 14:47:12276 {
277 "disable-webgl",
278 IDS_FLAGS_DISABLE_WEBGL_NAME,
279 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
280 kOsAll,
281 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
282 },
[email protected]09096e02012-05-24 11:12:04283 {
284 "enable-browser-plugin",
285 IDS_FLAGS_ENABLE_BROWSER_PLUGIN_NAME,
286 IDS_FLAGS_ENABLE_BROWSER_PLUGIN_DESCRIPTION,
287 kOsAll,
[email protected]b1c4de4c2012-06-08 00:04:56288 MULTI_VALUE_TYPE(kBrowserPluginChoices)
[email protected]09096e02012-05-24 11:12:04289 },
[email protected]96bcdc102012-05-24 23:42:10290 {
291 "fixed-position-creates-stacking-context",
292 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_NAME,
293 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_DESCRIPTION,
294 kOsAll,
295 SINGLE_VALUE_TYPE(switches::kFixedPositionCreatesStackingContext)
296 },
[email protected]d208f4d82011-05-23 21:52:03297 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53298 {
[email protected]e3791ce92011-08-09 01:03:32299 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40300 IDS_FLAGS_ENABLE_NACL_NAME,
301 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
302 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19303 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40304 },
[email protected]b39c6d92012-01-31 16:38:41305 // TODO(halyavin): When exception handling is on by default, replace this
306 // flag with disable-nacl-exception-handling.
307 {
308 "enable-nacl-exception-handling", // FLAGS:RECORD_UMA
309 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME,
310 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION,
311 kOsWin,
312 SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling)
313 },
[email protected]4ff87d202010-11-06 01:28:40314 {
[email protected]31a665e72012-03-11 12:37:46315 "nacl-gdb", // FLAGS:RECORD_UMA
316 IDS_FLAGS_NACL_GDB_NAME,
317 IDS_FLAGS_NACL_GDB_DESCRIPTION,
318 kOsWin,
319 SINGLE_VALUE_TYPE(switches::kNaClGdb)
320 },
321 {
[email protected]401b90792012-05-30 11:41:13322 "nacl-gdb-script", // FLAGS:RECORD_UMA
323 IDS_FLAGS_NACL_GDB_SCRIPT_NAME,
324 IDS_FLAGS_NACL_GDB_SCRIPT_DESCRIPTION,
325 kOsAll,
326 SINGLE_VALUE_TYPE(switches::kNaClGdbScript)
327 },
328 {
[email protected]4bc5050c2010-11-18 17:55:54329 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32330 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
331 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
332 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19333 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32334 },
[email protected]3627b06d2010-11-12 16:36:16335 {
[email protected]cab18ef2012-04-27 07:22:03336 "action-box",
337 IDS_FLAGS_ACTION_BOX_NAME,
338 IDS_FLAGS_ACTION_BOX_DESCRIPTION,
339 kOsAll,
340 SINGLE_VALUE_TYPE(switches::kEnableActionBox),
341 },
342 {
[email protected]3a362432012-06-18 20:39:51343 "script-badges",
344 IDS_FLAGS_SCRIPT_BADGES_NAME,
345 IDS_FLAGS_SCRIPT_BADGES_DESCRIPTION,
346 kOsAll,
347 SINGLE_VALUE_TYPE(switches::kEnableScriptBadges),
348 },
349 {
[email protected]cbe224d2011-08-04 22:12:49350 "apps-new-install-bubble",
351 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
352 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
353 kOsAll,
354 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
355 },
356 {
[email protected]80bd24e2010-11-30 09:34:38357 "disable-hyperlink-auditing",
358 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
359 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
360 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19361 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51362 },
363 {
364 "experimental-location-features", // FLAGS:RECORD_UMA
365 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
366 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
367 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19368 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
369 },
370 {
[email protected]04227962011-01-20 02:03:09371 "disable-interactive-form-validation",
372 IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_NAME,
373 IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_DESCRIPTION,
374 kOsAll,
375 SINGLE_VALUE_TYPE(switches::kDisableInteractiveFormValidation)
376 },
[email protected]8df51192011-01-22 20:05:03377 {
[email protected]07d490bc2011-03-07 17:05:26378 "focus-existing-tab-on-open", // FLAGS:RECORD_UMA
379 IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_NAME,
380 IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_DESCRIPTION,
381 kOsAll,
382 SINGLE_VALUE_TYPE(switches::kFocusExistingTabOnOpen)
383 },
[email protected]d5dcfb32011-03-19 00:49:24384 {
[email protected]5aea1862011-03-23 23:55:39385 "tab-groups-context-menu",
386 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
387 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
388 kOsWin,
389 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
390 },
[email protected]e9bf9d92011-03-31 20:57:15391 {
[email protected]354e33b2011-06-15 00:29:10392 "static-ip-config",
393 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
394 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
395 kOsCrOS,
396#if defined(OS_CHROMEOS)
397 // This switch exists only on Chrome OS.
398 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
399#else
400 SINGLE_VALUE_TYPE("")
401#endif
402 },
[email protected]3eb5728c2011-06-20 22:32:24403 {
404 "show-autofill-type-predictions",
405 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
406 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
407 kOsAll,
408 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
409 },
[email protected]bff4d3e2011-06-21 23:58:52410 {
[email protected]fdf4e252012-04-27 00:26:55411 "sync-tab-favicons",
412 IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
413 IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
414 kOsAll,
415 SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
416 },
417 {
[email protected]aae9eeb12011-10-21 21:59:26418 "sync-app-notifications",
419 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
420 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
421 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11422 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26423 },
424 {
[email protected]a22ebd812011-06-23 00:05:39425 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
426 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
427 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
428 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40429 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40430 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39431 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
432 },
[email protected]81a6b0b2011-06-24 17:55:40433 {
[email protected]68317802012-06-07 19:13:23434 "omnibox-history-quick-provider-new-scoring",
435 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_NAME,
436 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DESCRIPTION,
437 kOsAll,
438 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderNewScoringChoices)
439 },
440 {
[email protected]032d5e6c2012-02-17 17:53:55441 "omnibox-inline-history-quick-provider",
442 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME,
443 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION,
444 kOsAll,
445 MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices)
446 },
447 {
[email protected]7e7a28092011-12-09 22:24:55448 "enable-panels",
449 IDS_FLAGS_ENABLE_PANELS_NAME,
450 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54451 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55452 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54453 },
[email protected]e3749d12011-07-25 22:22:12454 {
[email protected]9931875b2011-11-02 00:19:48455 "disable-shortcuts-provider",
456 IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER,
457 IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER_DESCRIPTION,
[email protected]e3749d12011-07-25 22:22:12458 kOsAll,
[email protected]9931875b2011-11-02 00:19:48459 SINGLE_VALUE_TYPE(switches::kDisableShortcutsProvider)
[email protected]e3749d12011-07-25 22:22:12460 },
[email protected]80eb4262011-08-03 16:10:41461 {
[email protected]a0e4b072011-08-17 01:47:07462 "downloads-new-ui", // FLAGS:RECORD_UMA
463 IDS_FLAGS_DOWNLOADS_NEW_UI_NAME,
464 IDS_FLAGS_DOWNLOADS_NEW_UI_DESCRIPTION,
465 kOsAll,
466 SINGLE_VALUE_TYPE(switches::kDownloadsNewUI)
467 },
[email protected]b7bb44f2011-09-01 05:17:03468 {
[email protected]6474b112012-05-04 19:35:27469 "save-page-as-mhtml", // FLAGS:RECORD_UMA
470 IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME,
471 IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION,
472 kOsMac | kOsWin | kOsLinux,
473 SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)
474 },
475 {
[email protected]b7bb44f2011-09-01 05:17:03476 "enable-autologin",
477 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
478 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
479 kOsMac | kOsWin | kOsLinux,
480 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
481 },
[email protected]b9841172011-09-26 23:36:09482 {
[email protected]bbadb112011-12-12 16:55:28483 "enable-http-pipelining",
484 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
485 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
486 kOsAll,
487 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
488 },
[email protected]d411c01d2011-10-18 16:00:27489 {
[email protected]3231b612012-03-23 05:57:54490 "enable-spdy3",
491 IDS_FLAGS_ENABLE_SPDY3_NAME,
492 IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION,
493 kOsAll,
494 SINGLE_VALUE_TYPE(switches::kEnableSpdy3)
495 },
496 {
[email protected]27b3fe92012-03-21 05:35:06497 "enable-async-dns",
498 IDS_FLAGS_ENABLE_ASYNC_DNS_NAME,
499 IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32500 kOsWin | kOsMac | kOsLinux | kOsCrOS,
[email protected]27b3fe92012-03-21 05:35:06501 SINGLE_VALUE_TYPE(switches::kEnableAsyncDns)
502 },
503 {
[email protected]f5da41d2011-10-08 17:40:07504 "enable-video-track",
505 IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME,
506 IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION,
507 kOsAll,
508 SINGLE_VALUE_TYPE(switches::kEnableVideoTrack)
509 },
[email protected]08b83362011-10-19 05:23:17510 {
[email protected]6aa03b32011-10-27 21:44:44511 "enable-media-source",
512 IDS_FLAGS_ENABLE_MEDIA_SOURCE_NAME,
513 IDS_FLAGS_ENABLE_MEDIA_SOURCE_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32514 kOsAll,
[email protected]6aa03b32011-10-27 21:44:44515 SINGLE_VALUE_TYPE(switches::kEnableMediaSource)
516 },
[email protected]e4e68dbb2011-11-18 01:50:22517 {
[email protected]9f5b7822012-04-18 23:39:03518 "enable-encrypted-media",
519 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME,
520 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION,
521 kOsAll,
522 SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia)
523 },
524 {
[email protected]e4e68dbb2011-11-18 01:50:22525 "enable-pointer-lock",
526 IDS_FLAGS_ENABLE_POINTER_LOCK_NAME,
527 IDS_FLAGS_ENABLE_POINTER_LOCK_DESCRIPTION,
528 kOsAll,
529 SINGLE_VALUE_TYPE(switches::kEnablePointerLock)
530 },
[email protected]dc04be7c2012-03-15 23:57:49531#if defined(USE_ASH)
[email protected]8cc10df2011-11-03 23:57:50532 {
[email protected]57b8bb352012-01-11 05:11:46533 "aura-google-dialog-frames",
534 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME,
535 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION,
536 kOsWin | kOsLinux | kOsCrOS,
537 SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames)
538 },
[email protected]dc04be7c2012-03-15 23:57:49539#endif
[email protected]eaae8b462012-01-20 22:20:39540 {
541 "enable-gamepad",
542 IDS_FLAGS_ENABLE_GAMEPAD_NAME,
543 IDS_FLAGS_ENABLE_GAMEPAD_DESCRIPTION,
544 kOsAll,
545 SINGLE_VALUE_TYPE(switches::kEnableGamepad)
546 },
[email protected]db543d322011-12-15 20:40:15547 {
548 "per-tile-painting",
549 IDS_FLAGS_PER_TILE_PAINTING_NAME,
550 IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION,
551#if defined(USE_SKIA)
[email protected]a5b1b272012-01-06 20:44:37552 kOsMac | kOsLinux | kOsCrOS,
[email protected]db543d322011-12-15 20:40:15553#else
554 0,
555#endif
556 SINGLE_VALUE_TYPE(switches::kEnablePerTilePainting)
557 },
[email protected]bf88c032011-12-22 19:05:47558 {
559 "enable-javascript-harmony",
560 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME,
561 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION,
562 kOsAll,
563 SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony")
564 },
[email protected]7e7f378a2012-01-05 14:35:37565 {
[email protected]85646172012-01-09 22:45:54566 "enable-tab-browser-dragging",
567 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME,
568 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION,
569 kOsWin,
570 SINGLE_VALUE_TYPE(switches::kTabBrowserDragging)
571 },
572 {
[email protected]068b7b52012-02-27 12:41:44573 "disable-restore-session-state",
574 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME,
575 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION,
[email protected]7e7f378a2012-01-05 14:35:37576 kOsAll,
[email protected]068b7b52012-02-27 12:41:44577 SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState)
[email protected]7e7f378a2012-01-05 14:35:37578 },
[email protected]88864db2012-01-18 20:56:35579 {
580 "disable-software-rasterizer",
581 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME,
582 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION,
583#if defined(ENABLE_SWIFTSHADER)
584 kOsAll,
585#else
586 0,
587#endif
588 SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer)
589 },
[email protected]15a5d722012-01-23 09:11:14590 {
[email protected]8ea05a12012-05-02 09:17:47591 "enable-peer-connection",
592 IDS_FLAGS_PEER_CONNECTION_NAME,
593 IDS_FLAGS_PEER_CONNECTION_DESCRIPTION,
594 kOsAll,
595 SINGLE_VALUE_TYPE(switches::kEnablePeerConnection)
596 },
597 {
[email protected]d2edc6702012-01-30 09:13:16598 "enable-shadow-dom",
599 IDS_FLAGS_SHADOW_DOM_NAME,
600 IDS_FLAGS_SHADOW_DOM_DESCRIPTION,
601 kOsAll,
602 SINGLE_VALUE_TYPE(switches::kEnableShadowDOM)
603 },
[email protected]9860c68b2012-02-02 01:58:09604 {
[email protected]4961218f2012-02-23 10:11:07605 "enable-style-scoped",
606 IDS_FLAGS_STYLE_SCOPED_NAME,
607 IDS_FLAGS_STYLE_SCOPED_DESCRIPTION,
608 kOsAll,
609 SINGLE_VALUE_TYPE(switches::kEnableStyleScoped)
610 },
611 {
[email protected]ca7a3d792012-03-02 15:55:49612 "enable-css-regions",
613 IDS_FLAGS_CSS_REGIONS_NAME,
614 IDS_FLAGS_CSS_REGIONS_DESCRIPTION,
615 kOsAll,
616 SINGLE_VALUE_TYPE(switches::kEnableCssRegions)
617 },
618 {
[email protected]9860c68b2012-02-02 01:58:09619 "enable-extension-activity-ui",
620 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME,
621 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION,
622 kOsAll,
623 SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI)
[email protected]8bed69d2012-02-02 06:46:00624 },
[email protected]54ae4e92012-02-16 15:19:05625 {
[email protected]3e8befc2012-03-13 01:17:03626 "disable-ntp-other-sessions-menu",
[email protected]156f966332012-02-29 00:03:16627 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME,
628 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION,
629 kOsAll,
[email protected]3e8befc2012-03-13 01:17:03630 SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu)
[email protected]156f966332012-02-29 00:03:16631 },
[email protected]dc04be7c2012-03-15 23:57:49632#if defined(USE_ASH)
[email protected]31cf1c52012-02-29 20:55:01633 {
[email protected]3cd198a22012-03-12 20:38:01634 "enable-ash-oak",
635 IDS_FLAGS_ENABLE_ASH_OAK_NAME,
636 IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION,
637 kOsAll,
638 SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak),
639 },
[email protected]31cf1c52012-02-29 20:55:01640#endif
[email protected]184ec592012-03-01 11:54:28641 {
642 "enable-devtools-experiments",
643 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME,
644 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION,
645 kOsAll,
646 SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments)
647 },
[email protected]76d1854e2012-03-02 23:57:44648 {
649 "enable-suggestions-ntp",
650 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME,
651 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION,
652 kOsAll,
653 SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage)
654 },
[email protected]a78ef9e2012-03-21 02:49:55655 {
[email protected]9f0f0062012-06-18 20:52:09656 "enable-chrome-to-mobile", // FLAGS:RECORD_UMA
657 IDS_FLAGS_ENABLE_CHROME_TO_MOBILE_NAME,
658 IDS_FLAGS_ENABLE_CHROME_TO_MOBILE_DESCRIPTION,
[email protected]a78ef9e2012-03-21 02:49:55659 kOsAll,
[email protected]9f0f0062012-06-18 20:52:09660 SINGLE_VALUE_TYPE(switches::kEnableChromeToMobile)
[email protected]a78ef9e2012-03-21 02:49:55661 },
[email protected]db92eeb2012-05-11 18:59:20662 {
663 "enable-captive-portal-detection",
664 IDS_FLAGS_CAPTIVE_PORTAL_CHECK_ON_ERROR_NAME,
665 IDS_FLAGS_CAPTIVE_PORTAL_CHECK_ON_ERROR_DESCRIPTION,
666 kOsMac | kOsWin | kOsLinux | kOsCrOS,
667 SINGLE_VALUE_TYPE(switches::kCaptivePortalDetection)
668 },
[email protected]8e466dd2012-05-04 19:16:05669#if defined(GOOGLE_CHROME_BUILD)
[email protected]a3d54252012-04-05 20:04:13670 {
[email protected]37b928e2012-05-30 09:01:10671 "disable-asynchronous-spellchecking",
672 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING,
673 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING_DESCRIPTION,
674 kOsWin | kOsLinux | kOsCrOS,
675 SINGLE_VALUE_TYPE(switches::kDisableAsynchronousSpellChecking)
[email protected]a3d54252012-04-05 20:04:13676 },
[email protected]8e466dd2012-05-04 19:16:05677#endif
[email protected]c9c73ad42012-04-18 03:35:59678 {
679 "touch-optimized-ui",
[email protected]347a0c72012-05-14 20:28:06680 IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME,
681 IDS_FLAGS_TOUCH_OPTIMIZED_UI_DESCRIPTION,
[email protected]f5364d22012-05-31 18:57:29682 kOsWin | kOsCrOS,
[email protected]347a0c72012-05-14 20:28:06683 MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
[email protected]c9c73ad42012-04-18 03:35:59684 },
[email protected]8a6aaa72012-04-20 20:53:58685 {
686 "enable-touch-events",
687 IDS_ENABLE_TOUCH_EVENTS_NAME,
688 IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
689 kOsAll,
690 SINGLE_VALUE_TYPE(switches::kEnableTouchEvents)
691 },
[email protected]0b60afa2012-04-19 17:36:39692#if defined(OS_CHROMEOS)
693 {
694 "no-discard-tabs",
695 IDS_FLAGS_NO_DISCARD_TABS_NAME,
696 IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION,
697 kOsCrOS,
698 SINGLE_VALUE_TYPE(switches::kNoDiscardTabs)
699 },
700#endif
[email protected]79be6d32012-04-24 20:47:44701 {
[email protected]9a5940d2012-04-27 19:16:23702 "allow-nacl-socket-api",
703 IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME,
704 IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION,
705 kOsAll,
706 SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*")
707 },
[email protected]85333732012-05-01 19:02:24708 {
[email protected]60673ad72012-05-02 06:16:33709 "stacked-tab-strip",
710 IDS_FLAGS_STACKED_TAB_STRIP_NAME,
711 IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION,
712 kOsWin,
713 SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip)
714 },
715 {
[email protected]4bd20202012-06-14 17:35:01716 "force-device-scale-factor",
[email protected]85333732012-05-01 19:02:24717 IDS_FLAGS_FORCE_HIGH_DPI_NAME,
718 IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION,
719 kOsCrOS,
[email protected]4bd20202012-06-14 17:35:01720 SINGLE_VALUE_TYPE_AND_VALUE(switches::kForceDeviceScaleFactor, "2")
[email protected]85333732012-05-01 19:02:24721 },
[email protected]190349fd2012-05-02 00:10:47722#if defined(OS_CHROMEOS)
723 {
724 "allow-touchpad-three-finger-click",
725 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME,
726 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION,
727 kOsCrOS,
728 SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick)
729 },
730#endif
[email protected]aab64e02012-05-03 19:24:16731 {
[email protected]816385ee2012-06-05 00:17:52732 "disable-client-oauth-signin",
733 IDS_FLAGS_DISABLE_CLIENT_OAUTH_SIGNIN_NAME,
734 IDS_FLAGS_DISABLE_CLIENT_OAUTH_SIGNIN_DESCRIPTION,
[email protected]aab64e02012-05-03 19:24:16735 kOsMac | kOsWin | kOsLinux,
[email protected]816385ee2012-06-05 00:17:52736 SINGLE_VALUE_TYPE(switches::kDisableClientOAuthSignin)
[email protected]aab64e02012-05-03 19:24:16737 },
[email protected]53520b1b2012-05-07 21:43:37738#if defined(USE_ASH)
739 {
[email protected]55444502012-05-10 15:43:53740 "show-launcher-alignment-menu",
741 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_NAME,
742 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION,
743 kOsAll,
744 SINGLE_VALUE_TYPE(switches::kShowLauncherAlignmentMenu)
745 },
[email protected]817ecd12012-05-16 18:36:53746 {
[email protected]73074742012-05-17 01:44:41747 "show-touch-hud",
748 IDS_FLAGS_SHOW_TOUCH_HUD_NAME,
749 IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION,
750 kOsAll,
751 SINGLE_VALUE_TYPE(ash::switches::kAshTouchHud)
752 },
753 {
[email protected]e154db32012-06-18 16:20:46754 "ash-notify-disabled",
755 IDS_FLAGS_DISABLE_ASH_NOTIFY_NAME,
756 IDS_FLAGS_DISABLE_ASH_NOTIFY_DESCRIPTION,
[email protected]817ecd12012-05-16 18:36:53757 kOsAll,
[email protected]e154db32012-06-18 16:20:46758 SINGLE_VALUE_TYPE(ash::switches::kAshNotifyDisabled),
[email protected]817ecd12012-05-16 18:36:53759 },
[email protected]9f0940b62012-05-23 22:56:35760 {
761 "enable-pinch",
762 IDS_FLAGS_ENABLE_PINCH_SCALE_NAME,
763 IDS_FLAGS_ENABLE_PINCH_SCALE_DESCRIPTION,
764 kOsAll,
765 SINGLE_VALUE_TYPE(switches::kEnablePinch),
766 },
[email protected]a8379312012-06-15 00:20:43767 {
768 "app-list-show-apps-only",
769 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_NAME,
770 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_DESCRIPTION,
771 kOsAll,
772 SINGLE_VALUE_TYPE(ash::switches::kAppListShowAppsOnly),
773 },
[email protected]6aee2592012-06-15 19:51:06774 {
775 "ash-extended-desktop",
776 IDS_FLAGS_ENABLE_ASH_EXTENDED_DESKTOP_NAME,
777 IDS_FLAGS_ENABLE_ASH_EXTENDED_DESKTOP_DESCRIPTION,
778 kOsAll,
779 SINGLE_VALUE_TYPE(ash::switches::kAshExtendedDesktop)
780 },
[email protected]73074742012-05-17 01:44:41781#endif // defined(USE_ASH)
[email protected]ed7b67f32012-05-28 10:12:28782#if defined(OS_CHROMEOS)
783 {
[email protected]a7668a12012-05-28 22:23:48784 "experimental-wallpaper-ui",
785 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_NAME,
786 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_DESCRIPTION,
787 kOsCrOS,
788 SINGLE_VALUE_TYPE(switches::kExperimentalWallpaperUI)
789 },
790 {
[email protected]ed7b67f32012-05-28 10:12:28791 "enable-new-oobe",
792 IDS_FLAGS_ENABLE_NEW_OOBE,
793 IDS_FLAGS_ENABLE_NEW_OOBE_DESCRIPTION,
794 kOsCrOS,
795 SINGLE_VALUE_TYPE(switches::kEnableNewOobe),
796 },
797#endif
[email protected]fc7a93c2012-06-08 20:25:39798 {
799 "enable-views-textfield",
800 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_NAME,
801 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_DESCRIPTION,
802 kOsWin,
803 SINGLE_VALUE_TYPE(switches::kEnableViewsTextfield),
804 },
[email protected]bd0cd3bb2012-06-14 03:03:38805 {
806 "new-checkbox-style",
807 IDS_FLAGS_NEW_CHECKBOX_STYLE,
808 IDS_FLAGS_NEW_CHECKBOX_STYLE_DESCRIPTION,
809 kOsLinux | kOsCrOS,
810 SINGLE_VALUE_TYPE(switches::kNewCheckboxStyle),
811 },
[email protected]2faeaabd2012-06-15 01:05:02812 {
813 "disable-non-fullscreen-mouse-lock",
814 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_NAME,
815 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_DESCRIPTION,
816 kOsAll,
817 SINGLE_VALUE_TYPE(switches::kDisableNonFullscreenMouseLock),
818 },
[email protected]7057b3e2012-06-18 19:19:16819#if defined(OS_CHROMEOS)
820 {
821 "enable-unsupported-bluetooth-devices",
822 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_NAME,
823 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_DESCRIPTION,
824 kOsCrOS,
825 SINGLE_VALUE_TYPE(switches::kEnableUnsupportedBluetoothDevices)
826 },
827#endif
[email protected]66dcb0492012-06-18 22:32:15828 { "enable-accelerated-video-decode",
829 IDS_FLAGS_ENABLE_ACCELERATED_VIDEO_DECODE_NAME,
830 IDS_FLAGS_ENABLE_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
831 kOsAll,
832 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedVideoDecode),
833 },
[email protected]a0e4b072011-08-17 01:47:07834};
[email protected]ad2a3ded2010-08-27 13:19:05835
[email protected]a314ee5a2010-10-26 21:23:28836const Experiment* experiments = kExperiments;
837size_t num_experiments = arraysize(kExperiments);
838
[email protected]e2ddbc92010-10-15 20:02:07839// Stores and encapsulates the little state that about:flags has.
840class FlagsState {
841 public:
842 FlagsState() : needs_restart_(false) {}
843 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
844 bool IsRestartNeededToCommitChanges();
845 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28846 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07847 void RemoveFlagsSwitches(
848 std::map<std::string, CommandLine::StringType>* switch_list);
849 void reset();
850
851 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55852 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07853 return Singleton<FlagsState>::get();
854 }
855
856 private:
857 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53858 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07859
860 DISALLOW_COPY_AND_ASSIGN(FlagsState);
861};
862
[email protected]c7b7800a2010-10-07 18:51:35863// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:05864// in a set.
[email protected]1a47d7e2010-10-15 00:37:24865void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:05866 const ListValue* enabled_experiments = prefs->GetList(
867 prefs::kEnabledLabsExperiments);
868 if (!enabled_experiments)
869 return;
870
871 for (ListValue::const_iterator it = enabled_experiments->begin();
872 it != enabled_experiments->end();
873 ++it) {
874 std::string experiment_name;
875 if (!(*it)->GetAsString(&experiment_name)) {
876 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
877 continue;
878 }
879 result->insert(experiment_name);
880 }
881}
882
883// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:24884void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05885 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:38886 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
887 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:05888
889 experiments_list->Clear();
890 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
891 it != enabled_experiments.end();
892 ++it) {
893 experiments_list->Append(new StringValue(*it));
894 }
895}
896
[email protected]8a6ff28d2010-12-02 16:35:19897// Returns the name used in prefs for the choice at the specified index.
898std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:34899 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
900 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:19901 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
902 base::IntToString(index);
903}
904
905// Adds the internal names for the specified experiment to |names|.
906void AddInternalName(const Experiment& e, std::set<std::string>* names) {
907 if (e.type == Experiment::SINGLE_VALUE) {
908 names->insert(e.internal_name);
909 } else {
[email protected]2ce9c89752011-02-25 18:24:34910 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:19911 for (int i = 0; i < e.num_choices; ++i)
912 names->insert(NameForChoice(e, i));
913 }
914}
915
[email protected]28e35af2011-02-09 12:56:22916// Confirms that an experiment is valid, used in a DCHECK in
917// SanitizeList below.
918bool ValidateExperiment(const Experiment& e) {
919 switch (e.type) {
920 case Experiment::SINGLE_VALUE:
921 DCHECK_EQ(0, e.num_choices);
922 DCHECK(!e.choices);
923 break;
924 case Experiment::MULTI_VALUE:
925 DCHECK_GT(e.num_choices, 0);
926 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:53927 DCHECK(e.choices[0].command_line_switch);
928 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:22929 break;
930 default:
931 NOTREACHED();
932 }
933 return true;
934}
935
[email protected]ad2a3ded2010-08-27 13:19:05936// Removes all experiments from prefs::kEnabledLabsExperiments that are
937// unknown, to prevent this list to become very long as experiments are added
938// and removed.
939void SanitizeList(PrefService* prefs) {
940 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:22941 for (size_t i = 0; i < num_experiments; ++i) {
942 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:19943 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:22944 }
[email protected]ad2a3ded2010-08-27 13:19:05945
946 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24947 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05948
949 std::set<std::string> new_enabled_experiments;
950 std::set_intersection(
951 known_experiments.begin(), known_experiments.end(),
952 enabled_experiments.begin(), enabled_experiments.end(),
953 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
954
[email protected]1a47d7e2010-10-15 00:37:24955 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05956}
957
[email protected]1a47d7e2010-10-15 00:37:24958void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05959 PrefService* prefs, std::set<std::string>* result) {
960 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:24961 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:05962}
963
[email protected]a314ee5a2010-10-26 21:23:28964// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
965// enabled on the current platform.
966void GetSanitizedEnabledFlagsForCurrentPlatform(
967 PrefService* prefs, std::set<std::string>* result) {
968 GetSanitizedEnabledFlags(prefs, result);
969
970 // Filter out any experiments that aren't enabled on the current platform. We
971 // don't remove these from prefs else syncing to a platform with a different
972 // set of experiments would be lossy.
973 std::set<std::string> platform_experiments;
974 int current_platform = GetCurrentPlatform();
975 for (size_t i = 0; i < num_experiments; ++i) {
976 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:19977 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:28978 }
979
980 std::set<std::string> new_enabled_experiments;
981 std::set_intersection(
982 platform_experiments.begin(), platform_experiments.end(),
983 result->begin(), result->end(),
984 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
985
986 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05987}
988
[email protected]8a6ff28d2010-12-02 16:35:19989// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:19990Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:22991 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:34992 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:19993 ListValue* result = new ListValue;
994 for (int i = 0; i < experiment.num_choices; ++i) {
995 const Experiment::Choice& choice = experiment.choices[i];
996 DictionaryValue* value = new DictionaryValue;
997 std::string name = NameForChoice(experiment, i);
998 value->SetString("description",
999 l10n_util::GetStringUTF16(choice.description_id));
1000 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:221001 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:191002 result->Append(value);
1003 }
1004 return result;
1005}
1006
[email protected]e2ddbc92010-10-15 20:02:071007} // namespace
1008
[email protected]1a47d7e2010-10-15 00:37:241009void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:551010 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:051011}
1012
[email protected]1a47d7e2010-10-15 00:37:241013ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:051014 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241015 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051016
1017 int current_platform = GetCurrentPlatform();
1018
1019 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:281020 for (size_t i = 0; i < num_experiments; ++i) {
1021 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:051022
1023 DictionaryValue* data = new DictionaryValue();
1024 data->SetString("internal_name", experiment.internal_name);
1025 data->SetString("name",
1026 l10n_util::GetStringUTF16(experiment.visible_name_id));
1027 data->SetString("description",
1028 l10n_util::GetStringUTF16(
1029 experiment.visible_description_id));
[email protected]cc3e2052011-12-20 01:01:401030 bool supported = !!(experiment.supported_platforms & current_platform);
1031 data->SetBoolean("supported", supported);
1032
1033 ListValue* supported_platforms = new ListValue();
1034 AddOsStrings(experiment.supported_platforms, supported_platforms);
1035 data->Set("supported_platforms", supported_platforms);
[email protected]ad2a3ded2010-08-27 13:19:051036
[email protected]28e35af2011-02-09 12:56:221037 switch (experiment.type) {
1038 case Experiment::SINGLE_VALUE:
1039 data->SetBoolean(
1040 "enabled",
1041 enabled_experiments.count(experiment.internal_name) > 0);
1042 break;
1043 case Experiment::MULTI_VALUE:
1044 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
1045 break;
1046 default:
1047 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:191048 }
1049
[email protected]ad2a3ded2010-08-27 13:19:051050 experiments_data->Append(data);
1051 }
1052 return experiments_data;
1053}
1054
[email protected]ad2a3ded2010-08-27 13:19:051055bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:551056 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:051057}
1058
1059void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:351060 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:551061 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:071062}
1063
1064void RemoveFlagsSwitches(
1065 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:551066 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:071067}
1068
[email protected]a314ee5a2010-10-26 21:23:281069int GetCurrentPlatform() {
1070#if defined(OS_MACOSX)
1071 return kOsMac;
1072#elif defined(OS_WIN)
1073 return kOsWin;
1074#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
1075 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:211076#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:281077 return kOsLinux;
[email protected]9c7453d2012-01-21 00:45:401078#elif defined(OS_ANDROID)
1079 return kOsAndroid;
[email protected]a314ee5a2010-10-26 21:23:281080#else
1081#error Unknown platform
1082#endif
1083}
1084
[email protected]4bc5050c2010-11-18 17:55:541085void RecordUMAStatistics(const PrefService* prefs) {
1086 std::set<std::string> flags;
1087 GetEnabledFlags(prefs, &flags);
1088 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
1089 ++it) {
1090 std::string action("AboutFlags_");
1091 action += *it;
[email protected]7f6f44c2011-12-14 13:23:381092 content::RecordComputedAction(action);
[email protected]4bc5050c2010-11-18 17:55:541093 }
1094 // Since flag metrics are recorded every startup, add a tick so that the
1095 // stats can be made meaningful.
1096 if (flags.size())
[email protected]7f6f44c2011-12-14 13:23:381097 content::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
1098 content::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:541099}
1100
[email protected]e2ddbc92010-10-15 20:02:071101//////////////////////////////////////////////////////////////////////////////
1102// FlagsState implementation.
1103
1104namespace {
1105
1106void FlagsState::ConvertFlagsToSwitches(
1107 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:071108 if (command_line->HasSwitch(switches::kNoExperiments))
1109 return;
1110
1111 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:001112
[email protected]a314ee5a2010-10-26 21:23:281113 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:071114
[email protected]a82744532011-02-11 16:15:531115 typedef std::map<std::string, std::pair<std::string, std::string> >
1116 NameToSwitchAndValueMap;
1117 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:191118 for (size_t i = 0; i < num_experiments; ++i) {
1119 const Experiment& e = experiments[i];
1120 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:531121 name_to_switch_map[e.internal_name] =
1122 std::pair<std::string, std::string>(e.command_line_switch,
1123 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191124 } else {
1125 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:531126 name_to_switch_map[NameForChoice(e, j)] =
1127 std::pair<std::string, std::string>(
1128 e.choices[j].command_line_switch,
1129 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191130 }
1131 }
[email protected]e2ddbc92010-10-15 20:02:071132
1133 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:531134 flags_switches_.insert(
1135 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
1136 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071137 for (std::set<std::string>::iterator it = enabled_experiments.begin();
1138 it != enabled_experiments.end();
1139 ++it) {
1140 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:531141 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:191142 name_to_switch_map.find(experiment_name);
1143 if (name_to_switch_it == name_to_switch_map.end()) {
1144 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:071145 continue;
[email protected]8a6ff28d2010-12-02 16:35:191146 }
[email protected]e2ddbc92010-10-15 20:02:071147
[email protected]a82744532011-02-11 16:15:531148 const std::pair<std::string, std::string>&
1149 switch_and_value_pair = name_to_switch_it->second;
1150
1151 command_line->AppendSwitchASCII(switch_and_value_pair.first,
1152 switch_and_value_pair.second);
1153 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:071154 }
1155 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:531156 flags_switches_.insert(
1157 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
1158 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071159}
1160
1161bool FlagsState::IsRestartNeededToCommitChanges() {
1162 return needs_restart_;
1163}
1164
1165void FlagsState::SetExperimentEnabled(
1166 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:051167 needs_restart_ = true;
1168
[email protected]8a6ff28d2010-12-02 16:35:191169 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
1170 if (at_index != std::string::npos) {
1171 DCHECK(enable);
1172 // We're being asked to enable a multi-choice experiment. Disable the
1173 // currently selected choice.
1174 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:221175 const std::string experiment_name = internal_name.substr(0, at_index);
1176 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:191177
[email protected]28e35af2011-02-09 12:56:221178 // And enable the new choice, if it is not the default first choice.
1179 if (internal_name != experiment_name + "@0") {
1180 std::set<std::string> enabled_experiments;
1181 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
1182 enabled_experiments.insert(internal_name);
1183 SetEnabledFlags(prefs, enabled_experiments);
1184 }
[email protected]8a6ff28d2010-12-02 16:35:191185 return;
1186 }
1187
[email protected]ad2a3ded2010-08-27 13:19:051188 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241189 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051190
[email protected]8a6ff28d2010-12-02 16:35:191191 const Experiment* e = NULL;
1192 for (size_t i = 0; i < num_experiments; ++i) {
1193 if (experiments[i].internal_name == internal_name) {
1194 e = experiments + i;
1195 break;
1196 }
1197 }
1198 DCHECK(e);
1199
1200 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:591201 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:191202 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:591203 else
[email protected]8a6ff28d2010-12-02 16:35:191204 enabled_experiments.erase(internal_name);
1205 } else {
1206 if (enable) {
1207 // Enable the first choice.
1208 enabled_experiments.insert(NameForChoice(*e, 0));
1209 } else {
1210 // Find the currently enabled choice and disable it.
1211 for (int i = 0; i < e->num_choices; ++i) {
1212 std::string choice_name = NameForChoice(*e, i);
1213 if (enabled_experiments.find(choice_name) !=
1214 enabled_experiments.end()) {
1215 enabled_experiments.erase(choice_name);
1216 // Continue on just in case there's a bug and more than one
1217 // experiment for this choice was enabled.
1218 }
1219 }
1220 }
1221 }
[email protected]ad2a3ded2010-08-27 13:19:051222
[email protected]1a47d7e2010-10-15 00:37:241223 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051224}
1225
[email protected]e2ddbc92010-10-15 20:02:071226void FlagsState::RemoveFlagsSwitches(
1227 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:531228 for (std::map<std::string, std::string>::const_iterator
1229 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
1230 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:071231 }
1232}
1233
1234void FlagsState::reset() {
1235 needs_restart_ = false;
1236 flags_switches_.clear();
1237}
1238
[email protected]38e46812011-05-09 20:49:221239} // namespace
[email protected]e2ddbc92010-10-15 20:02:071240
1241namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:191242
1243// WARNING: '@' is also used in the html file. If you update this constant you
1244// also need to update the html file.
1245const char kMultiSeparator[] = "@";
1246
[email protected]e2ddbc92010-10-15 20:02:071247void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:551248 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:071249}
[email protected]a314ee5a2010-10-26 21:23:281250
1251void SetExperiments(const Experiment* e, size_t count) {
1252 if (!e) {
1253 experiments = kExperiments;
1254 num_experiments = arraysize(kExperiments);
1255 } else {
1256 experiments = e;
1257 num_experiments = count;
1258 }
1259}
1260
[email protected]8a6ff28d2010-12-02 16:35:191261const Experiment* GetExperiments(size_t* count) {
1262 *count = num_experiments;
1263 return experiments;
1264}
1265
[email protected]e2ddbc92010-10-15 20:02:071266} // namespace testing
1267
[email protected]1a47d7e2010-10-15 00:37:241268} // namespace about_flags