blob: 7aacb3bfd372d843b28d27bfaf7ea480160e1a3c [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]128dc6c2012-06-22 20:30:3585const Experiment::Choice
86 kOmniboxHistoryQuickProviderReorderForInliningChoices[] = {
87 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_AUTOMATIC,
88 "",
89 "" },
90 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_ENABLED,
91 switches::kOmniboxHistoryQuickProviderReorderForInlining,
92 switches::kOmniboxHistoryQuickProviderReorderForInliningEnabled },
93 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DISABLED,
94 switches::kOmniboxHistoryQuickProviderReorderForInlining,
95 switches::kOmniboxHistoryQuickProviderReorderForInliningDisabled }
96};
97
[email protected]032d5e6c2012-02-17 17:53:5598const Experiment::Choice kOmniboxInlineHistoryQuickProviderChoices[] = {
99 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_AUTOMATIC, "", "" },
100 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_ALLOWED,
101 switches::kOmniboxInlineHistoryQuickProvider,
102 switches::kOmniboxInlineHistoryQuickProviderAllowed },
103 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_PROHIBITED,
104 switches::kOmniboxInlineHistoryQuickProvider,
105 switches::kOmniboxInlineHistoryQuickProviderProhibited }
106};
107
[email protected]9b19cf82012-06-13 06:23:23108const Experiment::Choice kForceCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20109 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
110 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]9b19cf82012-06-13 06:23:23111 switches::kForceCompositingMode, ""},
[email protected]a45c69402012-06-24 16:32:20112 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]9b19cf82012-06-13 06:23:23113 switches::kDisableForceCompositingMode, ""}
114};
115
[email protected]72787e392012-03-23 05:55:43116const Experiment::Choice kThreadedCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20117 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
118 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]72787e392012-03-23 05:55:43119 switches::kDisableThreadedCompositing, ""},
[email protected]a45c69402012-06-24 16:32:20120 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]72787e392012-03-23 05:55:43121 switches::kEnableThreadedCompositing, ""}
122};
123
[email protected]347a0c72012-05-14 20:28:06124const Experiment::Choice kTouchOptimizedUIChoices[] = {
125 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_AUTOMATIC, "", "" },
[email protected]a45c69402012-06-24 16:32:20126 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]347a0c72012-05-14 20:28:06127 switches::kTouchOptimizedUI,
128 switches::kTouchOptimizedUIEnabled },
[email protected]a45c69402012-06-24 16:32:20129 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]347a0c72012-05-14 20:28:06130 switches::kTouchOptimizedUI,
131 switches::kTouchOptimizedUIDisabled }
132};
133
[email protected]e4a81662012-06-25 23:57:07134const Experiment::Choice kPointerLockUIChoices[] = {
135 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
136 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
137 switches::kEnablePointerLock, ""},
138 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
139 switches::kDisablePointerLock, ""}
140};
141
[email protected]347a0c72012-05-14 20:28:06142
[email protected]4bc5050c2010-11-18 17:55:54143// RECORDING USER METRICS FOR FLAGS:
144// -----------------------------------------------------------------------------
145// The first line of the experiment is the internal name. If you'd like to
146// gather statistics about the usage of your flag, you should append a marker
147// comment to the end of the feature name, like so:
148// "my-special-feature", // FLAGS:RECORD_UMA
149//
150// After doing that, run //chrome/tools/extract_actions.py (see instructions at
151// the top of that file for details) to update the chromeactions.txt file, which
152// will enable UMA to record your feature flag.
153//
154// After your feature has shipped under a flag, you can locate the metrics
155// under the action name AboutFlags_internal-action-name. Actions are recorded
156// once per startup, so you should divide this number by AboutFlags_StartupTick
157// to get a sense of usage. Note that this will not be the same as number of
158// users with a given feature enabled because users can quit and relaunch
159// the application multiple times over a given time interval.
160// TODO(rsesek): See if there's a way to count per-user, rather than
161// per-startup.
162
[email protected]8a6ff28d2010-12-02 16:35:19163// To add a new experiment add to the end of kExperiments. There are two
164// distinct types of experiments:
165// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
166// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:22167// . MULTI_VALUE: a list of choices, the first of which should correspond to a
168// deactivated state for this lab (i.e. no command line option). To specify
169// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
170// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:19171// See the documentation of Experiment for details on the fields.
172//
173// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:05174const Experiment kExperiments[] = {
175 {
[email protected]aac169d2011-03-18 19:53:03176 "expose-for-tabs", // FLAGS:RECORD_UMA
177 IDS_FLAGS_TABPOSE_NAME,
178 IDS_FLAGS_TABPOSE_DESCRIPTION,
179 kOsMac,
180#if defined(OS_MACOSX)
181 // The switch exists only on OS X.
182 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
183#else
184 SINGLE_VALUE_TYPE("")
185#endif
186 },
187 {
[email protected]4bc5050c2010-11-18 17:55:54188 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05189 IDS_FLAGS_CONFLICTS_CHECK_NAME,
190 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
191 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19192 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05193 },
194 {
[email protected]4bc5050c2010-11-18 17:55:54195 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]dae7325b2011-12-21 20:56:54196 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME,
197 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45198 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22199 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31200 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22201 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
202 // always have PDF rasterization available, so no flag needed there.
203#if !defined(GOOGLE_CHROME_BUILD)
204 kOsWin,
205#else
206 0,
[email protected]fa6d2a2f2010-11-30 21:47:19207#endif
[email protected]8a6ff28d2010-12-02 16:35:19208 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42209 },
[email protected]580939a2010-10-12 18:54:37210 {
[email protected]bb461532010-11-26 21:50:23211 "crxless-web-apps",
212 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
213 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
214 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19215 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23216 },
217 {
[email protected]96c6f4c2011-05-18 19:36:22218 "ignore-gpu-blacklist",
219 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
220 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
221 kOsAll,
222 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
223 },
224 {
[email protected]0110cf112011-07-02 00:39:43225 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22226 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
227 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
[email protected]9b19cf82012-06-13 06:23:23228 kOsMac | kOsWin | kOsLinux,
229 MULTI_VALUE_TYPE(kForceCompositingModeChoices)
[email protected]96c6f4c2011-05-18 19:36:22230 },
231 {
[email protected]72787e392012-03-23 05:55:43232 "threaded-compositing-mode",
233 IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME,
234 IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59235 kOsAll,
[email protected]72787e392012-03-23 05:55:43236 MULTI_VALUE_TYPE(kThreadedCompositingModeChoices)
[email protected]644a1072012-03-16 09:29:59237 },
238 {
[email protected]81c64af62012-06-06 20:15:52239 "disable-accelerated-2d-canvas",
240 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_NAME,
241 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_DESCRIPTION,
242 kOsAll,
243 SINGLE_VALUE_TYPE(switches::kDisableAccelerated2dCanvas)
244 },
245 {
[email protected]7aca2362012-07-10 20:17:08246 "disable-deferred-2d-canvas",
247 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_NAME,
248 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_DESCRIPTION,
249 kOsAll,
250 SINGLE_VALUE_TYPE(switches::kDisableDeferred2dCanvas)
251 },
252 {
[email protected]efcde132012-05-30 01:05:18253 "disable-threaded-animation",
254 IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME,
255 IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59256 kOsAll,
[email protected]efcde132012-05-30 01:05:18257 SINGLE_VALUE_TYPE(switches::kDisableThreadedAnimation)
[email protected]644a1072012-03-16 09:29:59258 },
259 {
[email protected]5963b772011-02-09 22:55:38260 "composited-layer-borders",
261 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
262 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
263 kOsAll,
264 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
265 },
266 {
[email protected]a8f1eaa2011-03-07 19:00:58267 "show-fps-counter",
268 IDS_FLAGS_SHOW_FPS_COUNTER,
269 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
270 kOsAll,
271 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
272 },
[email protected]8ff7f342011-05-25 01:49:47273 {
[email protected]70c98a332011-12-21 20:51:52274 "accelerated-filters",
275 IDS_FLAGS_ACCELERATED_FILTERS,
276 IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION,
277 kOsAll,
278 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters)
279 },
280 {
[email protected]8ff7f342011-05-25 01:49:47281 "disable-gpu-vsync",
282 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
283 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
284 kOsAll,
285 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
286 },
[email protected]deaba6d52011-09-23 14:47:12287 {
288 "disable-webgl",
289 IDS_FLAGS_DISABLE_WEBGL_NAME,
290 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
291 kOsAll,
292 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
293 },
[email protected]09096e02012-05-24 11:12:04294 {
[email protected]96bcdc102012-05-24 23:42:10295 "fixed-position-creates-stacking-context",
296 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_NAME,
297 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_DESCRIPTION,
298 kOsAll,
299 SINGLE_VALUE_TYPE(switches::kFixedPositionCreatesStackingContext)
300 },
[email protected]d208f4d82011-05-23 21:52:03301 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53302 {
[email protected]e3791ce92011-08-09 01:03:32303 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40304 IDS_FLAGS_ENABLE_NACL_NAME,
305 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
306 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19307 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40308 },
[email protected]b39c6d92012-01-31 16:38:41309 // TODO(halyavin): When exception handling is on by default, replace this
310 // flag with disable-nacl-exception-handling.
311 {
312 "enable-nacl-exception-handling", // FLAGS:RECORD_UMA
313 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME,
314 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION,
315 kOsWin,
316 SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling)
317 },
[email protected]4ff87d202010-11-06 01:28:40318 {
[email protected]31a665e72012-03-11 12:37:46319 "nacl-gdb", // FLAGS:RECORD_UMA
320 IDS_FLAGS_NACL_GDB_NAME,
321 IDS_FLAGS_NACL_GDB_DESCRIPTION,
322 kOsWin,
323 SINGLE_VALUE_TYPE(switches::kNaClGdb)
324 },
325 {
[email protected]401b90792012-05-30 11:41:13326 "nacl-gdb-script", // FLAGS:RECORD_UMA
327 IDS_FLAGS_NACL_GDB_SCRIPT_NAME,
328 IDS_FLAGS_NACL_GDB_SCRIPT_DESCRIPTION,
329 kOsAll,
330 SINGLE_VALUE_TYPE(switches::kNaClGdbScript)
331 },
332 {
[email protected]4bc5050c2010-11-18 17:55:54333 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32334 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
335 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
336 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19337 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32338 },
[email protected]3627b06d2010-11-12 16:36:16339 {
[email protected]cab18ef2012-04-27 07:22:03340 "action-box",
341 IDS_FLAGS_ACTION_BOX_NAME,
342 IDS_FLAGS_ACTION_BOX_DESCRIPTION,
343 kOsAll,
344 SINGLE_VALUE_TYPE(switches::kEnableActionBox),
345 },
346 {
[email protected]3a362432012-06-18 20:39:51347 "script-badges",
348 IDS_FLAGS_SCRIPT_BADGES_NAME,
349 IDS_FLAGS_SCRIPT_BADGES_DESCRIPTION,
350 kOsAll,
351 SINGLE_VALUE_TYPE(switches::kEnableScriptBadges),
352 },
353 {
[email protected]cbe224d2011-08-04 22:12:49354 "apps-new-install-bubble",
355 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
356 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
357 kOsAll,
358 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
359 },
360 {
[email protected]80bd24e2010-11-30 09:34:38361 "disable-hyperlink-auditing",
362 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
363 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
364 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19365 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51366 },
367 {
368 "experimental-location-features", // FLAGS:RECORD_UMA
369 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
370 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
371 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19372 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
373 },
374 {
[email protected]5aea1862011-03-23 23:55:39375 "tab-groups-context-menu",
376 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
377 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
378 kOsWin,
379 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
380 },
[email protected]c94cebd2012-06-21 00:55:28381#if defined(OS_CHROMEOS)
382 {
383 "enable-instant-extended-api",
384 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API,
385 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API_DESCRIPTION,
386 kOsAll,
387 SINGLE_VALUE_TYPE(switches::kEnableInstantExtendedAPI)
388 },
389#endif
[email protected]e9bf9d92011-03-31 20:57:15390 {
[email protected]354e33b2011-06-15 00:29:10391 "static-ip-config",
392 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
393 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
394 kOsCrOS,
395#if defined(OS_CHROMEOS)
396 // This switch exists only on Chrome OS.
397 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
398#else
399 SINGLE_VALUE_TYPE("")
400#endif
401 },
[email protected]3eb5728c2011-06-20 22:32:24402 {
403 "show-autofill-type-predictions",
404 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
405 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
406 kOsAll,
407 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
408 },
[email protected]bff4d3e2011-06-21 23:58:52409 {
[email protected]fdf4e252012-04-27 00:26:55410 "sync-tab-favicons",
411 IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
412 IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
413 kOsAll,
414 SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
415 },
416 {
[email protected]aae9eeb12011-10-21 21:59:26417 "sync-app-notifications",
418 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
419 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
420 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11421 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26422 },
423 {
[email protected]a22ebd812011-06-23 00:05:39424 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
425 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
426 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
427 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40428 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40429 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39430 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
431 },
[email protected]81a6b0b2011-06-24 17:55:40432 {
[email protected]68317802012-06-07 19:13:23433 "omnibox-history-quick-provider-new-scoring",
434 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_NAME,
435 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DESCRIPTION,
436 kOsAll,
437 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderNewScoringChoices)
438 },
439 {
[email protected]128dc6c2012-06-22 20:30:35440 "omnibox-history-quick-provider-reorder-for-inlining",
441 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_NAME,
442 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DESCRIPTION,
443 kOsAll,
444 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderReorderForInliningChoices)
445 },
446 {
[email protected]032d5e6c2012-02-17 17:53:55447 "omnibox-inline-history-quick-provider",
448 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME,
449 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION,
450 kOsAll,
451 MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices)
452 },
453 {
[email protected]7e7a28092011-12-09 22:24:55454 "enable-panels",
455 IDS_FLAGS_ENABLE_PANELS_NAME,
456 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54457 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55458 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54459 },
[email protected]e3749d12011-07-25 22:22:12460 {
[email protected]27c14f02012-06-22 17:29:58461 // See http://crbug.com/120416 for how to remove this flag.
[email protected]6474b112012-05-04 19:35:27462 "save-page-as-mhtml", // FLAGS:RECORD_UMA
463 IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME,
464 IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION,
465 kOsMac | kOsWin | kOsLinux,
466 SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)
467 },
468 {
[email protected]b7bb44f2011-09-01 05:17:03469 "enable-autologin",
470 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
471 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
472 kOsMac | kOsWin | kOsLinux,
473 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
474 },
[email protected]b9841172011-09-26 23:36:09475 {
[email protected]bbadb112011-12-12 16:55:28476 "enable-http-pipelining",
477 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
478 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
479 kOsAll,
480 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
481 },
[email protected]d411c01d2011-10-18 16:00:27482 {
[email protected]3231b612012-03-23 05:57:54483 "enable-spdy3",
484 IDS_FLAGS_ENABLE_SPDY3_NAME,
485 IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION,
486 kOsAll,
487 SINGLE_VALUE_TYPE(switches::kEnableSpdy3)
488 },
489 {
[email protected]27b3fe92012-03-21 05:35:06490 "enable-async-dns",
491 IDS_FLAGS_ENABLE_ASYNC_DNS_NAME,
492 IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32493 kOsWin | kOsMac | kOsLinux | kOsCrOS,
[email protected]27b3fe92012-03-21 05:35:06494 SINGLE_VALUE_TYPE(switches::kEnableAsyncDns)
495 },
496 {
[email protected]f5da41d2011-10-08 17:40:07497 "enable-video-track",
498 IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME,
499 IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION,
500 kOsAll,
501 SINGLE_VALUE_TYPE(switches::kEnableVideoTrack)
502 },
[email protected]08b83362011-10-19 05:23:17503 {
[email protected]6aa03b32011-10-27 21:44:44504 "enable-media-source",
505 IDS_FLAGS_ENABLE_MEDIA_SOURCE_NAME,
506 IDS_FLAGS_ENABLE_MEDIA_SOURCE_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32507 kOsAll,
[email protected]6aa03b32011-10-27 21:44:44508 SINGLE_VALUE_TYPE(switches::kEnableMediaSource)
509 },
[email protected]e4e68dbb2011-11-18 01:50:22510 {
[email protected]9f5b7822012-04-18 23:39:03511 "enable-encrypted-media",
512 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME,
513 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION,
514 kOsAll,
515 SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia)
516 },
517 {
[email protected]e4e68dbb2011-11-18 01:50:22518 "enable-pointer-lock",
519 IDS_FLAGS_ENABLE_POINTER_LOCK_NAME,
520 IDS_FLAGS_ENABLE_POINTER_LOCK_DESCRIPTION,
521 kOsAll,
[email protected]e4a81662012-06-25 23:57:07522 MULTI_VALUE_TYPE(kPointerLockUIChoices)
[email protected]e4e68dbb2011-11-18 01:50:22523 },
[email protected]dc04be7c2012-03-15 23:57:49524#if defined(USE_ASH)
[email protected]8cc10df2011-11-03 23:57:50525 {
[email protected]57b8bb352012-01-11 05:11:46526 "aura-google-dialog-frames",
527 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME,
528 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION,
529 kOsWin | kOsLinux | kOsCrOS,
530 SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames)
531 },
[email protected]dc04be7c2012-03-15 23:57:49532#endif
[email protected]eaae8b462012-01-20 22:20:39533 {
534 "enable-gamepad",
535 IDS_FLAGS_ENABLE_GAMEPAD_NAME,
536 IDS_FLAGS_ENABLE_GAMEPAD_DESCRIPTION,
537 kOsAll,
538 SINGLE_VALUE_TYPE(switches::kEnableGamepad)
539 },
[email protected]db543d322011-12-15 20:40:15540 {
541 "per-tile-painting",
542 IDS_FLAGS_PER_TILE_PAINTING_NAME,
543 IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION,
544#if defined(USE_SKIA)
[email protected]a5b1b272012-01-06 20:44:37545 kOsMac | kOsLinux | kOsCrOS,
[email protected]db543d322011-12-15 20:40:15546#else
547 0,
548#endif
549 SINGLE_VALUE_TYPE(switches::kEnablePerTilePainting)
550 },
[email protected]bf88c032011-12-22 19:05:47551 {
552 "enable-javascript-harmony",
553 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME,
554 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION,
555 kOsAll,
556 SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony")
557 },
[email protected]7e7f378a2012-01-05 14:35:37558 {
[email protected]85646172012-01-09 22:45:54559 "enable-tab-browser-dragging",
560 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME,
561 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION,
562 kOsWin,
563 SINGLE_VALUE_TYPE(switches::kTabBrowserDragging)
564 },
565 {
[email protected]068b7b52012-02-27 12:41:44566 "disable-restore-session-state",
567 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME,
568 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION,
[email protected]7e7f378a2012-01-05 14:35:37569 kOsAll,
[email protected]068b7b52012-02-27 12:41:44570 SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState)
[email protected]7e7f378a2012-01-05 14:35:37571 },
[email protected]88864db2012-01-18 20:56:35572 {
573 "disable-software-rasterizer",
574 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME,
575 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION,
576#if defined(ENABLE_SWIFTSHADER)
577 kOsAll,
578#else
579 0,
580#endif
581 SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer)
582 },
[email protected]15a5d722012-01-23 09:11:14583 {
[email protected]8ea05a12012-05-02 09:17:47584 "enable-peer-connection",
585 IDS_FLAGS_PEER_CONNECTION_NAME,
586 IDS_FLAGS_PEER_CONNECTION_DESCRIPTION,
587 kOsAll,
588 SINGLE_VALUE_TYPE(switches::kEnablePeerConnection)
589 },
590 {
[email protected]d2edc6702012-01-30 09:13:16591 "enable-shadow-dom",
592 IDS_FLAGS_SHADOW_DOM_NAME,
593 IDS_FLAGS_SHADOW_DOM_DESCRIPTION,
594 kOsAll,
595 SINGLE_VALUE_TYPE(switches::kEnableShadowDOM)
596 },
[email protected]9860c68b2012-02-02 01:58:09597 {
[email protected]4961218f2012-02-23 10:11:07598 "enable-style-scoped",
599 IDS_FLAGS_STYLE_SCOPED_NAME,
600 IDS_FLAGS_STYLE_SCOPED_DESCRIPTION,
601 kOsAll,
602 SINGLE_VALUE_TYPE(switches::kEnableStyleScoped)
603 },
604 {
[email protected]ca7a3d792012-03-02 15:55:49605 "enable-css-regions",
606 IDS_FLAGS_CSS_REGIONS_NAME,
607 IDS_FLAGS_CSS_REGIONS_DESCRIPTION,
608 kOsAll,
609 SINGLE_VALUE_TYPE(switches::kEnableCssRegions)
610 },
611 {
[email protected]9860c68b2012-02-02 01:58:09612 "enable-extension-activity-ui",
613 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME,
614 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION,
615 kOsAll,
616 SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI)
[email protected]8bed69d2012-02-02 06:46:00617 },
[email protected]54ae4e92012-02-16 15:19:05618 {
[email protected]3e8befc2012-03-13 01:17:03619 "disable-ntp-other-sessions-menu",
[email protected]156f966332012-02-29 00:03:16620 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME,
621 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION,
622 kOsAll,
[email protected]3e8befc2012-03-13 01:17:03623 SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu)
[email protected]156f966332012-02-29 00:03:16624 },
[email protected]dc04be7c2012-03-15 23:57:49625#if defined(USE_ASH)
[email protected]31cf1c52012-02-29 20:55:01626 {
[email protected]3cd198a22012-03-12 20:38:01627 "enable-ash-oak",
628 IDS_FLAGS_ENABLE_ASH_OAK_NAME,
629 IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION,
630 kOsAll,
631 SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak),
632 },
[email protected]31cf1c52012-02-29 20:55:01633#endif
[email protected]184ec592012-03-01 11:54:28634 {
635 "enable-devtools-experiments",
636 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME,
637 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION,
638 kOsAll,
639 SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments)
640 },
[email protected]76d1854e2012-03-02 23:57:44641 {
642 "enable-suggestions-ntp",
643 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME,
644 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION,
645 kOsAll,
646 SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage)
647 },
[email protected]a78ef9e2012-03-21 02:49:55648 {
[email protected]6f41d2e2012-06-21 18:44:25649 "disable-chrome-to-mobile", // FLAGS:RECORD_UMA
650 IDS_FLAGS_DISABLE_CHROME_TO_MOBILE_NAME,
651 IDS_FLAGS_DISABLE_CHROME_TO_MOBILE_DESCRIPTION,
[email protected]a78ef9e2012-03-21 02:49:55652 kOsAll,
[email protected]6f41d2e2012-06-21 18:44:25653 SINGLE_VALUE_TYPE(switches::kDisableChromeToMobile)
[email protected]a78ef9e2012-03-21 02:49:55654 },
[email protected]db92eeb2012-05-11 18:59:20655 {
656 "enable-captive-portal-detection",
657 IDS_FLAGS_CAPTIVE_PORTAL_CHECK_ON_ERROR_NAME,
658 IDS_FLAGS_CAPTIVE_PORTAL_CHECK_ON_ERROR_DESCRIPTION,
659 kOsMac | kOsWin | kOsLinux | kOsCrOS,
660 SINGLE_VALUE_TYPE(switches::kCaptivePortalDetection)
661 },
[email protected]8e466dd2012-05-04 19:16:05662#if defined(GOOGLE_CHROME_BUILD)
[email protected]a3d54252012-04-05 20:04:13663 {
[email protected]37b928e2012-05-30 09:01:10664 "disable-asynchronous-spellchecking",
665 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING,
666 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING_DESCRIPTION,
667 kOsWin | kOsLinux | kOsCrOS,
668 SINGLE_VALUE_TYPE(switches::kDisableAsynchronousSpellChecking)
[email protected]a3d54252012-04-05 20:04:13669 },
[email protected]8e466dd2012-05-04 19:16:05670#endif
[email protected]c9c73ad42012-04-18 03:35:59671 {
672 "touch-optimized-ui",
[email protected]347a0c72012-05-14 20:28:06673 IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME,
674 IDS_FLAGS_TOUCH_OPTIMIZED_UI_DESCRIPTION,
[email protected]f5364d22012-05-31 18:57:29675 kOsWin | kOsCrOS,
[email protected]347a0c72012-05-14 20:28:06676 MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
[email protected]c9c73ad42012-04-18 03:35:59677 },
[email protected]8a6aaa72012-04-20 20:53:58678 {
679 "enable-touch-events",
680 IDS_ENABLE_TOUCH_EVENTS_NAME,
681 IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
682 kOsAll,
683 SINGLE_VALUE_TYPE(switches::kEnableTouchEvents)
684 },
[email protected]0b60afa2012-04-19 17:36:39685#if defined(OS_CHROMEOS)
686 {
687 "no-discard-tabs",
688 IDS_FLAGS_NO_DISCARD_TABS_NAME,
689 IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION,
690 kOsCrOS,
691 SINGLE_VALUE_TYPE(switches::kNoDiscardTabs)
692 },
693#endif
[email protected]79be6d32012-04-24 20:47:44694 {
[email protected]9a5940d2012-04-27 19:16:23695 "allow-nacl-socket-api",
696 IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME,
697 IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION,
698 kOsAll,
699 SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*")
700 },
[email protected]85333732012-05-01 19:02:24701 {
[email protected]60673ad72012-05-02 06:16:33702 "stacked-tab-strip",
703 IDS_FLAGS_STACKED_TAB_STRIP_NAME,
704 IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION,
705 kOsWin,
706 SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip)
707 },
708 {
[email protected]4bd20202012-06-14 17:35:01709 "force-device-scale-factor",
[email protected]85333732012-05-01 19:02:24710 IDS_FLAGS_FORCE_HIGH_DPI_NAME,
711 IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION,
712 kOsCrOS,
[email protected]4bd20202012-06-14 17:35:01713 SINGLE_VALUE_TYPE_AND_VALUE(switches::kForceDeviceScaleFactor, "2")
[email protected]85333732012-05-01 19:02:24714 },
[email protected]190349fd2012-05-02 00:10:47715#if defined(OS_CHROMEOS)
716 {
717 "allow-touchpad-three-finger-click",
718 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME,
719 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION,
720 kOsCrOS,
721 SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick)
722 },
723#endif
[email protected]aab64e02012-05-03 19:24:16724 {
[email protected]816385ee2012-06-05 00:17:52725 "disable-client-oauth-signin",
726 IDS_FLAGS_DISABLE_CLIENT_OAUTH_SIGNIN_NAME,
727 IDS_FLAGS_DISABLE_CLIENT_OAUTH_SIGNIN_DESCRIPTION,
[email protected]aab64e02012-05-03 19:24:16728 kOsMac | kOsWin | kOsLinux,
[email protected]816385ee2012-06-05 00:17:52729 SINGLE_VALUE_TYPE(switches::kDisableClientOAuthSignin)
[email protected]aab64e02012-05-03 19:24:16730 },
[email protected]53520b1b2012-05-07 21:43:37731#if defined(USE_ASH)
732 {
[email protected]55444502012-05-10 15:43:53733 "show-launcher-alignment-menu",
734 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_NAME,
735 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION,
736 kOsAll,
737 SINGLE_VALUE_TYPE(switches::kShowLauncherAlignmentMenu)
738 },
[email protected]817ecd12012-05-16 18:36:53739 {
[email protected]73074742012-05-17 01:44:41740 "show-touch-hud",
741 IDS_FLAGS_SHOW_TOUCH_HUD_NAME,
742 IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION,
743 kOsAll,
744 SINGLE_VALUE_TYPE(ash::switches::kAshTouchHud)
745 },
746 {
[email protected]e154db32012-06-18 16:20:46747 "ash-notify-disabled",
748 IDS_FLAGS_DISABLE_ASH_NOTIFY_NAME,
749 IDS_FLAGS_DISABLE_ASH_NOTIFY_DESCRIPTION,
[email protected]817ecd12012-05-16 18:36:53750 kOsAll,
[email protected]e154db32012-06-18 16:20:46751 SINGLE_VALUE_TYPE(ash::switches::kAshNotifyDisabled),
[email protected]817ecd12012-05-16 18:36:53752 },
[email protected]9f0940b62012-05-23 22:56:35753 {
754 "enable-pinch",
755 IDS_FLAGS_ENABLE_PINCH_SCALE_NAME,
756 IDS_FLAGS_ENABLE_PINCH_SCALE_DESCRIPTION,
757 kOsAll,
758 SINGLE_VALUE_TYPE(switches::kEnablePinch),
759 },
[email protected]a8379312012-06-15 00:20:43760 {
761 "app-list-show-apps-only",
762 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_NAME,
763 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_DESCRIPTION,
764 kOsAll,
765 SINGLE_VALUE_TYPE(ash::switches::kAppListShowAppsOnly),
766 },
[email protected]6aee2592012-06-15 19:51:06767 {
768 "ash-extended-desktop",
769 IDS_FLAGS_ENABLE_ASH_EXTENDED_DESKTOP_NAME,
770 IDS_FLAGS_ENABLE_ASH_EXTENDED_DESKTOP_DESCRIPTION,
771 kOsAll,
772 SINGLE_VALUE_TYPE(ash::switches::kAshExtendedDesktop)
773 },
[email protected]73074742012-05-17 01:44:41774#endif // defined(USE_ASH)
[email protected]ed7b67f32012-05-28 10:12:28775#if defined(OS_CHROMEOS)
776 {
[email protected]a7668a12012-05-28 22:23:48777 "experimental-wallpaper-ui",
778 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_NAME,
779 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_DESCRIPTION,
780 kOsCrOS,
781 SINGLE_VALUE_TYPE(switches::kExperimentalWallpaperUI)
782 },
783 {
[email protected]898213072012-07-11 02:25:48784 "enable-drive-v2-api",
785 IDS_FLAGS_ENABLE_DRIVE_V2_API,
786 IDS_FLAGS_ENABLE_DRIVE_V2_API_DESCRIPTION,
787 kOsCrOS,
788 SINGLE_VALUE_TYPE(switches::kEnableDriveV2Api),
789 },
790 {
[email protected]ffc6f7b12012-07-04 09:11:33791 "enable-html5-camera",
792 IDS_FLAGS_ENABLE_HTML5_CAMERA,
793 IDS_FLAGS_ENABLE_HTML5_CAMERA_DESCRIPTION,
794 kOsCrOS,
795 SINGLE_VALUE_TYPE(switches::kEnableHtml5Camera),
796 },
797 {
[email protected]ed7b67f32012-05-28 10:12:28798 "enable-new-oobe",
799 IDS_FLAGS_ENABLE_NEW_OOBE,
800 IDS_FLAGS_ENABLE_NEW_OOBE_DESCRIPTION,
801 kOsCrOS,
802 SINGLE_VALUE_TYPE(switches::kEnableNewOobe),
803 },
804#endif
[email protected]fc7a93c2012-06-08 20:25:39805 {
806 "enable-views-textfield",
807 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_NAME,
808 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_DESCRIPTION,
809 kOsWin,
810 SINGLE_VALUE_TYPE(switches::kEnableViewsTextfield),
811 },
[email protected]bd0cd3bb2012-06-14 03:03:38812 {
813 "new-checkbox-style",
814 IDS_FLAGS_NEW_CHECKBOX_STYLE,
815 IDS_FLAGS_NEW_CHECKBOX_STYLE_DESCRIPTION,
816 kOsLinux | kOsCrOS,
817 SINGLE_VALUE_TYPE(switches::kNewCheckboxStyle),
818 },
[email protected]2faeaabd2012-06-15 01:05:02819 {
820 "disable-non-fullscreen-mouse-lock",
821 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_NAME,
822 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_DESCRIPTION,
823 kOsAll,
824 SINGLE_VALUE_TYPE(switches::kDisableNonFullscreenMouseLock),
825 },
[email protected]7057b3e2012-06-18 19:19:16826#if defined(OS_CHROMEOS)
827 {
828 "enable-unsupported-bluetooth-devices",
829 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_NAME,
830 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_DESCRIPTION,
831 kOsCrOS,
832 SINGLE_VALUE_TYPE(switches::kEnableUnsupportedBluetoothDevices)
833 },
834#endif
[email protected]66dcb0492012-06-18 22:32:15835 { "enable-accelerated-video-decode",
836 IDS_FLAGS_ENABLE_ACCELERATED_VIDEO_DECODE_NAME,
837 IDS_FLAGS_ENABLE_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
838 kOsAll,
839 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedVideoDecode),
840 },
[email protected]66ae9fc2012-06-19 21:33:52841#if defined(USE_ASH)
842 {
843 "ash-debug-shortcuts",
844 IDS_FLAGS_DEBUG_SHORTCUTS_NAME,
845 IDS_FLAGS_DEBUG_SHORTCUTS_DESCRIPTION,
846 kOsAll,
847 SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts),
848 },
849#endif
[email protected]a45b1bf2012-06-25 21:36:34850 {
851 "enable-speculative-resource-prefetching",
852 IDS_FLAGS_ENABLE_SPECULATIVE_RESOURCE_PREFETCHING_NAME,
853 IDS_FLAGS_ENABLE_SPECULATIVE_RESOURCE_PREFETCHING_DESCRIPTION,
854 kOsAll,
855 SINGLE_VALUE_TYPE(switches::kEnableSpeculativeResourcePrefetching),
856 },
[email protected]a0e4b072011-08-17 01:47:07857};
[email protected]ad2a3ded2010-08-27 13:19:05858
[email protected]a314ee5a2010-10-26 21:23:28859const Experiment* experiments = kExperiments;
860size_t num_experiments = arraysize(kExperiments);
861
[email protected]e2ddbc92010-10-15 20:02:07862// Stores and encapsulates the little state that about:flags has.
863class FlagsState {
864 public:
865 FlagsState() : needs_restart_(false) {}
866 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
867 bool IsRestartNeededToCommitChanges();
868 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28869 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07870 void RemoveFlagsSwitches(
871 std::map<std::string, CommandLine::StringType>* switch_list);
872 void reset();
873
874 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55875 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07876 return Singleton<FlagsState>::get();
877 }
878
879 private:
880 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53881 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07882
883 DISALLOW_COPY_AND_ASSIGN(FlagsState);
884};
885
[email protected]c7b7800a2010-10-07 18:51:35886// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:05887// in a set.
[email protected]1a47d7e2010-10-15 00:37:24888void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:05889 const ListValue* enabled_experiments = prefs->GetList(
890 prefs::kEnabledLabsExperiments);
891 if (!enabled_experiments)
892 return;
893
894 for (ListValue::const_iterator it = enabled_experiments->begin();
895 it != enabled_experiments->end();
896 ++it) {
897 std::string experiment_name;
898 if (!(*it)->GetAsString(&experiment_name)) {
899 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
900 continue;
901 }
902 result->insert(experiment_name);
903 }
904}
905
906// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:24907void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05908 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:38909 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
910 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:05911
912 experiments_list->Clear();
913 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
914 it != enabled_experiments.end();
915 ++it) {
916 experiments_list->Append(new StringValue(*it));
917 }
918}
919
[email protected]8a6ff28d2010-12-02 16:35:19920// Returns the name used in prefs for the choice at the specified index.
921std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:34922 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
923 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:19924 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
925 base::IntToString(index);
926}
927
928// Adds the internal names for the specified experiment to |names|.
929void AddInternalName(const Experiment& e, std::set<std::string>* names) {
930 if (e.type == Experiment::SINGLE_VALUE) {
931 names->insert(e.internal_name);
932 } else {
[email protected]2ce9c89752011-02-25 18:24:34933 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:19934 for (int i = 0; i < e.num_choices; ++i)
935 names->insert(NameForChoice(e, i));
936 }
937}
938
[email protected]28e35af2011-02-09 12:56:22939// Confirms that an experiment is valid, used in a DCHECK in
940// SanitizeList below.
941bool ValidateExperiment(const Experiment& e) {
942 switch (e.type) {
943 case Experiment::SINGLE_VALUE:
944 DCHECK_EQ(0, e.num_choices);
945 DCHECK(!e.choices);
946 break;
947 case Experiment::MULTI_VALUE:
948 DCHECK_GT(e.num_choices, 0);
949 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:53950 DCHECK(e.choices[0].command_line_switch);
951 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:22952 break;
953 default:
954 NOTREACHED();
955 }
956 return true;
957}
958
[email protected]ad2a3ded2010-08-27 13:19:05959// Removes all experiments from prefs::kEnabledLabsExperiments that are
960// unknown, to prevent this list to become very long as experiments are added
961// and removed.
962void SanitizeList(PrefService* prefs) {
963 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:22964 for (size_t i = 0; i < num_experiments; ++i) {
965 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:19966 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:22967 }
[email protected]ad2a3ded2010-08-27 13:19:05968
969 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24970 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05971
972 std::set<std::string> new_enabled_experiments;
973 std::set_intersection(
974 known_experiments.begin(), known_experiments.end(),
975 enabled_experiments.begin(), enabled_experiments.end(),
976 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
977
[email protected]1a47d7e2010-10-15 00:37:24978 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05979}
980
[email protected]1a47d7e2010-10-15 00:37:24981void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05982 PrefService* prefs, std::set<std::string>* result) {
983 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:24984 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:05985}
986
[email protected]a314ee5a2010-10-26 21:23:28987// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
988// enabled on the current platform.
989void GetSanitizedEnabledFlagsForCurrentPlatform(
990 PrefService* prefs, std::set<std::string>* result) {
991 GetSanitizedEnabledFlags(prefs, result);
992
993 // Filter out any experiments that aren't enabled on the current platform. We
994 // don't remove these from prefs else syncing to a platform with a different
995 // set of experiments would be lossy.
996 std::set<std::string> platform_experiments;
997 int current_platform = GetCurrentPlatform();
998 for (size_t i = 0; i < num_experiments; ++i) {
999 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:191000 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:281001 }
1002
1003 std::set<std::string> new_enabled_experiments;
1004 std::set_intersection(
1005 platform_experiments.begin(), platform_experiments.end(),
1006 result->begin(), result->end(),
1007 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1008
1009 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051010}
1011
[email protected]8a6ff28d2010-12-02 16:35:191012// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:191013Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:221014 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:341015 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:191016 ListValue* result = new ListValue;
1017 for (int i = 0; i < experiment.num_choices; ++i) {
1018 const Experiment::Choice& choice = experiment.choices[i];
1019 DictionaryValue* value = new DictionaryValue;
1020 std::string name = NameForChoice(experiment, i);
1021 value->SetString("description",
1022 l10n_util::GetStringUTF16(choice.description_id));
1023 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:221024 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:191025 result->Append(value);
1026 }
1027 return result;
1028}
1029
[email protected]e2ddbc92010-10-15 20:02:071030} // namespace
1031
[email protected]1a47d7e2010-10-15 00:37:241032void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:551033 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:051034}
1035
[email protected]1a47d7e2010-10-15 00:37:241036ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:051037 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241038 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051039
1040 int current_platform = GetCurrentPlatform();
1041
1042 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:281043 for (size_t i = 0; i < num_experiments; ++i) {
1044 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:051045
1046 DictionaryValue* data = new DictionaryValue();
1047 data->SetString("internal_name", experiment.internal_name);
1048 data->SetString("name",
1049 l10n_util::GetStringUTF16(experiment.visible_name_id));
1050 data->SetString("description",
1051 l10n_util::GetStringUTF16(
1052 experiment.visible_description_id));
[email protected]cc3e2052011-12-20 01:01:401053 bool supported = !!(experiment.supported_platforms & current_platform);
1054 data->SetBoolean("supported", supported);
1055
1056 ListValue* supported_platforms = new ListValue();
1057 AddOsStrings(experiment.supported_platforms, supported_platforms);
1058 data->Set("supported_platforms", supported_platforms);
[email protected]ad2a3ded2010-08-27 13:19:051059
[email protected]28e35af2011-02-09 12:56:221060 switch (experiment.type) {
1061 case Experiment::SINGLE_VALUE:
1062 data->SetBoolean(
1063 "enabled",
1064 enabled_experiments.count(experiment.internal_name) > 0);
1065 break;
1066 case Experiment::MULTI_VALUE:
1067 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
1068 break;
1069 default:
1070 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:191071 }
1072
[email protected]ad2a3ded2010-08-27 13:19:051073 experiments_data->Append(data);
1074 }
1075 return experiments_data;
1076}
1077
[email protected]ad2a3ded2010-08-27 13:19:051078bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:551079 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:051080}
1081
1082void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:351083 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:551084 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:071085}
1086
1087void RemoveFlagsSwitches(
1088 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:551089 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:071090}
1091
[email protected]a314ee5a2010-10-26 21:23:281092int GetCurrentPlatform() {
1093#if defined(OS_MACOSX)
1094 return kOsMac;
1095#elif defined(OS_WIN)
1096 return kOsWin;
1097#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
1098 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:211099#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:281100 return kOsLinux;
[email protected]9c7453d2012-01-21 00:45:401101#elif defined(OS_ANDROID)
1102 return kOsAndroid;
[email protected]a314ee5a2010-10-26 21:23:281103#else
1104#error Unknown platform
1105#endif
1106}
1107
[email protected]4bc5050c2010-11-18 17:55:541108void RecordUMAStatistics(const PrefService* prefs) {
1109 std::set<std::string> flags;
1110 GetEnabledFlags(prefs, &flags);
1111 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
1112 ++it) {
1113 std::string action("AboutFlags_");
1114 action += *it;
[email protected]7f6f44c2011-12-14 13:23:381115 content::RecordComputedAction(action);
[email protected]4bc5050c2010-11-18 17:55:541116 }
1117 // Since flag metrics are recorded every startup, add a tick so that the
1118 // stats can be made meaningful.
1119 if (flags.size())
[email protected]7f6f44c2011-12-14 13:23:381120 content::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
1121 content::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:541122}
1123
[email protected]e2ddbc92010-10-15 20:02:071124//////////////////////////////////////////////////////////////////////////////
1125// FlagsState implementation.
1126
1127namespace {
1128
1129void FlagsState::ConvertFlagsToSwitches(
1130 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:071131 if (command_line->HasSwitch(switches::kNoExperiments))
1132 return;
1133
1134 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:001135
[email protected]a314ee5a2010-10-26 21:23:281136 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:071137
[email protected]a82744532011-02-11 16:15:531138 typedef std::map<std::string, std::pair<std::string, std::string> >
1139 NameToSwitchAndValueMap;
1140 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:191141 for (size_t i = 0; i < num_experiments; ++i) {
1142 const Experiment& e = experiments[i];
1143 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:531144 name_to_switch_map[e.internal_name] =
1145 std::pair<std::string, std::string>(e.command_line_switch,
1146 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191147 } else {
1148 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:531149 name_to_switch_map[NameForChoice(e, j)] =
1150 std::pair<std::string, std::string>(
1151 e.choices[j].command_line_switch,
1152 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191153 }
1154 }
[email protected]e2ddbc92010-10-15 20:02:071155
1156 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:531157 flags_switches_.insert(
1158 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
1159 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071160 for (std::set<std::string>::iterator it = enabled_experiments.begin();
1161 it != enabled_experiments.end();
1162 ++it) {
1163 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:531164 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:191165 name_to_switch_map.find(experiment_name);
1166 if (name_to_switch_it == name_to_switch_map.end()) {
1167 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:071168 continue;
[email protected]8a6ff28d2010-12-02 16:35:191169 }
[email protected]e2ddbc92010-10-15 20:02:071170
[email protected]a82744532011-02-11 16:15:531171 const std::pair<std::string, std::string>&
1172 switch_and_value_pair = name_to_switch_it->second;
1173
1174 command_line->AppendSwitchASCII(switch_and_value_pair.first,
1175 switch_and_value_pair.second);
1176 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:071177 }
1178 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:531179 flags_switches_.insert(
1180 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
1181 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071182}
1183
1184bool FlagsState::IsRestartNeededToCommitChanges() {
1185 return needs_restart_;
1186}
1187
1188void FlagsState::SetExperimentEnabled(
1189 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:051190 needs_restart_ = true;
1191
[email protected]8a6ff28d2010-12-02 16:35:191192 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
1193 if (at_index != std::string::npos) {
1194 DCHECK(enable);
1195 // We're being asked to enable a multi-choice experiment. Disable the
1196 // currently selected choice.
1197 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:221198 const std::string experiment_name = internal_name.substr(0, at_index);
1199 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:191200
[email protected]28e35af2011-02-09 12:56:221201 // And enable the new choice, if it is not the default first choice.
1202 if (internal_name != experiment_name + "@0") {
1203 std::set<std::string> enabled_experiments;
1204 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
1205 enabled_experiments.insert(internal_name);
1206 SetEnabledFlags(prefs, enabled_experiments);
1207 }
[email protected]8a6ff28d2010-12-02 16:35:191208 return;
1209 }
1210
[email protected]ad2a3ded2010-08-27 13:19:051211 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241212 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051213
[email protected]8a6ff28d2010-12-02 16:35:191214 const Experiment* e = NULL;
1215 for (size_t i = 0; i < num_experiments; ++i) {
1216 if (experiments[i].internal_name == internal_name) {
1217 e = experiments + i;
1218 break;
1219 }
1220 }
1221 DCHECK(e);
1222
1223 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:591224 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:191225 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:591226 else
[email protected]8a6ff28d2010-12-02 16:35:191227 enabled_experiments.erase(internal_name);
1228 } else {
1229 if (enable) {
1230 // Enable the first choice.
1231 enabled_experiments.insert(NameForChoice(*e, 0));
1232 } else {
1233 // Find the currently enabled choice and disable it.
1234 for (int i = 0; i < e->num_choices; ++i) {
1235 std::string choice_name = NameForChoice(*e, i);
1236 if (enabled_experiments.find(choice_name) !=
1237 enabled_experiments.end()) {
1238 enabled_experiments.erase(choice_name);
1239 // Continue on just in case there's a bug and more than one
1240 // experiment for this choice was enabled.
1241 }
1242 }
1243 }
1244 }
[email protected]ad2a3ded2010-08-27 13:19:051245
[email protected]1a47d7e2010-10-15 00:37:241246 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051247}
1248
[email protected]e2ddbc92010-10-15 20:02:071249void FlagsState::RemoveFlagsSwitches(
1250 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:531251 for (std::map<std::string, std::string>::const_iterator
1252 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
1253 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:071254 }
1255}
1256
1257void FlagsState::reset() {
1258 needs_restart_ = false;
1259 flags_switches_.clear();
1260}
1261
[email protected]38e46812011-05-09 20:49:221262} // namespace
[email protected]e2ddbc92010-10-15 20:02:071263
1264namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:191265
1266// WARNING: '@' is also used in the html file. If you update this constant you
1267// also need to update the html file.
1268const char kMultiSeparator[] = "@";
1269
[email protected]e2ddbc92010-10-15 20:02:071270void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:551271 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:071272}
[email protected]a314ee5a2010-10-26 21:23:281273
1274void SetExperiments(const Experiment* e, size_t count) {
1275 if (!e) {
1276 experiments = kExperiments;
1277 num_experiments = arraysize(kExperiments);
1278 } else {
1279 experiments = e;
1280 num_experiments = count;
1281 }
1282}
1283
[email protected]8a6ff28d2010-12-02 16:35:191284const Experiment* GetExperiments(size_t* count) {
1285 *count = num_experiments;
1286 return experiments;
1287}
1288
[email protected]e2ddbc92010-10-15 20:02:071289} // namespace testing
1290
[email protected]1a47d7e2010-10-15 00:37:241291} // namespace about_flags