blob: 5d4d65f1753950aea1d74cb49803f87471a5b32e [file] [log] [blame]
[email protected]9c66adc2012-01-05 02:10:161// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ad2a3ded2010-08-27 13:19:052// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]1a47d7e2010-10-15 00:37:245#include "chrome/browser/about_flags.h"
[email protected]ad2a3ded2010-08-27 13:19:056
7#include <algorithm>
8#include <iterator>
9#include <map>
10#include <set>
11
[email protected]ad2a3ded2010-08-27 13:19:0512#include "base/command_line.h"
[email protected]3b63f8f42011-03-28 01:54:1513#include "base/memory/singleton.h"
[email protected]8a6ff28d2010-12-02 16:35:1914#include "base/string_number_conversions.h"
[email protected]d208f4d82011-05-23 21:52:0315#include "base/utf_string_conversions.h"
[email protected]ad2a3ded2010-08-27 13:19:0516#include "base/values.h"
[email protected]ad2a3ded2010-08-27 13:19:0517#include "chrome/browser/prefs/pref_service.h"
[email protected]1bc78422011-03-31 08:41:3818#include "chrome/browser/prefs/scoped_user_pref_update.h"
[email protected]d208f4d82011-05-23 21:52:0319#include "chrome/common/chrome_content_client.h"
[email protected]ad2a3ded2010-08-27 13:19:0520#include "chrome/common/chrome_switches.h"
21#include "chrome/common/pref_names.h"
[email protected]7f6f44c2011-12-14 13:23:3822#include "content/public/browser/user_metrics.h"
[email protected]ad2a3ded2010-08-27 13:19:0523#include "grit/generated_resources.h"
[email protected]c051a1b2011-01-21 23:30:1724#include "ui/base/l10n/l10n_util.h"
[email protected]c9c73ad42012-04-18 03:35:5925#include "ui/base/ui_base_switches.h"
[email protected]c9e2cbbb2012-05-12 21:17:2726#include "ui/gl/gl_switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0527
[email protected]dc04be7c2012-03-15 23:57:4928#if defined(USE_ASH)
[email protected]b65bdda2011-12-23 23:35:3129#include "ash/ash_switches.h"
[email protected]dc04be7c2012-03-15 23:57:4930#endif
31
32#if defined(USE_AURA)
[email protected]308aaa32012-03-12 13:14:5033#include "ui/aura/aura_switches.h"
[email protected]8cc10df2011-11-03 23:57:5034#endif
35
[email protected]7f6f44c2011-12-14 13:23:3836using content::UserMetricsAction;
37
[email protected]1a47d7e2010-10-15 00:37:2438namespace about_flags {
[email protected]ad2a3ded2010-08-27 13:19:0539
[email protected]8a6ff28d2010-12-02 16:35:1940// Macros to simplify specifying the type.
[email protected]a82744532011-02-11 16:15:5341#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
42 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0
43#define SINGLE_VALUE_TYPE(command_line_switch) \
44 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
45#define MULTI_VALUE_TYPE(choices) \
[email protected]0e6f56d2011-02-12 23:45:1546 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices)
[email protected]8a6ff28d2010-12-02 16:35:1947
[email protected]e2ddbc92010-10-15 20:02:0748namespace {
49
[email protected]9c7453d2012-01-21 00:45:4050const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS | kOsAndroid;
[email protected]ad2a3ded2010-08-27 13:19:0551
[email protected]cc3e2052011-12-20 01:01:4052// Adds a |StringValue| to |list| for each platform where |bitmask| indicates
53// whether the experiment is available on that platform.
54void AddOsStrings(unsigned bitmask, ListValue* list) {
55 struct {
56 unsigned bit;
57 const char* const name;
58 } kBitsToOs[] = {
59 {kOsMac, "Mac"},
60 {kOsWin, "Windows"},
61 {kOsLinux, "Linux"},
62 {kOsCrOS, "Chrome OS"},
63 };
64 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i)
65 if (bitmask & kBitsToOs[i].bit)
66 list->Append(new StringValue(kBitsToOs[i].name));
67}
68
[email protected]ba8164242010-11-16 21:31:0069// Names for former Chrome OS Labs experiments, shared with prefs migration
70// code.
71const char kMediaPlayerExperimentName[] = "media-player";
72const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
73const char kVerticalTabsExperimentName[] = "vertical-tabs";
74
[email protected]032d5e6c2012-02-17 17:53:5575const Experiment::Choice kOmniboxInlineHistoryQuickProviderChoices[] = {
76 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_AUTOMATIC, "", "" },
77 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_ALLOWED,
78 switches::kOmniboxInlineHistoryQuickProvider,
79 switches::kOmniboxInlineHistoryQuickProviderAllowed },
80 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_PROHIBITED,
81 switches::kOmniboxInlineHistoryQuickProvider,
82 switches::kOmniboxInlineHistoryQuickProviderProhibited }
83};
84
[email protected]72787e392012-03-23 05:55:4385const Experiment::Choice kThreadedCompositingModeChoices[] = {
86 { IDS_FLAGS_THREADED_COMPOSITING_MODE_DEFAULT, "", "" },
87 { IDS_FLAGS_THREADED_COMPOSITING_MODE_DISABLED,
88 switches::kDisableThreadedCompositing, ""},
89 { IDS_FLAGS_THREADED_COMPOSITING_MODE_ENABLED,
90 switches::kEnableThreadedCompositing, ""}
91};
92
[email protected]347a0c72012-05-14 20:28:0693const Experiment::Choice kTouchOptimizedUIChoices[] = {
94 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_AUTOMATIC, "", "" },
95 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_ENABLED,
96 switches::kTouchOptimizedUI,
97 switches::kTouchOptimizedUIEnabled },
98 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_DISABLED,
99 switches::kTouchOptimizedUI,
100 switches::kTouchOptimizedUIDisabled }
101};
102
103
[email protected]4bc5050c2010-11-18 17:55:54104// RECORDING USER METRICS FOR FLAGS:
105// -----------------------------------------------------------------------------
106// The first line of the experiment is the internal name. If you'd like to
107// gather statistics about the usage of your flag, you should append a marker
108// comment to the end of the feature name, like so:
109// "my-special-feature", // FLAGS:RECORD_UMA
110//
111// After doing that, run //chrome/tools/extract_actions.py (see instructions at
112// the top of that file for details) to update the chromeactions.txt file, which
113// will enable UMA to record your feature flag.
114//
115// After your feature has shipped under a flag, you can locate the metrics
116// under the action name AboutFlags_internal-action-name. Actions are recorded
117// once per startup, so you should divide this number by AboutFlags_StartupTick
118// to get a sense of usage. Note that this will not be the same as number of
119// users with a given feature enabled because users can quit and relaunch
120// the application multiple times over a given time interval.
121// TODO(rsesek): See if there's a way to count per-user, rather than
122// per-startup.
123
[email protected]8a6ff28d2010-12-02 16:35:19124// To add a new experiment add to the end of kExperiments. There are two
125// distinct types of experiments:
126// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
127// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:22128// . MULTI_VALUE: a list of choices, the first of which should correspond to a
129// deactivated state for this lab (i.e. no command line option). To specify
130// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
131// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:19132// See the documentation of Experiment for details on the fields.
133//
134// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:05135const Experiment kExperiments[] = {
136 {
[email protected]aac169d2011-03-18 19:53:03137 "expose-for-tabs", // FLAGS:RECORD_UMA
138 IDS_FLAGS_TABPOSE_NAME,
139 IDS_FLAGS_TABPOSE_DESCRIPTION,
140 kOsMac,
141#if defined(OS_MACOSX)
142 // The switch exists only on OS X.
143 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
144#else
145 SINGLE_VALUE_TYPE("")
146#endif
147 },
148 {
[email protected]4bc5050c2010-11-18 17:55:54149 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05150 IDS_FLAGS_CONFLICTS_CHECK_NAME,
151 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
152 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19153 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05154 },
155 {
[email protected]4bc5050c2010-11-18 17:55:54156 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]dae7325b2011-12-21 20:56:54157 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME,
158 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45159 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22160 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31161 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22162 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
163 // always have PDF rasterization available, so no flag needed there.
164#if !defined(GOOGLE_CHROME_BUILD)
165 kOsWin,
166#else
167 0,
[email protected]fa6d2a2f2010-11-30 21:47:19168#endif
[email protected]8a6ff28d2010-12-02 16:35:19169 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42170 },
[email protected]580939a2010-10-12 18:54:37171 {
[email protected]bb461532010-11-26 21:50:23172 "crxless-web-apps",
173 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
174 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
175 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19176 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23177 },
178 {
[email protected]96c6f4c2011-05-18 19:36:22179 "ignore-gpu-blacklist",
180 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
181 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
182 kOsAll,
183 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
184 },
185 {
[email protected]0110cf112011-07-02 00:39:43186 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22187 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
188 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
189 kOsAll,
190 SINGLE_VALUE_TYPE(switches::kForceCompositingMode)
191 },
192 {
[email protected]72787e392012-03-23 05:55:43193 "threaded-compositing-mode",
194 IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME,
195 IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59196 kOsAll,
[email protected]72787e392012-03-23 05:55:43197 MULTI_VALUE_TYPE(kThreadedCompositingModeChoices)
[email protected]644a1072012-03-16 09:29:59198 },
199 {
[email protected]efcde132012-05-30 01:05:18200 "disable-threaded-animation",
201 IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME,
202 IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59203 kOsAll,
[email protected]efcde132012-05-30 01:05:18204 SINGLE_VALUE_TYPE(switches::kDisableThreadedAnimation)
[email protected]644a1072012-03-16 09:29:59205 },
206 {
[email protected]5963b772011-02-09 22:55:38207 "composited-layer-borders",
208 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
209 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
210 kOsAll,
211 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
212 },
213 {
[email protected]a8f1eaa2011-03-07 19:00:58214 "show-fps-counter",
215 IDS_FLAGS_SHOW_FPS_COUNTER,
216 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
217 kOsAll,
218 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
219 },
[email protected]8ff7f342011-05-25 01:49:47220 {
[email protected]70c98a332011-12-21 20:51:52221 "accelerated-filters",
222 IDS_FLAGS_ACCELERATED_FILTERS,
223 IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION,
224 kOsAll,
225 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters)
226 },
227 {
[email protected]8ff7f342011-05-25 01:49:47228 "disable-gpu-vsync",
229 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
230 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
231 kOsAll,
232 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
233 },
[email protected]deaba6d52011-09-23 14:47:12234 {
235 "disable-webgl",
236 IDS_FLAGS_DISABLE_WEBGL_NAME,
237 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
238 kOsAll,
239 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
240 },
[email protected]09096e02012-05-24 11:12:04241 {
242 "enable-browser-plugin",
243 IDS_FLAGS_ENABLE_BROWSER_PLUGIN_NAME,
244 IDS_FLAGS_ENABLE_BROWSER_PLUGIN_DESCRIPTION,
245 kOsAll,
246 SINGLE_VALUE_TYPE(switches::kEnableBrowserPlugin)
247 },
[email protected]96bcdc102012-05-24 23:42:10248 {
249 "fixed-position-creates-stacking-context",
250 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_NAME,
251 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_DESCRIPTION,
252 kOsAll,
253 SINGLE_VALUE_TYPE(switches::kFixedPositionCreatesStackingContext)
254 },
[email protected]d208f4d82011-05-23 21:52:03255 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53256 {
[email protected]e3791ce92011-08-09 01:03:32257 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40258 IDS_FLAGS_ENABLE_NACL_NAME,
259 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
260 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19261 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40262 },
[email protected]b39c6d92012-01-31 16:38:41263 // TODO(halyavin): When exception handling is on by default, replace this
264 // flag with disable-nacl-exception-handling.
265 {
266 "enable-nacl-exception-handling", // FLAGS:RECORD_UMA
267 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME,
268 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION,
269 kOsWin,
270 SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling)
271 },
[email protected]4ff87d202010-11-06 01:28:40272 {
[email protected]31a665e72012-03-11 12:37:46273 "nacl-gdb", // FLAGS:RECORD_UMA
274 IDS_FLAGS_NACL_GDB_NAME,
275 IDS_FLAGS_NACL_GDB_DESCRIPTION,
276 kOsWin,
277 SINGLE_VALUE_TYPE(switches::kNaClGdb)
278 },
279 {
[email protected]401b90792012-05-30 11:41:13280 "nacl-gdb-script", // FLAGS:RECORD_UMA
281 IDS_FLAGS_NACL_GDB_SCRIPT_NAME,
282 IDS_FLAGS_NACL_GDB_SCRIPT_DESCRIPTION,
283 kOsAll,
284 SINGLE_VALUE_TYPE(switches::kNaClGdbScript)
285 },
286 {
[email protected]4bc5050c2010-11-18 17:55:54287 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32288 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
289 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
290 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19291 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32292 },
[email protected]3627b06d2010-11-12 16:36:16293 {
[email protected]cab18ef2012-04-27 07:22:03294 "action-box",
295 IDS_FLAGS_ACTION_BOX_NAME,
296 IDS_FLAGS_ACTION_BOX_DESCRIPTION,
297 kOsAll,
298 SINGLE_VALUE_TYPE(switches::kEnableActionBox),
299 },
300 {
[email protected]cbe224d2011-08-04 22:12:49301 "apps-new-install-bubble",
302 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
303 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
304 kOsAll,
305 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
306 },
307 {
[email protected]80bd24e2010-11-30 09:34:38308 "disable-hyperlink-auditing",
309 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
310 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
311 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19312 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51313 },
314 {
315 "experimental-location-features", // FLAGS:RECORD_UMA
316 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
317 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
318 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19319 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
320 },
321 {
[email protected]04227962011-01-20 02:03:09322 "disable-interactive-form-validation",
323 IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_NAME,
324 IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_DESCRIPTION,
325 kOsAll,
326 SINGLE_VALUE_TYPE(switches::kDisableInteractiveFormValidation)
327 },
[email protected]8df51192011-01-22 20:05:03328 {
[email protected]07d490bc2011-03-07 17:05:26329 "focus-existing-tab-on-open", // FLAGS:RECORD_UMA
330 IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_NAME,
331 IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_DESCRIPTION,
332 kOsAll,
333 SINGLE_VALUE_TYPE(switches::kFocusExistingTabOnOpen)
334 },
[email protected]d5dcfb32011-03-19 00:49:24335 {
[email protected]5aea1862011-03-23 23:55:39336 "tab-groups-context-menu",
337 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
338 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
339 kOsWin,
340 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
341 },
[email protected]e9bf9d92011-03-31 20:57:15342 {
[email protected]354e33b2011-06-15 00:29:10343 "static-ip-config",
344 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
345 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
346 kOsCrOS,
347#if defined(OS_CHROMEOS)
348 // This switch exists only on Chrome OS.
349 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
350#else
351 SINGLE_VALUE_TYPE("")
352#endif
353 },
[email protected]3eb5728c2011-06-20 22:32:24354 {
355 "show-autofill-type-predictions",
356 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
357 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
358 kOsAll,
359 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
360 },
[email protected]bff4d3e2011-06-21 23:58:52361 {
[email protected]fdf4e252012-04-27 00:26:55362 "sync-tab-favicons",
363 IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
364 IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
365 kOsAll,
366 SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
367 },
368 {
[email protected]aae9eeb12011-10-21 21:59:26369 "sync-app-notifications",
370 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
371 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
372 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11373 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26374 },
375 {
[email protected]a22ebd812011-06-23 00:05:39376 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
377 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
378 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
379 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40380 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40381 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39382 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
383 },
[email protected]81a6b0b2011-06-24 17:55:40384 {
[email protected]032d5e6c2012-02-17 17:53:55385 "omnibox-inline-history-quick-provider",
386 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME,
387 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION,
388 kOsAll,
389 MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices)
390 },
391 {
[email protected]7e7a28092011-12-09 22:24:55392 "enable-panels",
393 IDS_FLAGS_ENABLE_PANELS_NAME,
394 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54395 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55396 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54397 },
[email protected]e3749d12011-07-25 22:22:12398 {
[email protected]9931875b2011-11-02 00:19:48399 "disable-shortcuts-provider",
400 IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER,
401 IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER_DESCRIPTION,
[email protected]e3749d12011-07-25 22:22:12402 kOsAll,
[email protected]9931875b2011-11-02 00:19:48403 SINGLE_VALUE_TYPE(switches::kDisableShortcutsProvider)
[email protected]e3749d12011-07-25 22:22:12404 },
[email protected]80eb4262011-08-03 16:10:41405 {
[email protected]a0e4b072011-08-17 01:47:07406 "downloads-new-ui", // FLAGS:RECORD_UMA
407 IDS_FLAGS_DOWNLOADS_NEW_UI_NAME,
408 IDS_FLAGS_DOWNLOADS_NEW_UI_DESCRIPTION,
409 kOsAll,
410 SINGLE_VALUE_TYPE(switches::kDownloadsNewUI)
411 },
[email protected]b7bb44f2011-09-01 05:17:03412 {
[email protected]6474b112012-05-04 19:35:27413 "save-page-as-mhtml", // FLAGS:RECORD_UMA
414 IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME,
415 IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION,
416 kOsMac | kOsWin | kOsLinux,
417 SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)
418 },
419 {
[email protected]b7bb44f2011-09-01 05:17:03420 "enable-autologin",
421 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
422 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
423 kOsMac | kOsWin | kOsLinux,
424 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
425 },
[email protected]b9841172011-09-26 23:36:09426 {
[email protected]bbadb112011-12-12 16:55:28427 "enable-http-pipelining",
428 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
429 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
430 kOsAll,
431 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
432 },
[email protected]d411c01d2011-10-18 16:00:27433 {
[email protected]3231b612012-03-23 05:57:54434 "enable-spdy3",
435 IDS_FLAGS_ENABLE_SPDY3_NAME,
436 IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION,
437 kOsAll,
438 SINGLE_VALUE_TYPE(switches::kEnableSpdy3)
439 },
440 {
[email protected]27b3fe92012-03-21 05:35:06441 "enable-async-dns",
442 IDS_FLAGS_ENABLE_ASYNC_DNS_NAME,
443 IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32444 kOsWin | kOsMac | kOsLinux | kOsCrOS,
[email protected]27b3fe92012-03-21 05:35:06445 SINGLE_VALUE_TYPE(switches::kEnableAsyncDns)
446 },
447 {
[email protected]f5da41d2011-10-08 17:40:07448 "enable-video-track",
449 IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME,
450 IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION,
451 kOsAll,
452 SINGLE_VALUE_TYPE(switches::kEnableVideoTrack)
453 },
[email protected]08b83362011-10-19 05:23:17454 {
[email protected]6aa03b32011-10-27 21:44:44455 "enable-media-source",
456 IDS_FLAGS_ENABLE_MEDIA_SOURCE_NAME,
457 IDS_FLAGS_ENABLE_MEDIA_SOURCE_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32458 kOsAll,
[email protected]6aa03b32011-10-27 21:44:44459 SINGLE_VALUE_TYPE(switches::kEnableMediaSource)
460 },
[email protected]e4e68dbb2011-11-18 01:50:22461 {
[email protected]9f5b7822012-04-18 23:39:03462 "enable-encrypted-media",
463 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME,
464 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION,
465 kOsAll,
466 SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia)
467 },
468 {
[email protected]e4e68dbb2011-11-18 01:50:22469 "enable-pointer-lock",
470 IDS_FLAGS_ENABLE_POINTER_LOCK_NAME,
471 IDS_FLAGS_ENABLE_POINTER_LOCK_DESCRIPTION,
472 kOsAll,
473 SINGLE_VALUE_TYPE(switches::kEnablePointerLock)
474 },
[email protected]dc04be7c2012-03-15 23:57:49475#if defined(USE_ASH)
[email protected]8cc10df2011-11-03 23:57:50476 {
[email protected]57b8bb352012-01-11 05:11:46477 "aura-google-dialog-frames",
478 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME,
479 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION,
480 kOsWin | kOsLinux | kOsCrOS,
481 SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames)
482 },
[email protected]dc04be7c2012-03-15 23:57:49483#endif
484#if defined(USE_AURA)
[email protected]308aaa32012-03-12 13:14:50485 {
486 "aura-disable-hold-mouse-moves",
487 IDS_FLAGS_AURA_DISABLE_HOLD_MOUSE_MOVES_NAME,
488 IDS_FLAGS_AURA_DISABLE_HOLD_MOUSE_MOVES_DESCRIPTION,
489 kOsWin | kOsLinux | kOsCrOS,
490 SINGLE_VALUE_TYPE(switches::kAuraDisableHoldMouseMoves)
491 },
[email protected]eaae8b462012-01-20 22:20:39492#endif // defined(USE_AURA)
493 {
494 "enable-gamepad",
495 IDS_FLAGS_ENABLE_GAMEPAD_NAME,
496 IDS_FLAGS_ENABLE_GAMEPAD_DESCRIPTION,
497 kOsAll,
498 SINGLE_VALUE_TYPE(switches::kEnableGamepad)
499 },
[email protected]db543d322011-12-15 20:40:15500 {
501 "per-tile-painting",
502 IDS_FLAGS_PER_TILE_PAINTING_NAME,
503 IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION,
504#if defined(USE_SKIA)
[email protected]a5b1b272012-01-06 20:44:37505 kOsMac | kOsLinux | kOsCrOS,
[email protected]db543d322011-12-15 20:40:15506#else
507 0,
508#endif
509 SINGLE_VALUE_TYPE(switches::kEnablePerTilePainting)
510 },
[email protected]bf88c032011-12-22 19:05:47511 {
512 "enable-javascript-harmony",
513 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME,
514 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION,
515 kOsAll,
516 SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony")
517 },
[email protected]7e7f378a2012-01-05 14:35:37518 {
[email protected]85646172012-01-09 22:45:54519 "enable-tab-browser-dragging",
520 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME,
521 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION,
522 kOsWin,
523 SINGLE_VALUE_TYPE(switches::kTabBrowserDragging)
524 },
525 {
[email protected]068b7b52012-02-27 12:41:44526 "disable-restore-session-state",
527 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME,
528 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION,
[email protected]7e7f378a2012-01-05 14:35:37529 kOsAll,
[email protected]068b7b52012-02-27 12:41:44530 SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState)
[email protected]7e7f378a2012-01-05 14:35:37531 },
[email protected]88864db2012-01-18 20:56:35532 {
533 "disable-software-rasterizer",
534 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME,
535 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION,
536#if defined(ENABLE_SWIFTSHADER)
537 kOsAll,
538#else
539 0,
540#endif
541 SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer)
542 },
[email protected]15a5d722012-01-23 09:11:14543 {
[email protected]8ea05a12012-05-02 09:17:47544 "enable-peer-connection",
545 IDS_FLAGS_PEER_CONNECTION_NAME,
546 IDS_FLAGS_PEER_CONNECTION_DESCRIPTION,
547 kOsAll,
548 SINGLE_VALUE_TYPE(switches::kEnablePeerConnection)
549 },
550 {
[email protected]d2edc6702012-01-30 09:13:16551 "enable-shadow-dom",
552 IDS_FLAGS_SHADOW_DOM_NAME,
553 IDS_FLAGS_SHADOW_DOM_DESCRIPTION,
554 kOsAll,
555 SINGLE_VALUE_TYPE(switches::kEnableShadowDOM)
556 },
[email protected]9860c68b2012-02-02 01:58:09557 {
[email protected]4961218f2012-02-23 10:11:07558 "enable-style-scoped",
559 IDS_FLAGS_STYLE_SCOPED_NAME,
560 IDS_FLAGS_STYLE_SCOPED_DESCRIPTION,
561 kOsAll,
562 SINGLE_VALUE_TYPE(switches::kEnableStyleScoped)
563 },
564 {
[email protected]ca7a3d792012-03-02 15:55:49565 "enable-css-regions",
566 IDS_FLAGS_CSS_REGIONS_NAME,
567 IDS_FLAGS_CSS_REGIONS_DESCRIPTION,
568 kOsAll,
569 SINGLE_VALUE_TYPE(switches::kEnableCssRegions)
570 },
571 {
[email protected]9860c68b2012-02-02 01:58:09572 "enable-extension-activity-ui",
573 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME,
574 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION,
575 kOsAll,
576 SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI)
[email protected]8bed69d2012-02-02 06:46:00577 },
[email protected]54ae4e92012-02-16 15:19:05578 {
579 "webui-task-manager",
580 IDS_FLAGS_WEBUI_TASK_MANAGER_NAME,
581 IDS_FLAGS_WEBUI_TASK_MANAGER_DESCRIPTION,
582 kOsAll,
583 SINGLE_VALUE_TYPE(switches::kWebUITaskManager)
584 },
[email protected]156f966332012-02-29 00:03:16585 {
[email protected]3e8befc2012-03-13 01:17:03586 "disable-ntp-other-sessions-menu",
[email protected]156f966332012-02-29 00:03:16587 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME,
588 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION,
589 kOsAll,
[email protected]3e8befc2012-03-13 01:17:03590 SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu)
[email protected]156f966332012-02-29 00:03:16591 },
[email protected]dc04be7c2012-03-15 23:57:49592#if defined(USE_ASH)
[email protected]31cf1c52012-02-29 20:55:01593 {
[email protected]3cd198a22012-03-12 20:38:01594 "enable-ash-oak",
595 IDS_FLAGS_ENABLE_ASH_OAK_NAME,
596 IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION,
597 kOsAll,
598 SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak),
599 },
[email protected]31cf1c52012-02-29 20:55:01600#endif
[email protected]184ec592012-03-01 11:54:28601 {
602 "enable-devtools-experiments",
603 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME,
604 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION,
605 kOsAll,
606 SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments)
607 },
[email protected]76d1854e2012-03-02 23:57:44608 {
609 "enable-suggestions-ntp",
610 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME,
611 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION,
612 kOsAll,
613 SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage)
614 },
[email protected]a78ef9e2012-03-21 02:49:55615 {
[email protected]326be0e2012-05-08 16:06:59616 "disable-chrome-to-mobile", // FLAGS:RECORD_UMA
617 IDS_FLAGS_DISABLE_CHROME_TO_MOBILE_NAME,
618 IDS_FLAGS_DISABLE_CHROME_TO_MOBILE_DESCRIPTION,
[email protected]a78ef9e2012-03-21 02:49:55619 kOsAll,
[email protected]326be0e2012-05-08 16:06:59620 SINGLE_VALUE_TYPE(switches::kDisableChromeToMobile)
[email protected]a78ef9e2012-03-21 02:49:55621 },
[email protected]db92eeb2012-05-11 18:59:20622 {
623 "enable-captive-portal-detection",
624 IDS_FLAGS_CAPTIVE_PORTAL_CHECK_ON_ERROR_NAME,
625 IDS_FLAGS_CAPTIVE_PORTAL_CHECK_ON_ERROR_DESCRIPTION,
626 kOsMac | kOsWin | kOsLinux | kOsCrOS,
627 SINGLE_VALUE_TYPE(switches::kCaptivePortalDetection)
628 },
[email protected]8e466dd2012-05-04 19:16:05629#if defined(GOOGLE_CHROME_BUILD)
[email protected]a3d54252012-04-05 20:04:13630 {
[email protected]37b928e2012-05-30 09:01:10631 "disable-asynchronous-spellchecking",
632 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING,
633 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING_DESCRIPTION,
634 kOsWin | kOsLinux | kOsCrOS,
635 SINGLE_VALUE_TYPE(switches::kDisableAsynchronousSpellChecking)
[email protected]a3d54252012-04-05 20:04:13636 },
[email protected]8e466dd2012-05-04 19:16:05637#endif
[email protected]c9c73ad42012-04-18 03:35:59638 {
639 "touch-optimized-ui",
[email protected]347a0c72012-05-14 20:28:06640 IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME,
641 IDS_FLAGS_TOUCH_OPTIMIZED_UI_DESCRIPTION,
[email protected]8ae3ef12012-05-22 18:05:52642 kOsCrOS,
[email protected]347a0c72012-05-14 20:28:06643 MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
[email protected]c9c73ad42012-04-18 03:35:59644 },
[email protected]8a6aaa72012-04-20 20:53:58645 {
646 "enable-touch-events",
647 IDS_ENABLE_TOUCH_EVENTS_NAME,
648 IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
649 kOsAll,
650 SINGLE_VALUE_TYPE(switches::kEnableTouchEvents)
651 },
[email protected]0b60afa2012-04-19 17:36:39652#if defined(OS_CHROMEOS)
653 {
654 "no-discard-tabs",
655 IDS_FLAGS_NO_DISCARD_TABS_NAME,
656 IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION,
657 kOsCrOS,
658 SINGLE_VALUE_TYPE(switches::kNoDiscardTabs)
659 },
660#endif
[email protected]79be6d32012-04-24 20:47:44661 {
[email protected]f92fce5f2012-04-24 21:05:16662 "enable-sync-signin",
[email protected]79be6d32012-04-24 20:47:44663 IDS_ENABLE_SYNC_SIGNIN_NAME,
664 IDS_ENABLE_SYNC_SIGNIN_DESCRIPTION,
665 kOsAll,
666 SINGLE_VALUE_TYPE(switches::kEnableSyncSignin)
667 },
[email protected]6d947a602012-04-24 23:12:11668 {
669 "enable-platform-apps",
670 IDS_FLAGS_ENABLE_PLATFORM_APPS_NAME,
671 IDS_FLAGS_ENABLE_PLATFORM_APPS_DESCRIPTION,
672 kOsAll,
673 SINGLE_VALUE_TYPE(switches::kEnablePlatformApps)
[email protected]9a5940d2012-04-27 19:16:23674 },
675 {
676 "allow-nacl-socket-api",
677 IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME,
678 IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION,
679 kOsAll,
680 SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*")
681 },
[email protected]85333732012-05-01 19:02:24682 {
[email protected]60673ad72012-05-02 06:16:33683 "stacked-tab-strip",
684 IDS_FLAGS_STACKED_TAB_STRIP_NAME,
685 IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION,
686 kOsWin,
687 SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip)
688 },
689 {
[email protected]85333732012-05-01 19:02:24690 "default-device-scale-factor",
691 IDS_FLAGS_FORCE_HIGH_DPI_NAME,
692 IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION,
693 kOsCrOS,
694 SINGLE_VALUE_TYPE_AND_VALUE(switches::kDefaultDeviceScaleFactor, "2")
695 },
[email protected]190349fd2012-05-02 00:10:47696#if defined(OS_CHROMEOS)
697 {
698 "allow-touchpad-three-finger-click",
699 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME,
700 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION,
701 kOsCrOS,
702 SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick)
703 },
704#endif
[email protected]aab64e02012-05-03 19:24:16705 {
706 "enable-client-oauth-signin",
707 IDS_FLAGS_ENABLE_CLIENT_OAUTH_SIGNIN_NAME,
708 IDS_FLAGS_ENABLE_CLIENT_OAUTH_SIGNIN_DESCRIPTION,
709 kOsMac | kOsWin | kOsLinux,
710 SINGLE_VALUE_TYPE(switches::kEnableClientOAuthSignin)
711 },
[email protected]53520b1b2012-05-07 21:43:37712#if defined(USE_ASH)
713 {
714 "enable-applist-v2",
715 IDS_FLAGS_ENABLE_APPLIST_V2_NAME,
716 IDS_FLAGS_ENABLE_APPLIST_V2_DESCRIPTION,
717 kOsAll,
718 SINGLE_VALUE_TYPE(ash::switches::kEnableAppListV2),
719 },
[email protected]55444502012-05-10 15:43:53720 {
721 "show-launcher-alignment-menu",
722 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_NAME,
723 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION,
724 kOsAll,
725 SINGLE_VALUE_TYPE(switches::kShowLauncherAlignmentMenu)
726 },
[email protected]817ecd12012-05-16 18:36:53727 {
[email protected]73074742012-05-17 01:44:41728 "show-touch-hud",
729 IDS_FLAGS_SHOW_TOUCH_HUD_NAME,
730 IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION,
731 kOsAll,
732 SINGLE_VALUE_TYPE(ash::switches::kAshTouchHud)
733 },
734 {
[email protected]817ecd12012-05-16 18:36:53735 "ash-notify",
736 IDS_FLAGS_ENABLE_ASH_NOTIFY_NAME,
737 IDS_FLAGS_ENABLE_ASH_NOTIFY_DESCRIPTION,
738 kOsAll,
739 SINGLE_VALUE_TYPE(ash::switches::kAshNotify),
740 },
[email protected]9f0940b62012-05-23 22:56:35741 {
742 "enable-pinch",
743 IDS_FLAGS_ENABLE_PINCH_SCALE_NAME,
744 IDS_FLAGS_ENABLE_PINCH_SCALE_DESCRIPTION,
745 kOsAll,
746 SINGLE_VALUE_TYPE(switches::kEnablePinch),
747 },
[email protected]73074742012-05-17 01:44:41748#endif // defined(USE_ASH)
[email protected]ed7b67f32012-05-28 10:12:28749#if defined(OS_CHROMEOS)
750 {
[email protected]a7668a12012-05-28 22:23:48751 "experimental-wallpaper-ui",
752 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_NAME,
753 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_DESCRIPTION,
754 kOsCrOS,
755 SINGLE_VALUE_TYPE(switches::kExperimentalWallpaperUI)
756 },
757 {
[email protected]ed7b67f32012-05-28 10:12:28758 "enable-new-oobe",
759 IDS_FLAGS_ENABLE_NEW_OOBE,
760 IDS_FLAGS_ENABLE_NEW_OOBE_DESCRIPTION,
761 kOsCrOS,
762 SINGLE_VALUE_TYPE(switches::kEnableNewOobe),
763 },
764#endif
[email protected]a0e4b072011-08-17 01:47:07765};
[email protected]ad2a3ded2010-08-27 13:19:05766
[email protected]a314ee5a2010-10-26 21:23:28767const Experiment* experiments = kExperiments;
768size_t num_experiments = arraysize(kExperiments);
769
[email protected]e2ddbc92010-10-15 20:02:07770// Stores and encapsulates the little state that about:flags has.
771class FlagsState {
772 public:
773 FlagsState() : needs_restart_(false) {}
774 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
775 bool IsRestartNeededToCommitChanges();
776 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28777 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07778 void RemoveFlagsSwitches(
779 std::map<std::string, CommandLine::StringType>* switch_list);
780 void reset();
781
782 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55783 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07784 return Singleton<FlagsState>::get();
785 }
786
787 private:
788 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53789 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07790
791 DISALLOW_COPY_AND_ASSIGN(FlagsState);
792};
793
[email protected]c7b7800a2010-10-07 18:51:35794// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:05795// in a set.
[email protected]1a47d7e2010-10-15 00:37:24796void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:05797 const ListValue* enabled_experiments = prefs->GetList(
798 prefs::kEnabledLabsExperiments);
799 if (!enabled_experiments)
800 return;
801
802 for (ListValue::const_iterator it = enabled_experiments->begin();
803 it != enabled_experiments->end();
804 ++it) {
805 std::string experiment_name;
806 if (!(*it)->GetAsString(&experiment_name)) {
807 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
808 continue;
809 }
810 result->insert(experiment_name);
811 }
812}
813
814// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:24815void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05816 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:38817 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
818 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:05819
820 experiments_list->Clear();
821 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
822 it != enabled_experiments.end();
823 ++it) {
824 experiments_list->Append(new StringValue(*it));
825 }
826}
827
[email protected]8a6ff28d2010-12-02 16:35:19828// Returns the name used in prefs for the choice at the specified index.
829std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:34830 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
831 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:19832 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
833 base::IntToString(index);
834}
835
836// Adds the internal names for the specified experiment to |names|.
837void AddInternalName(const Experiment& e, std::set<std::string>* names) {
838 if (e.type == Experiment::SINGLE_VALUE) {
839 names->insert(e.internal_name);
840 } else {
[email protected]2ce9c89752011-02-25 18:24:34841 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:19842 for (int i = 0; i < e.num_choices; ++i)
843 names->insert(NameForChoice(e, i));
844 }
845}
846
[email protected]28e35af2011-02-09 12:56:22847// Confirms that an experiment is valid, used in a DCHECK in
848// SanitizeList below.
849bool ValidateExperiment(const Experiment& e) {
850 switch (e.type) {
851 case Experiment::SINGLE_VALUE:
852 DCHECK_EQ(0, e.num_choices);
853 DCHECK(!e.choices);
854 break;
855 case Experiment::MULTI_VALUE:
856 DCHECK_GT(e.num_choices, 0);
857 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:53858 DCHECK(e.choices[0].command_line_switch);
859 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:22860 break;
861 default:
862 NOTREACHED();
863 }
864 return true;
865}
866
[email protected]ad2a3ded2010-08-27 13:19:05867// Removes all experiments from prefs::kEnabledLabsExperiments that are
868// unknown, to prevent this list to become very long as experiments are added
869// and removed.
870void SanitizeList(PrefService* prefs) {
871 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:22872 for (size_t i = 0; i < num_experiments; ++i) {
873 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:19874 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:22875 }
[email protected]ad2a3ded2010-08-27 13:19:05876
877 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24878 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05879
880 std::set<std::string> new_enabled_experiments;
881 std::set_intersection(
882 known_experiments.begin(), known_experiments.end(),
883 enabled_experiments.begin(), enabled_experiments.end(),
884 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
885
[email protected]1a47d7e2010-10-15 00:37:24886 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05887}
888
[email protected]1a47d7e2010-10-15 00:37:24889void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05890 PrefService* prefs, std::set<std::string>* result) {
891 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:24892 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:05893}
894
[email protected]a314ee5a2010-10-26 21:23:28895// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
896// enabled on the current platform.
897void GetSanitizedEnabledFlagsForCurrentPlatform(
898 PrefService* prefs, std::set<std::string>* result) {
899 GetSanitizedEnabledFlags(prefs, result);
900
901 // Filter out any experiments that aren't enabled on the current platform. We
902 // don't remove these from prefs else syncing to a platform with a different
903 // set of experiments would be lossy.
904 std::set<std::string> platform_experiments;
905 int current_platform = GetCurrentPlatform();
906 for (size_t i = 0; i < num_experiments; ++i) {
907 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:19908 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:28909 }
910
911 std::set<std::string> new_enabled_experiments;
912 std::set_intersection(
913 platform_experiments.begin(), platform_experiments.end(),
914 result->begin(), result->end(),
915 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
916
917 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05918}
919
[email protected]8a6ff28d2010-12-02 16:35:19920// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:19921Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:22922 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:34923 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:19924 ListValue* result = new ListValue;
925 for (int i = 0; i < experiment.num_choices; ++i) {
926 const Experiment::Choice& choice = experiment.choices[i];
927 DictionaryValue* value = new DictionaryValue;
928 std::string name = NameForChoice(experiment, i);
929 value->SetString("description",
930 l10n_util::GetStringUTF16(choice.description_id));
931 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:22932 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:19933 result->Append(value);
934 }
935 return result;
936}
937
[email protected]e2ddbc92010-10-15 20:02:07938} // namespace
939
[email protected]1a47d7e2010-10-15 00:37:24940void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:55941 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:05942}
943
[email protected]1a47d7e2010-10-15 00:37:24944ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:05945 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24946 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05947
948 int current_platform = GetCurrentPlatform();
949
950 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:28951 for (size_t i = 0; i < num_experiments; ++i) {
952 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:05953
954 DictionaryValue* data = new DictionaryValue();
955 data->SetString("internal_name", experiment.internal_name);
956 data->SetString("name",
957 l10n_util::GetStringUTF16(experiment.visible_name_id));
958 data->SetString("description",
959 l10n_util::GetStringUTF16(
960 experiment.visible_description_id));
[email protected]cc3e2052011-12-20 01:01:40961 bool supported = !!(experiment.supported_platforms & current_platform);
962 data->SetBoolean("supported", supported);
963
964 ListValue* supported_platforms = new ListValue();
965 AddOsStrings(experiment.supported_platforms, supported_platforms);
966 data->Set("supported_platforms", supported_platforms);
[email protected]ad2a3ded2010-08-27 13:19:05967
[email protected]28e35af2011-02-09 12:56:22968 switch (experiment.type) {
969 case Experiment::SINGLE_VALUE:
970 data->SetBoolean(
971 "enabled",
972 enabled_experiments.count(experiment.internal_name) > 0);
973 break;
974 case Experiment::MULTI_VALUE:
975 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
976 break;
977 default:
978 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:19979 }
980
[email protected]ad2a3ded2010-08-27 13:19:05981 experiments_data->Append(data);
982 }
983 return experiments_data;
984}
985
[email protected]ad2a3ded2010-08-27 13:19:05986bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:55987 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:05988}
989
990void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:35991 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:55992 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:07993}
994
995void RemoveFlagsSwitches(
996 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:55997 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:07998}
999
[email protected]a314ee5a2010-10-26 21:23:281000int GetCurrentPlatform() {
1001#if defined(OS_MACOSX)
1002 return kOsMac;
1003#elif defined(OS_WIN)
1004 return kOsWin;
1005#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
1006 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:211007#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:281008 return kOsLinux;
[email protected]9c7453d2012-01-21 00:45:401009#elif defined(OS_ANDROID)
1010 return kOsAndroid;
[email protected]a314ee5a2010-10-26 21:23:281011#else
1012#error Unknown platform
1013#endif
1014}
1015
[email protected]4bc5050c2010-11-18 17:55:541016void RecordUMAStatistics(const PrefService* prefs) {
1017 std::set<std::string> flags;
1018 GetEnabledFlags(prefs, &flags);
1019 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
1020 ++it) {
1021 std::string action("AboutFlags_");
1022 action += *it;
[email protected]7f6f44c2011-12-14 13:23:381023 content::RecordComputedAction(action);
[email protected]4bc5050c2010-11-18 17:55:541024 }
1025 // Since flag metrics are recorded every startup, add a tick so that the
1026 // stats can be made meaningful.
1027 if (flags.size())
[email protected]7f6f44c2011-12-14 13:23:381028 content::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
1029 content::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:541030}
1031
[email protected]e2ddbc92010-10-15 20:02:071032//////////////////////////////////////////////////////////////////////////////
1033// FlagsState implementation.
1034
1035namespace {
1036
1037void FlagsState::ConvertFlagsToSwitches(
1038 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:071039 if (command_line->HasSwitch(switches::kNoExperiments))
1040 return;
1041
1042 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:001043
[email protected]a314ee5a2010-10-26 21:23:281044 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:071045
[email protected]a82744532011-02-11 16:15:531046 typedef std::map<std::string, std::pair<std::string, std::string> >
1047 NameToSwitchAndValueMap;
1048 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:191049 for (size_t i = 0; i < num_experiments; ++i) {
1050 const Experiment& e = experiments[i];
1051 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:531052 name_to_switch_map[e.internal_name] =
1053 std::pair<std::string, std::string>(e.command_line_switch,
1054 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191055 } else {
1056 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:531057 name_to_switch_map[NameForChoice(e, j)] =
1058 std::pair<std::string, std::string>(
1059 e.choices[j].command_line_switch,
1060 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191061 }
1062 }
[email protected]e2ddbc92010-10-15 20:02:071063
1064 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:531065 flags_switches_.insert(
1066 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
1067 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071068 for (std::set<std::string>::iterator it = enabled_experiments.begin();
1069 it != enabled_experiments.end();
1070 ++it) {
1071 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:531072 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:191073 name_to_switch_map.find(experiment_name);
1074 if (name_to_switch_it == name_to_switch_map.end()) {
1075 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:071076 continue;
[email protected]8a6ff28d2010-12-02 16:35:191077 }
[email protected]e2ddbc92010-10-15 20:02:071078
[email protected]a82744532011-02-11 16:15:531079 const std::pair<std::string, std::string>&
1080 switch_and_value_pair = name_to_switch_it->second;
1081
1082 command_line->AppendSwitchASCII(switch_and_value_pair.first,
1083 switch_and_value_pair.second);
1084 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:071085 }
1086 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:531087 flags_switches_.insert(
1088 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
1089 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071090}
1091
1092bool FlagsState::IsRestartNeededToCommitChanges() {
1093 return needs_restart_;
1094}
1095
1096void FlagsState::SetExperimentEnabled(
1097 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:051098 needs_restart_ = true;
1099
[email protected]8a6ff28d2010-12-02 16:35:191100 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
1101 if (at_index != std::string::npos) {
1102 DCHECK(enable);
1103 // We're being asked to enable a multi-choice experiment. Disable the
1104 // currently selected choice.
1105 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:221106 const std::string experiment_name = internal_name.substr(0, at_index);
1107 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:191108
[email protected]28e35af2011-02-09 12:56:221109 // And enable the new choice, if it is not the default first choice.
1110 if (internal_name != experiment_name + "@0") {
1111 std::set<std::string> enabled_experiments;
1112 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
1113 enabled_experiments.insert(internal_name);
1114 SetEnabledFlags(prefs, enabled_experiments);
1115 }
[email protected]8a6ff28d2010-12-02 16:35:191116 return;
1117 }
1118
[email protected]ad2a3ded2010-08-27 13:19:051119 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241120 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051121
[email protected]8a6ff28d2010-12-02 16:35:191122 const Experiment* e = NULL;
1123 for (size_t i = 0; i < num_experiments; ++i) {
1124 if (experiments[i].internal_name == internal_name) {
1125 e = experiments + i;
1126 break;
1127 }
1128 }
1129 DCHECK(e);
1130
1131 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:591132 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:191133 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:591134 else
[email protected]8a6ff28d2010-12-02 16:35:191135 enabled_experiments.erase(internal_name);
1136 } else {
1137 if (enable) {
1138 // Enable the first choice.
1139 enabled_experiments.insert(NameForChoice(*e, 0));
1140 } else {
1141 // Find the currently enabled choice and disable it.
1142 for (int i = 0; i < e->num_choices; ++i) {
1143 std::string choice_name = NameForChoice(*e, i);
1144 if (enabled_experiments.find(choice_name) !=
1145 enabled_experiments.end()) {
1146 enabled_experiments.erase(choice_name);
1147 // Continue on just in case there's a bug and more than one
1148 // experiment for this choice was enabled.
1149 }
1150 }
1151 }
1152 }
[email protected]ad2a3ded2010-08-27 13:19:051153
[email protected]1a47d7e2010-10-15 00:37:241154 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051155}
1156
[email protected]e2ddbc92010-10-15 20:02:071157void FlagsState::RemoveFlagsSwitches(
1158 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:531159 for (std::map<std::string, std::string>::const_iterator
1160 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
1161 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:071162 }
1163}
1164
1165void FlagsState::reset() {
1166 needs_restart_ = false;
1167 flags_switches_.clear();
1168}
1169
[email protected]38e46812011-05-09 20:49:221170} // namespace
[email protected]e2ddbc92010-10-15 20:02:071171
1172namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:191173
1174// WARNING: '@' is also used in the html file. If you update this constant you
1175// also need to update the html file.
1176const char kMultiSeparator[] = "@";
1177
[email protected]e2ddbc92010-10-15 20:02:071178void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:551179 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:071180}
[email protected]a314ee5a2010-10-26 21:23:281181
1182void SetExperiments(const Experiment* e, size_t count) {
1183 if (!e) {
1184 experiments = kExperiments;
1185 num_experiments = arraysize(kExperiments);
1186 } else {
1187 experiments = e;
1188 num_experiments = count;
1189 }
1190}
1191
[email protected]8a6ff28d2010-12-02 16:35:191192const Experiment* GetExperiments(size_t* count) {
1193 *count = num_experiments;
1194 return experiments;
1195}
1196
[email protected]e2ddbc92010-10-15 20:02:071197} // namespace testing
1198
[email protected]1a47d7e2010-10-15 00:37:241199} // namespace about_flags