blob: 60cd3d665d7514d54d026f45c9669360b0a8e746 [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]0bc6c272012-07-17 03:32:0324#include "ui/app_list/app_list_switches.h"
[email protected]c051a1b2011-01-21 23:30:1725#include "ui/base/l10n/l10n_util.h"
[email protected]c9c73ad42012-04-18 03:35:5926#include "ui/base/ui_base_switches.h"
[email protected]c9e2cbbb2012-05-12 21:17:2727#include "ui/gl/gl_switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0528
[email protected]dc04be7c2012-03-15 23:57:4929#if defined(USE_ASH)
[email protected]b65bdda2011-12-23 23:35:3130#include "ash/ash_switches.h"
[email protected]dc04be7c2012-03-15 23:57:4931#endif
32
33#if defined(USE_AURA)
[email protected]308aaa32012-03-12 13:14:5034#include "ui/aura/aura_switches.h"
[email protected]8cc10df2011-11-03 23:57:5035#endif
36
[email protected]7f6f44c2011-12-14 13:23:3837using content::UserMetricsAction;
38
[email protected]1a47d7e2010-10-15 00:37:2439namespace about_flags {
[email protected]ad2a3ded2010-08-27 13:19:0540
[email protected]8a6ff28d2010-12-02 16:35:1941// Macros to simplify specifying the type.
[email protected]a82744532011-02-11 16:15:5342#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
43 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0
44#define SINGLE_VALUE_TYPE(command_line_switch) \
45 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
46#define MULTI_VALUE_TYPE(choices) \
[email protected]0e6f56d2011-02-12 23:45:1547 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices)
[email protected]8a6ff28d2010-12-02 16:35:1948
[email protected]e2ddbc92010-10-15 20:02:0749namespace {
50
[email protected]9c7453d2012-01-21 00:45:4051const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS | kOsAndroid;
[email protected]ad2a3ded2010-08-27 13:19:0552
[email protected]cc3e2052011-12-20 01:01:4053// Adds a |StringValue| to |list| for each platform where |bitmask| indicates
54// whether the experiment is available on that platform.
55void AddOsStrings(unsigned bitmask, ListValue* list) {
56 struct {
57 unsigned bit;
58 const char* const name;
59 } kBitsToOs[] = {
60 {kOsMac, "Mac"},
61 {kOsWin, "Windows"},
62 {kOsLinux, "Linux"},
63 {kOsCrOS, "Chrome OS"},
64 };
65 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i)
66 if (bitmask & kBitsToOs[i].bit)
67 list->Append(new StringValue(kBitsToOs[i].name));
68}
69
[email protected]ba8164242010-11-16 21:31:0070// Names for former Chrome OS Labs experiments, shared with prefs migration
71// code.
72const char kMediaPlayerExperimentName[] = "media-player";
73const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
74const char kVerticalTabsExperimentName[] = "vertical-tabs";
75
[email protected]68317802012-06-07 19:13:2376const Experiment::Choice kOmniboxHistoryQuickProviderNewScoringChoices[] = {
77 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_AUTOMATIC, "", "" },
78 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_ENABLED,
79 switches::kOmniboxHistoryQuickProviderNewScoring,
80 switches::kOmniboxHistoryQuickProviderNewScoringEnabled },
81 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DISABLED,
82 switches::kOmniboxHistoryQuickProviderNewScoring,
83 switches::kOmniboxHistoryQuickProviderNewScoringDisabled }
84};
85
[email protected]128dc6c2012-06-22 20:30:3586const Experiment::Choice
87 kOmniboxHistoryQuickProviderReorderForInliningChoices[] = {
88 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_AUTOMATIC,
89 "",
90 "" },
91 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_ENABLED,
92 switches::kOmniboxHistoryQuickProviderReorderForInlining,
93 switches::kOmniboxHistoryQuickProviderReorderForInliningEnabled },
94 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DISABLED,
95 switches::kOmniboxHistoryQuickProviderReorderForInlining,
96 switches::kOmniboxHistoryQuickProviderReorderForInliningDisabled }
97};
98
[email protected]032d5e6c2012-02-17 17:53:5599const Experiment::Choice kOmniboxInlineHistoryQuickProviderChoices[] = {
100 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_AUTOMATIC, "", "" },
101 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_ALLOWED,
102 switches::kOmniboxInlineHistoryQuickProvider,
103 switches::kOmniboxInlineHistoryQuickProviderAllowed },
104 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_PROHIBITED,
105 switches::kOmniboxInlineHistoryQuickProvider,
106 switches::kOmniboxInlineHistoryQuickProviderProhibited }
107};
108
[email protected]de023762012-07-26 17:10:17109const Experiment::Choice kFixedPositionCreatesStackingContextChoices[] = {
110 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
111 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
112 switches::kEnableFixedPositionCreatesStackingContext, ""},
113 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
114 switches::kDisableFixedPositionCreatesStackingContext, ""}
115};
116
[email protected]9b19cf82012-06-13 06:23:23117const Experiment::Choice kForceCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20118 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
119 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]9b19cf82012-06-13 06:23:23120 switches::kForceCompositingMode, ""},
[email protected]a45c69402012-06-24 16:32:20121 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]9b19cf82012-06-13 06:23:23122 switches::kDisableForceCompositingMode, ""}
123};
124
[email protected]72787e392012-03-23 05:55:43125const Experiment::Choice kThreadedCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20126 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
127 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]72787e392012-03-23 05:55:43128 switches::kDisableThreadedCompositing, ""},
[email protected]a45c69402012-06-24 16:32:20129 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]72787e392012-03-23 05:55:43130 switches::kEnableThreadedCompositing, ""}
131};
132
[email protected]347a0c72012-05-14 20:28:06133const Experiment::Choice kTouchOptimizedUIChoices[] = {
134 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_AUTOMATIC, "", "" },
[email protected]a45c69402012-06-24 16:32:20135 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]347a0c72012-05-14 20:28:06136 switches::kTouchOptimizedUI,
137 switches::kTouchOptimizedUIEnabled },
[email protected]a45c69402012-06-24 16:32:20138 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]347a0c72012-05-14 20:28:06139 switches::kTouchOptimizedUI,
140 switches::kTouchOptimizedUIDisabled }
141};
142
[email protected]e4a81662012-06-25 23:57:07143const Experiment::Choice kPointerLockUIChoices[] = {
144 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
145 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
146 switches::kEnablePointerLock, ""},
147 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
148 switches::kDisablePointerLock, ""}
149};
150
[email protected]026876f32012-08-22 23:53:40151const Experiment::Choice kAsyncDnsChoices[] = {
152 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
153 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
154 switches::kDisableAsyncDns, ""},
155 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
156 switches::kEnableAsyncDns, ""}
157};
158
[email protected]347a0c72012-05-14 20:28:06159
[email protected]4bc5050c2010-11-18 17:55:54160// RECORDING USER METRICS FOR FLAGS:
161// -----------------------------------------------------------------------------
162// The first line of the experiment is the internal name. If you'd like to
163// gather statistics about the usage of your flag, you should append a marker
164// comment to the end of the feature name, like so:
165// "my-special-feature", // FLAGS:RECORD_UMA
166//
167// After doing that, run //chrome/tools/extract_actions.py (see instructions at
168// the top of that file for details) to update the chromeactions.txt file, which
169// will enable UMA to record your feature flag.
170//
171// After your feature has shipped under a flag, you can locate the metrics
172// under the action name AboutFlags_internal-action-name. Actions are recorded
173// once per startup, so you should divide this number by AboutFlags_StartupTick
174// to get a sense of usage. Note that this will not be the same as number of
175// users with a given feature enabled because users can quit and relaunch
176// the application multiple times over a given time interval.
177// TODO(rsesek): See if there's a way to count per-user, rather than
178// per-startup.
179
[email protected]8a6ff28d2010-12-02 16:35:19180// To add a new experiment add to the end of kExperiments. There are two
181// distinct types of experiments:
182// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
183// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:22184// . MULTI_VALUE: a list of choices, the first of which should correspond to a
185// deactivated state for this lab (i.e. no command line option). To specify
186// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
187// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:19188// See the documentation of Experiment for details on the fields.
189//
190// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:05191const Experiment kExperiments[] = {
192 {
[email protected]aac169d2011-03-18 19:53:03193 "expose-for-tabs", // FLAGS:RECORD_UMA
194 IDS_FLAGS_TABPOSE_NAME,
195 IDS_FLAGS_TABPOSE_DESCRIPTION,
196 kOsMac,
197#if defined(OS_MACOSX)
198 // The switch exists only on OS X.
199 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
200#else
201 SINGLE_VALUE_TYPE("")
202#endif
203 },
204 {
[email protected]4bc5050c2010-11-18 17:55:54205 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05206 IDS_FLAGS_CONFLICTS_CHECK_NAME,
207 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
208 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19209 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05210 },
211 {
[email protected]4bc5050c2010-11-18 17:55:54212 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]dae7325b2011-12-21 20:56:54213 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME,
214 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45215 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22216 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31217 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22218 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
219 // always have PDF rasterization available, so no flag needed there.
220#if !defined(GOOGLE_CHROME_BUILD)
221 kOsWin,
222#else
223 0,
[email protected]fa6d2a2f2010-11-30 21:47:19224#endif
[email protected]8a6ff28d2010-12-02 16:35:19225 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42226 },
[email protected]580939a2010-10-12 18:54:37227 {
[email protected]0209b442012-07-18 00:38:05228 "print-setting-reset", // FLAGS:RECORD_UMA
229 IDS_FLAGS_PRINT_SETTING_RESET_NAME,
230 IDS_FLAGS_PRINT_SETTING_RESET_DESCRIPTION,
231 kOsAll,
232 SINGLE_VALUE_TYPE(switches::kPrintSettingsReset)
233 },
[email protected]60d77bd2012-08-22 00:10:07234#if defined(OS_WIN)
235 {
236 "print-raster",
237 IDS_FLAGS_PRINT_RASTER_NAME,
238 IDS_FLAGS_PRINT_RASTER_DESCRIPTION,
239 kOsWin,
240 SINGLE_VALUE_TYPE(switches::kPrintRaster)
241 },
242#endif // OS_WIN
[email protected]0209b442012-07-18 00:38:05243 {
[email protected]bb461532010-11-26 21:50:23244 "crxless-web-apps",
245 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
246 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
247 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19248 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23249 },
250 {
[email protected]96c6f4c2011-05-18 19:36:22251 "ignore-gpu-blacklist",
252 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
253 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
254 kOsAll,
255 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
256 },
257 {
[email protected]0110cf112011-07-02 00:39:43258 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22259 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
260 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
[email protected]9b19cf82012-06-13 06:23:23261 kOsMac | kOsWin | kOsLinux,
262 MULTI_VALUE_TYPE(kForceCompositingModeChoices)
[email protected]96c6f4c2011-05-18 19:36:22263 },
264 {
[email protected]72787e392012-03-23 05:55:43265 "threaded-compositing-mode",
266 IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME,
267 IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59268 kOsAll,
[email protected]72787e392012-03-23 05:55:43269 MULTI_VALUE_TYPE(kThreadedCompositingModeChoices)
[email protected]644a1072012-03-16 09:29:59270 },
271 {
[email protected]81c64af62012-06-06 20:15:52272 "disable-accelerated-2d-canvas",
273 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_NAME,
274 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_DESCRIPTION,
275 kOsAll,
276 SINGLE_VALUE_TYPE(switches::kDisableAccelerated2dCanvas)
277 },
278 {
[email protected]69cffc82012-08-10 13:27:27279 "disable-deferred-2d-canvas",
280 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_NAME,
281 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_DESCRIPTION,
282 kOsAll,
283 SINGLE_VALUE_TYPE(switches::kDisableDeferred2dCanvas)
284 },
285 {
[email protected]efcde132012-05-30 01:05:18286 "disable-threaded-animation",
287 IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME,
288 IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59289 kOsAll,
[email protected]efcde132012-05-30 01:05:18290 SINGLE_VALUE_TYPE(switches::kDisableThreadedAnimation)
[email protected]644a1072012-03-16 09:29:59291 },
292 {
[email protected]5963b772011-02-09 22:55:38293 "composited-layer-borders",
294 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
295 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
296 kOsAll,
297 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
298 },
299 {
[email protected]a8f1eaa2011-03-07 19:00:58300 "show-fps-counter",
301 IDS_FLAGS_SHOW_FPS_COUNTER,
302 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
303 kOsAll,
304 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
305 },
[email protected]8ff7f342011-05-25 01:49:47306 {
[email protected]70c98a332011-12-21 20:51:52307 "accelerated-filters",
308 IDS_FLAGS_ACCELERATED_FILTERS,
309 IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION,
310 kOsAll,
311 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters)
312 },
313 {
[email protected]8ff7f342011-05-25 01:49:47314 "disable-gpu-vsync",
315 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
316 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
317 kOsAll,
318 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
319 },
[email protected]deaba6d52011-09-23 14:47:12320 {
321 "disable-webgl",
322 IDS_FLAGS_DISABLE_WEBGL_NAME,
323 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
324 kOsAll,
325 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
326 },
[email protected]09096e02012-05-24 11:12:04327 {
[email protected]96bcdc102012-05-24 23:42:10328 "fixed-position-creates-stacking-context",
329 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_NAME,
330 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_DESCRIPTION,
331 kOsAll,
[email protected]de023762012-07-26 17:10:17332 MULTI_VALUE_TYPE(kFixedPositionCreatesStackingContextChoices)
[email protected]96bcdc102012-05-24 23:42:10333 },
[email protected]d208f4d82011-05-23 21:52:03334 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53335 {
[email protected]e3791ce92011-08-09 01:03:32336 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40337 IDS_FLAGS_ENABLE_NACL_NAME,
338 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
339 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19340 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40341 },
[email protected]b39c6d92012-01-31 16:38:41342 // TODO(halyavin): When exception handling is on by default, replace this
343 // flag with disable-nacl-exception-handling.
344 {
345 "enable-nacl-exception-handling", // FLAGS:RECORD_UMA
346 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME,
347 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION,
[email protected]bf2c61b2012-08-30 16:37:04348 kOsAll,
[email protected]b39c6d92012-01-31 16:38:41349 SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling)
350 },
[email protected]4ff87d202010-11-06 01:28:40351 {
[email protected]31a665e72012-03-11 12:37:46352 "nacl-gdb", // FLAGS:RECORD_UMA
353 IDS_FLAGS_NACL_GDB_NAME,
354 IDS_FLAGS_NACL_GDB_DESCRIPTION,
355 kOsWin,
356 SINGLE_VALUE_TYPE(switches::kNaClGdb)
357 },
358 {
[email protected]401b90792012-05-30 11:41:13359 "nacl-gdb-script", // FLAGS:RECORD_UMA
360 IDS_FLAGS_NACL_GDB_SCRIPT_NAME,
361 IDS_FLAGS_NACL_GDB_SCRIPT_DESCRIPTION,
362 kOsAll,
363 SINGLE_VALUE_TYPE(switches::kNaClGdbScript)
364 },
365 {
[email protected]7babd1c2012-08-08 20:35:29366 "enable-pnacl", // FLAGS:RECORD_UMA
367 IDS_FLAGS_ENABLE_PNACL_NAME,
368 IDS_FLAGS_ENABLE_PNACL_DESCRIPTION,
369 kOsAll,
370 SINGLE_VALUE_TYPE(switches::kEnablePnacl)
371 },
372 {
[email protected]4bc5050c2010-11-18 17:55:54373 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32374 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
375 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
376 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19377 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32378 },
[email protected]3627b06d2010-11-12 16:36:16379 {
[email protected]958f2f02012-09-06 08:42:20380 "disable-action-box",
[email protected]cab18ef2012-04-27 07:22:03381 IDS_FLAGS_ACTION_BOX_NAME,
382 IDS_FLAGS_ACTION_BOX_DESCRIPTION,
383 kOsAll,
[email protected]958f2f02012-09-06 08:42:20384 SINGLE_VALUE_TYPE(switches::kDisableActionBox),
[email protected]cab18ef2012-04-27 07:22:03385 },
386 {
[email protected]3a362432012-06-18 20:39:51387 "script-badges",
388 IDS_FLAGS_SCRIPT_BADGES_NAME,
389 IDS_FLAGS_SCRIPT_BADGES_DESCRIPTION,
390 kOsAll,
391 SINGLE_VALUE_TYPE(switches::kEnableScriptBadges),
392 },
393 {
[email protected]cbe224d2011-08-04 22:12:49394 "apps-new-install-bubble",
395 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
396 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
397 kOsAll,
398 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
399 },
400 {
[email protected]80bd24e2010-11-30 09:34:38401 "disable-hyperlink-auditing",
402 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
403 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
404 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19405 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51406 },
407 {
408 "experimental-location-features", // FLAGS:RECORD_UMA
409 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
410 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
411 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19412 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
413 },
414 {
[email protected]5aea1862011-03-23 23:55:39415 "tab-groups-context-menu",
416 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
417 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
418 kOsWin,
419 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
420 },
[email protected]c94cebd2012-06-21 00:55:28421#if defined(OS_CHROMEOS)
422 {
423 "enable-instant-extended-api",
424 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API,
425 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API_DESCRIPTION,
426 kOsAll,
427 SINGLE_VALUE_TYPE(switches::kEnableInstantExtendedAPI)
428 },
429#endif
[email protected]e9bf9d92011-03-31 20:57:15430 {
[email protected]354e33b2011-06-15 00:29:10431 "static-ip-config",
432 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
433 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
434 kOsCrOS,
435#if defined(OS_CHROMEOS)
436 // This switch exists only on Chrome OS.
437 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
438#else
439 SINGLE_VALUE_TYPE("")
440#endif
441 },
[email protected]3eb5728c2011-06-20 22:32:24442 {
443 "show-autofill-type-predictions",
444 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
445 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
446 kOsAll,
447 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
448 },
[email protected]bff4d3e2011-06-21 23:58:52449 {
[email protected]fdf4e252012-04-27 00:26:55450 "sync-tab-favicons",
451 IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
452 IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
453 kOsAll,
454 SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
455 },
456 {
[email protected]aae9eeb12011-10-21 21:59:26457 "sync-app-notifications",
458 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
459 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
460 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11461 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26462 },
463 {
[email protected]a22ebd812011-06-23 00:05:39464 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
465 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
466 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
467 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40468 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40469 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39470 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
471 },
[email protected]81a6b0b2011-06-24 17:55:40472 {
[email protected]68317802012-06-07 19:13:23473 "omnibox-history-quick-provider-new-scoring",
474 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_NAME,
475 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DESCRIPTION,
476 kOsAll,
477 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderNewScoringChoices)
478 },
479 {
[email protected]128dc6c2012-06-22 20:30:35480 "omnibox-history-quick-provider-reorder-for-inlining",
481 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_NAME,
482 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DESCRIPTION,
483 kOsAll,
484 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderReorderForInliningChoices)
485 },
486 {
[email protected]032d5e6c2012-02-17 17:53:55487 "omnibox-inline-history-quick-provider",
488 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME,
489 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION,
490 kOsAll,
491 MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices)
492 },
493 {
[email protected]7e7a28092011-12-09 22:24:55494 "enable-panels",
495 IDS_FLAGS_ENABLE_PANELS_NAME,
496 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54497 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55498 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54499 },
[email protected]e3749d12011-07-25 22:22:12500 {
[email protected]27c14f02012-06-22 17:29:58501 // See http://crbug.com/120416 for how to remove this flag.
[email protected]6474b112012-05-04 19:35:27502 "save-page-as-mhtml", // FLAGS:RECORD_UMA
503 IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME,
504 IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION,
505 kOsMac | kOsWin | kOsLinux,
506 SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)
507 },
508 {
[email protected]b7bb44f2011-09-01 05:17:03509 "enable-autologin",
510 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
511 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
512 kOsMac | kOsWin | kOsLinux,
513 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
514 },
[email protected]b9841172011-09-26 23:36:09515 {
[email protected]bbadb112011-12-12 16:55:28516 "enable-http-pipelining",
517 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
518 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
519 kOsAll,
520 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
521 },
[email protected]d411c01d2011-10-18 16:00:27522 {
[email protected]3231b612012-03-23 05:57:54523 "enable-spdy3",
524 IDS_FLAGS_ENABLE_SPDY3_NAME,
525 IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION,
526 kOsAll,
527 SINGLE_VALUE_TYPE(switches::kEnableSpdy3)
528 },
529 {
[email protected]27b3fe92012-03-21 05:35:06530 "enable-async-dns",
531 IDS_FLAGS_ENABLE_ASYNC_DNS_NAME,
532 IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION,
[email protected]026876f32012-08-22 23:53:40533 kOsWin | kOsMac | kOsLinux,
534 MULTI_VALUE_TYPE(kAsyncDnsChoices)
[email protected]27b3fe92012-03-21 05:35:06535 },
536 {
[email protected]6aa03b32011-10-27 21:44:44537 "enable-media-source",
[email protected]da43c082012-09-07 18:56:11538 IDS_FLAGS_DISABLE_MEDIA_SOURCE_NAME,
539 IDS_FLAGS_DISABLE_MEDIA_SOURCE_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32540 kOsAll,
[email protected]da43c082012-09-07 18:56:11541 SINGLE_VALUE_TYPE(switches::kDisableMediaSource)
[email protected]6aa03b32011-10-27 21:44:44542 },
[email protected]e4e68dbb2011-11-18 01:50:22543 {
[email protected]9f5b7822012-04-18 23:39:03544 "enable-encrypted-media",
545 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME,
546 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION,
547 kOsAll,
548 SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia)
549 },
550 {
[email protected]e4e68dbb2011-11-18 01:50:22551 "enable-pointer-lock",
552 IDS_FLAGS_ENABLE_POINTER_LOCK_NAME,
553 IDS_FLAGS_ENABLE_POINTER_LOCK_DESCRIPTION,
554 kOsAll,
[email protected]e4a81662012-06-25 23:57:07555 MULTI_VALUE_TYPE(kPointerLockUIChoices)
[email protected]e4e68dbb2011-11-18 01:50:22556 },
[email protected]dc04be7c2012-03-15 23:57:49557#if defined(USE_ASH)
[email protected]8cc10df2011-11-03 23:57:50558 {
[email protected]57b8bb352012-01-11 05:11:46559 "aura-google-dialog-frames",
560 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME,
561 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION,
562 kOsWin | kOsLinux | kOsCrOS,
563 SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames)
564 },
[email protected]dc04be7c2012-03-15 23:57:49565#endif
[email protected]eaae8b462012-01-20 22:20:39566 {
[email protected]db543d322011-12-15 20:40:15567 "per-tile-painting",
568 IDS_FLAGS_PER_TILE_PAINTING_NAME,
569 IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION,
570#if defined(USE_SKIA)
[email protected]a5b1b272012-01-06 20:44:37571 kOsMac | kOsLinux | kOsCrOS,
[email protected]db543d322011-12-15 20:40:15572#else
573 0,
574#endif
575 SINGLE_VALUE_TYPE(switches::kEnablePerTilePainting)
576 },
[email protected]bf88c032011-12-22 19:05:47577 {
578 "enable-javascript-harmony",
579 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME,
580 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION,
581 kOsAll,
582 SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony")
583 },
[email protected]7e7f378a2012-01-05 14:35:37584 {
[email protected]85646172012-01-09 22:45:54585 "enable-tab-browser-dragging",
586 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME,
587 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION,
588 kOsWin,
589 SINGLE_VALUE_TYPE(switches::kTabBrowserDragging)
590 },
591 {
[email protected]068b7b52012-02-27 12:41:44592 "disable-restore-session-state",
593 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME,
594 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION,
[email protected]7e7f378a2012-01-05 14:35:37595 kOsAll,
[email protected]068b7b52012-02-27 12:41:44596 SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState)
[email protected]7e7f378a2012-01-05 14:35:37597 },
[email protected]88864db2012-01-18 20:56:35598 {
599 "disable-software-rasterizer",
600 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME,
601 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION,
602#if defined(ENABLE_SWIFTSHADER)
603 kOsAll,
604#else
605 0,
606#endif
607 SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer)
608 },
[email protected]15a5d722012-01-23 09:11:14609 {
[email protected]d2edc6702012-01-30 09:13:16610 "enable-shadow-dom",
611 IDS_FLAGS_SHADOW_DOM_NAME,
612 IDS_FLAGS_SHADOW_DOM_DESCRIPTION,
613 kOsAll,
614 SINGLE_VALUE_TYPE(switches::kEnableShadowDOM)
615 },
[email protected]9860c68b2012-02-02 01:58:09616 {
[email protected]4961218f2012-02-23 10:11:07617 "enable-style-scoped",
618 IDS_FLAGS_STYLE_SCOPED_NAME,
619 IDS_FLAGS_STYLE_SCOPED_DESCRIPTION,
620 kOsAll,
621 SINGLE_VALUE_TYPE(switches::kEnableStyleScoped)
622 },
623 {
[email protected]ca7a3d792012-03-02 15:55:49624 "enable-css-regions",
625 IDS_FLAGS_CSS_REGIONS_NAME,
626 IDS_FLAGS_CSS_REGIONS_DESCRIPTION,
627 kOsAll,
628 SINGLE_VALUE_TYPE(switches::kEnableCssRegions)
629 },
630 {
[email protected]b63b9692012-07-25 02:38:01631 "enable-css-variables",
632 IDS_FLAGS_CSS_VARIABLES_NAME,
633 IDS_FLAGS_CSS_VARIABLES_DESCRIPTION,
634 kOsAll,
635 SINGLE_VALUE_TYPE(switches::kEnableCssVariables)
636 },
637 {
[email protected]9860c68b2012-02-02 01:58:09638 "enable-extension-activity-ui",
639 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME,
640 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION,
641 kOsAll,
642 SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI)
[email protected]8bed69d2012-02-02 06:46:00643 },
[email protected]54ae4e92012-02-16 15:19:05644 {
[email protected]3e8befc2012-03-13 01:17:03645 "disable-ntp-other-sessions-menu",
[email protected]156f966332012-02-29 00:03:16646 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME,
647 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION,
648 kOsAll,
[email protected]3e8befc2012-03-13 01:17:03649 SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu)
[email protected]156f966332012-02-29 00:03:16650 },
[email protected]dc04be7c2012-03-15 23:57:49651#if defined(USE_ASH)
[email protected]31cf1c52012-02-29 20:55:01652 {
[email protected]3cd198a22012-03-12 20:38:01653 "enable-ash-oak",
654 IDS_FLAGS_ENABLE_ASH_OAK_NAME,
655 IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION,
656 kOsAll,
657 SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak),
658 },
[email protected]31cf1c52012-02-29 20:55:01659#endif
[email protected]184ec592012-03-01 11:54:28660 {
661 "enable-devtools-experiments",
662 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME,
663 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION,
664 kOsAll,
665 SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments)
666 },
[email protected]76d1854e2012-03-02 23:57:44667 {
668 "enable-suggestions-ntp",
669 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME,
670 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION,
671 kOsAll,
672 SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage)
673 },
[email protected]a78ef9e2012-03-21 02:49:55674 {
[email protected]72267352012-07-20 20:14:47675 "enable-discovery-ntp",
676 IDS_FLAGS_ENABLE_NTP_DISCOVERY_NAME,
677 IDS_FLAGS_ENABLE_NTP_DISCOVERY_DESCRIPTION,
678 kOsAll,
679 SINGLE_VALUE_TYPE(switches::kEnableDiscoveryInNewTabPage)
680 },
[email protected]8e466dd2012-05-04 19:16:05681#if defined(GOOGLE_CHROME_BUILD)
[email protected]a3d54252012-04-05 20:04:13682 {
[email protected]37b928e2012-05-30 09:01:10683 "disable-asynchronous-spellchecking",
684 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING,
685 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING_DESCRIPTION,
686 kOsWin | kOsLinux | kOsCrOS,
687 SINGLE_VALUE_TYPE(switches::kDisableAsynchronousSpellChecking)
[email protected]a3d54252012-04-05 20:04:13688 },
[email protected]8e466dd2012-05-04 19:16:05689#endif
[email protected]c9c73ad42012-04-18 03:35:59690 {
691 "touch-optimized-ui",
[email protected]347a0c72012-05-14 20:28:06692 IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME,
693 IDS_FLAGS_TOUCH_OPTIMIZED_UI_DESCRIPTION,
[email protected]c71fe6402012-08-15 15:22:55694 kOsWin,
[email protected]347a0c72012-05-14 20:28:06695 MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
[email protected]c9c73ad42012-04-18 03:35:59696 },
[email protected]8a6aaa72012-04-20 20:53:58697 {
[email protected]f6f82832012-09-04 17:12:04698 "enable-webkit-text-subpixel-positioning",
699 IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_NAME,
700 IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_DESCRIPTION,
701 kOsCrOS,
702 SINGLE_VALUE_TYPE(switches::kEnableWebkitTextSubpixelPositioning)
703 },
704 {
[email protected]8a6aaa72012-04-20 20:53:58705 "enable-touch-events",
706 IDS_ENABLE_TOUCH_EVENTS_NAME,
707 IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
708 kOsAll,
709 SINGLE_VALUE_TYPE(switches::kEnableTouchEvents)
710 },
[email protected]0b60afa2012-04-19 17:36:39711#if defined(OS_CHROMEOS)
712 {
[email protected]c5667b282012-08-31 00:32:50713 "enable-bezel-touch",
714 IDS_ENABLE_BEZEL_TOUCH_NAME,
715 IDS_ENABLE_BEZEL_TOUCH_DESCRIPTION,
[email protected]1995d80d2012-08-23 02:58:47716 kOsCrOS,
[email protected]c5667b282012-08-31 00:32:50717 SINGLE_VALUE_TYPE(switches::kEnableBezelTouch)
[email protected]1995d80d2012-08-23 02:58:47718 },
719 {
[email protected]0b60afa2012-04-19 17:36:39720 "no-discard-tabs",
721 IDS_FLAGS_NO_DISCARD_TABS_NAME,
722 IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION,
723 kOsCrOS,
724 SINGLE_VALUE_TYPE(switches::kNoDiscardTabs)
725 },
726#endif
[email protected]79be6d32012-04-24 20:47:44727 {
[email protected]9a5940d2012-04-27 19:16:23728 "allow-nacl-socket-api",
729 IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME,
730 IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION,
731 kOsAll,
732 SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*")
733 },
[email protected]85333732012-05-01 19:02:24734 {
[email protected]60673ad72012-05-02 06:16:33735 "stacked-tab-strip",
736 IDS_FLAGS_STACKED_TAB_STRIP_NAME,
737 IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION,
738 kOsWin,
739 SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip)
740 },
741 {
[email protected]4bd20202012-06-14 17:35:01742 "force-device-scale-factor",
[email protected]85333732012-05-01 19:02:24743 IDS_FLAGS_FORCE_HIGH_DPI_NAME,
744 IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION,
745 kOsCrOS,
[email protected]4bd20202012-06-14 17:35:01746 SINGLE_VALUE_TYPE_AND_VALUE(switches::kForceDeviceScaleFactor, "2")
[email protected]85333732012-05-01 19:02:24747 },
[email protected]190349fd2012-05-02 00:10:47748#if defined(OS_CHROMEOS)
749 {
750 "allow-touchpad-three-finger-click",
751 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME,
752 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION,
753 kOsCrOS,
754 SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick)
755 },
756#endif
[email protected]aab64e02012-05-03 19:24:16757 {
[email protected]d3ace932012-08-09 15:39:34758 "enable-client-oauth-signin",
759 IDS_FLAGS_ENABLE_CLIENT_OAUTH_SIGNIN_NAME,
760 IDS_FLAGS_ENABLE_CLIENT_OAUTH_SIGNIN_DESCRIPTION,
[email protected]aab64e02012-05-03 19:24:16761 kOsMac | kOsWin | kOsLinux,
[email protected]d3ace932012-08-09 15:39:34762 SINGLE_VALUE_TYPE(switches::kEnableClientOAuthSignin)
[email protected]aab64e02012-05-03 19:24:16763 },
[email protected]53520b1b2012-05-07 21:43:37764#if defined(USE_ASH)
765 {
[email protected]55444502012-05-10 15:43:53766 "show-launcher-alignment-menu",
767 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_NAME,
768 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION,
769 kOsAll,
770 SINGLE_VALUE_TYPE(switches::kShowLauncherAlignmentMenu)
771 },
[email protected]817ecd12012-05-16 18:36:53772 {
[email protected]73074742012-05-17 01:44:41773 "show-touch-hud",
774 IDS_FLAGS_SHOW_TOUCH_HUD_NAME,
775 IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION,
776 kOsAll,
777 SINGLE_VALUE_TYPE(ash::switches::kAshTouchHud)
778 },
779 {
[email protected]e154db32012-06-18 16:20:46780 "ash-notify-disabled",
781 IDS_FLAGS_DISABLE_ASH_NOTIFY_NAME,
782 IDS_FLAGS_DISABLE_ASH_NOTIFY_DESCRIPTION,
[email protected]817ecd12012-05-16 18:36:53783 kOsAll,
[email protected]e154db32012-06-18 16:20:46784 SINGLE_VALUE_TYPE(ash::switches::kAshNotifyDisabled),
[email protected]817ecd12012-05-16 18:36:53785 },
[email protected]9f0940b62012-05-23 22:56:35786 {
787 "enable-pinch",
788 IDS_FLAGS_ENABLE_PINCH_SCALE_NAME,
789 IDS_FLAGS_ENABLE_PINCH_SCALE_DESCRIPTION,
790 kOsAll,
791 SINGLE_VALUE_TYPE(switches::kEnablePinch),
792 },
[email protected]a8379312012-06-15 00:20:43793 {
794 "app-list-show-apps-only",
795 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_NAME,
796 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_DESCRIPTION,
797 kOsAll,
[email protected]0bc6c272012-07-17 03:32:03798 SINGLE_VALUE_TYPE(app_list::switches::kAppListShowAppsOnly),
[email protected]a8379312012-06-15 00:20:43799 },
[email protected]73074742012-05-17 01:44:41800#endif // defined(USE_ASH)
[email protected]ed7b67f32012-05-28 10:12:28801#if defined(OS_CHROMEOS)
802 {
[email protected]5064c562012-09-05 18:15:27803 "disable-new-wallpaper-picker-ui",
804 IDS_FLAGS_DISABLE_NEW_WALLPAPER_UI_NAME,
805 IDS_FLAGS_DISABLE_NEW_WALLPAPER_UI_DESCRIPTION,
[email protected]a7668a12012-05-28 22:23:48806 kOsCrOS,
[email protected]5064c562012-09-05 18:15:27807 SINGLE_VALUE_TYPE(switches::kDisableNewWallpaperUI)
[email protected]a7668a12012-05-28 22:23:48808 },
809 {
[email protected]898213072012-07-11 02:25:48810 "enable-drive-v2-api",
811 IDS_FLAGS_ENABLE_DRIVE_V2_API,
812 IDS_FLAGS_ENABLE_DRIVE_V2_API_DESCRIPTION,
813 kOsCrOS,
814 SINGLE_VALUE_TYPE(switches::kEnableDriveV2Api),
815 },
816 {
[email protected]02a8cb52012-08-06 22:21:12817 "use-leveldb-for-gdata",
818 IDS_FLAGS_USE_LEVELDB_FOR_GDATA_NAME,
819 IDS_FLAGS_USE_LEVELDB_FOR_GDATA_DESCRIPTION,
820 kOsCrOS,
821 SINGLE_VALUE_TYPE(switches::kUseLevelDBForGData),
822 },
823 {
[email protected]89ef50172012-07-24 21:58:38824 "disable-html5-camera",
825 IDS_FLAGS_DISABLE_HTML5_CAMERA,
826 IDS_FLAGS_DISABLE_HTML5_CAMERA_DESCRIPTION,
[email protected]ffc6f7b12012-07-04 09:11:33827 kOsCrOS,
[email protected]89ef50172012-07-24 21:58:38828 SINGLE_VALUE_TYPE(switches::kDisableHtml5Camera),
[email protected]ffc6f7b12012-07-04 09:11:33829 },
830 {
[email protected]e03dc78d2012-07-24 08:21:43831 "disable-new-oobe",
832 IDS_FLAGS_DISABLE_NEW_OOBE,
833 IDS_FLAGS_DISABLE_NEW_OOBE_DESCRIPTION,
[email protected]ed7b67f32012-05-28 10:12:28834 kOsCrOS,
[email protected]e03dc78d2012-07-24 08:21:43835 SINGLE_VALUE_TYPE(switches::kDisableNewOobe),
[email protected]ed7b67f32012-05-28 10:12:28836 },
[email protected]8b04a1652012-08-04 02:59:49837 {
838 "disable-boot-animation",
839 IDS_FLAGS_DISABLE_BOOT_ANIMATION,
840 IDS_FLAGS_DISABLE_BOOT_ANIMATION_DESCRIPTION,
841 kOsCrOS,
842 SINGLE_VALUE_TYPE(switches::kDisableBootAnimation),
843 },
[email protected]95058572012-08-20 14:57:29844 {
[email protected]6885b732012-09-05 20:47:58845 "disable-workspace2",
846 IDS_FLAGS_DISABLE_WORKSPACE2,
847 IDS_FLAGS_DISABLE_WORKSPACE2_DESCRIPTION,
[email protected]95058572012-08-20 14:57:29848 kOsCrOS,
[email protected]6885b732012-09-05 20:47:58849 SINGLE_VALUE_TYPE(ash::switches::kAshDisableWorkspace2),
[email protected]95058572012-08-20 14:57:29850 },
[email protected]ed7b67f32012-05-28 10:12:28851#endif
[email protected]fc7a93c2012-06-08 20:25:39852 {
853 "enable-views-textfield",
854 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_NAME,
855 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_DESCRIPTION,
856 kOsWin,
857 SINGLE_VALUE_TYPE(switches::kEnableViewsTextfield),
858 },
[email protected]bd0cd3bb2012-06-14 03:03:38859 {
[email protected]ef41b7ee2012-07-24 19:10:41860 "old-checkbox-style",
861 IDS_FLAGS_OLD_CHECKBOX_STYLE,
862 IDS_FLAGS_OLD_CHECKBOX_STYLE_DESCRIPTION,
863 kOsLinux | kOsCrOS,
864 SINGLE_VALUE_TYPE(switches::kOldCheckboxStyle),
865 },
866 {
[email protected]fcb88de2012-07-12 22:25:32867 "enable-frameless-constrained-dialogs",
868 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_NAME,
869 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_DESCRIPTION,
870 kOsWin | kOsCrOS,
871 SINGLE_VALUE_TYPE(switches::kEnableFramelessConstrainedDialogs),
872 },
873 {
[email protected]2faeaabd2012-06-15 01:05:02874 "disable-non-fullscreen-mouse-lock",
875 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_NAME,
876 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_DESCRIPTION,
877 kOsAll,
878 SINGLE_VALUE_TYPE(switches::kDisableNonFullscreenMouseLock),
879 },
[email protected]7057b3e2012-06-18 19:19:16880#if defined(OS_CHROMEOS)
881 {
882 "enable-unsupported-bluetooth-devices",
883 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_NAME,
884 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_DESCRIPTION,
885 kOsCrOS,
886 SINGLE_VALUE_TYPE(switches::kEnableUnsupportedBluetoothDevices)
887 },
888#endif
[email protected]7db8893a2012-07-26 00:49:40889 { "disable-accelerated-video-decode",
890 IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_NAME,
891 IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
[email protected]66dcb0492012-06-18 22:32:15892 kOsAll,
[email protected]7db8893a2012-07-26 00:49:40893 SINGLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
[email protected]66dcb0492012-06-18 22:32:15894 },
[email protected]66ae9fc2012-06-19 21:33:52895#if defined(USE_ASH)
896 {
897 "ash-debug-shortcuts",
898 IDS_FLAGS_DEBUG_SHORTCUTS_NAME,
899 IDS_FLAGS_DEBUG_SHORTCUTS_DESCRIPTION,
900 kOsAll,
901 SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts),
902 },
903#endif
[email protected]37fee0942012-08-07 21:07:45904 {
[email protected]9a8e9352012-08-24 00:45:17905 "disable-website-settings", // FLAGS:RECORD_UMA
906 IDS_FLAGS_DISABLE_WEBSITE_SETTINGS_NAME,
907 IDS_FLAGS_DISABLE_WEBSITE_SETTINGS_DESCRIPTION,
[email protected]37fee0942012-08-07 21:07:45908 kOsAll,
[email protected]9a8e9352012-08-24 00:45:17909 SINGLE_VALUE_TYPE(switches::kDisableWebsiteSettings),
[email protected]37fee0942012-08-07 21:07:45910 },
[email protected]ad3f6d22012-08-29 02:34:19911 {
912 "enable-contacts",
913 IDS_FLAGS_ENABLE_CONTACTS_NAME,
914 IDS_FLAGS_ENABLE_CONTACTS_DESCRIPTION,
915 kOsCrOS,
916 SINGLE_VALUE_TYPE(switches::kEnableContacts)
917 },
[email protected]1d9bb9cd2012-08-28 22:02:50918#if defined(USE_ASH)
919 { "ash-enable-advanced-gestures",
920 IDS_FLAGS_ENABLE_ADVANCED_GESTURES_NAME,
921 IDS_FLAGS_ENABLE_ADVANCED_GESTURES_DESCRIPTION,
922 kOsCrOS,
923 SINGLE_VALUE_TYPE(ash::switches::kAshEnableAdvancedGestures),
924 },
925#endif
[email protected]9b7ab882012-09-10 23:46:36926#if defined(OS_CHROMEOS)
927 {
928 "enable-request-tablet-site",
929 IDS_FLAGS_ENABLE_REQUEST_TABLET_SITE_NAME,
930 IDS_FLAGS_ENABLE_REQUEST_TABLET_SITE_DESCRIPTION,
931 kOsCrOS,
932 SINGLE_VALUE_TYPE(switches::kEnableRequestTabletSite)
933 },
934#endif
[email protected]a0e4b072011-08-17 01:47:07935};
[email protected]ad2a3ded2010-08-27 13:19:05936
[email protected]a314ee5a2010-10-26 21:23:28937const Experiment* experiments = kExperiments;
938size_t num_experiments = arraysize(kExperiments);
939
[email protected]e2ddbc92010-10-15 20:02:07940// Stores and encapsulates the little state that about:flags has.
941class FlagsState {
942 public:
943 FlagsState() : needs_restart_(false) {}
944 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
945 bool IsRestartNeededToCommitChanges();
946 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28947 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07948 void RemoveFlagsSwitches(
949 std::map<std::string, CommandLine::StringType>* switch_list);
950 void reset();
951
952 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55953 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07954 return Singleton<FlagsState>::get();
955 }
956
957 private:
958 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53959 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07960
961 DISALLOW_COPY_AND_ASSIGN(FlagsState);
962};
963
[email protected]c7b7800a2010-10-07 18:51:35964// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:05965// in a set.
[email protected]1a47d7e2010-10-15 00:37:24966void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:05967 const ListValue* enabled_experiments = prefs->GetList(
968 prefs::kEnabledLabsExperiments);
969 if (!enabled_experiments)
970 return;
971
972 for (ListValue::const_iterator it = enabled_experiments->begin();
973 it != enabled_experiments->end();
974 ++it) {
975 std::string experiment_name;
976 if (!(*it)->GetAsString(&experiment_name)) {
977 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
978 continue;
979 }
980 result->insert(experiment_name);
981 }
982}
983
984// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:24985void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05986 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:38987 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
988 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:05989
990 experiments_list->Clear();
991 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
992 it != enabled_experiments.end();
993 ++it) {
994 experiments_list->Append(new StringValue(*it));
995 }
996}
997
[email protected]8a6ff28d2010-12-02 16:35:19998// Returns the name used in prefs for the choice at the specified index.
999std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:341000 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
1001 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:191002 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
1003 base::IntToString(index);
1004}
1005
1006// Adds the internal names for the specified experiment to |names|.
1007void AddInternalName(const Experiment& e, std::set<std::string>* names) {
1008 if (e.type == Experiment::SINGLE_VALUE) {
1009 names->insert(e.internal_name);
1010 } else {
[email protected]2ce9c89752011-02-25 18:24:341011 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:191012 for (int i = 0; i < e.num_choices; ++i)
1013 names->insert(NameForChoice(e, i));
1014 }
1015}
1016
[email protected]28e35af2011-02-09 12:56:221017// Confirms that an experiment is valid, used in a DCHECK in
1018// SanitizeList below.
1019bool ValidateExperiment(const Experiment& e) {
1020 switch (e.type) {
1021 case Experiment::SINGLE_VALUE:
1022 DCHECK_EQ(0, e.num_choices);
1023 DCHECK(!e.choices);
1024 break;
1025 case Experiment::MULTI_VALUE:
1026 DCHECK_GT(e.num_choices, 0);
1027 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:531028 DCHECK(e.choices[0].command_line_switch);
1029 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:221030 break;
1031 default:
1032 NOTREACHED();
1033 }
1034 return true;
1035}
1036
[email protected]ad2a3ded2010-08-27 13:19:051037// Removes all experiments from prefs::kEnabledLabsExperiments that are
1038// unknown, to prevent this list to become very long as experiments are added
1039// and removed.
1040void SanitizeList(PrefService* prefs) {
1041 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:221042 for (size_t i = 0; i < num_experiments; ++i) {
1043 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:191044 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:221045 }
[email protected]ad2a3ded2010-08-27 13:19:051046
1047 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241048 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051049
1050 std::set<std::string> new_enabled_experiments;
1051 std::set_intersection(
1052 known_experiments.begin(), known_experiments.end(),
1053 enabled_experiments.begin(), enabled_experiments.end(),
1054 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1055
[email protected]4c8853f2012-07-23 01:29:161056 if (new_enabled_experiments != enabled_experiments)
1057 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051058}
1059
[email protected]1a47d7e2010-10-15 00:37:241060void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:051061 PrefService* prefs, std::set<std::string>* result) {
1062 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:241063 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:051064}
1065
[email protected]a314ee5a2010-10-26 21:23:281066// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
1067// enabled on the current platform.
1068void GetSanitizedEnabledFlagsForCurrentPlatform(
1069 PrefService* prefs, std::set<std::string>* result) {
1070 GetSanitizedEnabledFlags(prefs, result);
1071
1072 // Filter out any experiments that aren't enabled on the current platform. We
1073 // don't remove these from prefs else syncing to a platform with a different
1074 // set of experiments would be lossy.
1075 std::set<std::string> platform_experiments;
1076 int current_platform = GetCurrentPlatform();
1077 for (size_t i = 0; i < num_experiments; ++i) {
1078 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:191079 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:281080 }
1081
1082 std::set<std::string> new_enabled_experiments;
1083 std::set_intersection(
1084 platform_experiments.begin(), platform_experiments.end(),
1085 result->begin(), result->end(),
1086 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1087
1088 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051089}
1090
[email protected]8a6ff28d2010-12-02 16:35:191091// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:191092Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:221093 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:341094 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:191095 ListValue* result = new ListValue;
1096 for (int i = 0; i < experiment.num_choices; ++i) {
1097 const Experiment::Choice& choice = experiment.choices[i];
1098 DictionaryValue* value = new DictionaryValue;
1099 std::string name = NameForChoice(experiment, i);
1100 value->SetString("description",
1101 l10n_util::GetStringUTF16(choice.description_id));
1102 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:221103 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:191104 result->Append(value);
1105 }
1106 return result;
1107}
1108
[email protected]e2ddbc92010-10-15 20:02:071109} // namespace
1110
[email protected]1a47d7e2010-10-15 00:37:241111void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:551112 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:051113}
1114
[email protected]1a47d7e2010-10-15 00:37:241115ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:051116 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241117 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051118
1119 int current_platform = GetCurrentPlatform();
1120
1121 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:281122 for (size_t i = 0; i < num_experiments; ++i) {
1123 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:051124
1125 DictionaryValue* data = new DictionaryValue();
1126 data->SetString("internal_name", experiment.internal_name);
1127 data->SetString("name",
1128 l10n_util::GetStringUTF16(experiment.visible_name_id));
1129 data->SetString("description",
1130 l10n_util::GetStringUTF16(
1131 experiment.visible_description_id));
[email protected]cc3e2052011-12-20 01:01:401132 bool supported = !!(experiment.supported_platforms & current_platform);
1133 data->SetBoolean("supported", supported);
1134
1135 ListValue* supported_platforms = new ListValue();
1136 AddOsStrings(experiment.supported_platforms, supported_platforms);
1137 data->Set("supported_platforms", supported_platforms);
[email protected]ad2a3ded2010-08-27 13:19:051138
[email protected]28e35af2011-02-09 12:56:221139 switch (experiment.type) {
1140 case Experiment::SINGLE_VALUE:
1141 data->SetBoolean(
1142 "enabled",
1143 enabled_experiments.count(experiment.internal_name) > 0);
1144 break;
1145 case Experiment::MULTI_VALUE:
1146 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
1147 break;
1148 default:
1149 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:191150 }
1151
[email protected]ad2a3ded2010-08-27 13:19:051152 experiments_data->Append(data);
1153 }
1154 return experiments_data;
1155}
1156
[email protected]ad2a3ded2010-08-27 13:19:051157bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:551158 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:051159}
1160
1161void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:351162 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:551163 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:071164}
1165
1166void RemoveFlagsSwitches(
1167 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:551168 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:071169}
1170
[email protected]a314ee5a2010-10-26 21:23:281171int GetCurrentPlatform() {
1172#if defined(OS_MACOSX)
1173 return kOsMac;
1174#elif defined(OS_WIN)
1175 return kOsWin;
1176#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
1177 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:211178#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:281179 return kOsLinux;
[email protected]9c7453d2012-01-21 00:45:401180#elif defined(OS_ANDROID)
1181 return kOsAndroid;
[email protected]a314ee5a2010-10-26 21:23:281182#else
1183#error Unknown platform
1184#endif
1185}
1186
[email protected]4bc5050c2010-11-18 17:55:541187void RecordUMAStatistics(const PrefService* prefs) {
1188 std::set<std::string> flags;
1189 GetEnabledFlags(prefs, &flags);
1190 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
1191 ++it) {
1192 std::string action("AboutFlags_");
1193 action += *it;
[email protected]7f6f44c2011-12-14 13:23:381194 content::RecordComputedAction(action);
[email protected]4bc5050c2010-11-18 17:55:541195 }
1196 // Since flag metrics are recorded every startup, add a tick so that the
1197 // stats can be made meaningful.
1198 if (flags.size())
[email protected]7f6f44c2011-12-14 13:23:381199 content::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
1200 content::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:541201}
1202
[email protected]e2ddbc92010-10-15 20:02:071203//////////////////////////////////////////////////////////////////////////////
1204// FlagsState implementation.
1205
1206namespace {
1207
1208void FlagsState::ConvertFlagsToSwitches(
1209 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:071210 if (command_line->HasSwitch(switches::kNoExperiments))
1211 return;
1212
1213 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:001214
[email protected]a314ee5a2010-10-26 21:23:281215 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:071216
[email protected]a82744532011-02-11 16:15:531217 typedef std::map<std::string, std::pair<std::string, std::string> >
1218 NameToSwitchAndValueMap;
1219 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:191220 for (size_t i = 0; i < num_experiments; ++i) {
1221 const Experiment& e = experiments[i];
1222 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:531223 name_to_switch_map[e.internal_name] =
1224 std::pair<std::string, std::string>(e.command_line_switch,
1225 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191226 } else {
1227 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:531228 name_to_switch_map[NameForChoice(e, j)] =
1229 std::pair<std::string, std::string>(
1230 e.choices[j].command_line_switch,
1231 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191232 }
1233 }
[email protected]e2ddbc92010-10-15 20:02:071234
1235 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:531236 flags_switches_.insert(
1237 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
1238 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071239 for (std::set<std::string>::iterator it = enabled_experiments.begin();
1240 it != enabled_experiments.end();
1241 ++it) {
1242 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:531243 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:191244 name_to_switch_map.find(experiment_name);
1245 if (name_to_switch_it == name_to_switch_map.end()) {
1246 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:071247 continue;
[email protected]8a6ff28d2010-12-02 16:35:191248 }
[email protected]e2ddbc92010-10-15 20:02:071249
[email protected]a82744532011-02-11 16:15:531250 const std::pair<std::string, std::string>&
1251 switch_and_value_pair = name_to_switch_it->second;
1252
1253 command_line->AppendSwitchASCII(switch_and_value_pair.first,
1254 switch_and_value_pair.second);
1255 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:071256 }
1257 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:531258 flags_switches_.insert(
1259 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
1260 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071261}
1262
1263bool FlagsState::IsRestartNeededToCommitChanges() {
1264 return needs_restart_;
1265}
1266
1267void FlagsState::SetExperimentEnabled(
1268 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:051269 needs_restart_ = true;
1270
[email protected]8a6ff28d2010-12-02 16:35:191271 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
1272 if (at_index != std::string::npos) {
1273 DCHECK(enable);
1274 // We're being asked to enable a multi-choice experiment. Disable the
1275 // currently selected choice.
1276 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:221277 const std::string experiment_name = internal_name.substr(0, at_index);
1278 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:191279
[email protected]28e35af2011-02-09 12:56:221280 // And enable the new choice, if it is not the default first choice.
1281 if (internal_name != experiment_name + "@0") {
1282 std::set<std::string> enabled_experiments;
1283 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
1284 enabled_experiments.insert(internal_name);
1285 SetEnabledFlags(prefs, enabled_experiments);
1286 }
[email protected]8a6ff28d2010-12-02 16:35:191287 return;
1288 }
1289
[email protected]ad2a3ded2010-08-27 13:19:051290 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241291 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051292
[email protected]8a6ff28d2010-12-02 16:35:191293 const Experiment* e = NULL;
1294 for (size_t i = 0; i < num_experiments; ++i) {
1295 if (experiments[i].internal_name == internal_name) {
1296 e = experiments + i;
1297 break;
1298 }
1299 }
1300 DCHECK(e);
1301
1302 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:591303 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:191304 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:591305 else
[email protected]8a6ff28d2010-12-02 16:35:191306 enabled_experiments.erase(internal_name);
1307 } else {
1308 if (enable) {
1309 // Enable the first choice.
1310 enabled_experiments.insert(NameForChoice(*e, 0));
1311 } else {
1312 // Find the currently enabled choice and disable it.
1313 for (int i = 0; i < e->num_choices; ++i) {
1314 std::string choice_name = NameForChoice(*e, i);
1315 if (enabled_experiments.find(choice_name) !=
1316 enabled_experiments.end()) {
1317 enabled_experiments.erase(choice_name);
1318 // Continue on just in case there's a bug and more than one
1319 // experiment for this choice was enabled.
1320 }
1321 }
1322 }
1323 }
[email protected]ad2a3ded2010-08-27 13:19:051324
[email protected]1a47d7e2010-10-15 00:37:241325 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051326}
1327
[email protected]e2ddbc92010-10-15 20:02:071328void FlagsState::RemoveFlagsSwitches(
1329 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:531330 for (std::map<std::string, std::string>::const_iterator
1331 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
1332 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:071333 }
1334}
1335
1336void FlagsState::reset() {
1337 needs_restart_ = false;
1338 flags_switches_.clear();
1339}
1340
[email protected]38e46812011-05-09 20:49:221341} // namespace
[email protected]e2ddbc92010-10-15 20:02:071342
1343namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:191344
1345// WARNING: '@' is also used in the html file. If you update this constant you
1346// also need to update the html file.
1347const char kMultiSeparator[] = "@";
1348
[email protected]e2ddbc92010-10-15 20:02:071349void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:551350 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:071351}
[email protected]a314ee5a2010-10-26 21:23:281352
1353void SetExperiments(const Experiment* e, size_t count) {
1354 if (!e) {
1355 experiments = kExperiments;
1356 num_experiments = arraysize(kExperiments);
1357 } else {
1358 experiments = e;
1359 num_experiments = count;
1360 }
1361}
1362
[email protected]8a6ff28d2010-12-02 16:35:191363const Experiment* GetExperiments(size_t* count) {
1364 *count = num_experiments;
1365 return experiments;
1366}
1367
[email protected]e2ddbc92010-10-15 20:02:071368} // namespace testing
1369
[email protected]1a47d7e2010-10-15 00:37:241370} // namespace about_flags