blob: fef0984c52acf4a7ac4de7992f01ab74f01a692f [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]e2e8e322012-09-12 04:37:0224#include "media/base/media_switches.h"
[email protected]0bc6c272012-07-17 03:32:0325#include "ui/app_list/app_list_switches.h"
[email protected]c051a1b2011-01-21 23:30:1726#include "ui/base/l10n/l10n_util.h"
[email protected]c9c73ad42012-04-18 03:35:5927#include "ui/base/ui_base_switches.h"
[email protected]c9e2cbbb2012-05-12 21:17:2728#include "ui/gl/gl_switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0529
[email protected]dc04be7c2012-03-15 23:57:4930#if defined(USE_ASH)
[email protected]b65bdda2011-12-23 23:35:3131#include "ash/ash_switches.h"
[email protected]dc04be7c2012-03-15 23:57:4932#endif
33
34#if defined(USE_AURA)
[email protected]308aaa32012-03-12 13:14:5035#include "ui/aura/aura_switches.h"
[email protected]8cc10df2011-11-03 23:57:5036#endif
37
[email protected]7f6f44c2011-12-14 13:23:3838using content::UserMetricsAction;
39
[email protected]1a47d7e2010-10-15 00:37:2440namespace about_flags {
[email protected]ad2a3ded2010-08-27 13:19:0541
[email protected]8a6ff28d2010-12-02 16:35:1942// Macros to simplify specifying the type.
[email protected]a82744532011-02-11 16:15:5343#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
44 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0
45#define SINGLE_VALUE_TYPE(command_line_switch) \
46 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
47#define MULTI_VALUE_TYPE(choices) \
[email protected]0e6f56d2011-02-12 23:45:1548 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices)
[email protected]8a6ff28d2010-12-02 16:35:1949
[email protected]e2ddbc92010-10-15 20:02:0750namespace {
51
[email protected]9c7453d2012-01-21 00:45:4052const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS | kOsAndroid;
[email protected]ad2a3ded2010-08-27 13:19:0553
[email protected]cc3e2052011-12-20 01:01:4054// Adds a |StringValue| to |list| for each platform where |bitmask| indicates
55// whether the experiment is available on that platform.
56void AddOsStrings(unsigned bitmask, ListValue* list) {
57 struct {
58 unsigned bit;
59 const char* const name;
60 } kBitsToOs[] = {
61 {kOsMac, "Mac"},
62 {kOsWin, "Windows"},
63 {kOsLinux, "Linux"},
64 {kOsCrOS, "Chrome OS"},
65 };
66 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i)
67 if (bitmask & kBitsToOs[i].bit)
68 list->Append(new StringValue(kBitsToOs[i].name));
69}
70
[email protected]ba8164242010-11-16 21:31:0071// Names for former Chrome OS Labs experiments, shared with prefs migration
72// code.
73const char kMediaPlayerExperimentName[] = "media-player";
74const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
75const char kVerticalTabsExperimentName[] = "vertical-tabs";
76
[email protected]68317802012-06-07 19:13:2377const Experiment::Choice kOmniboxHistoryQuickProviderNewScoringChoices[] = {
78 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_AUTOMATIC, "", "" },
79 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_ENABLED,
80 switches::kOmniboxHistoryQuickProviderNewScoring,
81 switches::kOmniboxHistoryQuickProviderNewScoringEnabled },
82 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DISABLED,
83 switches::kOmniboxHistoryQuickProviderNewScoring,
84 switches::kOmniboxHistoryQuickProviderNewScoringDisabled }
85};
86
[email protected]128dc6c2012-06-22 20:30:3587const Experiment::Choice
88 kOmniboxHistoryQuickProviderReorderForInliningChoices[] = {
89 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_AUTOMATIC,
90 "",
91 "" },
92 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_ENABLED,
93 switches::kOmniboxHistoryQuickProviderReorderForInlining,
94 switches::kOmniboxHistoryQuickProviderReorderForInliningEnabled },
95 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DISABLED,
96 switches::kOmniboxHistoryQuickProviderReorderForInlining,
97 switches::kOmniboxHistoryQuickProviderReorderForInliningDisabled }
98};
99
[email protected]032d5e6c2012-02-17 17:53:55100const Experiment::Choice kOmniboxInlineHistoryQuickProviderChoices[] = {
101 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_AUTOMATIC, "", "" },
102 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_ALLOWED,
103 switches::kOmniboxInlineHistoryQuickProvider,
104 switches::kOmniboxInlineHistoryQuickProviderAllowed },
105 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_PROHIBITED,
106 switches::kOmniboxInlineHistoryQuickProvider,
107 switches::kOmniboxInlineHistoryQuickProviderProhibited }
108};
109
[email protected]de023762012-07-26 17:10:17110const Experiment::Choice kFixedPositionCreatesStackingContextChoices[] = {
111 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
112 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
113 switches::kEnableFixedPositionCreatesStackingContext, ""},
114 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
115 switches::kDisableFixedPositionCreatesStackingContext, ""}
116};
117
[email protected]9b19cf82012-06-13 06:23:23118const Experiment::Choice kForceCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20119 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
120 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]9b19cf82012-06-13 06:23:23121 switches::kForceCompositingMode, ""},
[email protected]a45c69402012-06-24 16:32:20122 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]9b19cf82012-06-13 06:23:23123 switches::kDisableForceCompositingMode, ""}
124};
125
[email protected]72787e392012-03-23 05:55:43126const Experiment::Choice kThreadedCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20127 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
128 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]72787e392012-03-23 05:55:43129 switches::kDisableThreadedCompositing, ""},
[email protected]a45c69402012-06-24 16:32:20130 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]72787e392012-03-23 05:55:43131 switches::kEnableThreadedCompositing, ""}
132};
133
[email protected]347a0c72012-05-14 20:28:06134const Experiment::Choice kTouchOptimizedUIChoices[] = {
135 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_AUTOMATIC, "", "" },
[email protected]a45c69402012-06-24 16:32:20136 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]347a0c72012-05-14 20:28:06137 switches::kTouchOptimizedUI,
138 switches::kTouchOptimizedUIEnabled },
[email protected]a45c69402012-06-24 16:32:20139 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]347a0c72012-05-14 20:28:06140 switches::kTouchOptimizedUI,
141 switches::kTouchOptimizedUIDisabled }
142};
143
[email protected]026876f32012-08-22 23:53:40144const Experiment::Choice kAsyncDnsChoices[] = {
145 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
146 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
147 switches::kDisableAsyncDns, ""},
148 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
149 switches::kEnableAsyncDns, ""}
150};
151
[email protected]66f409c2012-10-04 20:59:04152const Experiment::Choice kNaClDebugMaskChoices[] = {
153 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
154 // Secure shell can be used on ChromeOS for forwarding the TCP port opened by
155 // debug stub to a remote machine. Since secure shell uses NaCl, we provide
156 // an option to switch off its debugging.
157 { IDS_NACL_DEBUG_MASK_CHOICE_EXCLUDE_UTILS,
158 switches::kNaClDebugMask, "!*://*/*ssh_client.nmf" },
159 { IDS_NACL_DEBUG_MASK_CHOICE_INCLUDE_DEBUG,
160 switches::kNaClDebugMask, "*://*/*debug.nmf" }
161};
162
[email protected]544471a2012-10-13 05:27:09163const Experiment::Choice kActionBoxChoices[] = {
164 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
165 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
166 switches::kActionBox, "0"},
167 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
168 switches::kActionBox, "1"}
169};
170
171const Experiment::Choice kScriptBubbleChoices[] = {
172 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
173 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
174 switches::kScriptBubble, "0"},
175 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
176 switches::kScriptBubble, "1"}
177};
178
[email protected]ea2f3342012-09-21 21:13:36179#if defined(OS_CHROMEOS)
180const Experiment::Choice kAshBootAnimationFunction[] = {
181 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
182 { IDS_FLAGS_ASH_BOOT_ANIMATION_FUNCTION2,
183 ash::switches::kAshBootAnimationFunction2, ""},
184 { IDS_FLAGS_ASH_BOOT_ANIMATION_FUNCTION3,
185 ash::switches::kAshBootAnimationFunction3, ""}
186};
187#endif
188
[email protected]347a0c72012-05-14 20:28:06189
[email protected]4bc5050c2010-11-18 17:55:54190// RECORDING USER METRICS FOR FLAGS:
191// -----------------------------------------------------------------------------
192// The first line of the experiment is the internal name. If you'd like to
193// gather statistics about the usage of your flag, you should append a marker
194// comment to the end of the feature name, like so:
195// "my-special-feature", // FLAGS:RECORD_UMA
196//
197// After doing that, run //chrome/tools/extract_actions.py (see instructions at
198// the top of that file for details) to update the chromeactions.txt file, which
199// will enable UMA to record your feature flag.
200//
201// After your feature has shipped under a flag, you can locate the metrics
202// under the action name AboutFlags_internal-action-name. Actions are recorded
203// once per startup, so you should divide this number by AboutFlags_StartupTick
204// to get a sense of usage. Note that this will not be the same as number of
205// users with a given feature enabled because users can quit and relaunch
206// the application multiple times over a given time interval.
207// TODO(rsesek): See if there's a way to count per-user, rather than
208// per-startup.
209
[email protected]8a6ff28d2010-12-02 16:35:19210// To add a new experiment add to the end of kExperiments. There are two
211// distinct types of experiments:
212// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
213// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:22214// . MULTI_VALUE: a list of choices, the first of which should correspond to a
215// deactivated state for this lab (i.e. no command line option). To specify
216// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
217// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:19218// See the documentation of Experiment for details on the fields.
219//
220// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:05221const Experiment kExperiments[] = {
222 {
[email protected]aac169d2011-03-18 19:53:03223 "expose-for-tabs", // FLAGS:RECORD_UMA
224 IDS_FLAGS_TABPOSE_NAME,
225 IDS_FLAGS_TABPOSE_DESCRIPTION,
226 kOsMac,
227#if defined(OS_MACOSX)
228 // The switch exists only on OS X.
229 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
230#else
231 SINGLE_VALUE_TYPE("")
232#endif
233 },
234 {
[email protected]4bc5050c2010-11-18 17:55:54235 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05236 IDS_FLAGS_CONFLICTS_CHECK_NAME,
237 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
238 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19239 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05240 },
241 {
[email protected]4bc5050c2010-11-18 17:55:54242 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]dae7325b2011-12-21 20:56:54243 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME,
244 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45245 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22246 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31247 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22248 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
249 // always have PDF rasterization available, so no flag needed there.
250#if !defined(GOOGLE_CHROME_BUILD)
251 kOsWin,
252#else
253 0,
[email protected]fa6d2a2f2010-11-30 21:47:19254#endif
[email protected]8a6ff28d2010-12-02 16:35:19255 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42256 },
[email protected]60d77bd2012-08-22 00:10:07257#if defined(OS_WIN)
258 {
259 "print-raster",
260 IDS_FLAGS_PRINT_RASTER_NAME,
261 IDS_FLAGS_PRINT_RASTER_DESCRIPTION,
262 kOsWin,
263 SINGLE_VALUE_TYPE(switches::kPrintRaster)
264 },
265#endif // OS_WIN
[email protected]0209b442012-07-18 00:38:05266 {
[email protected]bb461532010-11-26 21:50:23267 "crxless-web-apps",
268 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
269 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
270 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19271 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23272 },
273 {
[email protected]96c6f4c2011-05-18 19:36:22274 "ignore-gpu-blacklist",
275 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
276 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
277 kOsAll,
278 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
279 },
280 {
[email protected]0110cf112011-07-02 00:39:43281 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22282 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
283 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
[email protected]9b19cf82012-06-13 06:23:23284 kOsMac | kOsWin | kOsLinux,
285 MULTI_VALUE_TYPE(kForceCompositingModeChoices)
[email protected]96c6f4c2011-05-18 19:36:22286 },
287 {
[email protected]72787e392012-03-23 05:55:43288 "threaded-compositing-mode",
289 IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME,
290 IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59291 kOsAll,
[email protected]72787e392012-03-23 05:55:43292 MULTI_VALUE_TYPE(kThreadedCompositingModeChoices)
[email protected]644a1072012-03-16 09:29:59293 },
294 {
[email protected]81c64af62012-06-06 20:15:52295 "disable-accelerated-2d-canvas",
296 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_NAME,
297 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_DESCRIPTION,
298 kOsAll,
299 SINGLE_VALUE_TYPE(switches::kDisableAccelerated2dCanvas)
300 },
301 {
[email protected]69cffc82012-08-10 13:27:27302 "disable-deferred-2d-canvas",
303 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_NAME,
304 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_DESCRIPTION,
305 kOsAll,
306 SINGLE_VALUE_TYPE(switches::kDisableDeferred2dCanvas)
307 },
308 {
[email protected]efcde132012-05-30 01:05:18309 "disable-threaded-animation",
310 IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME,
311 IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59312 kOsAll,
[email protected]efcde132012-05-30 01:05:18313 SINGLE_VALUE_TYPE(switches::kDisableThreadedAnimation)
[email protected]644a1072012-03-16 09:29:59314 },
315 {
[email protected]5963b772011-02-09 22:55:38316 "composited-layer-borders",
317 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
318 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
319 kOsAll,
320 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
321 },
322 {
[email protected]a8f1eaa2011-03-07 19:00:58323 "show-fps-counter",
324 IDS_FLAGS_SHOW_FPS_COUNTER,
325 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
326 kOsAll,
327 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
328 },
[email protected]8ff7f342011-05-25 01:49:47329 {
[email protected]70c98a332011-12-21 20:51:52330 "accelerated-filters",
331 IDS_FLAGS_ACCELERATED_FILTERS,
332 IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION,
333 kOsAll,
334 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters)
335 },
336 {
[email protected]8ff7f342011-05-25 01:49:47337 "disable-gpu-vsync",
338 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
339 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
340 kOsAll,
341 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
342 },
[email protected]deaba6d52011-09-23 14:47:12343 {
344 "disable-webgl",
345 IDS_FLAGS_DISABLE_WEBGL_NAME,
346 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
347 kOsAll,
348 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
349 },
[email protected]09096e02012-05-24 11:12:04350 {
[email protected]96bcdc102012-05-24 23:42:10351 "fixed-position-creates-stacking-context",
352 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_NAME,
353 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_DESCRIPTION,
354 kOsAll,
[email protected]de023762012-07-26 17:10:17355 MULTI_VALUE_TYPE(kFixedPositionCreatesStackingContextChoices)
[email protected]96bcdc102012-05-24 23:42:10356 },
[email protected]a7640ef22012-10-06 00:52:08357 // TODO(bbudge): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53358 {
[email protected]e3791ce92011-08-09 01:03:32359 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40360 IDS_FLAGS_ENABLE_NACL_NAME,
361 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
362 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19363 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40364 },
[email protected]b39c6d92012-01-31 16:38:41365 // TODO(halyavin): When exception handling is on by default, replace this
366 // flag with disable-nacl-exception-handling.
367 {
368 "enable-nacl-exception-handling", // FLAGS:RECORD_UMA
369 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME,
370 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION,
[email protected]bf2c61b2012-08-30 16:37:04371 kOsAll,
[email protected]b39c6d92012-01-31 16:38:41372 SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling)
373 },
[email protected]4ff87d202010-11-06 01:28:40374 {
[email protected]9addd1c2012-09-15 14:28:24375 "enable-nacl-debug", // FLAGS:RECORD_UMA
376 IDS_FLAGS_ENABLE_NACL_DEBUG_NAME,
377 IDS_FLAGS_ENABLE_NACL_DEBUG_DESCRIPTION,
[email protected]401b90792012-05-30 11:41:13378 kOsAll,
[email protected]9addd1c2012-09-15 14:28:24379 SINGLE_VALUE_TYPE(switches::kEnableNaClDebug)
[email protected]401b90792012-05-30 11:41:13380 },
381 {
[email protected]66f409c2012-10-04 20:59:04382 "nacl-debug-mask", // FLAGS:RECORD_UMA
383 IDS_FLAGS_NACL_DEBUG_MASK_NAME,
384 IDS_FLAGS_NACL_DEBUG_MASK_DESCRIPTION,
385 kOsAll,
386 MULTI_VALUE_TYPE(kNaClDebugMaskChoices)
387 },
388 {
[email protected]7babd1c2012-08-08 20:35:29389 "enable-pnacl", // FLAGS:RECORD_UMA
390 IDS_FLAGS_ENABLE_PNACL_NAME,
391 IDS_FLAGS_ENABLE_PNACL_DESCRIPTION,
392 kOsAll,
393 SINGLE_VALUE_TYPE(switches::kEnablePnacl)
394 },
[email protected]a7640ef22012-10-06 00:52:08395 // TODO(bbudge): When NaCl switches to the IPC-based proxy, remove this
396 // flag entry.
397 {
398 "enable-nacl-ipc-proxy", // FLAGS:RECORD_UMA
399 IDS_FLAGS_ENABLE_NACL_IPC_PROXY_NAME,
400 IDS_FLAGS_ENABLE_NACL_IPC_PROXY_DESCRIPTION,
401 kOsAll,
402 SINGLE_VALUE_TYPE(switches::kEnableNaClIPCProxy)
403 },
[email protected]7babd1c2012-08-08 20:35:29404 {
[email protected]d3a8cfc2012-09-14 18:31:38405 "enable-scripted-speech", // FLAGS:RECORD_UMA
406 IDS_FLAGS_ENABLE_SCRIPTED_SPEECH_NAME,
407 IDS_FLAGS_ENABLE_SCRIPTED_SPEECH_DESCRIPTION,
408 kOsAll,
409 SINGLE_VALUE_TYPE(switches::kEnableScriptedSpeech)
410 },
411 {
[email protected]4bc5050c2010-11-18 17:55:54412 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32413 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
414 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
415 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19416 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32417 },
[email protected]3627b06d2010-11-12 16:36:16418 {
[email protected]544471a2012-10-13 05:27:09419 "action-box",
[email protected]cab18ef2012-04-27 07:22:03420 IDS_FLAGS_ACTION_BOX_NAME,
421 IDS_FLAGS_ACTION_BOX_DESCRIPTION,
422 kOsAll,
[email protected]544471a2012-10-13 05:27:09423 MULTI_VALUE_TYPE(kActionBoxChoices),
[email protected]cab18ef2012-04-27 07:22:03424 },
425 {
[email protected]3a362432012-06-18 20:39:51426 "script-badges",
427 IDS_FLAGS_SCRIPT_BADGES_NAME,
428 IDS_FLAGS_SCRIPT_BADGES_DESCRIPTION,
429 kOsAll,
[email protected]544471a2012-10-13 05:27:09430 SINGLE_VALUE_TYPE(switches::kScriptBadges)
431 },
432 {
433 "script-bubble",
434 IDS_FLAGS_SCRIPT_BUBBLE_NAME,
435 IDS_FLAGS_SCRIPT_BUBBLE_DESCRIPTION,
436 kOsAll,
437 MULTI_VALUE_TYPE(kScriptBubbleChoices),
[email protected]3a362432012-06-18 20:39:51438 },
439 {
[email protected]cbe224d2011-08-04 22:12:49440 "apps-new-install-bubble",
441 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
442 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
443 kOsAll,
444 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
445 },
446 {
[email protected]80bd24e2010-11-30 09:34:38447 "disable-hyperlink-auditing",
448 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
449 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
450 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19451 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51452 },
453 {
454 "experimental-location-features", // FLAGS:RECORD_UMA
455 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
456 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
457 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19458 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
459 },
460 {
[email protected]5aea1862011-03-23 23:55:39461 "tab-groups-context-menu",
462 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
463 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
464 kOsWin,
465 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
466 },
[email protected]c94cebd2012-06-21 00:55:28467#if defined(OS_CHROMEOS)
468 {
469 "enable-instant-extended-api",
470 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API,
471 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API_DESCRIPTION,
472 kOsAll,
473 SINGLE_VALUE_TYPE(switches::kEnableInstantExtendedAPI)
474 },
475#endif
[email protected]e9bf9d92011-03-31 20:57:15476 {
[email protected]354e33b2011-06-15 00:29:10477 "static-ip-config",
478 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
479 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
480 kOsCrOS,
481#if defined(OS_CHROMEOS)
482 // This switch exists only on Chrome OS.
483 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
484#else
485 SINGLE_VALUE_TYPE("")
486#endif
487 },
[email protected]3eb5728c2011-06-20 22:32:24488 {
489 "show-autofill-type-predictions",
490 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
491 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
492 kOsAll,
493 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
494 },
[email protected]bff4d3e2011-06-21 23:58:52495 {
[email protected]fdf4e252012-04-27 00:26:55496 "sync-tab-favicons",
497 IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
498 IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
499 kOsAll,
500 SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
501 },
502 {
[email protected]aae9eeb12011-10-21 21:59:26503 "sync-app-notifications",
504 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
505 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
506 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11507 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26508 },
509 {
[email protected]e755a382012-09-13 17:16:35510 "enable-gesture-tap-highlight",
511 IDS_FLAGS_ENABLE_GESTURE_TAP_HIGHLIGHTING_NAME,
512 IDS_FLAGS_ENABLE_GESTURE_TAP_HIGHLIGHTING_DESCRIPTION,
513 kOsLinux | kOsCrOS,
514 SINGLE_VALUE_TYPE(switches::kEnableGestureTapHighlight)
515 },
516 {
[email protected]a22ebd812011-06-23 00:05:39517 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
518 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
519 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
520 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40521 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40522 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39523 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
524 },
[email protected]81a6b0b2011-06-24 17:55:40525 {
[email protected]68317802012-06-07 19:13:23526 "omnibox-history-quick-provider-new-scoring",
527 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_NAME,
528 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DESCRIPTION,
529 kOsAll,
530 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderNewScoringChoices)
531 },
532 {
[email protected]128dc6c2012-06-22 20:30:35533 "omnibox-history-quick-provider-reorder-for-inlining",
534 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_NAME,
535 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DESCRIPTION,
536 kOsAll,
537 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderReorderForInliningChoices)
538 },
539 {
[email protected]032d5e6c2012-02-17 17:53:55540 "omnibox-inline-history-quick-provider",
541 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME,
542 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION,
543 kOsAll,
544 MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices)
545 },
546 {
[email protected]7e7a28092011-12-09 22:24:55547 "enable-panels",
548 IDS_FLAGS_ENABLE_PANELS_NAME,
549 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54550 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55551 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54552 },
[email protected]e3749d12011-07-25 22:22:12553 {
[email protected]27c14f02012-06-22 17:29:58554 // See http://crbug.com/120416 for how to remove this flag.
[email protected]6474b112012-05-04 19:35:27555 "save-page-as-mhtml", // FLAGS:RECORD_UMA
556 IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME,
557 IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION,
558 kOsMac | kOsWin | kOsLinux,
559 SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)
560 },
561 {
[email protected]b7bb44f2011-09-01 05:17:03562 "enable-autologin",
563 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
564 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
565 kOsMac | kOsWin | kOsLinux,
566 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
567 },
[email protected]b9841172011-09-26 23:36:09568 {
[email protected]bbadb112011-12-12 16:55:28569 "enable-http-pipelining",
570 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
571 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
572 kOsAll,
573 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
574 },
[email protected]d411c01d2011-10-18 16:00:27575 {
[email protected]3231b612012-03-23 05:57:54576 "enable-spdy3",
577 IDS_FLAGS_ENABLE_SPDY3_NAME,
578 IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION,
579 kOsAll,
580 SINGLE_VALUE_TYPE(switches::kEnableSpdy3)
581 },
582 {
[email protected]27b3fe92012-03-21 05:35:06583 "enable-async-dns",
584 IDS_FLAGS_ENABLE_ASYNC_DNS_NAME,
585 IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION,
[email protected]85594c142012-09-11 18:02:46586 kOsWin | kOsMac | kOsLinux | kOsCrOS,
[email protected]026876f32012-08-22 23:53:40587 MULTI_VALUE_TYPE(kAsyncDnsChoices)
[email protected]27b3fe92012-03-21 05:35:06588 },
589 {
[email protected]1eb93802012-09-11 18:57:56590 "disable-media-source",
[email protected]da43c082012-09-07 18:56:11591 IDS_FLAGS_DISABLE_MEDIA_SOURCE_NAME,
592 IDS_FLAGS_DISABLE_MEDIA_SOURCE_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32593 kOsAll,
[email protected]da43c082012-09-07 18:56:11594 SINGLE_VALUE_TYPE(switches::kDisableMediaSource)
[email protected]6aa03b32011-10-27 21:44:44595 },
[email protected]e4e68dbb2011-11-18 01:50:22596 {
[email protected]9f5b7822012-04-18 23:39:03597 "enable-encrypted-media",
598 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME,
599 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION,
600 kOsAll,
601 SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia)
602 },
[email protected]dc04be7c2012-03-15 23:57:49603#if defined(USE_ASH)
[email protected]8cc10df2011-11-03 23:57:50604 {
[email protected]57b8bb352012-01-11 05:11:46605 "aura-google-dialog-frames",
606 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME,
607 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION,
608 kOsWin | kOsLinux | kOsCrOS,
609 SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames)
610 },
[email protected]dc04be7c2012-03-15 23:57:49611#endif
[email protected]eaae8b462012-01-20 22:20:39612 {
[email protected]db543d322011-12-15 20:40:15613 "per-tile-painting",
614 IDS_FLAGS_PER_TILE_PAINTING_NAME,
615 IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION,
616#if defined(USE_SKIA)
[email protected]a5b1b272012-01-06 20:44:37617 kOsMac | kOsLinux | kOsCrOS,
[email protected]db543d322011-12-15 20:40:15618#else
619 0,
620#endif
621 SINGLE_VALUE_TYPE(switches::kEnablePerTilePainting)
622 },
[email protected]bf88c032011-12-22 19:05:47623 {
624 "enable-javascript-harmony",
625 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME,
626 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION,
627 kOsAll,
628 SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony")
629 },
[email protected]7e7f378a2012-01-05 14:35:37630 {
[email protected]85646172012-01-09 22:45:54631 "enable-tab-browser-dragging",
632 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME,
633 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION,
634 kOsWin,
635 SINGLE_VALUE_TYPE(switches::kTabBrowserDragging)
636 },
637 {
[email protected]068b7b52012-02-27 12:41:44638 "disable-restore-session-state",
639 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME,
640 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION,
[email protected]7e7f378a2012-01-05 14:35:37641 kOsAll,
[email protected]068b7b52012-02-27 12:41:44642 SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState)
[email protected]7e7f378a2012-01-05 14:35:37643 },
[email protected]88864db2012-01-18 20:56:35644 {
645 "disable-software-rasterizer",
646 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME,
647 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION,
648#if defined(ENABLE_SWIFTSHADER)
649 kOsAll,
650#else
651 0,
652#endif
653 SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer)
654 },
[email protected]15a5d722012-01-23 09:11:14655 {
[email protected]ff7b6dd2012-09-15 20:20:03656 "enable-experimental-webkit-features",
657 IDS_FLAGS_EXPERIMENTAL_WEBKIT_FEATURES_NAME,
658 IDS_FLAGS_EXPERIMENTAL_WEBKIT_FEATURES_DESCRIPTION,
[email protected]d2edc6702012-01-30 09:13:16659 kOsAll,
[email protected]ff7b6dd2012-09-15 20:20:03660 SINGLE_VALUE_TYPE(switches::kEnableExperimentalWebKitFeatures)
[email protected]ca7a3d792012-03-02 15:55:49661 },
662 {
[email protected]0f95a252012-09-13 22:30:04663 "enable-css-shaders",
664 IDS_FLAGS_CSS_SHADERS_NAME,
665 IDS_FLAGS_CSS_SHADERS_DESCRIPTION,
666 kOsAll,
667 SINGLE_VALUE_TYPE(switches::kEnableCssShaders)
668 },
669 {
[email protected]9860c68b2012-02-02 01:58:09670 "enable-extension-activity-ui",
671 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME,
672 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION,
673 kOsAll,
674 SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI)
[email protected]8bed69d2012-02-02 06:46:00675 },
[email protected]54ae4e92012-02-16 15:19:05676 {
[email protected]3e8befc2012-03-13 01:17:03677 "disable-ntp-other-sessions-menu",
[email protected]156f966332012-02-29 00:03:16678 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME,
679 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION,
680 kOsAll,
[email protected]3e8befc2012-03-13 01:17:03681 SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu)
[email protected]156f966332012-02-29 00:03:16682 },
[email protected]dc04be7c2012-03-15 23:57:49683#if defined(USE_ASH)
[email protected]31cf1c52012-02-29 20:55:01684 {
[email protected]3cd198a22012-03-12 20:38:01685 "enable-ash-oak",
686 IDS_FLAGS_ENABLE_ASH_OAK_NAME,
687 IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION,
688 kOsAll,
689 SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak),
690 },
[email protected]31cf1c52012-02-29 20:55:01691#endif
[email protected]184ec592012-03-01 11:54:28692 {
693 "enable-devtools-experiments",
694 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME,
695 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION,
696 kOsAll,
697 SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments)
698 },
[email protected]76d1854e2012-03-02 23:57:44699 {
700 "enable-suggestions-ntp",
701 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME,
702 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION,
703 kOsAll,
704 SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage)
705 },
[email protected]8e466dd2012-05-04 19:16:05706#if defined(GOOGLE_CHROME_BUILD)
[email protected]a3d54252012-04-05 20:04:13707 {
[email protected]37b928e2012-05-30 09:01:10708 "disable-asynchronous-spellchecking",
709 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING,
710 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING_DESCRIPTION,
711 kOsWin | kOsLinux | kOsCrOS,
712 SINGLE_VALUE_TYPE(switches::kDisableAsynchronousSpellChecking)
[email protected]a3d54252012-04-05 20:04:13713 },
[email protected]8e466dd2012-05-04 19:16:05714#endif
[email protected]c9c73ad42012-04-18 03:35:59715 {
716 "touch-optimized-ui",
[email protected]347a0c72012-05-14 20:28:06717 IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME,
718 IDS_FLAGS_TOUCH_OPTIMIZED_UI_DESCRIPTION,
[email protected]c71fe6402012-08-15 15:22:55719 kOsWin,
[email protected]347a0c72012-05-14 20:28:06720 MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
[email protected]c9c73ad42012-04-18 03:35:59721 },
[email protected]8a6aaa72012-04-20 20:53:58722 {
[email protected]f6f82832012-09-04 17:12:04723 "enable-webkit-text-subpixel-positioning",
724 IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_NAME,
725 IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_DESCRIPTION,
726 kOsCrOS,
727 SINGLE_VALUE_TYPE(switches::kEnableWebkitTextSubpixelPositioning)
728 },
729 {
[email protected]8a6aaa72012-04-20 20:53:58730 "enable-touch-events",
731 IDS_ENABLE_TOUCH_EVENTS_NAME,
732 IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
[email protected]223a31e42012-10-04 01:12:18733 kOsWin | kOsMac | kOsLinux,
[email protected]8a6aaa72012-04-20 20:53:58734 SINGLE_VALUE_TYPE(switches::kEnableTouchEvents)
735 },
[email protected]0b60afa2012-04-19 17:36:39736#if defined(OS_CHROMEOS)
737 {
[email protected]7c4a9bc2012-09-11 22:10:05738 "enable-background-loader",
739 IDS_ENABLE_BACKLOADER_NAME,
740 IDS_ENABLE_BACKLOADER_DESCRIPTION,
741 kOsCrOS,
742 SINGLE_VALUE_TYPE(switches::kEnableBackgroundLoader)
743 },
744 {
[email protected]c5667b282012-08-31 00:32:50745 "enable-bezel-touch",
746 IDS_ENABLE_BEZEL_TOUCH_NAME,
747 IDS_ENABLE_BEZEL_TOUCH_DESCRIPTION,
[email protected]1995d80d2012-08-23 02:58:47748 kOsCrOS,
[email protected]c5667b282012-08-31 00:32:50749 SINGLE_VALUE_TYPE(switches::kEnableBezelTouch)
[email protected]1995d80d2012-08-23 02:58:47750 },
751 {
[email protected]0b60afa2012-04-19 17:36:39752 "no-discard-tabs",
753 IDS_FLAGS_NO_DISCARD_TABS_NAME,
754 IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION,
755 kOsCrOS,
756 SINGLE_VALUE_TYPE(switches::kNoDiscardTabs)
757 },
758#endif
[email protected]79be6d32012-04-24 20:47:44759 {
[email protected]9a5940d2012-04-27 19:16:23760 "allow-nacl-socket-api",
761 IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME,
762 IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION,
763 kOsAll,
764 SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*")
765 },
[email protected]85333732012-05-01 19:02:24766 {
[email protected]60673ad72012-05-02 06:16:33767 "stacked-tab-strip",
768 IDS_FLAGS_STACKED_TAB_STRIP_NAME,
769 IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION,
770 kOsWin,
771 SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip)
772 },
773 {
[email protected]4bd20202012-06-14 17:35:01774 "force-device-scale-factor",
[email protected]85333732012-05-01 19:02:24775 IDS_FLAGS_FORCE_HIGH_DPI_NAME,
776 IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION,
777 kOsCrOS,
[email protected]4bd20202012-06-14 17:35:01778 SINGLE_VALUE_TYPE_AND_VALUE(switches::kForceDeviceScaleFactor, "2")
[email protected]85333732012-05-01 19:02:24779 },
[email protected]190349fd2012-05-02 00:10:47780#if defined(OS_CHROMEOS)
781 {
782 "allow-touchpad-three-finger-click",
783 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME,
784 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION,
785 kOsCrOS,
786 SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick)
787 },
788#endif
[email protected]53520b1b2012-05-07 21:43:37789#if defined(USE_ASH)
790 {
[email protected]55444502012-05-10 15:43:53791 "show-launcher-alignment-menu",
792 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_NAME,
793 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION,
794 kOsAll,
795 SINGLE_VALUE_TYPE(switches::kShowLauncherAlignmentMenu)
796 },
[email protected]817ecd12012-05-16 18:36:53797 {
[email protected]73074742012-05-17 01:44:41798 "show-touch-hud",
799 IDS_FLAGS_SHOW_TOUCH_HUD_NAME,
800 IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION,
801 kOsAll,
802 SINGLE_VALUE_TYPE(ash::switches::kAshTouchHud)
803 },
804 {
[email protected]9f0940b62012-05-23 22:56:35805 "enable-pinch",
806 IDS_FLAGS_ENABLE_PINCH_SCALE_NAME,
807 IDS_FLAGS_ENABLE_PINCH_SCALE_DESCRIPTION,
808 kOsAll,
809 SINGLE_VALUE_TYPE(switches::kEnablePinch),
810 },
[email protected]a8379312012-06-15 00:20:43811 {
812 "app-list-show-apps-only",
813 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_NAME,
814 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_DESCRIPTION,
815 kOsAll,
[email protected]0bc6c272012-07-17 03:32:03816 SINGLE_VALUE_TYPE(app_list::switches::kAppListShowAppsOnly),
[email protected]a8379312012-06-15 00:20:43817 },
[email protected]73074742012-05-17 01:44:41818#endif // defined(USE_ASH)
[email protected]ed7b67f32012-05-28 10:12:28819#if defined(OS_CHROMEOS)
820 {
[email protected]5064c562012-09-05 18:15:27821 "disable-new-wallpaper-picker-ui",
822 IDS_FLAGS_DISABLE_NEW_WALLPAPER_UI_NAME,
823 IDS_FLAGS_DISABLE_NEW_WALLPAPER_UI_DESCRIPTION,
[email protected]a7668a12012-05-28 22:23:48824 kOsCrOS,
[email protected]5064c562012-09-05 18:15:27825 SINGLE_VALUE_TYPE(switches::kDisableNewWallpaperUI)
[email protected]a7668a12012-05-28 22:23:48826 },
827 {
[email protected]89ef50172012-07-24 21:58:38828 "disable-html5-camera",
829 IDS_FLAGS_DISABLE_HTML5_CAMERA,
830 IDS_FLAGS_DISABLE_HTML5_CAMERA_DESCRIPTION,
[email protected]ffc6f7b12012-07-04 09:11:33831 kOsCrOS,
[email protected]89ef50172012-07-24 21:58:38832 SINGLE_VALUE_TYPE(switches::kDisableHtml5Camera),
[email protected]ffc6f7b12012-07-04 09:11:33833 },
834 {
[email protected]e03dc78d2012-07-24 08:21:43835 "disable-new-oobe",
836 IDS_FLAGS_DISABLE_NEW_OOBE,
837 IDS_FLAGS_DISABLE_NEW_OOBE_DESCRIPTION,
[email protected]ed7b67f32012-05-28 10:12:28838 kOsCrOS,
[email protected]e03dc78d2012-07-24 08:21:43839 SINGLE_VALUE_TYPE(switches::kDisableNewOobe),
[email protected]ed7b67f32012-05-28 10:12:28840 },
[email protected]8b04a1652012-08-04 02:59:49841 {
[email protected]f59324d2012-09-17 19:41:47842 "disable-factory-reset",
843 IDS_FLAGS_DISABLE_FACTORY_RESET,
844 IDS_FLAGS_DISABLE_FACTORY_RESET_DESCRIPTION,
845 kOsCrOS,
846 SINGLE_VALUE_TYPE(switches::kDisableFactoryReset),
847 },
848 {
[email protected]8b04a1652012-08-04 02:59:49849 "disable-boot-animation",
850 IDS_FLAGS_DISABLE_BOOT_ANIMATION,
851 IDS_FLAGS_DISABLE_BOOT_ANIMATION_DESCRIPTION,
852 kOsCrOS,
853 SINGLE_VALUE_TYPE(switches::kDisableBootAnimation),
854 },
[email protected]95058572012-08-20 14:57:29855 {
[email protected]b4557192012-09-19 11:29:58856 "disable-boot-animation2",
857 IDS_FLAGS_DISABLE_BOOT_ANIMATION2,
858 IDS_FLAGS_DISABLE_BOOT_ANIMATION2_DESCRIPTION,
859 kOsCrOS,
860 SINGLE_VALUE_TYPE(ash::switches::kAshDisableBootAnimation2),
861 },
862 {
[email protected]ea2f3342012-09-21 21:13:36863 "boot-animation-fucntion",
864 IDS_FLAGS_ASH_BOOT_ANIMATION_FUNCTION,
865 IDS_FLAGS_ASH_BOOT_ANIMATION_FUNCTION_DESCRIPTION,
866 kOsCrOS,
867 MULTI_VALUE_TYPE(kAshBootAnimationFunction),
868 },
[email protected]ed7b67f32012-05-28 10:12:28869#endif
[email protected]fc7a93c2012-06-08 20:25:39870 {
871 "enable-views-textfield",
872 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_NAME,
873 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_DESCRIPTION,
874 kOsWin,
875 SINGLE_VALUE_TYPE(switches::kEnableViewsTextfield),
876 },
[email protected]bd0cd3bb2012-06-14 03:03:38877 {
[email protected]ef41b7ee2012-07-24 19:10:41878 "old-checkbox-style",
879 IDS_FLAGS_OLD_CHECKBOX_STYLE,
880 IDS_FLAGS_OLD_CHECKBOX_STYLE_DESCRIPTION,
881 kOsLinux | kOsCrOS,
882 SINGLE_VALUE_TYPE(switches::kOldCheckboxStyle),
883 },
884 {
[email protected]fcb88de2012-07-12 22:25:32885 "enable-frameless-constrained-dialogs",
886 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_NAME,
887 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_DESCRIPTION,
888 kOsWin | kOsCrOS,
889 SINGLE_VALUE_TYPE(switches::kEnableFramelessConstrainedDialogs),
890 },
[email protected]7db8893a2012-07-26 00:49:40891 { "disable-accelerated-video-decode",
892 IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_NAME,
893 IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
[email protected]66dcb0492012-06-18 22:32:15894 kOsAll,
[email protected]7db8893a2012-07-26 00:49:40895 SINGLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
[email protected]66dcb0492012-06-18 22:32:15896 },
[email protected]66ae9fc2012-06-19 21:33:52897#if defined(USE_ASH)
898 {
899 "ash-debug-shortcuts",
900 IDS_FLAGS_DEBUG_SHORTCUTS_NAME,
901 IDS_FLAGS_DEBUG_SHORTCUTS_DESCRIPTION,
902 kOsAll,
903 SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts),
904 },
905#endif
[email protected]37fee0942012-08-07 21:07:45906 {
[email protected]9a8e9352012-08-24 00:45:17907 "disable-website-settings", // FLAGS:RECORD_UMA
908 IDS_FLAGS_DISABLE_WEBSITE_SETTINGS_NAME,
909 IDS_FLAGS_DISABLE_WEBSITE_SETTINGS_DESCRIPTION,
[email protected]37fee0942012-08-07 21:07:45910 kOsAll,
[email protected]9a8e9352012-08-24 00:45:17911 SINGLE_VALUE_TYPE(switches::kDisableWebsiteSettings),
[email protected]37fee0942012-08-07 21:07:45912 },
[email protected]ad3f6d22012-08-29 02:34:19913 {
[email protected]e2e8e322012-09-12 04:37:02914 "enable-webaudio-input",
915 IDS_FLAGS_ENABLE_WEBAUDIO_INPUT_NAME,
916 IDS_FLAGS_ENABLE_WEBAUDIO_INPUT_DESCRIPTION,
917 kOsAll,
918 SINGLE_VALUE_TYPE(switches::kEnableWebAudioInput),
919 },
920 {
[email protected]ad3f6d22012-08-29 02:34:19921 "enable-contacts",
922 IDS_FLAGS_ENABLE_CONTACTS_NAME,
923 IDS_FLAGS_ENABLE_CONTACTS_DESCRIPTION,
924 kOsCrOS,
925 SINGLE_VALUE_TYPE(switches::kEnableContacts)
926 },
[email protected]1d9bb9cd2012-08-28 22:02:50927#if defined(USE_ASH)
928 { "ash-enable-advanced-gestures",
929 IDS_FLAGS_ENABLE_ADVANCED_GESTURES_NAME,
930 IDS_FLAGS_ENABLE_ADVANCED_GESTURES_DESCRIPTION,
931 kOsCrOS,
932 SINGLE_VALUE_TYPE(ash::switches::kAshEnableAdvancedGestures),
933 },
934#endif
[email protected]9b7ab882012-09-10 23:46:36935#if defined(OS_CHROMEOS)
936 {
[email protected]205f07892012-10-16 20:26:22937 "enable-carrier-switching",
938 IDS_FLAGS_ENABLE_CARRIER_SWITCHING,
939 IDS_FLAGS_ENABLE_CARRIER_SWITCHING_DESCRIPTION,
940 kOsCrOS,
941 SINGLE_VALUE_TYPE(switches::kEnableCarrierSwitching)
942 },
943 {
[email protected]9b7ab882012-09-10 23:46:36944 "enable-request-tablet-site",
945 IDS_FLAGS_ENABLE_REQUEST_TABLET_SITE_NAME,
946 IDS_FLAGS_ENABLE_REQUEST_TABLET_SITE_DESCRIPTION,
947 kOsCrOS,
948 SINGLE_VALUE_TYPE(switches::kEnableRequestTabletSite)
949 },
950#endif
[email protected]dab49c0b2012-10-04 05:55:35951 {
952 "debug-packed-apps",
953 IDS_FLAGS_DEBUG_PACKED_APP_NAME,
954 IDS_FLAGS_DEBUG_PACKED_APP_DESCRIPTION,
955 kOsAll,
956 SINGLE_VALUE_TYPE(switches::kDebugPackedApps)
957 },
[email protected]d1459ed2012-10-10 01:29:33958 {
959 "enable-password-generation",
960 IDS_FLAGS_ENABLE_PASSWORD_GENERATION_NAME,
961 IDS_FLAGS_ENABLE_PASSWORD_GENERATION_DESCRIPTION,
962 kOsWin | kOsLinux | kOsCrOS,
963 SINGLE_VALUE_TYPE(switches::kEnablePasswordGeneration)
964 },
[email protected]26d045f2012-10-18 21:18:43965 {
966 "crash-on-gpu-hang",
967 IDS_FLAGS_CRASH_ON_GPU_HANG_NAME,
968 IDS_FLAGS_CRASH_ON_GPU_HANG_DESCRIPTION,
969 kOsAll,
970 SINGLE_VALUE_TYPE(switches::kCrashOnGpuHang)
971 },
[email protected]a0e4b072011-08-17 01:47:07972};
[email protected]ad2a3ded2010-08-27 13:19:05973
[email protected]a314ee5a2010-10-26 21:23:28974const Experiment* experiments = kExperiments;
975size_t num_experiments = arraysize(kExperiments);
976
[email protected]e2ddbc92010-10-15 20:02:07977// Stores and encapsulates the little state that about:flags has.
978class FlagsState {
979 public:
980 FlagsState() : needs_restart_(false) {}
981 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
982 bool IsRestartNeededToCommitChanges();
983 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28984 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07985 void RemoveFlagsSwitches(
986 std::map<std::string, CommandLine::StringType>* switch_list);
987 void reset();
988
989 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55990 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07991 return Singleton<FlagsState>::get();
992 }
993
994 private:
995 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53996 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07997
998 DISALLOW_COPY_AND_ASSIGN(FlagsState);
999};
1000
[email protected]c7b7800a2010-10-07 18:51:351001// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:051002// in a set.
[email protected]1a47d7e2010-10-15 00:37:241003void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:051004 const ListValue* enabled_experiments = prefs->GetList(
1005 prefs::kEnabledLabsExperiments);
1006 if (!enabled_experiments)
1007 return;
1008
1009 for (ListValue::const_iterator it = enabled_experiments->begin();
1010 it != enabled_experiments->end();
1011 ++it) {
1012 std::string experiment_name;
1013 if (!(*it)->GetAsString(&experiment_name)) {
1014 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
1015 continue;
1016 }
1017 result->insert(experiment_name);
1018 }
1019}
1020
1021// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:241022void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:051023 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:381024 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
1025 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:051026
1027 experiments_list->Clear();
1028 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
1029 it != enabled_experiments.end();
1030 ++it) {
1031 experiments_list->Append(new StringValue(*it));
1032 }
1033}
1034
[email protected]8a6ff28d2010-12-02 16:35:191035// Returns the name used in prefs for the choice at the specified index.
1036std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:341037 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
1038 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:191039 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
1040 base::IntToString(index);
1041}
1042
1043// Adds the internal names for the specified experiment to |names|.
1044void AddInternalName(const Experiment& e, std::set<std::string>* names) {
1045 if (e.type == Experiment::SINGLE_VALUE) {
1046 names->insert(e.internal_name);
1047 } else {
[email protected]2ce9c89752011-02-25 18:24:341048 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:191049 for (int i = 0; i < e.num_choices; ++i)
1050 names->insert(NameForChoice(e, i));
1051 }
1052}
1053
[email protected]28e35af2011-02-09 12:56:221054// Confirms that an experiment is valid, used in a DCHECK in
1055// SanitizeList below.
1056bool ValidateExperiment(const Experiment& e) {
1057 switch (e.type) {
1058 case Experiment::SINGLE_VALUE:
1059 DCHECK_EQ(0, e.num_choices);
1060 DCHECK(!e.choices);
1061 break;
1062 case Experiment::MULTI_VALUE:
1063 DCHECK_GT(e.num_choices, 0);
1064 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:531065 DCHECK(e.choices[0].command_line_switch);
1066 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:221067 break;
1068 default:
1069 NOTREACHED();
1070 }
1071 return true;
1072}
1073
[email protected]ad2a3ded2010-08-27 13:19:051074// Removes all experiments from prefs::kEnabledLabsExperiments that are
1075// unknown, to prevent this list to become very long as experiments are added
1076// and removed.
1077void SanitizeList(PrefService* prefs) {
1078 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:221079 for (size_t i = 0; i < num_experiments; ++i) {
1080 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:191081 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:221082 }
[email protected]ad2a3ded2010-08-27 13:19:051083
1084 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241085 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051086
1087 std::set<std::string> new_enabled_experiments;
1088 std::set_intersection(
1089 known_experiments.begin(), known_experiments.end(),
1090 enabled_experiments.begin(), enabled_experiments.end(),
1091 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1092
[email protected]4c8853f2012-07-23 01:29:161093 if (new_enabled_experiments != enabled_experiments)
1094 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051095}
1096
[email protected]1a47d7e2010-10-15 00:37:241097void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:051098 PrefService* prefs, std::set<std::string>* result) {
1099 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:241100 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:051101}
1102
[email protected]a314ee5a2010-10-26 21:23:281103// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
1104// enabled on the current platform.
1105void GetSanitizedEnabledFlagsForCurrentPlatform(
1106 PrefService* prefs, std::set<std::string>* result) {
1107 GetSanitizedEnabledFlags(prefs, result);
1108
1109 // Filter out any experiments that aren't enabled on the current platform. We
1110 // don't remove these from prefs else syncing to a platform with a different
1111 // set of experiments would be lossy.
1112 std::set<std::string> platform_experiments;
1113 int current_platform = GetCurrentPlatform();
1114 for (size_t i = 0; i < num_experiments; ++i) {
1115 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:191116 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:281117 }
1118
1119 std::set<std::string> new_enabled_experiments;
1120 std::set_intersection(
1121 platform_experiments.begin(), platform_experiments.end(),
1122 result->begin(), result->end(),
1123 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1124
1125 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051126}
1127
[email protected]8a6ff28d2010-12-02 16:35:191128// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:191129Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:221130 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:341131 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:191132 ListValue* result = new ListValue;
1133 for (int i = 0; i < experiment.num_choices; ++i) {
1134 const Experiment::Choice& choice = experiment.choices[i];
1135 DictionaryValue* value = new DictionaryValue;
1136 std::string name = NameForChoice(experiment, i);
1137 value->SetString("description",
1138 l10n_util::GetStringUTF16(choice.description_id));
1139 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:221140 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:191141 result->Append(value);
1142 }
1143 return result;
1144}
1145
[email protected]e2ddbc92010-10-15 20:02:071146} // namespace
1147
[email protected]1a47d7e2010-10-15 00:37:241148void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:551149 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:051150}
1151
[email protected]1a47d7e2010-10-15 00:37:241152ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:051153 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241154 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051155
1156 int current_platform = GetCurrentPlatform();
1157
1158 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:281159 for (size_t i = 0; i < num_experiments; ++i) {
1160 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:051161
1162 DictionaryValue* data = new DictionaryValue();
1163 data->SetString("internal_name", experiment.internal_name);
1164 data->SetString("name",
1165 l10n_util::GetStringUTF16(experiment.visible_name_id));
1166 data->SetString("description",
1167 l10n_util::GetStringUTF16(
1168 experiment.visible_description_id));
[email protected]cc3e2052011-12-20 01:01:401169 bool supported = !!(experiment.supported_platforms & current_platform);
1170 data->SetBoolean("supported", supported);
1171
1172 ListValue* supported_platforms = new ListValue();
1173 AddOsStrings(experiment.supported_platforms, supported_platforms);
1174 data->Set("supported_platforms", supported_platforms);
[email protected]ad2a3ded2010-08-27 13:19:051175
[email protected]28e35af2011-02-09 12:56:221176 switch (experiment.type) {
1177 case Experiment::SINGLE_VALUE:
1178 data->SetBoolean(
1179 "enabled",
1180 enabled_experiments.count(experiment.internal_name) > 0);
1181 break;
1182 case Experiment::MULTI_VALUE:
1183 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
1184 break;
1185 default:
1186 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:191187 }
1188
[email protected]ad2a3ded2010-08-27 13:19:051189 experiments_data->Append(data);
1190 }
1191 return experiments_data;
1192}
1193
[email protected]ad2a3ded2010-08-27 13:19:051194bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:551195 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:051196}
1197
1198void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:351199 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:551200 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:071201}
1202
1203void RemoveFlagsSwitches(
1204 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:551205 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:071206}
1207
[email protected]a314ee5a2010-10-26 21:23:281208int GetCurrentPlatform() {
1209#if defined(OS_MACOSX)
1210 return kOsMac;
1211#elif defined(OS_WIN)
1212 return kOsWin;
1213#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
1214 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:211215#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:281216 return kOsLinux;
[email protected]9c7453d2012-01-21 00:45:401217#elif defined(OS_ANDROID)
1218 return kOsAndroid;
[email protected]a314ee5a2010-10-26 21:23:281219#else
1220#error Unknown platform
1221#endif
1222}
1223
[email protected]4bc5050c2010-11-18 17:55:541224void RecordUMAStatistics(const PrefService* prefs) {
1225 std::set<std::string> flags;
1226 GetEnabledFlags(prefs, &flags);
1227 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
1228 ++it) {
1229 std::string action("AboutFlags_");
1230 action += *it;
[email protected]7f6f44c2011-12-14 13:23:381231 content::RecordComputedAction(action);
[email protected]4bc5050c2010-11-18 17:55:541232 }
1233 // Since flag metrics are recorded every startup, add a tick so that the
1234 // stats can be made meaningful.
1235 if (flags.size())
[email protected]7f6f44c2011-12-14 13:23:381236 content::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
1237 content::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:541238}
1239
[email protected]e2ddbc92010-10-15 20:02:071240//////////////////////////////////////////////////////////////////////////////
1241// FlagsState implementation.
1242
1243namespace {
1244
1245void FlagsState::ConvertFlagsToSwitches(
1246 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:071247 if (command_line->HasSwitch(switches::kNoExperiments))
1248 return;
1249
1250 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:001251
[email protected]a314ee5a2010-10-26 21:23:281252 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:071253
[email protected]a82744532011-02-11 16:15:531254 typedef std::map<std::string, std::pair<std::string, std::string> >
1255 NameToSwitchAndValueMap;
1256 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:191257 for (size_t i = 0; i < num_experiments; ++i) {
1258 const Experiment& e = experiments[i];
1259 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:531260 name_to_switch_map[e.internal_name] =
1261 std::pair<std::string, std::string>(e.command_line_switch,
1262 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191263 } else {
1264 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:531265 name_to_switch_map[NameForChoice(e, j)] =
1266 std::pair<std::string, std::string>(
1267 e.choices[j].command_line_switch,
1268 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191269 }
1270 }
[email protected]e2ddbc92010-10-15 20:02:071271
1272 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:531273 flags_switches_.insert(
1274 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
1275 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071276 for (std::set<std::string>::iterator it = enabled_experiments.begin();
1277 it != enabled_experiments.end();
1278 ++it) {
1279 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:531280 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:191281 name_to_switch_map.find(experiment_name);
1282 if (name_to_switch_it == name_to_switch_map.end()) {
1283 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:071284 continue;
[email protected]8a6ff28d2010-12-02 16:35:191285 }
[email protected]e2ddbc92010-10-15 20:02:071286
[email protected]a82744532011-02-11 16:15:531287 const std::pair<std::string, std::string>&
1288 switch_and_value_pair = name_to_switch_it->second;
1289
1290 command_line->AppendSwitchASCII(switch_and_value_pair.first,
1291 switch_and_value_pair.second);
1292 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:071293 }
1294 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:531295 flags_switches_.insert(
1296 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
1297 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071298}
1299
1300bool FlagsState::IsRestartNeededToCommitChanges() {
1301 return needs_restart_;
1302}
1303
1304void FlagsState::SetExperimentEnabled(
1305 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:051306 needs_restart_ = true;
1307
[email protected]8a6ff28d2010-12-02 16:35:191308 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
1309 if (at_index != std::string::npos) {
1310 DCHECK(enable);
1311 // We're being asked to enable a multi-choice experiment. Disable the
1312 // currently selected choice.
1313 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:221314 const std::string experiment_name = internal_name.substr(0, at_index);
1315 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:191316
[email protected]28e35af2011-02-09 12:56:221317 // And enable the new choice, if it is not the default first choice.
1318 if (internal_name != experiment_name + "@0") {
1319 std::set<std::string> enabled_experiments;
1320 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
1321 enabled_experiments.insert(internal_name);
1322 SetEnabledFlags(prefs, enabled_experiments);
1323 }
[email protected]8a6ff28d2010-12-02 16:35:191324 return;
1325 }
1326
[email protected]ad2a3ded2010-08-27 13:19:051327 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241328 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051329
[email protected]8a6ff28d2010-12-02 16:35:191330 const Experiment* e = NULL;
1331 for (size_t i = 0; i < num_experiments; ++i) {
1332 if (experiments[i].internal_name == internal_name) {
1333 e = experiments + i;
1334 break;
1335 }
1336 }
1337 DCHECK(e);
1338
1339 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:591340 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:191341 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:591342 else
[email protected]8a6ff28d2010-12-02 16:35:191343 enabled_experiments.erase(internal_name);
1344 } else {
1345 if (enable) {
1346 // Enable the first choice.
1347 enabled_experiments.insert(NameForChoice(*e, 0));
1348 } else {
1349 // Find the currently enabled choice and disable it.
1350 for (int i = 0; i < e->num_choices; ++i) {
1351 std::string choice_name = NameForChoice(*e, i);
1352 if (enabled_experiments.find(choice_name) !=
1353 enabled_experiments.end()) {
1354 enabled_experiments.erase(choice_name);
1355 // Continue on just in case there's a bug and more than one
1356 // experiment for this choice was enabled.
1357 }
1358 }
1359 }
1360 }
[email protected]ad2a3ded2010-08-27 13:19:051361
[email protected]1a47d7e2010-10-15 00:37:241362 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051363}
1364
[email protected]e2ddbc92010-10-15 20:02:071365void FlagsState::RemoveFlagsSwitches(
1366 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:531367 for (std::map<std::string, std::string>::const_iterator
1368 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
1369 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:071370 }
1371}
1372
1373void FlagsState::reset() {
1374 needs_restart_ = false;
1375 flags_switches_.clear();
1376}
1377
[email protected]38e46812011-05-09 20:49:221378} // namespace
[email protected]e2ddbc92010-10-15 20:02:071379
1380namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:191381
1382// WARNING: '@' is also used in the html file. If you update this constant you
1383// also need to update the html file.
1384const char kMultiSeparator[] = "@";
1385
[email protected]e2ddbc92010-10-15 20:02:071386void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:551387 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:071388}
[email protected]a314ee5a2010-10-26 21:23:281389
1390void SetExperiments(const Experiment* e, size_t count) {
1391 if (!e) {
1392 experiments = kExperiments;
1393 num_experiments = arraysize(kExperiments);
1394 } else {
1395 experiments = e;
1396 num_experiments = count;
1397 }
1398}
1399
[email protected]8a6ff28d2010-12-02 16:35:191400const Experiment* GetExperiments(size_t* count) {
1401 *count = num_experiments;
1402 return experiments;
1403}
1404
[email protected]e2ddbc92010-10-15 20:02:071405} // namespace testing
1406
[email protected]1a47d7e2010-10-15 00:37:241407} // namespace about_flags