blob: 4d0d9ea3e6b2947f8628834ef6ee5e7f70915447 [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]9b19cf82012-06-13 06:23:23109const Experiment::Choice kForceCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20110 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
111 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]9b19cf82012-06-13 06:23:23112 switches::kForceCompositingMode, ""},
[email protected]a45c69402012-06-24 16:32:20113 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]9b19cf82012-06-13 06:23:23114 switches::kDisableForceCompositingMode, ""}
115};
116
[email protected]72787e392012-03-23 05:55:43117const Experiment::Choice kThreadedCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20118 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
119 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]72787e392012-03-23 05:55:43120 switches::kDisableThreadedCompositing, ""},
[email protected]a45c69402012-06-24 16:32:20121 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]72787e392012-03-23 05:55:43122 switches::kEnableThreadedCompositing, ""}
123};
124
[email protected]347a0c72012-05-14 20:28:06125const Experiment::Choice kTouchOptimizedUIChoices[] = {
126 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_AUTOMATIC, "", "" },
[email protected]a45c69402012-06-24 16:32:20127 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]347a0c72012-05-14 20:28:06128 switches::kTouchOptimizedUI,
129 switches::kTouchOptimizedUIEnabled },
[email protected]a45c69402012-06-24 16:32:20130 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]347a0c72012-05-14 20:28:06131 switches::kTouchOptimizedUI,
132 switches::kTouchOptimizedUIDisabled }
133};
134
[email protected]e4a81662012-06-25 23:57:07135const Experiment::Choice kPointerLockUIChoices[] = {
136 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
137 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
138 switches::kEnablePointerLock, ""},
139 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
140 switches::kDisablePointerLock, ""}
141};
142
[email protected]347a0c72012-05-14 20:28:06143
[email protected]4bc5050c2010-11-18 17:55:54144// RECORDING USER METRICS FOR FLAGS:
145// -----------------------------------------------------------------------------
146// The first line of the experiment is the internal name. If you'd like to
147// gather statistics about the usage of your flag, you should append a marker
148// comment to the end of the feature name, like so:
149// "my-special-feature", // FLAGS:RECORD_UMA
150//
151// After doing that, run //chrome/tools/extract_actions.py (see instructions at
152// the top of that file for details) to update the chromeactions.txt file, which
153// will enable UMA to record your feature flag.
154//
155// After your feature has shipped under a flag, you can locate the metrics
156// under the action name AboutFlags_internal-action-name. Actions are recorded
157// once per startup, so you should divide this number by AboutFlags_StartupTick
158// to get a sense of usage. Note that this will not be the same as number of
159// users with a given feature enabled because users can quit and relaunch
160// the application multiple times over a given time interval.
161// TODO(rsesek): See if there's a way to count per-user, rather than
162// per-startup.
163
[email protected]8a6ff28d2010-12-02 16:35:19164// To add a new experiment add to the end of kExperiments. There are two
165// distinct types of experiments:
166// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
167// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:22168// . MULTI_VALUE: a list of choices, the first of which should correspond to a
169// deactivated state for this lab (i.e. no command line option). To specify
170// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
171// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:19172// See the documentation of Experiment for details on the fields.
173//
174// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:05175const Experiment kExperiments[] = {
176 {
[email protected]aac169d2011-03-18 19:53:03177 "expose-for-tabs", // FLAGS:RECORD_UMA
178 IDS_FLAGS_TABPOSE_NAME,
179 IDS_FLAGS_TABPOSE_DESCRIPTION,
180 kOsMac,
181#if defined(OS_MACOSX)
182 // The switch exists only on OS X.
183 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
184#else
185 SINGLE_VALUE_TYPE("")
186#endif
187 },
188 {
[email protected]4bc5050c2010-11-18 17:55:54189 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05190 IDS_FLAGS_CONFLICTS_CHECK_NAME,
191 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
192 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19193 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05194 },
195 {
[email protected]4bc5050c2010-11-18 17:55:54196 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]dae7325b2011-12-21 20:56:54197 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME,
198 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45199 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22200 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31201 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22202 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
203 // always have PDF rasterization available, so no flag needed there.
204#if !defined(GOOGLE_CHROME_BUILD)
205 kOsWin,
206#else
207 0,
[email protected]fa6d2a2f2010-11-30 21:47:19208#endif
[email protected]8a6ff28d2010-12-02 16:35:19209 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42210 },
[email protected]580939a2010-10-12 18:54:37211 {
[email protected]bb461532010-11-26 21:50:23212 "crxless-web-apps",
213 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
214 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
215 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19216 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23217 },
218 {
[email protected]96c6f4c2011-05-18 19:36:22219 "ignore-gpu-blacklist",
220 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
221 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
222 kOsAll,
223 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
224 },
225 {
[email protected]0110cf112011-07-02 00:39:43226 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22227 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
228 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
[email protected]9b19cf82012-06-13 06:23:23229 kOsMac | kOsWin | kOsLinux,
230 MULTI_VALUE_TYPE(kForceCompositingModeChoices)
[email protected]96c6f4c2011-05-18 19:36:22231 },
232 {
[email protected]72787e392012-03-23 05:55:43233 "threaded-compositing-mode",
234 IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME,
235 IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59236 kOsAll,
[email protected]72787e392012-03-23 05:55:43237 MULTI_VALUE_TYPE(kThreadedCompositingModeChoices)
[email protected]644a1072012-03-16 09:29:59238 },
239 {
[email protected]81c64af62012-06-06 20:15:52240 "disable-accelerated-2d-canvas",
241 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_NAME,
242 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_DESCRIPTION,
243 kOsAll,
244 SINGLE_VALUE_TYPE(switches::kDisableAccelerated2dCanvas)
245 },
246 {
[email protected]7aca2362012-07-10 20:17:08247 "disable-deferred-2d-canvas",
248 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_NAME,
249 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_DESCRIPTION,
250 kOsAll,
251 SINGLE_VALUE_TYPE(switches::kDisableDeferred2dCanvas)
252 },
253 {
[email protected]efcde132012-05-30 01:05:18254 "disable-threaded-animation",
255 IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME,
256 IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59257 kOsAll,
[email protected]efcde132012-05-30 01:05:18258 SINGLE_VALUE_TYPE(switches::kDisableThreadedAnimation)
[email protected]644a1072012-03-16 09:29:59259 },
260 {
[email protected]5963b772011-02-09 22:55:38261 "composited-layer-borders",
262 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
263 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
264 kOsAll,
265 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
266 },
267 {
[email protected]a8f1eaa2011-03-07 19:00:58268 "show-fps-counter",
269 IDS_FLAGS_SHOW_FPS_COUNTER,
270 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
271 kOsAll,
272 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
273 },
[email protected]8ff7f342011-05-25 01:49:47274 {
[email protected]70c98a332011-12-21 20:51:52275 "accelerated-filters",
276 IDS_FLAGS_ACCELERATED_FILTERS,
277 IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION,
278 kOsAll,
279 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters)
280 },
281 {
[email protected]8ff7f342011-05-25 01:49:47282 "disable-gpu-vsync",
283 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
284 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
285 kOsAll,
286 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
287 },
[email protected]deaba6d52011-09-23 14:47:12288 {
289 "disable-webgl",
290 IDS_FLAGS_DISABLE_WEBGL_NAME,
291 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
292 kOsAll,
293 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
294 },
[email protected]09096e02012-05-24 11:12:04295 {
[email protected]96bcdc102012-05-24 23:42:10296 "fixed-position-creates-stacking-context",
297 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_NAME,
298 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_DESCRIPTION,
299 kOsAll,
300 SINGLE_VALUE_TYPE(switches::kFixedPositionCreatesStackingContext)
301 },
[email protected]d208f4d82011-05-23 21:52:03302 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53303 {
[email protected]e3791ce92011-08-09 01:03:32304 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40305 IDS_FLAGS_ENABLE_NACL_NAME,
306 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
307 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19308 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40309 },
[email protected]b39c6d92012-01-31 16:38:41310 // TODO(halyavin): When exception handling is on by default, replace this
311 // flag with disable-nacl-exception-handling.
312 {
313 "enable-nacl-exception-handling", // FLAGS:RECORD_UMA
314 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME,
315 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION,
316 kOsWin,
317 SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling)
318 },
[email protected]4ff87d202010-11-06 01:28:40319 {
[email protected]31a665e72012-03-11 12:37:46320 "nacl-gdb", // FLAGS:RECORD_UMA
321 IDS_FLAGS_NACL_GDB_NAME,
322 IDS_FLAGS_NACL_GDB_DESCRIPTION,
323 kOsWin,
324 SINGLE_VALUE_TYPE(switches::kNaClGdb)
325 },
326 {
[email protected]401b90792012-05-30 11:41:13327 "nacl-gdb-script", // FLAGS:RECORD_UMA
328 IDS_FLAGS_NACL_GDB_SCRIPT_NAME,
329 IDS_FLAGS_NACL_GDB_SCRIPT_DESCRIPTION,
330 kOsAll,
331 SINGLE_VALUE_TYPE(switches::kNaClGdbScript)
332 },
333 {
[email protected]4bc5050c2010-11-18 17:55:54334 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32335 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
336 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
337 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19338 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32339 },
[email protected]3627b06d2010-11-12 16:36:16340 {
[email protected]cab18ef2012-04-27 07:22:03341 "action-box",
342 IDS_FLAGS_ACTION_BOX_NAME,
343 IDS_FLAGS_ACTION_BOX_DESCRIPTION,
344 kOsAll,
345 SINGLE_VALUE_TYPE(switches::kEnableActionBox),
346 },
347 {
[email protected]3a362432012-06-18 20:39:51348 "script-badges",
349 IDS_FLAGS_SCRIPT_BADGES_NAME,
350 IDS_FLAGS_SCRIPT_BADGES_DESCRIPTION,
351 kOsAll,
352 SINGLE_VALUE_TYPE(switches::kEnableScriptBadges),
353 },
354 {
[email protected]cbe224d2011-08-04 22:12:49355 "apps-new-install-bubble",
356 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
357 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
358 kOsAll,
359 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
360 },
361 {
[email protected]80bd24e2010-11-30 09:34:38362 "disable-hyperlink-auditing",
363 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
364 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
365 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19366 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51367 },
368 {
369 "experimental-location-features", // FLAGS:RECORD_UMA
370 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
371 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
372 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19373 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
374 },
375 {
[email protected]5aea1862011-03-23 23:55:39376 "tab-groups-context-menu",
377 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
378 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
379 kOsWin,
380 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
381 },
[email protected]c94cebd2012-06-21 00:55:28382#if defined(OS_CHROMEOS)
383 {
384 "enable-instant-extended-api",
385 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API,
386 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API_DESCRIPTION,
387 kOsAll,
388 SINGLE_VALUE_TYPE(switches::kEnableInstantExtendedAPI)
389 },
390#endif
[email protected]e9bf9d92011-03-31 20:57:15391 {
[email protected]354e33b2011-06-15 00:29:10392 "static-ip-config",
393 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
394 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
395 kOsCrOS,
396#if defined(OS_CHROMEOS)
397 // This switch exists only on Chrome OS.
398 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
399#else
400 SINGLE_VALUE_TYPE("")
401#endif
402 },
[email protected]3eb5728c2011-06-20 22:32:24403 {
404 "show-autofill-type-predictions",
405 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
406 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
407 kOsAll,
408 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
409 },
[email protected]bff4d3e2011-06-21 23:58:52410 {
[email protected]fdf4e252012-04-27 00:26:55411 "sync-tab-favicons",
412 IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
413 IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
414 kOsAll,
415 SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
416 },
417 {
[email protected]aae9eeb12011-10-21 21:59:26418 "sync-app-notifications",
419 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
420 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
421 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11422 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26423 },
424 {
[email protected]a22ebd812011-06-23 00:05:39425 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
426 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
427 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
428 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40429 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40430 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39431 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
432 },
[email protected]81a6b0b2011-06-24 17:55:40433 {
[email protected]68317802012-06-07 19:13:23434 "omnibox-history-quick-provider-new-scoring",
435 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_NAME,
436 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DESCRIPTION,
437 kOsAll,
438 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderNewScoringChoices)
439 },
440 {
[email protected]128dc6c2012-06-22 20:30:35441 "omnibox-history-quick-provider-reorder-for-inlining",
442 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_NAME,
443 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DESCRIPTION,
444 kOsAll,
445 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderReorderForInliningChoices)
446 },
447 {
[email protected]032d5e6c2012-02-17 17:53:55448 "omnibox-inline-history-quick-provider",
449 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME,
450 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION,
451 kOsAll,
452 MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices)
453 },
454 {
[email protected]7e7a28092011-12-09 22:24:55455 "enable-panels",
456 IDS_FLAGS_ENABLE_PANELS_NAME,
457 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54458 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55459 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54460 },
[email protected]e3749d12011-07-25 22:22:12461 {
[email protected]27c14f02012-06-22 17:29:58462 // See http://crbug.com/120416 for how to remove this flag.
[email protected]6474b112012-05-04 19:35:27463 "save-page-as-mhtml", // FLAGS:RECORD_UMA
464 IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME,
465 IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION,
466 kOsMac | kOsWin | kOsLinux,
467 SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)
468 },
469 {
[email protected]b7bb44f2011-09-01 05:17:03470 "enable-autologin",
471 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
472 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
473 kOsMac | kOsWin | kOsLinux,
474 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
475 },
[email protected]b9841172011-09-26 23:36:09476 {
[email protected]bbadb112011-12-12 16:55:28477 "enable-http-pipelining",
478 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
479 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
480 kOsAll,
481 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
482 },
[email protected]d411c01d2011-10-18 16:00:27483 {
[email protected]3231b612012-03-23 05:57:54484 "enable-spdy3",
485 IDS_FLAGS_ENABLE_SPDY3_NAME,
486 IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION,
487 kOsAll,
488 SINGLE_VALUE_TYPE(switches::kEnableSpdy3)
489 },
490 {
[email protected]27b3fe92012-03-21 05:35:06491 "enable-async-dns",
492 IDS_FLAGS_ENABLE_ASYNC_DNS_NAME,
493 IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32494 kOsWin | kOsMac | kOsLinux | kOsCrOS,
[email protected]27b3fe92012-03-21 05:35:06495 SINGLE_VALUE_TYPE(switches::kEnableAsyncDns)
496 },
497 {
[email protected]f5da41d2011-10-08 17:40:07498 "enable-video-track",
499 IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME,
500 IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION,
501 kOsAll,
502 SINGLE_VALUE_TYPE(switches::kEnableVideoTrack)
503 },
[email protected]08b83362011-10-19 05:23:17504 {
[email protected]6aa03b32011-10-27 21:44:44505 "enable-media-source",
506 IDS_FLAGS_ENABLE_MEDIA_SOURCE_NAME,
507 IDS_FLAGS_ENABLE_MEDIA_SOURCE_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32508 kOsAll,
[email protected]6aa03b32011-10-27 21:44:44509 SINGLE_VALUE_TYPE(switches::kEnableMediaSource)
510 },
[email protected]e4e68dbb2011-11-18 01:50:22511 {
[email protected]9f5b7822012-04-18 23:39:03512 "enable-encrypted-media",
513 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME,
514 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION,
515 kOsAll,
516 SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia)
517 },
518 {
[email protected]e4e68dbb2011-11-18 01:50:22519 "enable-pointer-lock",
520 IDS_FLAGS_ENABLE_POINTER_LOCK_NAME,
521 IDS_FLAGS_ENABLE_POINTER_LOCK_DESCRIPTION,
522 kOsAll,
[email protected]e4a81662012-06-25 23:57:07523 MULTI_VALUE_TYPE(kPointerLockUIChoices)
[email protected]e4e68dbb2011-11-18 01:50:22524 },
[email protected]dc04be7c2012-03-15 23:57:49525#if defined(USE_ASH)
[email protected]8cc10df2011-11-03 23:57:50526 {
[email protected]57b8bb352012-01-11 05:11:46527 "aura-google-dialog-frames",
528 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME,
529 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION,
530 kOsWin | kOsLinux | kOsCrOS,
531 SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames)
532 },
[email protected]dc04be7c2012-03-15 23:57:49533#endif
[email protected]eaae8b462012-01-20 22:20:39534 {
535 "enable-gamepad",
536 IDS_FLAGS_ENABLE_GAMEPAD_NAME,
537 IDS_FLAGS_ENABLE_GAMEPAD_DESCRIPTION,
538 kOsAll,
539 SINGLE_VALUE_TYPE(switches::kEnableGamepad)
540 },
[email protected]db543d322011-12-15 20:40:15541 {
542 "per-tile-painting",
543 IDS_FLAGS_PER_TILE_PAINTING_NAME,
544 IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION,
545#if defined(USE_SKIA)
[email protected]a5b1b272012-01-06 20:44:37546 kOsMac | kOsLinux | kOsCrOS,
[email protected]db543d322011-12-15 20:40:15547#else
548 0,
549#endif
550 SINGLE_VALUE_TYPE(switches::kEnablePerTilePainting)
551 },
[email protected]bf88c032011-12-22 19:05:47552 {
553 "enable-javascript-harmony",
554 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME,
555 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION,
556 kOsAll,
557 SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony")
558 },
[email protected]7e7f378a2012-01-05 14:35:37559 {
[email protected]85646172012-01-09 22:45:54560 "enable-tab-browser-dragging",
561 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME,
562 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION,
563 kOsWin,
564 SINGLE_VALUE_TYPE(switches::kTabBrowserDragging)
565 },
566 {
[email protected]068b7b52012-02-27 12:41:44567 "disable-restore-session-state",
568 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME,
569 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION,
[email protected]7e7f378a2012-01-05 14:35:37570 kOsAll,
[email protected]068b7b52012-02-27 12:41:44571 SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState)
[email protected]7e7f378a2012-01-05 14:35:37572 },
[email protected]88864db2012-01-18 20:56:35573 {
574 "disable-software-rasterizer",
575 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME,
576 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION,
577#if defined(ENABLE_SWIFTSHADER)
578 kOsAll,
579#else
580 0,
581#endif
582 SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer)
583 },
[email protected]15a5d722012-01-23 09:11:14584 {
[email protected]8ea05a12012-05-02 09:17:47585 "enable-peer-connection",
586 IDS_FLAGS_PEER_CONNECTION_NAME,
587 IDS_FLAGS_PEER_CONNECTION_DESCRIPTION,
588 kOsAll,
589 SINGLE_VALUE_TYPE(switches::kEnablePeerConnection)
590 },
591 {
[email protected]d2edc6702012-01-30 09:13:16592 "enable-shadow-dom",
593 IDS_FLAGS_SHADOW_DOM_NAME,
594 IDS_FLAGS_SHADOW_DOM_DESCRIPTION,
595 kOsAll,
596 SINGLE_VALUE_TYPE(switches::kEnableShadowDOM)
597 },
[email protected]9860c68b2012-02-02 01:58:09598 {
[email protected]4961218f2012-02-23 10:11:07599 "enable-style-scoped",
600 IDS_FLAGS_STYLE_SCOPED_NAME,
601 IDS_FLAGS_STYLE_SCOPED_DESCRIPTION,
602 kOsAll,
603 SINGLE_VALUE_TYPE(switches::kEnableStyleScoped)
604 },
605 {
[email protected]ca7a3d792012-03-02 15:55:49606 "enable-css-regions",
607 IDS_FLAGS_CSS_REGIONS_NAME,
608 IDS_FLAGS_CSS_REGIONS_DESCRIPTION,
609 kOsAll,
610 SINGLE_VALUE_TYPE(switches::kEnableCssRegions)
611 },
612 {
[email protected]9860c68b2012-02-02 01:58:09613 "enable-extension-activity-ui",
614 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME,
615 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION,
616 kOsAll,
617 SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI)
[email protected]8bed69d2012-02-02 06:46:00618 },
[email protected]54ae4e92012-02-16 15:19:05619 {
[email protected]3e8befc2012-03-13 01:17:03620 "disable-ntp-other-sessions-menu",
[email protected]156f966332012-02-29 00:03:16621 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME,
622 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION,
623 kOsAll,
[email protected]3e8befc2012-03-13 01:17:03624 SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu)
[email protected]156f966332012-02-29 00:03:16625 },
[email protected]dc04be7c2012-03-15 23:57:49626#if defined(USE_ASH)
[email protected]31cf1c52012-02-29 20:55:01627 {
[email protected]3cd198a22012-03-12 20:38:01628 "enable-ash-oak",
629 IDS_FLAGS_ENABLE_ASH_OAK_NAME,
630 IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION,
631 kOsAll,
632 SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak),
633 },
[email protected]31cf1c52012-02-29 20:55:01634#endif
[email protected]184ec592012-03-01 11:54:28635 {
636 "enable-devtools-experiments",
637 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME,
638 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION,
639 kOsAll,
640 SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments)
641 },
[email protected]76d1854e2012-03-02 23:57:44642 {
643 "enable-suggestions-ntp",
644 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME,
645 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION,
646 kOsAll,
647 SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage)
648 },
[email protected]a78ef9e2012-03-21 02:49:55649 {
[email protected]6f41d2e2012-06-21 18:44:25650 "disable-chrome-to-mobile", // FLAGS:RECORD_UMA
651 IDS_FLAGS_DISABLE_CHROME_TO_MOBILE_NAME,
652 IDS_FLAGS_DISABLE_CHROME_TO_MOBILE_DESCRIPTION,
[email protected]a78ef9e2012-03-21 02:49:55653 kOsAll,
[email protected]6f41d2e2012-06-21 18:44:25654 SINGLE_VALUE_TYPE(switches::kDisableChromeToMobile)
[email protected]a78ef9e2012-03-21 02:49:55655 },
[email protected]db92eeb2012-05-11 18:59:20656 {
657 "enable-captive-portal-detection",
658 IDS_FLAGS_CAPTIVE_PORTAL_CHECK_ON_ERROR_NAME,
659 IDS_FLAGS_CAPTIVE_PORTAL_CHECK_ON_ERROR_DESCRIPTION,
660 kOsMac | kOsWin | kOsLinux | kOsCrOS,
661 SINGLE_VALUE_TYPE(switches::kCaptivePortalDetection)
662 },
[email protected]8e466dd2012-05-04 19:16:05663#if defined(GOOGLE_CHROME_BUILD)
[email protected]a3d54252012-04-05 20:04:13664 {
[email protected]37b928e2012-05-30 09:01:10665 "disable-asynchronous-spellchecking",
666 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING,
667 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING_DESCRIPTION,
668 kOsWin | kOsLinux | kOsCrOS,
669 SINGLE_VALUE_TYPE(switches::kDisableAsynchronousSpellChecking)
[email protected]a3d54252012-04-05 20:04:13670 },
[email protected]8e466dd2012-05-04 19:16:05671#endif
[email protected]c9c73ad42012-04-18 03:35:59672 {
673 "touch-optimized-ui",
[email protected]347a0c72012-05-14 20:28:06674 IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME,
675 IDS_FLAGS_TOUCH_OPTIMIZED_UI_DESCRIPTION,
[email protected]f5364d22012-05-31 18:57:29676 kOsWin | kOsCrOS,
[email protected]347a0c72012-05-14 20:28:06677 MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
[email protected]c9c73ad42012-04-18 03:35:59678 },
[email protected]8a6aaa72012-04-20 20:53:58679 {
680 "enable-touch-events",
681 IDS_ENABLE_TOUCH_EVENTS_NAME,
682 IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
683 kOsAll,
684 SINGLE_VALUE_TYPE(switches::kEnableTouchEvents)
685 },
[email protected]0b60afa2012-04-19 17:36:39686#if defined(OS_CHROMEOS)
687 {
688 "no-discard-tabs",
689 IDS_FLAGS_NO_DISCARD_TABS_NAME,
690 IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION,
691 kOsCrOS,
692 SINGLE_VALUE_TYPE(switches::kNoDiscardTabs)
693 },
694#endif
[email protected]79be6d32012-04-24 20:47:44695 {
[email protected]9a5940d2012-04-27 19:16:23696 "allow-nacl-socket-api",
697 IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME,
698 IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION,
699 kOsAll,
700 SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*")
701 },
[email protected]85333732012-05-01 19:02:24702 {
[email protected]60673ad72012-05-02 06:16:33703 "stacked-tab-strip",
704 IDS_FLAGS_STACKED_TAB_STRIP_NAME,
705 IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION,
706 kOsWin,
707 SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip)
708 },
709 {
[email protected]4bd20202012-06-14 17:35:01710 "force-device-scale-factor",
[email protected]85333732012-05-01 19:02:24711 IDS_FLAGS_FORCE_HIGH_DPI_NAME,
712 IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION,
713 kOsCrOS,
[email protected]4bd20202012-06-14 17:35:01714 SINGLE_VALUE_TYPE_AND_VALUE(switches::kForceDeviceScaleFactor, "2")
[email protected]85333732012-05-01 19:02:24715 },
[email protected]190349fd2012-05-02 00:10:47716#if defined(OS_CHROMEOS)
717 {
718 "allow-touchpad-three-finger-click",
719 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME,
720 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION,
721 kOsCrOS,
722 SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick)
723 },
724#endif
[email protected]aab64e02012-05-03 19:24:16725 {
[email protected]816385ee2012-06-05 00:17:52726 "disable-client-oauth-signin",
727 IDS_FLAGS_DISABLE_CLIENT_OAUTH_SIGNIN_NAME,
728 IDS_FLAGS_DISABLE_CLIENT_OAUTH_SIGNIN_DESCRIPTION,
[email protected]aab64e02012-05-03 19:24:16729 kOsMac | kOsWin | kOsLinux,
[email protected]816385ee2012-06-05 00:17:52730 SINGLE_VALUE_TYPE(switches::kDisableClientOAuthSignin)
[email protected]aab64e02012-05-03 19:24:16731 },
[email protected]53520b1b2012-05-07 21:43:37732#if defined(USE_ASH)
733 {
[email protected]55444502012-05-10 15:43:53734 "show-launcher-alignment-menu",
735 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_NAME,
736 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION,
737 kOsAll,
738 SINGLE_VALUE_TYPE(switches::kShowLauncherAlignmentMenu)
739 },
[email protected]817ecd12012-05-16 18:36:53740 {
[email protected]73074742012-05-17 01:44:41741 "show-touch-hud",
742 IDS_FLAGS_SHOW_TOUCH_HUD_NAME,
743 IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION,
744 kOsAll,
745 SINGLE_VALUE_TYPE(ash::switches::kAshTouchHud)
746 },
747 {
[email protected]e154db32012-06-18 16:20:46748 "ash-notify-disabled",
749 IDS_FLAGS_DISABLE_ASH_NOTIFY_NAME,
750 IDS_FLAGS_DISABLE_ASH_NOTIFY_DESCRIPTION,
[email protected]817ecd12012-05-16 18:36:53751 kOsAll,
[email protected]e154db32012-06-18 16:20:46752 SINGLE_VALUE_TYPE(ash::switches::kAshNotifyDisabled),
[email protected]817ecd12012-05-16 18:36:53753 },
[email protected]9f0940b62012-05-23 22:56:35754 {
755 "enable-pinch",
756 IDS_FLAGS_ENABLE_PINCH_SCALE_NAME,
757 IDS_FLAGS_ENABLE_PINCH_SCALE_DESCRIPTION,
758 kOsAll,
759 SINGLE_VALUE_TYPE(switches::kEnablePinch),
760 },
[email protected]a8379312012-06-15 00:20:43761 {
762 "app-list-show-apps-only",
763 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_NAME,
764 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_DESCRIPTION,
765 kOsAll,
[email protected]0bc6c272012-07-17 03:32:03766 SINGLE_VALUE_TYPE(app_list::switches::kAppListShowAppsOnly),
[email protected]a8379312012-06-15 00:20:43767 },
[email protected]6aee2592012-06-15 19:51:06768 {
769 "ash-extended-desktop",
770 IDS_FLAGS_ENABLE_ASH_EXTENDED_DESKTOP_NAME,
771 IDS_FLAGS_ENABLE_ASH_EXTENDED_DESKTOP_DESCRIPTION,
772 kOsAll,
773 SINGLE_VALUE_TYPE(ash::switches::kAshExtendedDesktop)
774 },
[email protected]73074742012-05-17 01:44:41775#endif // defined(USE_ASH)
[email protected]ed7b67f32012-05-28 10:12:28776#if defined(OS_CHROMEOS)
777 {
[email protected]a7668a12012-05-28 22:23:48778 "experimental-wallpaper-ui",
779 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_NAME,
780 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_DESCRIPTION,
781 kOsCrOS,
782 SINGLE_VALUE_TYPE(switches::kExperimentalWallpaperUI)
783 },
784 {
[email protected]898213072012-07-11 02:25:48785 "enable-drive-v2-api",
786 IDS_FLAGS_ENABLE_DRIVE_V2_API,
787 IDS_FLAGS_ENABLE_DRIVE_V2_API_DESCRIPTION,
788 kOsCrOS,
789 SINGLE_VALUE_TYPE(switches::kEnableDriveV2Api),
790 },
791 {
[email protected]ffc6f7b12012-07-04 09:11:33792 "enable-html5-camera",
793 IDS_FLAGS_ENABLE_HTML5_CAMERA,
794 IDS_FLAGS_ENABLE_HTML5_CAMERA_DESCRIPTION,
795 kOsCrOS,
796 SINGLE_VALUE_TYPE(switches::kEnableHtml5Camera),
797 },
798 {
[email protected]ed7b67f32012-05-28 10:12:28799 "enable-new-oobe",
800 IDS_FLAGS_ENABLE_NEW_OOBE,
801 IDS_FLAGS_ENABLE_NEW_OOBE_DESCRIPTION,
802 kOsCrOS,
803 SINGLE_VALUE_TYPE(switches::kEnableNewOobe),
804 },
805#endif
[email protected]fc7a93c2012-06-08 20:25:39806 {
807 "enable-views-textfield",
808 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_NAME,
809 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_DESCRIPTION,
810 kOsWin,
811 SINGLE_VALUE_TYPE(switches::kEnableViewsTextfield),
812 },
[email protected]bd0cd3bb2012-06-14 03:03:38813 {
[email protected]fcb88de2012-07-12 22:25:32814 "enable-frameless-constrained-dialogs",
815 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_NAME,
816 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_DESCRIPTION,
817 kOsWin | kOsCrOS,
818 SINGLE_VALUE_TYPE(switches::kEnableFramelessConstrainedDialogs),
819 },
820 {
[email protected]bd0cd3bb2012-06-14 03:03:38821 "new-checkbox-style",
822 IDS_FLAGS_NEW_CHECKBOX_STYLE,
823 IDS_FLAGS_NEW_CHECKBOX_STYLE_DESCRIPTION,
824 kOsLinux | kOsCrOS,
825 SINGLE_VALUE_TYPE(switches::kNewCheckboxStyle),
826 },
[email protected]2faeaabd2012-06-15 01:05:02827 {
828 "disable-non-fullscreen-mouse-lock",
829 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_NAME,
830 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_DESCRIPTION,
831 kOsAll,
832 SINGLE_VALUE_TYPE(switches::kDisableNonFullscreenMouseLock),
833 },
[email protected]7057b3e2012-06-18 19:19:16834#if defined(OS_CHROMEOS)
835 {
836 "enable-unsupported-bluetooth-devices",
837 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_NAME,
838 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_DESCRIPTION,
839 kOsCrOS,
840 SINGLE_VALUE_TYPE(switches::kEnableUnsupportedBluetoothDevices)
841 },
842#endif
[email protected]66dcb0492012-06-18 22:32:15843 { "enable-accelerated-video-decode",
844 IDS_FLAGS_ENABLE_ACCELERATED_VIDEO_DECODE_NAME,
845 IDS_FLAGS_ENABLE_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
846 kOsAll,
847 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedVideoDecode),
848 },
[email protected]66ae9fc2012-06-19 21:33:52849#if defined(USE_ASH)
850 {
851 "ash-debug-shortcuts",
852 IDS_FLAGS_DEBUG_SHORTCUTS_NAME,
853 IDS_FLAGS_DEBUG_SHORTCUTS_DESCRIPTION,
854 kOsAll,
855 SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts),
856 },
857#endif
[email protected]c0dd4ab2012-07-11 22:14:11858 {
859 "enable-speculative-resource-prefetching",
860 IDS_FLAGS_ENABLE_SPECULATIVE_RESOURCE_PREFETCHING_NAME,
861 IDS_FLAGS_ENABLE_SPECULATIVE_RESOURCE_PREFETCHING_DESCRIPTION,
862 kOsAll,
863 SINGLE_VALUE_TYPE(switches::kEnableSpeculativeResourcePrefetching),
864 },
[email protected]a0e4b072011-08-17 01:47:07865};
[email protected]ad2a3ded2010-08-27 13:19:05866
[email protected]a314ee5a2010-10-26 21:23:28867const Experiment* experiments = kExperiments;
868size_t num_experiments = arraysize(kExperiments);
869
[email protected]e2ddbc92010-10-15 20:02:07870// Stores and encapsulates the little state that about:flags has.
871class FlagsState {
872 public:
873 FlagsState() : needs_restart_(false) {}
874 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
875 bool IsRestartNeededToCommitChanges();
876 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28877 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07878 void RemoveFlagsSwitches(
879 std::map<std::string, CommandLine::StringType>* switch_list);
880 void reset();
881
882 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55883 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07884 return Singleton<FlagsState>::get();
885 }
886
887 private:
888 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53889 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07890
891 DISALLOW_COPY_AND_ASSIGN(FlagsState);
892};
893
[email protected]c7b7800a2010-10-07 18:51:35894// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:05895// in a set.
[email protected]1a47d7e2010-10-15 00:37:24896void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:05897 const ListValue* enabled_experiments = prefs->GetList(
898 prefs::kEnabledLabsExperiments);
899 if (!enabled_experiments)
900 return;
901
902 for (ListValue::const_iterator it = enabled_experiments->begin();
903 it != enabled_experiments->end();
904 ++it) {
905 std::string experiment_name;
906 if (!(*it)->GetAsString(&experiment_name)) {
907 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
908 continue;
909 }
910 result->insert(experiment_name);
911 }
912}
913
914// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:24915void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05916 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:38917 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
918 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:05919
920 experiments_list->Clear();
921 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
922 it != enabled_experiments.end();
923 ++it) {
924 experiments_list->Append(new StringValue(*it));
925 }
926}
927
[email protected]8a6ff28d2010-12-02 16:35:19928// Returns the name used in prefs for the choice at the specified index.
929std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:34930 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
931 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:19932 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
933 base::IntToString(index);
934}
935
936// Adds the internal names for the specified experiment to |names|.
937void AddInternalName(const Experiment& e, std::set<std::string>* names) {
938 if (e.type == Experiment::SINGLE_VALUE) {
939 names->insert(e.internal_name);
940 } else {
[email protected]2ce9c89752011-02-25 18:24:34941 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:19942 for (int i = 0; i < e.num_choices; ++i)
943 names->insert(NameForChoice(e, i));
944 }
945}
946
[email protected]28e35af2011-02-09 12:56:22947// Confirms that an experiment is valid, used in a DCHECK in
948// SanitizeList below.
949bool ValidateExperiment(const Experiment& e) {
950 switch (e.type) {
951 case Experiment::SINGLE_VALUE:
952 DCHECK_EQ(0, e.num_choices);
953 DCHECK(!e.choices);
954 break;
955 case Experiment::MULTI_VALUE:
956 DCHECK_GT(e.num_choices, 0);
957 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:53958 DCHECK(e.choices[0].command_line_switch);
959 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:22960 break;
961 default:
962 NOTREACHED();
963 }
964 return true;
965}
966
[email protected]ad2a3ded2010-08-27 13:19:05967// Removes all experiments from prefs::kEnabledLabsExperiments that are
968// unknown, to prevent this list to become very long as experiments are added
969// and removed.
970void SanitizeList(PrefService* prefs) {
971 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:22972 for (size_t i = 0; i < num_experiments; ++i) {
973 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:19974 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:22975 }
[email protected]ad2a3ded2010-08-27 13:19:05976
977 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24978 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05979
980 std::set<std::string> new_enabled_experiments;
981 std::set_intersection(
982 known_experiments.begin(), known_experiments.end(),
983 enabled_experiments.begin(), enabled_experiments.end(),
984 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
985
[email protected]1a47d7e2010-10-15 00:37:24986 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05987}
988
[email protected]1a47d7e2010-10-15 00:37:24989void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05990 PrefService* prefs, std::set<std::string>* result) {
991 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:24992 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:05993}
994
[email protected]a314ee5a2010-10-26 21:23:28995// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
996// enabled on the current platform.
997void GetSanitizedEnabledFlagsForCurrentPlatform(
998 PrefService* prefs, std::set<std::string>* result) {
999 GetSanitizedEnabledFlags(prefs, result);
1000
1001 // Filter out any experiments that aren't enabled on the current platform. We
1002 // don't remove these from prefs else syncing to a platform with a different
1003 // set of experiments would be lossy.
1004 std::set<std::string> platform_experiments;
1005 int current_platform = GetCurrentPlatform();
1006 for (size_t i = 0; i < num_experiments; ++i) {
1007 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:191008 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:281009 }
1010
1011 std::set<std::string> new_enabled_experiments;
1012 std::set_intersection(
1013 platform_experiments.begin(), platform_experiments.end(),
1014 result->begin(), result->end(),
1015 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1016
1017 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051018}
1019
[email protected]8a6ff28d2010-12-02 16:35:191020// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:191021Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:221022 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:341023 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:191024 ListValue* result = new ListValue;
1025 for (int i = 0; i < experiment.num_choices; ++i) {
1026 const Experiment::Choice& choice = experiment.choices[i];
1027 DictionaryValue* value = new DictionaryValue;
1028 std::string name = NameForChoice(experiment, i);
1029 value->SetString("description",
1030 l10n_util::GetStringUTF16(choice.description_id));
1031 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:221032 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:191033 result->Append(value);
1034 }
1035 return result;
1036}
1037
[email protected]e2ddbc92010-10-15 20:02:071038} // namespace
1039
[email protected]1a47d7e2010-10-15 00:37:241040void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:551041 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:051042}
1043
[email protected]1a47d7e2010-10-15 00:37:241044ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:051045 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241046 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051047
1048 int current_platform = GetCurrentPlatform();
1049
1050 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:281051 for (size_t i = 0; i < num_experiments; ++i) {
1052 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:051053
1054 DictionaryValue* data = new DictionaryValue();
1055 data->SetString("internal_name", experiment.internal_name);
1056 data->SetString("name",
1057 l10n_util::GetStringUTF16(experiment.visible_name_id));
1058 data->SetString("description",
1059 l10n_util::GetStringUTF16(
1060 experiment.visible_description_id));
[email protected]cc3e2052011-12-20 01:01:401061 bool supported = !!(experiment.supported_platforms & current_platform);
1062 data->SetBoolean("supported", supported);
1063
1064 ListValue* supported_platforms = new ListValue();
1065 AddOsStrings(experiment.supported_platforms, supported_platforms);
1066 data->Set("supported_platforms", supported_platforms);
[email protected]ad2a3ded2010-08-27 13:19:051067
[email protected]28e35af2011-02-09 12:56:221068 switch (experiment.type) {
1069 case Experiment::SINGLE_VALUE:
1070 data->SetBoolean(
1071 "enabled",
1072 enabled_experiments.count(experiment.internal_name) > 0);
1073 break;
1074 case Experiment::MULTI_VALUE:
1075 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
1076 break;
1077 default:
1078 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:191079 }
1080
[email protected]ad2a3ded2010-08-27 13:19:051081 experiments_data->Append(data);
1082 }
1083 return experiments_data;
1084}
1085
[email protected]ad2a3ded2010-08-27 13:19:051086bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:551087 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:051088}
1089
1090void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:351091 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:551092 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:071093}
1094
1095void RemoveFlagsSwitches(
1096 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:551097 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:071098}
1099
[email protected]a314ee5a2010-10-26 21:23:281100int GetCurrentPlatform() {
1101#if defined(OS_MACOSX)
1102 return kOsMac;
1103#elif defined(OS_WIN)
1104 return kOsWin;
1105#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
1106 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:211107#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:281108 return kOsLinux;
[email protected]9c7453d2012-01-21 00:45:401109#elif defined(OS_ANDROID)
1110 return kOsAndroid;
[email protected]a314ee5a2010-10-26 21:23:281111#else
1112#error Unknown platform
1113#endif
1114}
1115
[email protected]4bc5050c2010-11-18 17:55:541116void RecordUMAStatistics(const PrefService* prefs) {
1117 std::set<std::string> flags;
1118 GetEnabledFlags(prefs, &flags);
1119 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
1120 ++it) {
1121 std::string action("AboutFlags_");
1122 action += *it;
[email protected]7f6f44c2011-12-14 13:23:381123 content::RecordComputedAction(action);
[email protected]4bc5050c2010-11-18 17:55:541124 }
1125 // Since flag metrics are recorded every startup, add a tick so that the
1126 // stats can be made meaningful.
1127 if (flags.size())
[email protected]7f6f44c2011-12-14 13:23:381128 content::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
1129 content::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:541130}
1131
[email protected]e2ddbc92010-10-15 20:02:071132//////////////////////////////////////////////////////////////////////////////
1133// FlagsState implementation.
1134
1135namespace {
1136
1137void FlagsState::ConvertFlagsToSwitches(
1138 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:071139 if (command_line->HasSwitch(switches::kNoExperiments))
1140 return;
1141
1142 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:001143
[email protected]a314ee5a2010-10-26 21:23:281144 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:071145
[email protected]a82744532011-02-11 16:15:531146 typedef std::map<std::string, std::pair<std::string, std::string> >
1147 NameToSwitchAndValueMap;
1148 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:191149 for (size_t i = 0; i < num_experiments; ++i) {
1150 const Experiment& e = experiments[i];
1151 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:531152 name_to_switch_map[e.internal_name] =
1153 std::pair<std::string, std::string>(e.command_line_switch,
1154 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191155 } else {
1156 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:531157 name_to_switch_map[NameForChoice(e, j)] =
1158 std::pair<std::string, std::string>(
1159 e.choices[j].command_line_switch,
1160 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191161 }
1162 }
[email protected]e2ddbc92010-10-15 20:02:071163
1164 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:531165 flags_switches_.insert(
1166 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
1167 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071168 for (std::set<std::string>::iterator it = enabled_experiments.begin();
1169 it != enabled_experiments.end();
1170 ++it) {
1171 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:531172 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:191173 name_to_switch_map.find(experiment_name);
1174 if (name_to_switch_it == name_to_switch_map.end()) {
1175 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:071176 continue;
[email protected]8a6ff28d2010-12-02 16:35:191177 }
[email protected]e2ddbc92010-10-15 20:02:071178
[email protected]a82744532011-02-11 16:15:531179 const std::pair<std::string, std::string>&
1180 switch_and_value_pair = name_to_switch_it->second;
1181
1182 command_line->AppendSwitchASCII(switch_and_value_pair.first,
1183 switch_and_value_pair.second);
1184 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:071185 }
1186 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:531187 flags_switches_.insert(
1188 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
1189 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071190}
1191
1192bool FlagsState::IsRestartNeededToCommitChanges() {
1193 return needs_restart_;
1194}
1195
1196void FlagsState::SetExperimentEnabled(
1197 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:051198 needs_restart_ = true;
1199
[email protected]8a6ff28d2010-12-02 16:35:191200 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
1201 if (at_index != std::string::npos) {
1202 DCHECK(enable);
1203 // We're being asked to enable a multi-choice experiment. Disable the
1204 // currently selected choice.
1205 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:221206 const std::string experiment_name = internal_name.substr(0, at_index);
1207 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:191208
[email protected]28e35af2011-02-09 12:56:221209 // And enable the new choice, if it is not the default first choice.
1210 if (internal_name != experiment_name + "@0") {
1211 std::set<std::string> enabled_experiments;
1212 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
1213 enabled_experiments.insert(internal_name);
1214 SetEnabledFlags(prefs, enabled_experiments);
1215 }
[email protected]8a6ff28d2010-12-02 16:35:191216 return;
1217 }
1218
[email protected]ad2a3ded2010-08-27 13:19:051219 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241220 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051221
[email protected]8a6ff28d2010-12-02 16:35:191222 const Experiment* e = NULL;
1223 for (size_t i = 0; i < num_experiments; ++i) {
1224 if (experiments[i].internal_name == internal_name) {
1225 e = experiments + i;
1226 break;
1227 }
1228 }
1229 DCHECK(e);
1230
1231 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:591232 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:191233 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:591234 else
[email protected]8a6ff28d2010-12-02 16:35:191235 enabled_experiments.erase(internal_name);
1236 } else {
1237 if (enable) {
1238 // Enable the first choice.
1239 enabled_experiments.insert(NameForChoice(*e, 0));
1240 } else {
1241 // Find the currently enabled choice and disable it.
1242 for (int i = 0; i < e->num_choices; ++i) {
1243 std::string choice_name = NameForChoice(*e, i);
1244 if (enabled_experiments.find(choice_name) !=
1245 enabled_experiments.end()) {
1246 enabled_experiments.erase(choice_name);
1247 // Continue on just in case there's a bug and more than one
1248 // experiment for this choice was enabled.
1249 }
1250 }
1251 }
1252 }
[email protected]ad2a3ded2010-08-27 13:19:051253
[email protected]1a47d7e2010-10-15 00:37:241254 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051255}
1256
[email protected]e2ddbc92010-10-15 20:02:071257void FlagsState::RemoveFlagsSwitches(
1258 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:531259 for (std::map<std::string, std::string>::const_iterator
1260 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
1261 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:071262 }
1263}
1264
1265void FlagsState::reset() {
1266 needs_restart_ = false;
1267 flags_switches_.clear();
1268}
1269
[email protected]38e46812011-05-09 20:49:221270} // namespace
[email protected]e2ddbc92010-10-15 20:02:071271
1272namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:191273
1274// WARNING: '@' is also used in the html file. If you update this constant you
1275// also need to update the html file.
1276const char kMultiSeparator[] = "@";
1277
[email protected]e2ddbc92010-10-15 20:02:071278void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:551279 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:071280}
[email protected]a314ee5a2010-10-26 21:23:281281
1282void SetExperiments(const Experiment* e, size_t count) {
1283 if (!e) {
1284 experiments = kExperiments;
1285 num_experiments = arraysize(kExperiments);
1286 } else {
1287 experiments = e;
1288 num_experiments = count;
1289 }
1290}
1291
[email protected]8a6ff28d2010-12-02 16:35:191292const Experiment* GetExperiments(size_t* count) {
1293 *count = num_experiments;
1294 return experiments;
1295}
1296
[email protected]e2ddbc92010-10-15 20:02:071297} // namespace testing
1298
[email protected]1a47d7e2010-10-15 00:37:241299} // namespace about_flags