blob: b88520b16cb567be79893530d76e68f6249247f3 [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]65bfd9972012-10-19 03:39:3717#include "cc/switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0518#include "chrome/browser/prefs/pref_service.h"
[email protected]1bc78422011-03-31 08:41:3819#include "chrome/browser/prefs/scoped_user_pref_update.h"
[email protected]d208f4d82011-05-23 21:52:0320#include "chrome/common/chrome_content_client.h"
[email protected]ad2a3ded2010-08-27 13:19:0521#include "chrome/common/chrome_switches.h"
22#include "chrome/common/pref_names.h"
[email protected]7f6f44c2011-12-14 13:23:3823#include "content/public/browser/user_metrics.h"
[email protected]ad2a3ded2010-08-27 13:19:0524#include "grit/generated_resources.h"
[email protected]e2e8e322012-09-12 04:37:0225#include "media/base/media_switches.h"
[email protected]0bc6c272012-07-17 03:32:0326#include "ui/app_list/app_list_switches.h"
[email protected]c051a1b2011-01-21 23:30:1727#include "ui/base/l10n/l10n_util.h"
[email protected]c9c73ad42012-04-18 03:35:5928#include "ui/base/ui_base_switches.h"
[email protected]c9e2cbbb2012-05-12 21:17:2729#include "ui/gl/gl_switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0530
[email protected]dc04be7c2012-03-15 23:57:4931#if defined(USE_ASH)
[email protected]b65bdda2011-12-23 23:35:3132#include "ash/ash_switches.h"
[email protected]dc04be7c2012-03-15 23:57:4933#endif
34
35#if defined(USE_AURA)
[email protected]308aaa32012-03-12 13:14:5036#include "ui/aura/aura_switches.h"
[email protected]8cc10df2011-11-03 23:57:5037#endif
38
[email protected]7f6f44c2011-12-14 13:23:3839using content::UserMetricsAction;
40
[email protected]1a47d7e2010-10-15 00:37:2441namespace about_flags {
[email protected]ad2a3ded2010-08-27 13:19:0542
[email protected]8a6ff28d2010-12-02 16:35:1943// Macros to simplify specifying the type.
[email protected]a82744532011-02-11 16:15:5344#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
45 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0
46#define SINGLE_VALUE_TYPE(command_line_switch) \
47 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
48#define MULTI_VALUE_TYPE(choices) \
[email protected]0e6f56d2011-02-12 23:45:1549 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices)
[email protected]8a6ff28d2010-12-02 16:35:1950
[email protected]e2ddbc92010-10-15 20:02:0751namespace {
52
[email protected]9c7453d2012-01-21 00:45:4053const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS | kOsAndroid;
[email protected]ad2a3ded2010-08-27 13:19:0554
[email protected]cc3e2052011-12-20 01:01:4055// Adds a |StringValue| to |list| for each platform where |bitmask| indicates
56// whether the experiment is available on that platform.
57void AddOsStrings(unsigned bitmask, ListValue* list) {
58 struct {
59 unsigned bit;
60 const char* const name;
61 } kBitsToOs[] = {
62 {kOsMac, "Mac"},
63 {kOsWin, "Windows"},
64 {kOsLinux, "Linux"},
65 {kOsCrOS, "Chrome OS"},
66 };
67 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i)
68 if (bitmask & kBitsToOs[i].bit)
69 list->Append(new StringValue(kBitsToOs[i].name));
70}
71
[email protected]ba8164242010-11-16 21:31:0072// Names for former Chrome OS Labs experiments, shared with prefs migration
73// code.
74const char kMediaPlayerExperimentName[] = "media-player";
75const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
76const char kVerticalTabsExperimentName[] = "vertical-tabs";
77
[email protected]68317802012-06-07 19:13:2378const Experiment::Choice kOmniboxHistoryQuickProviderNewScoringChoices[] = {
79 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_AUTOMATIC, "", "" },
80 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_ENABLED,
81 switches::kOmniboxHistoryQuickProviderNewScoring,
82 switches::kOmniboxHistoryQuickProviderNewScoringEnabled },
83 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DISABLED,
84 switches::kOmniboxHistoryQuickProviderNewScoring,
85 switches::kOmniboxHistoryQuickProviderNewScoringDisabled }
86};
87
[email protected]128dc6c2012-06-22 20:30:3588const Experiment::Choice
89 kOmniboxHistoryQuickProviderReorderForInliningChoices[] = {
90 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_AUTOMATIC,
91 "",
92 "" },
93 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_ENABLED,
94 switches::kOmniboxHistoryQuickProviderReorderForInlining,
95 switches::kOmniboxHistoryQuickProviderReorderForInliningEnabled },
96 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DISABLED,
97 switches::kOmniboxHistoryQuickProviderReorderForInlining,
98 switches::kOmniboxHistoryQuickProviderReorderForInliningDisabled }
99};
100
[email protected]032d5e6c2012-02-17 17:53:55101const Experiment::Choice kOmniboxInlineHistoryQuickProviderChoices[] = {
102 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_AUTOMATIC, "", "" },
103 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_ALLOWED,
104 switches::kOmniboxInlineHistoryQuickProvider,
105 switches::kOmniboxInlineHistoryQuickProviderAllowed },
106 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_PROHIBITED,
107 switches::kOmniboxInlineHistoryQuickProvider,
108 switches::kOmniboxInlineHistoryQuickProviderProhibited }
109};
110
[email protected]de023762012-07-26 17:10:17111const Experiment::Choice kFixedPositionCreatesStackingContextChoices[] = {
112 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
113 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
114 switches::kEnableFixedPositionCreatesStackingContext, ""},
115 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
116 switches::kDisableFixedPositionCreatesStackingContext, ""}
117};
118
[email protected]9b19cf82012-06-13 06:23:23119const Experiment::Choice kForceCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20120 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
121 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]9b19cf82012-06-13 06:23:23122 switches::kForceCompositingMode, ""},
[email protected]a45c69402012-06-24 16:32:20123 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]9b19cf82012-06-13 06:23:23124 switches::kDisableForceCompositingMode, ""}
125};
126
[email protected]72787e392012-03-23 05:55:43127const Experiment::Choice kThreadedCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20128 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
129 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]72787e392012-03-23 05:55:43130 switches::kDisableThreadedCompositing, ""},
[email protected]a45c69402012-06-24 16:32:20131 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]72787e392012-03-23 05:55:43132 switches::kEnableThreadedCompositing, ""}
133};
134
[email protected]347a0c72012-05-14 20:28:06135const Experiment::Choice kTouchOptimizedUIChoices[] = {
136 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_AUTOMATIC, "", "" },
[email protected]a45c69402012-06-24 16:32:20137 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]347a0c72012-05-14 20:28:06138 switches::kTouchOptimizedUI,
139 switches::kTouchOptimizedUIEnabled },
[email protected]a45c69402012-06-24 16:32:20140 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]347a0c72012-05-14 20:28:06141 switches::kTouchOptimizedUI,
142 switches::kTouchOptimizedUIDisabled }
143};
144
[email protected]026876f32012-08-22 23:53:40145const Experiment::Choice kAsyncDnsChoices[] = {
146 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
147 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
148 switches::kDisableAsyncDns, ""},
149 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
150 switches::kEnableAsyncDns, ""}
151};
152
[email protected]66f409c2012-10-04 20:59:04153const Experiment::Choice kNaClDebugMaskChoices[] = {
154 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
155 // Secure shell can be used on ChromeOS for forwarding the TCP port opened by
156 // debug stub to a remote machine. Since secure shell uses NaCl, we provide
157 // an option to switch off its debugging.
158 { IDS_NACL_DEBUG_MASK_CHOICE_EXCLUDE_UTILS,
159 switches::kNaClDebugMask, "!*://*/*ssh_client.nmf" },
160 { IDS_NACL_DEBUG_MASK_CHOICE_INCLUDE_DEBUG,
161 switches::kNaClDebugMask, "*://*/*debug.nmf" }
162};
163
[email protected]544471a2012-10-13 05:27:09164const Experiment::Choice kActionBoxChoices[] = {
165 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
166 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
167 switches::kActionBox, "0"},
168 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
169 switches::kActionBox, "1"}
170};
171
172const Experiment::Choice kScriptBubbleChoices[] = {
173 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
174 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
175 switches::kScriptBubble, "0"},
176 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
177 switches::kScriptBubble, "1"}
178};
179
[email protected]ea2f3342012-09-21 21:13:36180#if defined(OS_CHROMEOS)
181const Experiment::Choice kAshBootAnimationFunction[] = {
182 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
183 { IDS_FLAGS_ASH_BOOT_ANIMATION_FUNCTION2,
184 ash::switches::kAshBootAnimationFunction2, ""},
185 { IDS_FLAGS_ASH_BOOT_ANIMATION_FUNCTION3,
186 ash::switches::kAshBootAnimationFunction3, ""}
187};
188#endif
189
[email protected]347a0c72012-05-14 20:28:06190
[email protected]4bc5050c2010-11-18 17:55:54191// RECORDING USER METRICS FOR FLAGS:
192// -----------------------------------------------------------------------------
193// The first line of the experiment is the internal name. If you'd like to
194// gather statistics about the usage of your flag, you should append a marker
195// comment to the end of the feature name, like so:
196// "my-special-feature", // FLAGS:RECORD_UMA
197//
198// After doing that, run //chrome/tools/extract_actions.py (see instructions at
199// the top of that file for details) to update the chromeactions.txt file, which
200// will enable UMA to record your feature flag.
201//
[email protected]783d5bb2012-10-24 03:47:14202// After your feature has shipped under a flag, you can locate the metrics under
203// the action name AboutFlags_internal-action-name. Actions are recorded once
204// per startup, so you should divide this number by AboutFlags_StartupTick to
205// get a sense of usage. Note that this will not be the same as number of users
206// with a given feature enabled because users can quit and relaunch the
207// application multiple times over a given time interval. The dashboard also
208// shows you how many (metrics reporting) users have enabled the flag over the
209// last seven days. However, note that this is not the same as the number of
210// users who have the flag enabled, since enabling the flag happens once,
211// whereas running with the flag enabled happens until the user flips the flag
212// again.
[email protected]4bc5050c2010-11-18 17:55:54213
[email protected]8a6ff28d2010-12-02 16:35:19214// To add a new experiment add to the end of kExperiments. There are two
215// distinct types of experiments:
216// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
217// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:22218// . MULTI_VALUE: a list of choices, the first of which should correspond to a
219// deactivated state for this lab (i.e. no command line option). To specify
220// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
221// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:19222// See the documentation of Experiment for details on the fields.
223//
224// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:05225const Experiment kExperiments[] = {
226 {
[email protected]aac169d2011-03-18 19:53:03227 "expose-for-tabs", // FLAGS:RECORD_UMA
228 IDS_FLAGS_TABPOSE_NAME,
229 IDS_FLAGS_TABPOSE_DESCRIPTION,
230 kOsMac,
231#if defined(OS_MACOSX)
232 // The switch exists only on OS X.
233 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
234#else
235 SINGLE_VALUE_TYPE("")
236#endif
237 },
238 {
[email protected]4bc5050c2010-11-18 17:55:54239 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05240 IDS_FLAGS_CONFLICTS_CHECK_NAME,
241 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
242 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19243 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05244 },
245 {
[email protected]4bc5050c2010-11-18 17:55:54246 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]dae7325b2011-12-21 20:56:54247 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME,
248 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45249 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22250 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31251 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22252 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
253 // always have PDF rasterization available, so no flag needed there.
254#if !defined(GOOGLE_CHROME_BUILD)
255 kOsWin,
256#else
257 0,
[email protected]fa6d2a2f2010-11-30 21:47:19258#endif
[email protected]8a6ff28d2010-12-02 16:35:19259 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42260 },
[email protected]60d77bd2012-08-22 00:10:07261#if defined(OS_WIN)
262 {
263 "print-raster",
264 IDS_FLAGS_PRINT_RASTER_NAME,
265 IDS_FLAGS_PRINT_RASTER_DESCRIPTION,
266 kOsWin,
267 SINGLE_VALUE_TYPE(switches::kPrintRaster)
268 },
269#endif // OS_WIN
[email protected]0209b442012-07-18 00:38:05270 {
[email protected]bb461532010-11-26 21:50:23271 "crxless-web-apps",
272 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
273 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
274 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19275 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23276 },
277 {
[email protected]96c6f4c2011-05-18 19:36:22278 "ignore-gpu-blacklist",
279 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
280 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
281 kOsAll,
282 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
283 },
284 {
[email protected]0110cf112011-07-02 00:39:43285 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22286 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
287 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
[email protected]9b19cf82012-06-13 06:23:23288 kOsMac | kOsWin | kOsLinux,
289 MULTI_VALUE_TYPE(kForceCompositingModeChoices)
[email protected]96c6f4c2011-05-18 19:36:22290 },
291 {
[email protected]72787e392012-03-23 05:55:43292 "threaded-compositing-mode",
293 IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME,
294 IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59295 kOsAll,
[email protected]72787e392012-03-23 05:55:43296 MULTI_VALUE_TYPE(kThreadedCompositingModeChoices)
[email protected]644a1072012-03-16 09:29:59297 },
298 {
[email protected]81c64af62012-06-06 20:15:52299 "disable-accelerated-2d-canvas",
300 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_NAME,
301 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_DESCRIPTION,
302 kOsAll,
303 SINGLE_VALUE_TYPE(switches::kDisableAccelerated2dCanvas)
304 },
305 {
[email protected]69cffc82012-08-10 13:27:27306 "disable-deferred-2d-canvas",
307 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_NAME,
308 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_DESCRIPTION,
309 kOsAll,
310 SINGLE_VALUE_TYPE(switches::kDisableDeferred2dCanvas)
311 },
312 {
[email protected]efcde132012-05-30 01:05:18313 "disable-threaded-animation",
314 IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME,
315 IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59316 kOsAll,
[email protected]65bfd9972012-10-19 03:39:37317 SINGLE_VALUE_TYPE(cc::switches::kDisableThreadedAnimation)
[email protected]644a1072012-03-16 09:29:59318 },
319 {
[email protected]5963b772011-02-09 22:55:38320 "composited-layer-borders",
321 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
322 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
323 kOsAll,
324 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
325 },
326 {
[email protected]a8f1eaa2011-03-07 19:00:58327 "show-fps-counter",
328 IDS_FLAGS_SHOW_FPS_COUNTER,
329 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
330 kOsAll,
331 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
332 },
[email protected]8ff7f342011-05-25 01:49:47333 {
[email protected]70c98a332011-12-21 20:51:52334 "accelerated-filters",
335 IDS_FLAGS_ACCELERATED_FILTERS,
336 IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION,
337 kOsAll,
338 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters)
339 },
340 {
[email protected]8ff7f342011-05-25 01:49:47341 "disable-gpu-vsync",
342 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
343 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
344 kOsAll,
345 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
346 },
[email protected]deaba6d52011-09-23 14:47:12347 {
348 "disable-webgl",
349 IDS_FLAGS_DISABLE_WEBGL_NAME,
350 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
351 kOsAll,
352 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
353 },
[email protected]09096e02012-05-24 11:12:04354 {
[email protected]96bcdc102012-05-24 23:42:10355 "fixed-position-creates-stacking-context",
356 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_NAME,
357 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_DESCRIPTION,
358 kOsAll,
[email protected]de023762012-07-26 17:10:17359 MULTI_VALUE_TYPE(kFixedPositionCreatesStackingContextChoices)
[email protected]96bcdc102012-05-24 23:42:10360 },
[email protected]a7640ef22012-10-06 00:52:08361 // TODO(bbudge): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53362 {
[email protected]e3791ce92011-08-09 01:03:32363 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40364 IDS_FLAGS_ENABLE_NACL_NAME,
365 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
366 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19367 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40368 },
[email protected]b39c6d92012-01-31 16:38:41369 // TODO(halyavin): When exception handling is on by default, replace this
370 // flag with disable-nacl-exception-handling.
371 {
372 "enable-nacl-exception-handling", // FLAGS:RECORD_UMA
373 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME,
374 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION,
[email protected]bf2c61b2012-08-30 16:37:04375 kOsAll,
[email protected]b39c6d92012-01-31 16:38:41376 SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling)
377 },
[email protected]4ff87d202010-11-06 01:28:40378 {
[email protected]9addd1c2012-09-15 14:28:24379 "enable-nacl-debug", // FLAGS:RECORD_UMA
380 IDS_FLAGS_ENABLE_NACL_DEBUG_NAME,
381 IDS_FLAGS_ENABLE_NACL_DEBUG_DESCRIPTION,
[email protected]401b90792012-05-30 11:41:13382 kOsAll,
[email protected]9addd1c2012-09-15 14:28:24383 SINGLE_VALUE_TYPE(switches::kEnableNaClDebug)
[email protected]401b90792012-05-30 11:41:13384 },
385 {
[email protected]66f409c2012-10-04 20:59:04386 "nacl-debug-mask", // FLAGS:RECORD_UMA
387 IDS_FLAGS_NACL_DEBUG_MASK_NAME,
388 IDS_FLAGS_NACL_DEBUG_MASK_DESCRIPTION,
389 kOsAll,
390 MULTI_VALUE_TYPE(kNaClDebugMaskChoices)
391 },
392 {
[email protected]7babd1c2012-08-08 20:35:29393 "enable-pnacl", // FLAGS:RECORD_UMA
394 IDS_FLAGS_ENABLE_PNACL_NAME,
395 IDS_FLAGS_ENABLE_PNACL_DESCRIPTION,
396 kOsAll,
397 SINGLE_VALUE_TYPE(switches::kEnablePnacl)
398 },
[email protected]a7640ef22012-10-06 00:52:08399 // TODO(bbudge): When NaCl switches to the IPC-based proxy, remove this
400 // flag entry.
401 {
402 "enable-nacl-ipc-proxy", // FLAGS:RECORD_UMA
403 IDS_FLAGS_ENABLE_NACL_IPC_PROXY_NAME,
404 IDS_FLAGS_ENABLE_NACL_IPC_PROXY_DESCRIPTION,
405 kOsAll,
406 SINGLE_VALUE_TYPE(switches::kEnableNaClIPCProxy)
407 },
[email protected]7babd1c2012-08-08 20:35:29408 {
[email protected]d3a8cfc2012-09-14 18:31:38409 "enable-scripted-speech", // FLAGS:RECORD_UMA
410 IDS_FLAGS_ENABLE_SCRIPTED_SPEECH_NAME,
411 IDS_FLAGS_ENABLE_SCRIPTED_SPEECH_DESCRIPTION,
412 kOsAll,
413 SINGLE_VALUE_TYPE(switches::kEnableScriptedSpeech)
414 },
415 {
[email protected]4bc5050c2010-11-18 17:55:54416 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32417 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
418 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
419 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19420 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32421 },
[email protected]3627b06d2010-11-12 16:36:16422 {
[email protected]544471a2012-10-13 05:27:09423 "action-box",
[email protected]cab18ef2012-04-27 07:22:03424 IDS_FLAGS_ACTION_BOX_NAME,
425 IDS_FLAGS_ACTION_BOX_DESCRIPTION,
426 kOsAll,
[email protected]544471a2012-10-13 05:27:09427 MULTI_VALUE_TYPE(kActionBoxChoices),
[email protected]cab18ef2012-04-27 07:22:03428 },
429 {
[email protected]3a362432012-06-18 20:39:51430 "script-badges",
431 IDS_FLAGS_SCRIPT_BADGES_NAME,
432 IDS_FLAGS_SCRIPT_BADGES_DESCRIPTION,
433 kOsAll,
[email protected]544471a2012-10-13 05:27:09434 SINGLE_VALUE_TYPE(switches::kScriptBadges)
435 },
436 {
437 "script-bubble",
438 IDS_FLAGS_SCRIPT_BUBBLE_NAME,
439 IDS_FLAGS_SCRIPT_BUBBLE_DESCRIPTION,
440 kOsAll,
441 MULTI_VALUE_TYPE(kScriptBubbleChoices),
[email protected]3a362432012-06-18 20:39:51442 },
443 {
[email protected]cbe224d2011-08-04 22:12:49444 "apps-new-install-bubble",
445 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
446 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
447 kOsAll,
448 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
449 },
450 {
[email protected]80bd24e2010-11-30 09:34:38451 "disable-hyperlink-auditing",
452 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
453 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
454 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19455 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51456 },
457 {
458 "experimental-location-features", // FLAGS:RECORD_UMA
459 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
460 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
461 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19462 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
463 },
464 {
[email protected]5aea1862011-03-23 23:55:39465 "tab-groups-context-menu",
466 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
467 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
468 kOsWin,
469 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
470 },
[email protected]c94cebd2012-06-21 00:55:28471#if defined(OS_CHROMEOS)
472 {
473 "enable-instant-extended-api",
474 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API,
475 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API_DESCRIPTION,
476 kOsAll,
477 SINGLE_VALUE_TYPE(switches::kEnableInstantExtendedAPI)
478 },
479#endif
[email protected]e9bf9d92011-03-31 20:57:15480 {
[email protected]354e33b2011-06-15 00:29:10481 "static-ip-config",
482 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
483 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
484 kOsCrOS,
485#if defined(OS_CHROMEOS)
486 // This switch exists only on Chrome OS.
487 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
488#else
489 SINGLE_VALUE_TYPE("")
490#endif
491 },
[email protected]3eb5728c2011-06-20 22:32:24492 {
493 "show-autofill-type-predictions",
494 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
495 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
496 kOsAll,
497 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
498 },
[email protected]bff4d3e2011-06-21 23:58:52499 {
[email protected]fdf4e252012-04-27 00:26:55500 "sync-tab-favicons",
501 IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
502 IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
503 kOsAll,
504 SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
505 },
506 {
[email protected]aae9eeb12011-10-21 21:59:26507 "sync-app-notifications",
508 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
509 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
510 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11511 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26512 },
513 {
[email protected]e755a382012-09-13 17:16:35514 "enable-gesture-tap-highlight",
515 IDS_FLAGS_ENABLE_GESTURE_TAP_HIGHLIGHTING_NAME,
516 IDS_FLAGS_ENABLE_GESTURE_TAP_HIGHLIGHTING_DESCRIPTION,
517 kOsLinux | kOsCrOS,
518 SINGLE_VALUE_TYPE(switches::kEnableGestureTapHighlight)
519 },
520 {
[email protected]a22ebd812011-06-23 00:05:39521 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
522 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
523 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
524 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40525 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40526 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39527 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
528 },
[email protected]81a6b0b2011-06-24 17:55:40529 {
[email protected]68317802012-06-07 19:13:23530 "omnibox-history-quick-provider-new-scoring",
531 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_NAME,
532 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DESCRIPTION,
533 kOsAll,
534 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderNewScoringChoices)
535 },
536 {
[email protected]128dc6c2012-06-22 20:30:35537 "omnibox-history-quick-provider-reorder-for-inlining",
538 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_NAME,
539 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DESCRIPTION,
540 kOsAll,
541 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderReorderForInliningChoices)
542 },
543 {
[email protected]032d5e6c2012-02-17 17:53:55544 "omnibox-inline-history-quick-provider",
545 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME,
546 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION,
547 kOsAll,
548 MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices)
549 },
550 {
[email protected]7e7a28092011-12-09 22:24:55551 "enable-panels",
552 IDS_FLAGS_ENABLE_PANELS_NAME,
553 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54554 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55555 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54556 },
[email protected]e3749d12011-07-25 22:22:12557 {
[email protected]27c14f02012-06-22 17:29:58558 // See http://crbug.com/120416 for how to remove this flag.
[email protected]6474b112012-05-04 19:35:27559 "save-page-as-mhtml", // FLAGS:RECORD_UMA
560 IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME,
561 IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION,
562 kOsMac | kOsWin | kOsLinux,
563 SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)
564 },
565 {
[email protected]b7bb44f2011-09-01 05:17:03566 "enable-autologin",
567 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
568 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
569 kOsMac | kOsWin | kOsLinux,
570 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
571 },
[email protected]b9841172011-09-26 23:36:09572 {
[email protected]bbadb112011-12-12 16:55:28573 "enable-http-pipelining",
574 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
575 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
576 kOsAll,
577 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
578 },
[email protected]d411c01d2011-10-18 16:00:27579 {
[email protected]3231b612012-03-23 05:57:54580 "enable-spdy3",
581 IDS_FLAGS_ENABLE_SPDY3_NAME,
582 IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION,
583 kOsAll,
584 SINGLE_VALUE_TYPE(switches::kEnableSpdy3)
585 },
586 {
[email protected]27b3fe92012-03-21 05:35:06587 "enable-async-dns",
588 IDS_FLAGS_ENABLE_ASYNC_DNS_NAME,
589 IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION,
[email protected]85594c142012-09-11 18:02:46590 kOsWin | kOsMac | kOsLinux | kOsCrOS,
[email protected]026876f32012-08-22 23:53:40591 MULTI_VALUE_TYPE(kAsyncDnsChoices)
[email protected]27b3fe92012-03-21 05:35:06592 },
593 {
[email protected]1eb93802012-09-11 18:57:56594 "disable-media-source",
[email protected]da43c082012-09-07 18:56:11595 IDS_FLAGS_DISABLE_MEDIA_SOURCE_NAME,
596 IDS_FLAGS_DISABLE_MEDIA_SOURCE_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32597 kOsAll,
[email protected]da43c082012-09-07 18:56:11598 SINGLE_VALUE_TYPE(switches::kDisableMediaSource)
[email protected]6aa03b32011-10-27 21:44:44599 },
[email protected]e4e68dbb2011-11-18 01:50:22600 {
[email protected]9f5b7822012-04-18 23:39:03601 "enable-encrypted-media",
602 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME,
603 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION,
604 kOsAll,
605 SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia)
606 },
[email protected]dc04be7c2012-03-15 23:57:49607#if defined(USE_ASH)
[email protected]8cc10df2011-11-03 23:57:50608 {
[email protected]57b8bb352012-01-11 05:11:46609 "aura-google-dialog-frames",
610 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME,
611 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION,
612 kOsWin | kOsLinux | kOsCrOS,
613 SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames)
614 },
[email protected]dc04be7c2012-03-15 23:57:49615#endif
[email protected]eaae8b462012-01-20 22:20:39616 {
[email protected]db543d322011-12-15 20:40:15617 "per-tile-painting",
618 IDS_FLAGS_PER_TILE_PAINTING_NAME,
619 IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION,
620#if defined(USE_SKIA)
[email protected]a5b1b272012-01-06 20:44:37621 kOsMac | kOsLinux | kOsCrOS,
[email protected]db543d322011-12-15 20:40:15622#else
623 0,
624#endif
[email protected]65bfd9972012-10-19 03:39:37625 SINGLE_VALUE_TYPE(cc::switches::kEnablePerTilePainting)
[email protected]db543d322011-12-15 20:40:15626 },
[email protected]bf88c032011-12-22 19:05:47627 {
628 "enable-javascript-harmony",
629 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME,
630 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION,
631 kOsAll,
632 SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony")
633 },
[email protected]7e7f378a2012-01-05 14:35:37634 {
[email protected]85646172012-01-09 22:45:54635 "enable-tab-browser-dragging",
636 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME,
637 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION,
638 kOsWin,
639 SINGLE_VALUE_TYPE(switches::kTabBrowserDragging)
640 },
641 {
[email protected]068b7b52012-02-27 12:41:44642 "disable-restore-session-state",
643 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME,
644 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION,
[email protected]7e7f378a2012-01-05 14:35:37645 kOsAll,
[email protected]068b7b52012-02-27 12:41:44646 SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState)
[email protected]7e7f378a2012-01-05 14:35:37647 },
[email protected]88864db2012-01-18 20:56:35648 {
649 "disable-software-rasterizer",
650 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME,
651 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION,
652#if defined(ENABLE_SWIFTSHADER)
653 kOsAll,
654#else
655 0,
656#endif
657 SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer)
658 },
[email protected]15a5d722012-01-23 09:11:14659 {
[email protected]ff7b6dd2012-09-15 20:20:03660 "enable-experimental-webkit-features",
661 IDS_FLAGS_EXPERIMENTAL_WEBKIT_FEATURES_NAME,
662 IDS_FLAGS_EXPERIMENTAL_WEBKIT_FEATURES_DESCRIPTION,
[email protected]d2edc6702012-01-30 09:13:16663 kOsAll,
[email protected]ff7b6dd2012-09-15 20:20:03664 SINGLE_VALUE_TYPE(switches::kEnableExperimentalWebKitFeatures)
[email protected]ca7a3d792012-03-02 15:55:49665 },
666 {
[email protected]0f95a252012-09-13 22:30:04667 "enable-css-shaders",
668 IDS_FLAGS_CSS_SHADERS_NAME,
669 IDS_FLAGS_CSS_SHADERS_DESCRIPTION,
670 kOsAll,
671 SINGLE_VALUE_TYPE(switches::kEnableCssShaders)
672 },
673 {
[email protected]9860c68b2012-02-02 01:58:09674 "enable-extension-activity-ui",
675 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME,
676 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION,
677 kOsAll,
678 SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI)
[email protected]8bed69d2012-02-02 06:46:00679 },
[email protected]54ae4e92012-02-16 15:19:05680 {
[email protected]3e8befc2012-03-13 01:17:03681 "disable-ntp-other-sessions-menu",
[email protected]156f966332012-02-29 00:03:16682 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME,
683 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION,
684 kOsAll,
[email protected]3e8befc2012-03-13 01:17:03685 SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu)
[email protected]156f966332012-02-29 00:03:16686 },
[email protected]dc04be7c2012-03-15 23:57:49687#if defined(USE_ASH)
[email protected]31cf1c52012-02-29 20:55:01688 {
[email protected]3cd198a22012-03-12 20:38:01689 "enable-ash-oak",
690 IDS_FLAGS_ENABLE_ASH_OAK_NAME,
691 IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION,
692 kOsAll,
693 SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak),
694 },
[email protected]31cf1c52012-02-29 20:55:01695#endif
[email protected]184ec592012-03-01 11:54:28696 {
697 "enable-devtools-experiments",
698 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME,
699 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION,
700 kOsAll,
701 SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments)
702 },
[email protected]76d1854e2012-03-02 23:57:44703 {
704 "enable-suggestions-ntp",
705 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME,
706 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION,
707 kOsAll,
708 SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage)
709 },
[email protected]a3d54252012-04-05 20:04:13710 {
[email protected]57890242012-10-23 17:46:52711 "force-sync-spellcheck",
712 IDS_FLAGS_FORCE_SYNC_SPELLCHECK,
713 IDS_FLAGS_FORCE_SYNC_SPELLCHECK_DESCRIPTION,
[email protected]37b928e2012-05-30 09:01:10714 kOsWin | kOsLinux | kOsCrOS,
[email protected]57890242012-10-23 17:46:52715 SINGLE_VALUE_TYPE(switches::kForceSyncSpellCheck)
[email protected]a3d54252012-04-05 20:04:13716 },
[email protected]c9c73ad42012-04-18 03:35:59717 {
718 "touch-optimized-ui",
[email protected]347a0c72012-05-14 20:28:06719 IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME,
720 IDS_FLAGS_TOUCH_OPTIMIZED_UI_DESCRIPTION,
[email protected]c71fe6402012-08-15 15:22:55721 kOsWin,
[email protected]347a0c72012-05-14 20:28:06722 MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
[email protected]c9c73ad42012-04-18 03:35:59723 },
[email protected]8a6aaa72012-04-20 20:53:58724 {
[email protected]f6f82832012-09-04 17:12:04725 "enable-webkit-text-subpixel-positioning",
726 IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_NAME,
727 IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_DESCRIPTION,
728 kOsCrOS,
729 SINGLE_VALUE_TYPE(switches::kEnableWebkitTextSubpixelPositioning)
730 },
731 {
[email protected]8a6aaa72012-04-20 20:53:58732 "enable-touch-events",
733 IDS_ENABLE_TOUCH_EVENTS_NAME,
734 IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
[email protected]223a31e42012-10-04 01:12:18735 kOsWin | kOsMac | kOsLinux,
[email protected]8a6aaa72012-04-20 20:53:58736 SINGLE_VALUE_TYPE(switches::kEnableTouchEvents)
737 },
[email protected]0b60afa2012-04-19 17:36:39738#if defined(OS_CHROMEOS)
739 {
[email protected]7c4a9bc2012-09-11 22:10:05740 "enable-background-loader",
741 IDS_ENABLE_BACKLOADER_NAME,
742 IDS_ENABLE_BACKLOADER_DESCRIPTION,
743 kOsCrOS,
744 SINGLE_VALUE_TYPE(switches::kEnableBackgroundLoader)
745 },
746 {
[email protected]c5667b282012-08-31 00:32:50747 "enable-bezel-touch",
748 IDS_ENABLE_BEZEL_TOUCH_NAME,
749 IDS_ENABLE_BEZEL_TOUCH_DESCRIPTION,
[email protected]1995d80d2012-08-23 02:58:47750 kOsCrOS,
[email protected]c5667b282012-08-31 00:32:50751 SINGLE_VALUE_TYPE(switches::kEnableBezelTouch)
[email protected]1995d80d2012-08-23 02:58:47752 },
753 {
[email protected]0b60afa2012-04-19 17:36:39754 "no-discard-tabs",
755 IDS_FLAGS_NO_DISCARD_TABS_NAME,
756 IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION,
757 kOsCrOS,
758 SINGLE_VALUE_TYPE(switches::kNoDiscardTabs)
759 },
760#endif
[email protected]79be6d32012-04-24 20:47:44761 {
[email protected]9a5940d2012-04-27 19:16:23762 "allow-nacl-socket-api",
763 IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME,
764 IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION,
765 kOsAll,
766 SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*")
767 },
[email protected]85333732012-05-01 19:02:24768 {
[email protected]60673ad72012-05-02 06:16:33769 "stacked-tab-strip",
770 IDS_FLAGS_STACKED_TAB_STRIP_NAME,
771 IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION,
772 kOsWin,
773 SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip)
774 },
775 {
[email protected]4bd20202012-06-14 17:35:01776 "force-device-scale-factor",
[email protected]85333732012-05-01 19:02:24777 IDS_FLAGS_FORCE_HIGH_DPI_NAME,
778 IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION,
779 kOsCrOS,
[email protected]4bd20202012-06-14 17:35:01780 SINGLE_VALUE_TYPE_AND_VALUE(switches::kForceDeviceScaleFactor, "2")
[email protected]85333732012-05-01 19:02:24781 },
[email protected]190349fd2012-05-02 00:10:47782#if defined(OS_CHROMEOS)
783 {
784 "allow-touchpad-three-finger-click",
785 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME,
786 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION,
787 kOsCrOS,
788 SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick)
789 },
790#endif
[email protected]1992a2f42012-10-23 18:32:21791 {
792 "use-web-based-signin-flow",
793 IDS_FLAGS_USE_WEB_BASED_SIGNIN_FLOW_NAME,
794 IDS_FLAGS_USE_WEB_BASED_SIGNIN_FLOW_DESCRIPTION,
795 kOsMac | kOsWin | kOsLinux,
796 SINGLE_VALUE_TYPE(switches::kUseWebBasedSigninFlow)
797 },
[email protected]53520b1b2012-05-07 21:43:37798#if defined(USE_ASH)
799 {
[email protected]55444502012-05-10 15:43:53800 "show-launcher-alignment-menu",
801 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_NAME,
802 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION,
803 kOsAll,
804 SINGLE_VALUE_TYPE(switches::kShowLauncherAlignmentMenu)
805 },
[email protected]817ecd12012-05-16 18:36:53806 {
[email protected]73074742012-05-17 01:44:41807 "show-touch-hud",
808 IDS_FLAGS_SHOW_TOUCH_HUD_NAME,
809 IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION,
810 kOsAll,
811 SINGLE_VALUE_TYPE(ash::switches::kAshTouchHud)
812 },
813 {
[email protected]9f0940b62012-05-23 22:56:35814 "enable-pinch",
815 IDS_FLAGS_ENABLE_PINCH_SCALE_NAME,
816 IDS_FLAGS_ENABLE_PINCH_SCALE_DESCRIPTION,
817 kOsAll,
818 SINGLE_VALUE_TYPE(switches::kEnablePinch),
819 },
[email protected]a8379312012-06-15 00:20:43820 {
821 "app-list-show-apps-only",
822 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_NAME,
823 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_DESCRIPTION,
824 kOsAll,
[email protected]0bc6c272012-07-17 03:32:03825 SINGLE_VALUE_TYPE(app_list::switches::kAppListShowAppsOnly),
[email protected]a8379312012-06-15 00:20:43826 },
[email protected]73074742012-05-17 01:44:41827#endif // defined(USE_ASH)
[email protected]ed7b67f32012-05-28 10:12:28828#if defined(OS_CHROMEOS)
829 {
[email protected]5064c562012-09-05 18:15:27830 "disable-new-wallpaper-picker-ui",
831 IDS_FLAGS_DISABLE_NEW_WALLPAPER_UI_NAME,
832 IDS_FLAGS_DISABLE_NEW_WALLPAPER_UI_DESCRIPTION,
[email protected]a7668a12012-05-28 22:23:48833 kOsCrOS,
[email protected]5064c562012-09-05 18:15:27834 SINGLE_VALUE_TYPE(switches::kDisableNewWallpaperUI)
[email protected]a7668a12012-05-28 22:23:48835 },
836 {
[email protected]89ef50172012-07-24 21:58:38837 "disable-html5-camera",
838 IDS_FLAGS_DISABLE_HTML5_CAMERA,
839 IDS_FLAGS_DISABLE_HTML5_CAMERA_DESCRIPTION,
[email protected]ffc6f7b12012-07-04 09:11:33840 kOsCrOS,
[email protected]89ef50172012-07-24 21:58:38841 SINGLE_VALUE_TYPE(switches::kDisableHtml5Camera),
[email protected]ffc6f7b12012-07-04 09:11:33842 },
843 {
[email protected]e03dc78d2012-07-24 08:21:43844 "disable-new-oobe",
845 IDS_FLAGS_DISABLE_NEW_OOBE,
846 IDS_FLAGS_DISABLE_NEW_OOBE_DESCRIPTION,
[email protected]ed7b67f32012-05-28 10:12:28847 kOsCrOS,
[email protected]e03dc78d2012-07-24 08:21:43848 SINGLE_VALUE_TYPE(switches::kDisableNewOobe),
[email protected]ed7b67f32012-05-28 10:12:28849 },
[email protected]8b04a1652012-08-04 02:59:49850 {
[email protected]f59324d2012-09-17 19:41:47851 "disable-factory-reset",
852 IDS_FLAGS_DISABLE_FACTORY_RESET,
853 IDS_FLAGS_DISABLE_FACTORY_RESET_DESCRIPTION,
854 kOsCrOS,
855 SINGLE_VALUE_TYPE(switches::kDisableFactoryReset),
856 },
857 {
[email protected]8b04a1652012-08-04 02:59:49858 "disable-boot-animation",
859 IDS_FLAGS_DISABLE_BOOT_ANIMATION,
860 IDS_FLAGS_DISABLE_BOOT_ANIMATION_DESCRIPTION,
861 kOsCrOS,
862 SINGLE_VALUE_TYPE(switches::kDisableBootAnimation),
863 },
[email protected]95058572012-08-20 14:57:29864 {
[email protected]b4557192012-09-19 11:29:58865 "disable-boot-animation2",
866 IDS_FLAGS_DISABLE_BOOT_ANIMATION2,
867 IDS_FLAGS_DISABLE_BOOT_ANIMATION2_DESCRIPTION,
868 kOsCrOS,
869 SINGLE_VALUE_TYPE(ash::switches::kAshDisableBootAnimation2),
870 },
871 {
[email protected]ea2f3342012-09-21 21:13:36872 "boot-animation-fucntion",
873 IDS_FLAGS_ASH_BOOT_ANIMATION_FUNCTION,
874 IDS_FLAGS_ASH_BOOT_ANIMATION_FUNCTION_DESCRIPTION,
875 kOsCrOS,
876 MULTI_VALUE_TYPE(kAshBootAnimationFunction),
877 },
[email protected]839667d62012-10-23 19:38:57878 {
879 "new-lock-animations",
880 IDS_FLAGS_ASH_NEW_LOCK_ANIMATIONS,
881 IDS_FLAGS_ASH_NEW_LOCK_ANIMATIONS_DESCRIPTION,
882 kOsCrOS,
883 SINGLE_VALUE_TYPE(ash::switches::kAshNewLockAnimationsEnabled),
884 },
[email protected]ed7b67f32012-05-28 10:12:28885#endif
[email protected]fc7a93c2012-06-08 20:25:39886 {
887 "enable-views-textfield",
888 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_NAME,
889 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_DESCRIPTION,
890 kOsWin,
891 SINGLE_VALUE_TYPE(switches::kEnableViewsTextfield),
892 },
[email protected]bd0cd3bb2012-06-14 03:03:38893 {
[email protected]ef41b7ee2012-07-24 19:10:41894 "old-checkbox-style",
895 IDS_FLAGS_OLD_CHECKBOX_STYLE,
896 IDS_FLAGS_OLD_CHECKBOX_STYLE_DESCRIPTION,
897 kOsLinux | kOsCrOS,
898 SINGLE_VALUE_TYPE(switches::kOldCheckboxStyle),
899 },
900 {
[email protected]fcb88de2012-07-12 22:25:32901 "enable-frameless-constrained-dialogs",
902 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_NAME,
903 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_DESCRIPTION,
904 kOsWin | kOsCrOS,
905 SINGLE_VALUE_TYPE(switches::kEnableFramelessConstrainedDialogs),
906 },
[email protected]7db8893a2012-07-26 00:49:40907 { "disable-accelerated-video-decode",
908 IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_NAME,
909 IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
[email protected]66dcb0492012-06-18 22:32:15910 kOsAll,
[email protected]7db8893a2012-07-26 00:49:40911 SINGLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
[email protected]66dcb0492012-06-18 22:32:15912 },
[email protected]66ae9fc2012-06-19 21:33:52913#if defined(USE_ASH)
914 {
915 "ash-debug-shortcuts",
916 IDS_FLAGS_DEBUG_SHORTCUTS_NAME,
917 IDS_FLAGS_DEBUG_SHORTCUTS_DESCRIPTION,
918 kOsAll,
919 SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts),
920 },
921#endif
[email protected]37fee0942012-08-07 21:07:45922 {
[email protected]9a8e9352012-08-24 00:45:17923 "disable-website-settings", // FLAGS:RECORD_UMA
924 IDS_FLAGS_DISABLE_WEBSITE_SETTINGS_NAME,
925 IDS_FLAGS_DISABLE_WEBSITE_SETTINGS_DESCRIPTION,
[email protected]37fee0942012-08-07 21:07:45926 kOsAll,
[email protected]9a8e9352012-08-24 00:45:17927 SINGLE_VALUE_TYPE(switches::kDisableWebsiteSettings),
[email protected]37fee0942012-08-07 21:07:45928 },
[email protected]ad3f6d22012-08-29 02:34:19929 {
[email protected]e2e8e322012-09-12 04:37:02930 "enable-webaudio-input",
931 IDS_FLAGS_ENABLE_WEBAUDIO_INPUT_NAME,
932 IDS_FLAGS_ENABLE_WEBAUDIO_INPUT_DESCRIPTION,
933 kOsAll,
934 SINGLE_VALUE_TYPE(switches::kEnableWebAudioInput),
935 },
936 {
[email protected]ad3f6d22012-08-29 02:34:19937 "enable-contacts",
938 IDS_FLAGS_ENABLE_CONTACTS_NAME,
939 IDS_FLAGS_ENABLE_CONTACTS_DESCRIPTION,
940 kOsCrOS,
941 SINGLE_VALUE_TYPE(switches::kEnableContacts)
942 },
[email protected]1d9bb9cd2012-08-28 22:02:50943#if defined(USE_ASH)
944 { "ash-enable-advanced-gestures",
945 IDS_FLAGS_ENABLE_ADVANCED_GESTURES_NAME,
946 IDS_FLAGS_ENABLE_ADVANCED_GESTURES_DESCRIPTION,
947 kOsCrOS,
948 SINGLE_VALUE_TYPE(ash::switches::kAshEnableAdvancedGestures),
949 },
950#endif
[email protected]9b7ab882012-09-10 23:46:36951#if defined(OS_CHROMEOS)
952 {
[email protected]205f07892012-10-16 20:26:22953 "enable-carrier-switching",
954 IDS_FLAGS_ENABLE_CARRIER_SWITCHING,
955 IDS_FLAGS_ENABLE_CARRIER_SWITCHING_DESCRIPTION,
956 kOsCrOS,
957 SINGLE_VALUE_TYPE(switches::kEnableCarrierSwitching)
958 },
959 {
[email protected]9b7ab882012-09-10 23:46:36960 "enable-request-tablet-site",
961 IDS_FLAGS_ENABLE_REQUEST_TABLET_SITE_NAME,
962 IDS_FLAGS_ENABLE_REQUEST_TABLET_SITE_DESCRIPTION,
963 kOsCrOS,
964 SINGLE_VALUE_TYPE(switches::kEnableRequestTabletSite)
965 },
966#endif
[email protected]dab49c0b2012-10-04 05:55:35967 {
968 "debug-packed-apps",
969 IDS_FLAGS_DEBUG_PACKED_APP_NAME,
970 IDS_FLAGS_DEBUG_PACKED_APP_DESCRIPTION,
971 kOsAll,
972 SINGLE_VALUE_TYPE(switches::kDebugPackedApps)
973 },
[email protected]d1459ed2012-10-10 01:29:33974 {
975 "enable-password-generation",
976 IDS_FLAGS_ENABLE_PASSWORD_GENERATION_NAME,
977 IDS_FLAGS_ENABLE_PASSWORD_GENERATION_DESCRIPTION,
978 kOsWin | kOsLinux | kOsCrOS,
979 SINGLE_VALUE_TYPE(switches::kEnablePasswordGeneration)
980 },
[email protected]26d045f2012-10-18 21:18:43981 {
982 "crash-on-gpu-hang",
983 IDS_FLAGS_CRASH_ON_GPU_HANG_NAME,
984 IDS_FLAGS_CRASH_ON_GPU_HANG_DESCRIPTION,
985 kOsAll,
986 SINGLE_VALUE_TYPE(switches::kCrashOnGpuHang)
987 },
[email protected]075543d2012-10-24 01:29:14988 {
989 "performance-monitor-gathering",
990 IDS_FLAGS_PERFORMANCE_MONITOR_GATHERING_NAME,
991 IDS_FLAGS_PERFORMANCE_MONITOR_GATHERING_DESCRIPTION,
992 kOsAll,
993 SINGLE_VALUE_TYPE(switches::kPerformanceMonitorGathering)
994 },
[email protected]783d5bb2012-10-24 03:47:14995 {
996 "enable-new-autofill-ui",
997 IDS_FLAGS_ENABLE_NEW_AUTOFILL_UI_NAME,
998 IDS_FLAGS_ENABLE_NEW_AUTOFILL_UI_DESCRIPTION,
999 kOsWin | kOsLinux,
1000 SINGLE_VALUE_TYPE(switches::kEnableNewAutofillUi)
1001 },
1002 {
1003 "enable-new-autofill-heuristics",
1004 IDS_FLAGS_ENABLE_NEW_AUTOFILL_HEURISTICS_NAME,
1005 IDS_FLAGS_ENABLE_NEW_AUTOFILL_HEURISTICS_DESCRIPTION,
1006 kOsAll,
1007 SINGLE_VALUE_TYPE(switches::kEnableNewAutofillHeuristics)
1008 },
[email protected]a0e4b072011-08-17 01:47:071009};
[email protected]ad2a3ded2010-08-27 13:19:051010
[email protected]a314ee5a2010-10-26 21:23:281011const Experiment* experiments = kExperiments;
1012size_t num_experiments = arraysize(kExperiments);
1013
[email protected]e2ddbc92010-10-15 20:02:071014// Stores and encapsulates the little state that about:flags has.
1015class FlagsState {
1016 public:
1017 FlagsState() : needs_restart_(false) {}
1018 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
1019 bool IsRestartNeededToCommitChanges();
1020 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:281021 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:071022 void RemoveFlagsSwitches(
1023 std::map<std::string, CommandLine::StringType>* switch_list);
1024 void reset();
1025
1026 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:551027 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:071028 return Singleton<FlagsState>::get();
1029 }
1030
1031 private:
1032 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:531033 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:071034
1035 DISALLOW_COPY_AND_ASSIGN(FlagsState);
1036};
1037
[email protected]c7b7800a2010-10-07 18:51:351038// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:051039// in a set.
[email protected]1a47d7e2010-10-15 00:37:241040void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:051041 const ListValue* enabled_experiments = prefs->GetList(
1042 prefs::kEnabledLabsExperiments);
1043 if (!enabled_experiments)
1044 return;
1045
1046 for (ListValue::const_iterator it = enabled_experiments->begin();
1047 it != enabled_experiments->end();
1048 ++it) {
1049 std::string experiment_name;
1050 if (!(*it)->GetAsString(&experiment_name)) {
1051 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
1052 continue;
1053 }
1054 result->insert(experiment_name);
1055 }
1056}
1057
1058// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:241059void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:051060 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:381061 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
1062 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:051063
1064 experiments_list->Clear();
1065 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
1066 it != enabled_experiments.end();
1067 ++it) {
1068 experiments_list->Append(new StringValue(*it));
1069 }
1070}
1071
[email protected]8a6ff28d2010-12-02 16:35:191072// Returns the name used in prefs for the choice at the specified index.
1073std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:341074 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
1075 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:191076 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
1077 base::IntToString(index);
1078}
1079
1080// Adds the internal names for the specified experiment to |names|.
1081void AddInternalName(const Experiment& e, std::set<std::string>* names) {
1082 if (e.type == Experiment::SINGLE_VALUE) {
1083 names->insert(e.internal_name);
1084 } else {
[email protected]2ce9c89752011-02-25 18:24:341085 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:191086 for (int i = 0; i < e.num_choices; ++i)
1087 names->insert(NameForChoice(e, i));
1088 }
1089}
1090
[email protected]28e35af2011-02-09 12:56:221091// Confirms that an experiment is valid, used in a DCHECK in
1092// SanitizeList below.
1093bool ValidateExperiment(const Experiment& e) {
1094 switch (e.type) {
1095 case Experiment::SINGLE_VALUE:
1096 DCHECK_EQ(0, e.num_choices);
1097 DCHECK(!e.choices);
1098 break;
1099 case Experiment::MULTI_VALUE:
1100 DCHECK_GT(e.num_choices, 0);
1101 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:531102 DCHECK(e.choices[0].command_line_switch);
1103 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:221104 break;
1105 default:
1106 NOTREACHED();
1107 }
1108 return true;
1109}
1110
[email protected]ad2a3ded2010-08-27 13:19:051111// Removes all experiments from prefs::kEnabledLabsExperiments that are
1112// unknown, to prevent this list to become very long as experiments are added
1113// and removed.
1114void SanitizeList(PrefService* prefs) {
1115 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:221116 for (size_t i = 0; i < num_experiments; ++i) {
1117 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:191118 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:221119 }
[email protected]ad2a3ded2010-08-27 13:19:051120
1121 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241122 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051123
1124 std::set<std::string> new_enabled_experiments;
1125 std::set_intersection(
1126 known_experiments.begin(), known_experiments.end(),
1127 enabled_experiments.begin(), enabled_experiments.end(),
1128 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1129
[email protected]4c8853f2012-07-23 01:29:161130 if (new_enabled_experiments != enabled_experiments)
1131 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051132}
1133
[email protected]1a47d7e2010-10-15 00:37:241134void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:051135 PrefService* prefs, std::set<std::string>* result) {
1136 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:241137 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:051138}
1139
[email protected]a314ee5a2010-10-26 21:23:281140// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
1141// enabled on the current platform.
1142void GetSanitizedEnabledFlagsForCurrentPlatform(
1143 PrefService* prefs, std::set<std::string>* result) {
1144 GetSanitizedEnabledFlags(prefs, result);
1145
1146 // Filter out any experiments that aren't enabled on the current platform. We
1147 // don't remove these from prefs else syncing to a platform with a different
1148 // set of experiments would be lossy.
1149 std::set<std::string> platform_experiments;
1150 int current_platform = GetCurrentPlatform();
1151 for (size_t i = 0; i < num_experiments; ++i) {
1152 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:191153 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:281154 }
1155
1156 std::set<std::string> new_enabled_experiments;
1157 std::set_intersection(
1158 platform_experiments.begin(), platform_experiments.end(),
1159 result->begin(), result->end(),
1160 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1161
1162 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051163}
1164
[email protected]8a6ff28d2010-12-02 16:35:191165// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:191166Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:221167 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:341168 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:191169 ListValue* result = new ListValue;
1170 for (int i = 0; i < experiment.num_choices; ++i) {
1171 const Experiment::Choice& choice = experiment.choices[i];
1172 DictionaryValue* value = new DictionaryValue;
1173 std::string name = NameForChoice(experiment, i);
1174 value->SetString("description",
1175 l10n_util::GetStringUTF16(choice.description_id));
1176 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:221177 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:191178 result->Append(value);
1179 }
1180 return result;
1181}
1182
[email protected]e2ddbc92010-10-15 20:02:071183} // namespace
1184
[email protected]1a47d7e2010-10-15 00:37:241185void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:551186 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:051187}
1188
[email protected]1a47d7e2010-10-15 00:37:241189ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:051190 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241191 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051192
1193 int current_platform = GetCurrentPlatform();
1194
1195 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:281196 for (size_t i = 0; i < num_experiments; ++i) {
1197 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:051198
1199 DictionaryValue* data = new DictionaryValue();
1200 data->SetString("internal_name", experiment.internal_name);
1201 data->SetString("name",
1202 l10n_util::GetStringUTF16(experiment.visible_name_id));
1203 data->SetString("description",
1204 l10n_util::GetStringUTF16(
1205 experiment.visible_description_id));
[email protected]cc3e2052011-12-20 01:01:401206 bool supported = !!(experiment.supported_platforms & current_platform);
1207 data->SetBoolean("supported", supported);
1208
1209 ListValue* supported_platforms = new ListValue();
1210 AddOsStrings(experiment.supported_platforms, supported_platforms);
1211 data->Set("supported_platforms", supported_platforms);
[email protected]ad2a3ded2010-08-27 13:19:051212
[email protected]28e35af2011-02-09 12:56:221213 switch (experiment.type) {
1214 case Experiment::SINGLE_VALUE:
1215 data->SetBoolean(
1216 "enabled",
1217 enabled_experiments.count(experiment.internal_name) > 0);
1218 break;
1219 case Experiment::MULTI_VALUE:
1220 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
1221 break;
1222 default:
1223 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:191224 }
1225
[email protected]ad2a3ded2010-08-27 13:19:051226 experiments_data->Append(data);
1227 }
1228 return experiments_data;
1229}
1230
[email protected]ad2a3ded2010-08-27 13:19:051231bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:551232 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:051233}
1234
1235void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:351236 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:551237 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:071238}
1239
1240void RemoveFlagsSwitches(
1241 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:551242 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:071243}
1244
[email protected]a314ee5a2010-10-26 21:23:281245int GetCurrentPlatform() {
1246#if defined(OS_MACOSX)
1247 return kOsMac;
1248#elif defined(OS_WIN)
1249 return kOsWin;
1250#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
1251 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:211252#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:281253 return kOsLinux;
[email protected]9c7453d2012-01-21 00:45:401254#elif defined(OS_ANDROID)
1255 return kOsAndroid;
[email protected]a314ee5a2010-10-26 21:23:281256#else
1257#error Unknown platform
1258#endif
1259}
1260
[email protected]4bc5050c2010-11-18 17:55:541261void RecordUMAStatistics(const PrefService* prefs) {
1262 std::set<std::string> flags;
1263 GetEnabledFlags(prefs, &flags);
1264 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
1265 ++it) {
1266 std::string action("AboutFlags_");
1267 action += *it;
[email protected]7f6f44c2011-12-14 13:23:381268 content::RecordComputedAction(action);
[email protected]4bc5050c2010-11-18 17:55:541269 }
1270 // Since flag metrics are recorded every startup, add a tick so that the
1271 // stats can be made meaningful.
1272 if (flags.size())
[email protected]7f6f44c2011-12-14 13:23:381273 content::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
1274 content::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:541275}
1276
[email protected]e2ddbc92010-10-15 20:02:071277//////////////////////////////////////////////////////////////////////////////
1278// FlagsState implementation.
1279
1280namespace {
1281
1282void FlagsState::ConvertFlagsToSwitches(
1283 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:071284 if (command_line->HasSwitch(switches::kNoExperiments))
1285 return;
1286
1287 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:001288
[email protected]a314ee5a2010-10-26 21:23:281289 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:071290
[email protected]a82744532011-02-11 16:15:531291 typedef std::map<std::string, std::pair<std::string, std::string> >
1292 NameToSwitchAndValueMap;
1293 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:191294 for (size_t i = 0; i < num_experiments; ++i) {
1295 const Experiment& e = experiments[i];
1296 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:531297 name_to_switch_map[e.internal_name] =
1298 std::pair<std::string, std::string>(e.command_line_switch,
1299 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191300 } else {
1301 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:531302 name_to_switch_map[NameForChoice(e, j)] =
1303 std::pair<std::string, std::string>(
1304 e.choices[j].command_line_switch,
1305 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191306 }
1307 }
[email protected]e2ddbc92010-10-15 20:02:071308
1309 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:531310 flags_switches_.insert(
1311 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
1312 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071313 for (std::set<std::string>::iterator it = enabled_experiments.begin();
1314 it != enabled_experiments.end();
1315 ++it) {
1316 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:531317 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:191318 name_to_switch_map.find(experiment_name);
1319 if (name_to_switch_it == name_to_switch_map.end()) {
1320 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:071321 continue;
[email protected]8a6ff28d2010-12-02 16:35:191322 }
[email protected]e2ddbc92010-10-15 20:02:071323
[email protected]a82744532011-02-11 16:15:531324 const std::pair<std::string, std::string>&
1325 switch_and_value_pair = name_to_switch_it->second;
1326
1327 command_line->AppendSwitchASCII(switch_and_value_pair.first,
1328 switch_and_value_pair.second);
1329 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:071330 }
1331 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:531332 flags_switches_.insert(
1333 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
1334 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071335}
1336
1337bool FlagsState::IsRestartNeededToCommitChanges() {
1338 return needs_restart_;
1339}
1340
1341void FlagsState::SetExperimentEnabled(
1342 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:051343 needs_restart_ = true;
1344
[email protected]8a6ff28d2010-12-02 16:35:191345 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
1346 if (at_index != std::string::npos) {
1347 DCHECK(enable);
1348 // We're being asked to enable a multi-choice experiment. Disable the
1349 // currently selected choice.
1350 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:221351 const std::string experiment_name = internal_name.substr(0, at_index);
1352 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:191353
[email protected]28e35af2011-02-09 12:56:221354 // And enable the new choice, if it is not the default first choice.
1355 if (internal_name != experiment_name + "@0") {
1356 std::set<std::string> enabled_experiments;
1357 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
1358 enabled_experiments.insert(internal_name);
1359 SetEnabledFlags(prefs, enabled_experiments);
1360 }
[email protected]8a6ff28d2010-12-02 16:35:191361 return;
1362 }
1363
[email protected]ad2a3ded2010-08-27 13:19:051364 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241365 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051366
[email protected]8a6ff28d2010-12-02 16:35:191367 const Experiment* e = NULL;
1368 for (size_t i = 0; i < num_experiments; ++i) {
1369 if (experiments[i].internal_name == internal_name) {
1370 e = experiments + i;
1371 break;
1372 }
1373 }
1374 DCHECK(e);
1375
1376 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:591377 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:191378 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:591379 else
[email protected]8a6ff28d2010-12-02 16:35:191380 enabled_experiments.erase(internal_name);
1381 } else {
1382 if (enable) {
1383 // Enable the first choice.
1384 enabled_experiments.insert(NameForChoice(*e, 0));
1385 } else {
1386 // Find the currently enabled choice and disable it.
1387 for (int i = 0; i < e->num_choices; ++i) {
1388 std::string choice_name = NameForChoice(*e, i);
1389 if (enabled_experiments.find(choice_name) !=
1390 enabled_experiments.end()) {
1391 enabled_experiments.erase(choice_name);
1392 // Continue on just in case there's a bug and more than one
1393 // experiment for this choice was enabled.
1394 }
1395 }
1396 }
1397 }
[email protected]ad2a3ded2010-08-27 13:19:051398
[email protected]1a47d7e2010-10-15 00:37:241399 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051400}
1401
[email protected]e2ddbc92010-10-15 20:02:071402void FlagsState::RemoveFlagsSwitches(
1403 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:531404 for (std::map<std::string, std::string>::const_iterator
1405 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
1406 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:071407 }
1408}
1409
1410void FlagsState::reset() {
1411 needs_restart_ = false;
1412 flags_switches_.clear();
1413}
1414
[email protected]38e46812011-05-09 20:49:221415} // namespace
[email protected]e2ddbc92010-10-15 20:02:071416
1417namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:191418
1419// WARNING: '@' is also used in the html file. If you update this constant you
1420// also need to update the html file.
1421const char kMultiSeparator[] = "@";
1422
[email protected]e2ddbc92010-10-15 20:02:071423void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:551424 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:071425}
[email protected]a314ee5a2010-10-26 21:23:281426
1427void SetExperiments(const Experiment* e, size_t count) {
1428 if (!e) {
1429 experiments = kExperiments;
1430 num_experiments = arraysize(kExperiments);
1431 } else {
1432 experiments = e;
1433 num_experiments = count;
1434 }
1435}
1436
[email protected]8a6ff28d2010-12-02 16:35:191437const Experiment* GetExperiments(size_t* count) {
1438 *count = num_experiments;
1439 return experiments;
1440}
1441
[email protected]e2ddbc92010-10-15 20:02:071442} // namespace testing
1443
[email protected]1a47d7e2010-10-15 00:37:241444} // namespace about_flags