blob: b5885cbad82c986d5c2f55c5ade964e2a560f18c [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]032d5e6c2012-02-17 17:53:5585const Experiment::Choice kOmniboxInlineHistoryQuickProviderChoices[] = {
86 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_AUTOMATIC, "", "" },
87 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_ALLOWED,
88 switches::kOmniboxInlineHistoryQuickProvider,
89 switches::kOmniboxInlineHistoryQuickProviderAllowed },
90 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_PROHIBITED,
91 switches::kOmniboxInlineHistoryQuickProvider,
92 switches::kOmniboxInlineHistoryQuickProviderProhibited }
93};
94
[email protected]9b19cf82012-06-13 06:23:2395const Experiment::Choice kForceCompositingModeChoices[] = {
96 { IDS_FLAGS_FORCE_COMPOSITING_MODE_DEFAULT, "", "" },
97 { IDS_FLAGS_FORCE_COMPOSITING_MODE_ENABLED,
98 switches::kForceCompositingMode, ""},
99 { IDS_FLAGS_FORCE_COMPOSITING_MODE_DISABLED,
100 switches::kDisableForceCompositingMode, ""}
101};
102
[email protected]72787e392012-03-23 05:55:43103const Experiment::Choice kThreadedCompositingModeChoices[] = {
104 { IDS_FLAGS_THREADED_COMPOSITING_MODE_DEFAULT, "", "" },
105 { IDS_FLAGS_THREADED_COMPOSITING_MODE_DISABLED,
106 switches::kDisableThreadedCompositing, ""},
107 { IDS_FLAGS_THREADED_COMPOSITING_MODE_ENABLED,
108 switches::kEnableThreadedCompositing, ""}
109};
110
[email protected]347a0c72012-05-14 20:28:06111const Experiment::Choice kTouchOptimizedUIChoices[] = {
112 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_AUTOMATIC, "", "" },
113 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_ENABLED,
114 switches::kTouchOptimizedUI,
115 switches::kTouchOptimizedUIEnabled },
116 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_DISABLED,
117 switches::kTouchOptimizedUI,
118 switches::kTouchOptimizedUIDisabled }
119};
120
121
[email protected]4bc5050c2010-11-18 17:55:54122// RECORDING USER METRICS FOR FLAGS:
123// -----------------------------------------------------------------------------
124// The first line of the experiment is the internal name. If you'd like to
125// gather statistics about the usage of your flag, you should append a marker
126// comment to the end of the feature name, like so:
127// "my-special-feature", // FLAGS:RECORD_UMA
128//
129// After doing that, run //chrome/tools/extract_actions.py (see instructions at
130// the top of that file for details) to update the chromeactions.txt file, which
131// will enable UMA to record your feature flag.
132//
133// After your feature has shipped under a flag, you can locate the metrics
134// under the action name AboutFlags_internal-action-name. Actions are recorded
135// once per startup, so you should divide this number by AboutFlags_StartupTick
136// to get a sense of usage. Note that this will not be the same as number of
137// users with a given feature enabled because users can quit and relaunch
138// the application multiple times over a given time interval.
139// TODO(rsesek): See if there's a way to count per-user, rather than
140// per-startup.
141
[email protected]8a6ff28d2010-12-02 16:35:19142// To add a new experiment add to the end of kExperiments. There are two
143// distinct types of experiments:
144// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
145// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:22146// . MULTI_VALUE: a list of choices, the first of which should correspond to a
147// deactivated state for this lab (i.e. no command line option). To specify
148// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
149// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:19150// See the documentation of Experiment for details on the fields.
151//
152// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:05153const Experiment kExperiments[] = {
154 {
[email protected]aac169d2011-03-18 19:53:03155 "expose-for-tabs", // FLAGS:RECORD_UMA
156 IDS_FLAGS_TABPOSE_NAME,
157 IDS_FLAGS_TABPOSE_DESCRIPTION,
158 kOsMac,
159#if defined(OS_MACOSX)
160 // The switch exists only on OS X.
161 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
162#else
163 SINGLE_VALUE_TYPE("")
164#endif
165 },
166 {
[email protected]4bc5050c2010-11-18 17:55:54167 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05168 IDS_FLAGS_CONFLICTS_CHECK_NAME,
169 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
170 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19171 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05172 },
173 {
[email protected]4bc5050c2010-11-18 17:55:54174 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]dae7325b2011-12-21 20:56:54175 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME,
176 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45177 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22178 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31179 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22180 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
181 // always have PDF rasterization available, so no flag needed there.
182#if !defined(GOOGLE_CHROME_BUILD)
183 kOsWin,
184#else
185 0,
[email protected]fa6d2a2f2010-11-30 21:47:19186#endif
[email protected]8a6ff28d2010-12-02 16:35:19187 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42188 },
[email protected]580939a2010-10-12 18:54:37189 {
[email protected]bb461532010-11-26 21:50:23190 "crxless-web-apps",
191 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
192 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
193 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19194 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23195 },
196 {
[email protected]96c6f4c2011-05-18 19:36:22197 "ignore-gpu-blacklist",
198 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
199 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
200 kOsAll,
201 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
202 },
203 {
[email protected]0110cf112011-07-02 00:39:43204 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22205 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
206 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
[email protected]9b19cf82012-06-13 06:23:23207 kOsMac | kOsWin | kOsLinux,
208 MULTI_VALUE_TYPE(kForceCompositingModeChoices)
[email protected]96c6f4c2011-05-18 19:36:22209 },
210 {
[email protected]72787e392012-03-23 05:55:43211 "threaded-compositing-mode",
212 IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME,
213 IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59214 kOsAll,
[email protected]72787e392012-03-23 05:55:43215 MULTI_VALUE_TYPE(kThreadedCompositingModeChoices)
[email protected]644a1072012-03-16 09:29:59216 },
217 {
[email protected]81c64af62012-06-06 20:15:52218 "disable-accelerated-2d-canvas",
219 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_NAME,
220 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_DESCRIPTION,
221 kOsAll,
222 SINGLE_VALUE_TYPE(switches::kDisableAccelerated2dCanvas)
223 },
224 {
[email protected]2cd73322012-05-30 13:15:49225 "disable-deferred-2d-canvas",
226 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_NAME,
227 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_DESCRIPTION,
228 kOsAll,
229 SINGLE_VALUE_TYPE(switches::kDisableDeferred2dCanvas)
230 },
231 {
[email protected]efcde132012-05-30 01:05:18232 "disable-threaded-animation",
233 IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME,
234 IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59235 kOsAll,
[email protected]efcde132012-05-30 01:05:18236 SINGLE_VALUE_TYPE(switches::kDisableThreadedAnimation)
[email protected]644a1072012-03-16 09:29:59237 },
238 {
[email protected]5963b772011-02-09 22:55:38239 "composited-layer-borders",
240 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
241 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
242 kOsAll,
243 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
244 },
245 {
[email protected]a8f1eaa2011-03-07 19:00:58246 "show-fps-counter",
247 IDS_FLAGS_SHOW_FPS_COUNTER,
248 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
249 kOsAll,
250 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
251 },
[email protected]8ff7f342011-05-25 01:49:47252 {
[email protected]70c98a332011-12-21 20:51:52253 "accelerated-filters",
254 IDS_FLAGS_ACCELERATED_FILTERS,
255 IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION,
256 kOsAll,
257 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters)
258 },
259 {
[email protected]8ff7f342011-05-25 01:49:47260 "disable-gpu-vsync",
261 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
262 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
263 kOsAll,
264 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
265 },
[email protected]deaba6d52011-09-23 14:47:12266 {
267 "disable-webgl",
268 IDS_FLAGS_DISABLE_WEBGL_NAME,
269 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
270 kOsAll,
271 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
272 },
[email protected]09096e02012-05-24 11:12:04273 {
[email protected]96bcdc102012-05-24 23:42:10274 "fixed-position-creates-stacking-context",
275 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_NAME,
276 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_DESCRIPTION,
277 kOsAll,
278 SINGLE_VALUE_TYPE(switches::kFixedPositionCreatesStackingContext)
279 },
[email protected]d208f4d82011-05-23 21:52:03280 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53281 {
[email protected]e3791ce92011-08-09 01:03:32282 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40283 IDS_FLAGS_ENABLE_NACL_NAME,
284 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
285 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19286 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40287 },
[email protected]b39c6d92012-01-31 16:38:41288 // TODO(halyavin): When exception handling is on by default, replace this
289 // flag with disable-nacl-exception-handling.
290 {
291 "enable-nacl-exception-handling", // FLAGS:RECORD_UMA
292 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME,
293 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION,
294 kOsWin,
295 SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling)
296 },
[email protected]4ff87d202010-11-06 01:28:40297 {
[email protected]31a665e72012-03-11 12:37:46298 "nacl-gdb", // FLAGS:RECORD_UMA
299 IDS_FLAGS_NACL_GDB_NAME,
300 IDS_FLAGS_NACL_GDB_DESCRIPTION,
301 kOsWin,
302 SINGLE_VALUE_TYPE(switches::kNaClGdb)
303 },
304 {
[email protected]401b90792012-05-30 11:41:13305 "nacl-gdb-script", // FLAGS:RECORD_UMA
306 IDS_FLAGS_NACL_GDB_SCRIPT_NAME,
307 IDS_FLAGS_NACL_GDB_SCRIPT_DESCRIPTION,
308 kOsAll,
309 SINGLE_VALUE_TYPE(switches::kNaClGdbScript)
310 },
311 {
[email protected]4bc5050c2010-11-18 17:55:54312 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32313 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
314 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
315 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19316 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32317 },
[email protected]3627b06d2010-11-12 16:36:16318 {
[email protected]cab18ef2012-04-27 07:22:03319 "action-box",
320 IDS_FLAGS_ACTION_BOX_NAME,
321 IDS_FLAGS_ACTION_BOX_DESCRIPTION,
322 kOsAll,
323 SINGLE_VALUE_TYPE(switches::kEnableActionBox),
324 },
325 {
[email protected]3a362432012-06-18 20:39:51326 "script-badges",
327 IDS_FLAGS_SCRIPT_BADGES_NAME,
328 IDS_FLAGS_SCRIPT_BADGES_DESCRIPTION,
329 kOsAll,
330 SINGLE_VALUE_TYPE(switches::kEnableScriptBadges),
331 },
332 {
[email protected]cbe224d2011-08-04 22:12:49333 "apps-new-install-bubble",
334 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
335 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
336 kOsAll,
337 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
338 },
339 {
[email protected]80bd24e2010-11-30 09:34:38340 "disable-hyperlink-auditing",
341 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
342 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
343 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19344 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51345 },
346 {
347 "experimental-location-features", // FLAGS:RECORD_UMA
348 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
349 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
350 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19351 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
352 },
353 {
[email protected]04227962011-01-20 02:03:09354 "disable-interactive-form-validation",
355 IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_NAME,
356 IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_DESCRIPTION,
357 kOsAll,
358 SINGLE_VALUE_TYPE(switches::kDisableInteractiveFormValidation)
359 },
[email protected]8df51192011-01-22 20:05:03360 {
[email protected]07d490bc2011-03-07 17:05:26361 "focus-existing-tab-on-open", // FLAGS:RECORD_UMA
362 IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_NAME,
363 IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_DESCRIPTION,
364 kOsAll,
365 SINGLE_VALUE_TYPE(switches::kFocusExistingTabOnOpen)
366 },
[email protected]d5dcfb32011-03-19 00:49:24367 {
[email protected]5aea1862011-03-23 23:55:39368 "tab-groups-context-menu",
369 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
370 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
371 kOsWin,
372 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
373 },
[email protected]c94cebd2012-06-21 00:55:28374#if defined(OS_CHROMEOS)
375 {
376 "enable-instant-extended-api",
377 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API,
378 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API_DESCRIPTION,
379 kOsAll,
380 SINGLE_VALUE_TYPE(switches::kEnableInstantExtendedAPI)
381 },
382#endif
[email protected]e9bf9d92011-03-31 20:57:15383 {
[email protected]354e33b2011-06-15 00:29:10384 "static-ip-config",
385 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
386 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
387 kOsCrOS,
388#if defined(OS_CHROMEOS)
389 // This switch exists only on Chrome OS.
390 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
391#else
392 SINGLE_VALUE_TYPE("")
393#endif
394 },
[email protected]3eb5728c2011-06-20 22:32:24395 {
396 "show-autofill-type-predictions",
397 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
398 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
399 kOsAll,
400 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
401 },
[email protected]bff4d3e2011-06-21 23:58:52402 {
[email protected]fdf4e252012-04-27 00:26:55403 "sync-tab-favicons",
404 IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
405 IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
406 kOsAll,
407 SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
408 },
409 {
[email protected]aae9eeb12011-10-21 21:59:26410 "sync-app-notifications",
411 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
412 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
413 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11414 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26415 },
416 {
[email protected]a22ebd812011-06-23 00:05:39417 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
418 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
419 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
420 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40421 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40422 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39423 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
424 },
[email protected]81a6b0b2011-06-24 17:55:40425 {
[email protected]68317802012-06-07 19:13:23426 "omnibox-history-quick-provider-new-scoring",
427 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_NAME,
428 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DESCRIPTION,
429 kOsAll,
430 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderNewScoringChoices)
431 },
432 {
[email protected]032d5e6c2012-02-17 17:53:55433 "omnibox-inline-history-quick-provider",
434 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME,
435 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION,
436 kOsAll,
437 MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices)
438 },
439 {
[email protected]7e7a28092011-12-09 22:24:55440 "enable-panels",
441 IDS_FLAGS_ENABLE_PANELS_NAME,
442 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54443 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55444 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54445 },
[email protected]e3749d12011-07-25 22:22:12446 {
[email protected]9931875b2011-11-02 00:19:48447 "disable-shortcuts-provider",
448 IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER,
449 IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER_DESCRIPTION,
[email protected]e3749d12011-07-25 22:22:12450 kOsAll,
[email protected]9931875b2011-11-02 00:19:48451 SINGLE_VALUE_TYPE(switches::kDisableShortcutsProvider)
[email protected]e3749d12011-07-25 22:22:12452 },
[email protected]80eb4262011-08-03 16:10:41453 {
[email protected]a0e4b072011-08-17 01:47:07454 "downloads-new-ui", // FLAGS:RECORD_UMA
455 IDS_FLAGS_DOWNLOADS_NEW_UI_NAME,
456 IDS_FLAGS_DOWNLOADS_NEW_UI_DESCRIPTION,
457 kOsAll,
458 SINGLE_VALUE_TYPE(switches::kDownloadsNewUI)
459 },
[email protected]b7bb44f2011-09-01 05:17:03460 {
[email protected]6474b112012-05-04 19:35:27461 "save-page-as-mhtml", // FLAGS:RECORD_UMA
462 IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME,
463 IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION,
464 kOsMac | kOsWin | kOsLinux,
465 SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)
466 },
467 {
[email protected]b7bb44f2011-09-01 05:17:03468 "enable-autologin",
469 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
470 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
471 kOsMac | kOsWin | kOsLinux,
472 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
473 },
[email protected]b9841172011-09-26 23:36:09474 {
[email protected]bbadb112011-12-12 16:55:28475 "enable-http-pipelining",
476 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
477 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
478 kOsAll,
479 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
480 },
[email protected]d411c01d2011-10-18 16:00:27481 {
[email protected]3231b612012-03-23 05:57:54482 "enable-spdy3",
483 IDS_FLAGS_ENABLE_SPDY3_NAME,
484 IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION,
485 kOsAll,
486 SINGLE_VALUE_TYPE(switches::kEnableSpdy3)
487 },
488 {
[email protected]27b3fe92012-03-21 05:35:06489 "enable-async-dns",
490 IDS_FLAGS_ENABLE_ASYNC_DNS_NAME,
491 IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32492 kOsWin | kOsMac | kOsLinux | kOsCrOS,
[email protected]27b3fe92012-03-21 05:35:06493 SINGLE_VALUE_TYPE(switches::kEnableAsyncDns)
494 },
495 {
[email protected]f5da41d2011-10-08 17:40:07496 "enable-video-track",
497 IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME,
498 IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION,
499 kOsAll,
500 SINGLE_VALUE_TYPE(switches::kEnableVideoTrack)
501 },
[email protected]08b83362011-10-19 05:23:17502 {
[email protected]6aa03b32011-10-27 21:44:44503 "enable-media-source",
504 IDS_FLAGS_ENABLE_MEDIA_SOURCE_NAME,
505 IDS_FLAGS_ENABLE_MEDIA_SOURCE_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32506 kOsAll,
[email protected]6aa03b32011-10-27 21:44:44507 SINGLE_VALUE_TYPE(switches::kEnableMediaSource)
508 },
[email protected]e4e68dbb2011-11-18 01:50:22509 {
[email protected]9f5b7822012-04-18 23:39:03510 "enable-encrypted-media",
511 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME,
512 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION,
513 kOsAll,
514 SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia)
515 },
516 {
[email protected]e4e68dbb2011-11-18 01:50:22517 "enable-pointer-lock",
518 IDS_FLAGS_ENABLE_POINTER_LOCK_NAME,
519 IDS_FLAGS_ENABLE_POINTER_LOCK_DESCRIPTION,
520 kOsAll,
521 SINGLE_VALUE_TYPE(switches::kEnablePointerLock)
522 },
[email protected]dc04be7c2012-03-15 23:57:49523#if defined(USE_ASH)
[email protected]8cc10df2011-11-03 23:57:50524 {
[email protected]57b8bb352012-01-11 05:11:46525 "aura-google-dialog-frames",
526 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME,
527 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION,
528 kOsWin | kOsLinux | kOsCrOS,
529 SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames)
530 },
[email protected]dc04be7c2012-03-15 23:57:49531#endif
[email protected]eaae8b462012-01-20 22:20:39532 {
533 "enable-gamepad",
534 IDS_FLAGS_ENABLE_GAMEPAD_NAME,
535 IDS_FLAGS_ENABLE_GAMEPAD_DESCRIPTION,
536 kOsAll,
537 SINGLE_VALUE_TYPE(switches::kEnableGamepad)
538 },
[email protected]db543d322011-12-15 20:40:15539 {
540 "per-tile-painting",
541 IDS_FLAGS_PER_TILE_PAINTING_NAME,
542 IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION,
543#if defined(USE_SKIA)
[email protected]a5b1b272012-01-06 20:44:37544 kOsMac | kOsLinux | kOsCrOS,
[email protected]db543d322011-12-15 20:40:15545#else
546 0,
547#endif
548 SINGLE_VALUE_TYPE(switches::kEnablePerTilePainting)
549 },
[email protected]bf88c032011-12-22 19:05:47550 {
551 "enable-javascript-harmony",
552 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME,
553 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION,
554 kOsAll,
555 SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony")
556 },
[email protected]7e7f378a2012-01-05 14:35:37557 {
[email protected]85646172012-01-09 22:45:54558 "enable-tab-browser-dragging",
559 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME,
560 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION,
561 kOsWin,
562 SINGLE_VALUE_TYPE(switches::kTabBrowserDragging)
563 },
564 {
[email protected]068b7b52012-02-27 12:41:44565 "disable-restore-session-state",
566 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME,
567 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION,
[email protected]7e7f378a2012-01-05 14:35:37568 kOsAll,
[email protected]068b7b52012-02-27 12:41:44569 SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState)
[email protected]7e7f378a2012-01-05 14:35:37570 },
[email protected]88864db2012-01-18 20:56:35571 {
572 "disable-software-rasterizer",
573 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME,
574 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION,
575#if defined(ENABLE_SWIFTSHADER)
576 kOsAll,
577#else
578 0,
579#endif
580 SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer)
581 },
[email protected]15a5d722012-01-23 09:11:14582 {
[email protected]8ea05a12012-05-02 09:17:47583 "enable-peer-connection",
584 IDS_FLAGS_PEER_CONNECTION_NAME,
585 IDS_FLAGS_PEER_CONNECTION_DESCRIPTION,
586 kOsAll,
587 SINGLE_VALUE_TYPE(switches::kEnablePeerConnection)
588 },
589 {
[email protected]d2edc6702012-01-30 09:13:16590 "enable-shadow-dom",
591 IDS_FLAGS_SHADOW_DOM_NAME,
592 IDS_FLAGS_SHADOW_DOM_DESCRIPTION,
593 kOsAll,
594 SINGLE_VALUE_TYPE(switches::kEnableShadowDOM)
595 },
[email protected]9860c68b2012-02-02 01:58:09596 {
[email protected]4961218f2012-02-23 10:11:07597 "enable-style-scoped",
598 IDS_FLAGS_STYLE_SCOPED_NAME,
599 IDS_FLAGS_STYLE_SCOPED_DESCRIPTION,
600 kOsAll,
601 SINGLE_VALUE_TYPE(switches::kEnableStyleScoped)
602 },
603 {
[email protected]ca7a3d792012-03-02 15:55:49604 "enable-css-regions",
605 IDS_FLAGS_CSS_REGIONS_NAME,
606 IDS_FLAGS_CSS_REGIONS_DESCRIPTION,
607 kOsAll,
608 SINGLE_VALUE_TYPE(switches::kEnableCssRegions)
609 },
610 {
[email protected]9860c68b2012-02-02 01:58:09611 "enable-extension-activity-ui",
612 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME,
613 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION,
614 kOsAll,
615 SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI)
[email protected]8bed69d2012-02-02 06:46:00616 },
[email protected]54ae4e92012-02-16 15:19:05617 {
[email protected]3e8befc2012-03-13 01:17:03618 "disable-ntp-other-sessions-menu",
[email protected]156f966332012-02-29 00:03:16619 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME,
620 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION,
621 kOsAll,
[email protected]3e8befc2012-03-13 01:17:03622 SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu)
[email protected]156f966332012-02-29 00:03:16623 },
[email protected]dc04be7c2012-03-15 23:57:49624#if defined(USE_ASH)
[email protected]31cf1c52012-02-29 20:55:01625 {
[email protected]3cd198a22012-03-12 20:38:01626 "enable-ash-oak",
627 IDS_FLAGS_ENABLE_ASH_OAK_NAME,
628 IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION,
629 kOsAll,
630 SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak),
631 },
[email protected]31cf1c52012-02-29 20:55:01632#endif
[email protected]184ec592012-03-01 11:54:28633 {
634 "enable-devtools-experiments",
635 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME,
636 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION,
637 kOsAll,
638 SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments)
639 },
[email protected]76d1854e2012-03-02 23:57:44640 {
641 "enable-suggestions-ntp",
642 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME,
643 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION,
644 kOsAll,
645 SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage)
646 },
[email protected]a78ef9e2012-03-21 02:49:55647 {
[email protected]9f0f0062012-06-18 20:52:09648 "enable-chrome-to-mobile", // FLAGS:RECORD_UMA
649 IDS_FLAGS_ENABLE_CHROME_TO_MOBILE_NAME,
650 IDS_FLAGS_ENABLE_CHROME_TO_MOBILE_DESCRIPTION,
[email protected]a78ef9e2012-03-21 02:49:55651 kOsAll,
[email protected]9f0f0062012-06-18 20:52:09652 SINGLE_VALUE_TYPE(switches::kEnableChromeToMobile)
[email protected]a78ef9e2012-03-21 02:49:55653 },
[email protected]db92eeb2012-05-11 18:59:20654 {
655 "enable-captive-portal-detection",
656 IDS_FLAGS_CAPTIVE_PORTAL_CHECK_ON_ERROR_NAME,
657 IDS_FLAGS_CAPTIVE_PORTAL_CHECK_ON_ERROR_DESCRIPTION,
658 kOsMac | kOsWin | kOsLinux | kOsCrOS,
659 SINGLE_VALUE_TYPE(switches::kCaptivePortalDetection)
660 },
[email protected]8e466dd2012-05-04 19:16:05661#if defined(GOOGLE_CHROME_BUILD)
[email protected]a3d54252012-04-05 20:04:13662 {
[email protected]37b928e2012-05-30 09:01:10663 "disable-asynchronous-spellchecking",
664 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING,
665 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING_DESCRIPTION,
666 kOsWin | kOsLinux | kOsCrOS,
667 SINGLE_VALUE_TYPE(switches::kDisableAsynchronousSpellChecking)
[email protected]a3d54252012-04-05 20:04:13668 },
[email protected]8e466dd2012-05-04 19:16:05669#endif
[email protected]c9c73ad42012-04-18 03:35:59670 {
671 "touch-optimized-ui",
[email protected]347a0c72012-05-14 20:28:06672 IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME,
673 IDS_FLAGS_TOUCH_OPTIMIZED_UI_DESCRIPTION,
[email protected]f5364d22012-05-31 18:57:29674 kOsWin | kOsCrOS,
[email protected]347a0c72012-05-14 20:28:06675 MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
[email protected]c9c73ad42012-04-18 03:35:59676 },
[email protected]8a6aaa72012-04-20 20:53:58677 {
678 "enable-touch-events",
679 IDS_ENABLE_TOUCH_EVENTS_NAME,
680 IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
681 kOsAll,
682 SINGLE_VALUE_TYPE(switches::kEnableTouchEvents)
683 },
[email protected]0b60afa2012-04-19 17:36:39684#if defined(OS_CHROMEOS)
685 {
686 "no-discard-tabs",
687 IDS_FLAGS_NO_DISCARD_TABS_NAME,
688 IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION,
689 kOsCrOS,
690 SINGLE_VALUE_TYPE(switches::kNoDiscardTabs)
691 },
692#endif
[email protected]79be6d32012-04-24 20:47:44693 {
[email protected]9a5940d2012-04-27 19:16:23694 "allow-nacl-socket-api",
695 IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME,
696 IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION,
697 kOsAll,
698 SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*")
699 },
[email protected]85333732012-05-01 19:02:24700 {
[email protected]60673ad72012-05-02 06:16:33701 "stacked-tab-strip",
702 IDS_FLAGS_STACKED_TAB_STRIP_NAME,
703 IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION,
704 kOsWin,
705 SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip)
706 },
707 {
[email protected]4bd20202012-06-14 17:35:01708 "force-device-scale-factor",
[email protected]85333732012-05-01 19:02:24709 IDS_FLAGS_FORCE_HIGH_DPI_NAME,
710 IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION,
711 kOsCrOS,
[email protected]4bd20202012-06-14 17:35:01712 SINGLE_VALUE_TYPE_AND_VALUE(switches::kForceDeviceScaleFactor, "2")
[email protected]85333732012-05-01 19:02:24713 },
[email protected]190349fd2012-05-02 00:10:47714#if defined(OS_CHROMEOS)
715 {
716 "allow-touchpad-three-finger-click",
717 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME,
718 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION,
719 kOsCrOS,
720 SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick)
721 },
722#endif
[email protected]aab64e02012-05-03 19:24:16723 {
[email protected]816385ee2012-06-05 00:17:52724 "disable-client-oauth-signin",
725 IDS_FLAGS_DISABLE_CLIENT_OAUTH_SIGNIN_NAME,
726 IDS_FLAGS_DISABLE_CLIENT_OAUTH_SIGNIN_DESCRIPTION,
[email protected]aab64e02012-05-03 19:24:16727 kOsMac | kOsWin | kOsLinux,
[email protected]816385ee2012-06-05 00:17:52728 SINGLE_VALUE_TYPE(switches::kDisableClientOAuthSignin)
[email protected]aab64e02012-05-03 19:24:16729 },
[email protected]53520b1b2012-05-07 21:43:37730#if defined(USE_ASH)
731 {
[email protected]55444502012-05-10 15:43:53732 "show-launcher-alignment-menu",
733 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_NAME,
734 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION,
735 kOsAll,
736 SINGLE_VALUE_TYPE(switches::kShowLauncherAlignmentMenu)
737 },
[email protected]817ecd12012-05-16 18:36:53738 {
[email protected]73074742012-05-17 01:44:41739 "show-touch-hud",
740 IDS_FLAGS_SHOW_TOUCH_HUD_NAME,
741 IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION,
742 kOsAll,
743 SINGLE_VALUE_TYPE(ash::switches::kAshTouchHud)
744 },
745 {
[email protected]e154db32012-06-18 16:20:46746 "ash-notify-disabled",
747 IDS_FLAGS_DISABLE_ASH_NOTIFY_NAME,
748 IDS_FLAGS_DISABLE_ASH_NOTIFY_DESCRIPTION,
[email protected]817ecd12012-05-16 18:36:53749 kOsAll,
[email protected]e154db32012-06-18 16:20:46750 SINGLE_VALUE_TYPE(ash::switches::kAshNotifyDisabled),
[email protected]817ecd12012-05-16 18:36:53751 },
[email protected]9f0940b62012-05-23 22:56:35752 {
753 "enable-pinch",
754 IDS_FLAGS_ENABLE_PINCH_SCALE_NAME,
755 IDS_FLAGS_ENABLE_PINCH_SCALE_DESCRIPTION,
756 kOsAll,
757 SINGLE_VALUE_TYPE(switches::kEnablePinch),
758 },
[email protected]a8379312012-06-15 00:20:43759 {
760 "app-list-show-apps-only",
761 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_NAME,
762 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_DESCRIPTION,
763 kOsAll,
764 SINGLE_VALUE_TYPE(ash::switches::kAppListShowAppsOnly),
765 },
[email protected]6aee2592012-06-15 19:51:06766 {
767 "ash-extended-desktop",
768 IDS_FLAGS_ENABLE_ASH_EXTENDED_DESKTOP_NAME,
769 IDS_FLAGS_ENABLE_ASH_EXTENDED_DESKTOP_DESCRIPTION,
770 kOsAll,
771 SINGLE_VALUE_TYPE(ash::switches::kAshExtendedDesktop)
772 },
[email protected]73074742012-05-17 01:44:41773#endif // defined(USE_ASH)
[email protected]ed7b67f32012-05-28 10:12:28774#if defined(OS_CHROMEOS)
775 {
[email protected]a7668a12012-05-28 22:23:48776 "experimental-wallpaper-ui",
777 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_NAME,
778 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_DESCRIPTION,
779 kOsCrOS,
780 SINGLE_VALUE_TYPE(switches::kExperimentalWallpaperUI)
781 },
782 {
[email protected]ed7b67f32012-05-28 10:12:28783 "enable-new-oobe",
784 IDS_FLAGS_ENABLE_NEW_OOBE,
785 IDS_FLAGS_ENABLE_NEW_OOBE_DESCRIPTION,
786 kOsCrOS,
787 SINGLE_VALUE_TYPE(switches::kEnableNewOobe),
788 },
789#endif
[email protected]fc7a93c2012-06-08 20:25:39790 {
791 "enable-views-textfield",
792 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_NAME,
793 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_DESCRIPTION,
794 kOsWin,
795 SINGLE_VALUE_TYPE(switches::kEnableViewsTextfield),
796 },
[email protected]bd0cd3bb2012-06-14 03:03:38797 {
798 "new-checkbox-style",
799 IDS_FLAGS_NEW_CHECKBOX_STYLE,
800 IDS_FLAGS_NEW_CHECKBOX_STYLE_DESCRIPTION,
801 kOsLinux | kOsCrOS,
802 SINGLE_VALUE_TYPE(switches::kNewCheckboxStyle),
803 },
[email protected]2faeaabd2012-06-15 01:05:02804 {
805 "disable-non-fullscreen-mouse-lock",
806 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_NAME,
807 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_DESCRIPTION,
808 kOsAll,
809 SINGLE_VALUE_TYPE(switches::kDisableNonFullscreenMouseLock),
810 },
[email protected]7057b3e2012-06-18 19:19:16811#if defined(OS_CHROMEOS)
812 {
813 "enable-unsupported-bluetooth-devices",
814 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_NAME,
815 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_DESCRIPTION,
816 kOsCrOS,
817 SINGLE_VALUE_TYPE(switches::kEnableUnsupportedBluetoothDevices)
818 },
819#endif
[email protected]66dcb0492012-06-18 22:32:15820 { "enable-accelerated-video-decode",
821 IDS_FLAGS_ENABLE_ACCELERATED_VIDEO_DECODE_NAME,
822 IDS_FLAGS_ENABLE_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
823 kOsAll,
824 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedVideoDecode),
825 },
[email protected]66ae9fc2012-06-19 21:33:52826#if defined(USE_ASH)
827 {
828 "ash-debug-shortcuts",
829 IDS_FLAGS_DEBUG_SHORTCUTS_NAME,
830 IDS_FLAGS_DEBUG_SHORTCUTS_DESCRIPTION,
831 kOsAll,
832 SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts),
833 },
834#endif
[email protected]a0e4b072011-08-17 01:47:07835};
[email protected]ad2a3ded2010-08-27 13:19:05836
[email protected]a314ee5a2010-10-26 21:23:28837const Experiment* experiments = kExperiments;
838size_t num_experiments = arraysize(kExperiments);
839
[email protected]e2ddbc92010-10-15 20:02:07840// Stores and encapsulates the little state that about:flags has.
841class FlagsState {
842 public:
843 FlagsState() : needs_restart_(false) {}
844 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
845 bool IsRestartNeededToCommitChanges();
846 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28847 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07848 void RemoveFlagsSwitches(
849 std::map<std::string, CommandLine::StringType>* switch_list);
850 void reset();
851
852 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55853 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07854 return Singleton<FlagsState>::get();
855 }
856
857 private:
858 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53859 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07860
861 DISALLOW_COPY_AND_ASSIGN(FlagsState);
862};
863
[email protected]c7b7800a2010-10-07 18:51:35864// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:05865// in a set.
[email protected]1a47d7e2010-10-15 00:37:24866void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:05867 const ListValue* enabled_experiments = prefs->GetList(
868 prefs::kEnabledLabsExperiments);
869 if (!enabled_experiments)
870 return;
871
872 for (ListValue::const_iterator it = enabled_experiments->begin();
873 it != enabled_experiments->end();
874 ++it) {
875 std::string experiment_name;
876 if (!(*it)->GetAsString(&experiment_name)) {
877 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
878 continue;
879 }
880 result->insert(experiment_name);
881 }
882}
883
884// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:24885void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05886 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:38887 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
888 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:05889
890 experiments_list->Clear();
891 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
892 it != enabled_experiments.end();
893 ++it) {
894 experiments_list->Append(new StringValue(*it));
895 }
896}
897
[email protected]8a6ff28d2010-12-02 16:35:19898// Returns the name used in prefs for the choice at the specified index.
899std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:34900 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
901 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:19902 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
903 base::IntToString(index);
904}
905
906// Adds the internal names for the specified experiment to |names|.
907void AddInternalName(const Experiment& e, std::set<std::string>* names) {
908 if (e.type == Experiment::SINGLE_VALUE) {
909 names->insert(e.internal_name);
910 } else {
[email protected]2ce9c89752011-02-25 18:24:34911 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:19912 for (int i = 0; i < e.num_choices; ++i)
913 names->insert(NameForChoice(e, i));
914 }
915}
916
[email protected]28e35af2011-02-09 12:56:22917// Confirms that an experiment is valid, used in a DCHECK in
918// SanitizeList below.
919bool ValidateExperiment(const Experiment& e) {
920 switch (e.type) {
921 case Experiment::SINGLE_VALUE:
922 DCHECK_EQ(0, e.num_choices);
923 DCHECK(!e.choices);
924 break;
925 case Experiment::MULTI_VALUE:
926 DCHECK_GT(e.num_choices, 0);
927 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:53928 DCHECK(e.choices[0].command_line_switch);
929 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:22930 break;
931 default:
932 NOTREACHED();
933 }
934 return true;
935}
936
[email protected]ad2a3ded2010-08-27 13:19:05937// Removes all experiments from prefs::kEnabledLabsExperiments that are
938// unknown, to prevent this list to become very long as experiments are added
939// and removed.
940void SanitizeList(PrefService* prefs) {
941 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:22942 for (size_t i = 0; i < num_experiments; ++i) {
943 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:19944 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:22945 }
[email protected]ad2a3ded2010-08-27 13:19:05946
947 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24948 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05949
950 std::set<std::string> new_enabled_experiments;
951 std::set_intersection(
952 known_experiments.begin(), known_experiments.end(),
953 enabled_experiments.begin(), enabled_experiments.end(),
954 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
955
[email protected]1a47d7e2010-10-15 00:37:24956 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05957}
958
[email protected]1a47d7e2010-10-15 00:37:24959void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05960 PrefService* prefs, std::set<std::string>* result) {
961 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:24962 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:05963}
964
[email protected]a314ee5a2010-10-26 21:23:28965// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
966// enabled on the current platform.
967void GetSanitizedEnabledFlagsForCurrentPlatform(
968 PrefService* prefs, std::set<std::string>* result) {
969 GetSanitizedEnabledFlags(prefs, result);
970
971 // Filter out any experiments that aren't enabled on the current platform. We
972 // don't remove these from prefs else syncing to a platform with a different
973 // set of experiments would be lossy.
974 std::set<std::string> platform_experiments;
975 int current_platform = GetCurrentPlatform();
976 for (size_t i = 0; i < num_experiments; ++i) {
977 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:19978 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:28979 }
980
981 std::set<std::string> new_enabled_experiments;
982 std::set_intersection(
983 platform_experiments.begin(), platform_experiments.end(),
984 result->begin(), result->end(),
985 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
986
987 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05988}
989
[email protected]8a6ff28d2010-12-02 16:35:19990// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:19991Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:22992 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:34993 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:19994 ListValue* result = new ListValue;
995 for (int i = 0; i < experiment.num_choices; ++i) {
996 const Experiment::Choice& choice = experiment.choices[i];
997 DictionaryValue* value = new DictionaryValue;
998 std::string name = NameForChoice(experiment, i);
999 value->SetString("description",
1000 l10n_util::GetStringUTF16(choice.description_id));
1001 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:221002 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:191003 result->Append(value);
1004 }
1005 return result;
1006}
1007
[email protected]e2ddbc92010-10-15 20:02:071008} // namespace
1009
[email protected]1a47d7e2010-10-15 00:37:241010void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:551011 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:051012}
1013
[email protected]1a47d7e2010-10-15 00:37:241014ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:051015 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241016 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051017
1018 int current_platform = GetCurrentPlatform();
1019
1020 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:281021 for (size_t i = 0; i < num_experiments; ++i) {
1022 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:051023
1024 DictionaryValue* data = new DictionaryValue();
1025 data->SetString("internal_name", experiment.internal_name);
1026 data->SetString("name",
1027 l10n_util::GetStringUTF16(experiment.visible_name_id));
1028 data->SetString("description",
1029 l10n_util::GetStringUTF16(
1030 experiment.visible_description_id));
[email protected]cc3e2052011-12-20 01:01:401031 bool supported = !!(experiment.supported_platforms & current_platform);
1032 data->SetBoolean("supported", supported);
1033
1034 ListValue* supported_platforms = new ListValue();
1035 AddOsStrings(experiment.supported_platforms, supported_platforms);
1036 data->Set("supported_platforms", supported_platforms);
[email protected]ad2a3ded2010-08-27 13:19:051037
[email protected]28e35af2011-02-09 12:56:221038 switch (experiment.type) {
1039 case Experiment::SINGLE_VALUE:
1040 data->SetBoolean(
1041 "enabled",
1042 enabled_experiments.count(experiment.internal_name) > 0);
1043 break;
1044 case Experiment::MULTI_VALUE:
1045 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
1046 break;
1047 default:
1048 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:191049 }
1050
[email protected]ad2a3ded2010-08-27 13:19:051051 experiments_data->Append(data);
1052 }
1053 return experiments_data;
1054}
1055
[email protected]ad2a3ded2010-08-27 13:19:051056bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:551057 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:051058}
1059
1060void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:351061 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:551062 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:071063}
1064
1065void RemoveFlagsSwitches(
1066 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:551067 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:071068}
1069
[email protected]a314ee5a2010-10-26 21:23:281070int GetCurrentPlatform() {
1071#if defined(OS_MACOSX)
1072 return kOsMac;
1073#elif defined(OS_WIN)
1074 return kOsWin;
1075#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
1076 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:211077#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:281078 return kOsLinux;
[email protected]9c7453d2012-01-21 00:45:401079#elif defined(OS_ANDROID)
1080 return kOsAndroid;
[email protected]a314ee5a2010-10-26 21:23:281081#else
1082#error Unknown platform
1083#endif
1084}
1085
[email protected]4bc5050c2010-11-18 17:55:541086void RecordUMAStatistics(const PrefService* prefs) {
1087 std::set<std::string> flags;
1088 GetEnabledFlags(prefs, &flags);
1089 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
1090 ++it) {
1091 std::string action("AboutFlags_");
1092 action += *it;
[email protected]7f6f44c2011-12-14 13:23:381093 content::RecordComputedAction(action);
[email protected]4bc5050c2010-11-18 17:55:541094 }
1095 // Since flag metrics are recorded every startup, add a tick so that the
1096 // stats can be made meaningful.
1097 if (flags.size())
[email protected]7f6f44c2011-12-14 13:23:381098 content::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
1099 content::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:541100}
1101
[email protected]e2ddbc92010-10-15 20:02:071102//////////////////////////////////////////////////////////////////////////////
1103// FlagsState implementation.
1104
1105namespace {
1106
1107void FlagsState::ConvertFlagsToSwitches(
1108 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:071109 if (command_line->HasSwitch(switches::kNoExperiments))
1110 return;
1111
1112 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:001113
[email protected]a314ee5a2010-10-26 21:23:281114 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:071115
[email protected]a82744532011-02-11 16:15:531116 typedef std::map<std::string, std::pair<std::string, std::string> >
1117 NameToSwitchAndValueMap;
1118 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:191119 for (size_t i = 0; i < num_experiments; ++i) {
1120 const Experiment& e = experiments[i];
1121 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:531122 name_to_switch_map[e.internal_name] =
1123 std::pair<std::string, std::string>(e.command_line_switch,
1124 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191125 } else {
1126 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:531127 name_to_switch_map[NameForChoice(e, j)] =
1128 std::pair<std::string, std::string>(
1129 e.choices[j].command_line_switch,
1130 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191131 }
1132 }
[email protected]e2ddbc92010-10-15 20:02:071133
1134 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:531135 flags_switches_.insert(
1136 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
1137 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071138 for (std::set<std::string>::iterator it = enabled_experiments.begin();
1139 it != enabled_experiments.end();
1140 ++it) {
1141 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:531142 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:191143 name_to_switch_map.find(experiment_name);
1144 if (name_to_switch_it == name_to_switch_map.end()) {
1145 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:071146 continue;
[email protected]8a6ff28d2010-12-02 16:35:191147 }
[email protected]e2ddbc92010-10-15 20:02:071148
[email protected]a82744532011-02-11 16:15:531149 const std::pair<std::string, std::string>&
1150 switch_and_value_pair = name_to_switch_it->second;
1151
1152 command_line->AppendSwitchASCII(switch_and_value_pair.first,
1153 switch_and_value_pair.second);
1154 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:071155 }
1156 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:531157 flags_switches_.insert(
1158 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
1159 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071160}
1161
1162bool FlagsState::IsRestartNeededToCommitChanges() {
1163 return needs_restart_;
1164}
1165
1166void FlagsState::SetExperimentEnabled(
1167 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:051168 needs_restart_ = true;
1169
[email protected]8a6ff28d2010-12-02 16:35:191170 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
1171 if (at_index != std::string::npos) {
1172 DCHECK(enable);
1173 // We're being asked to enable a multi-choice experiment. Disable the
1174 // currently selected choice.
1175 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:221176 const std::string experiment_name = internal_name.substr(0, at_index);
1177 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:191178
[email protected]28e35af2011-02-09 12:56:221179 // And enable the new choice, if it is not the default first choice.
1180 if (internal_name != experiment_name + "@0") {
1181 std::set<std::string> enabled_experiments;
1182 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
1183 enabled_experiments.insert(internal_name);
1184 SetEnabledFlags(prefs, enabled_experiments);
1185 }
[email protected]8a6ff28d2010-12-02 16:35:191186 return;
1187 }
1188
[email protected]ad2a3ded2010-08-27 13:19:051189 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241190 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051191
[email protected]8a6ff28d2010-12-02 16:35:191192 const Experiment* e = NULL;
1193 for (size_t i = 0; i < num_experiments; ++i) {
1194 if (experiments[i].internal_name == internal_name) {
1195 e = experiments + i;
1196 break;
1197 }
1198 }
1199 DCHECK(e);
1200
1201 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:591202 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:191203 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:591204 else
[email protected]8a6ff28d2010-12-02 16:35:191205 enabled_experiments.erase(internal_name);
1206 } else {
1207 if (enable) {
1208 // Enable the first choice.
1209 enabled_experiments.insert(NameForChoice(*e, 0));
1210 } else {
1211 // Find the currently enabled choice and disable it.
1212 for (int i = 0; i < e->num_choices; ++i) {
1213 std::string choice_name = NameForChoice(*e, i);
1214 if (enabled_experiments.find(choice_name) !=
1215 enabled_experiments.end()) {
1216 enabled_experiments.erase(choice_name);
1217 // Continue on just in case there's a bug and more than one
1218 // experiment for this choice was enabled.
1219 }
1220 }
1221 }
1222 }
[email protected]ad2a3ded2010-08-27 13:19:051223
[email protected]1a47d7e2010-10-15 00:37:241224 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051225}
1226
[email protected]e2ddbc92010-10-15 20:02:071227void FlagsState::RemoveFlagsSwitches(
1228 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:531229 for (std::map<std::string, std::string>::const_iterator
1230 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
1231 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:071232 }
1233}
1234
1235void FlagsState::reset() {
1236 needs_restart_ = false;
1237 flags_switches_.clear();
1238}
1239
[email protected]38e46812011-05-09 20:49:221240} // namespace
[email protected]e2ddbc92010-10-15 20:02:071241
1242namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:191243
1244// WARNING: '@' is also used in the html file. If you update this constant you
1245// also need to update the html file.
1246const char kMultiSeparator[] = "@";
1247
[email protected]e2ddbc92010-10-15 20:02:071248void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:551249 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:071250}
[email protected]a314ee5a2010-10-26 21:23:281251
1252void SetExperiments(const Experiment* e, size_t count) {
1253 if (!e) {
1254 experiments = kExperiments;
1255 num_experiments = arraysize(kExperiments);
1256 } else {
1257 experiments = e;
1258 num_experiments = count;
1259 }
1260}
1261
[email protected]8a6ff28d2010-12-02 16:35:191262const Experiment* GetExperiments(size_t* count) {
1263 *count = num_experiments;
1264 return experiments;
1265}
1266
[email protected]e2ddbc92010-10-15 20:02:071267} // namespace testing
1268
[email protected]1a47d7e2010-10-15 00:37:241269} // namespace about_flags