blob: 5d27dd75970932169ccd1cac043730869ea48821 [file] [log] [blame]
[email protected]3828d6f2011-02-24 18:32:211// Copyright (c) 2011 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]afd1e522011-04-27 23:29:5922#include "content/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]8ff7f342011-05-25 01:49:4725#include "ui/gfx/gl/gl_switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0526
[email protected]8cc10df2011-11-03 23:57:5027#if defined(USE_AURA)
28#include "ui/aura/aura_switches.h"
29#endif
30
[email protected]1a47d7e2010-10-15 00:37:2431namespace about_flags {
[email protected]ad2a3ded2010-08-27 13:19:0532
[email protected]8a6ff28d2010-12-02 16:35:1933// Macros to simplify specifying the type.
[email protected]a82744532011-02-11 16:15:5334#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
35 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0
36#define SINGLE_VALUE_TYPE(command_line_switch) \
37 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
38#define MULTI_VALUE_TYPE(choices) \
[email protected]0e6f56d2011-02-12 23:45:1539 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices)
[email protected]8a6ff28d2010-12-02 16:35:1940
[email protected]e2ddbc92010-10-15 20:02:0741namespace {
42
[email protected]a314ee5a2010-10-26 21:23:2843const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS;
[email protected]ad2a3ded2010-08-27 13:19:0544
[email protected]ba8164242010-11-16 21:31:0045// Names for former Chrome OS Labs experiments, shared with prefs migration
46// code.
47const char kMediaPlayerExperimentName[] = "media-player";
48const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
49const char kVerticalTabsExperimentName[] = "vertical-tabs";
50
[email protected]778ef7c2011-10-11 15:37:0551const Experiment::Choice kPrerenderFromOmniboxChoices[] = {
52 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_AUTOMATIC, "", "" },
53 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_ENABLED, switches::kPrerenderFromOmnibox,
54 switches::kPrerenderFromOmniboxSwitchValueEnabled },
55 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_DISABLED, switches::kPrerenderFromOmnibox,
56 switches::kPrerenderFromOmniboxSwitchValueDisabled }
57};
58
[email protected]4bc5050c2010-11-18 17:55:5459// RECORDING USER METRICS FOR FLAGS:
60// -----------------------------------------------------------------------------
61// The first line of the experiment is the internal name. If you'd like to
62// gather statistics about the usage of your flag, you should append a marker
63// comment to the end of the feature name, like so:
64// "my-special-feature", // FLAGS:RECORD_UMA
65//
66// After doing that, run //chrome/tools/extract_actions.py (see instructions at
67// the top of that file for details) to update the chromeactions.txt file, which
68// will enable UMA to record your feature flag.
69//
70// After your feature has shipped under a flag, you can locate the metrics
71// under the action name AboutFlags_internal-action-name. Actions are recorded
72// once per startup, so you should divide this number by AboutFlags_StartupTick
73// to get a sense of usage. Note that this will not be the same as number of
74// users with a given feature enabled because users can quit and relaunch
75// the application multiple times over a given time interval.
76// TODO(rsesek): See if there's a way to count per-user, rather than
77// per-startup.
78
[email protected]8a6ff28d2010-12-02 16:35:1979// To add a new experiment add to the end of kExperiments. There are two
80// distinct types of experiments:
81// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
82// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:2283// . MULTI_VALUE: a list of choices, the first of which should correspond to a
84// deactivated state for this lab (i.e. no command line option). To specify
85// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
86// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:1987// See the documentation of Experiment for details on the fields.
88//
89// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:0590const Experiment kExperiments[] = {
91 {
[email protected]aac169d2011-03-18 19:53:0392 "expose-for-tabs", // FLAGS:RECORD_UMA
93 IDS_FLAGS_TABPOSE_NAME,
94 IDS_FLAGS_TABPOSE_DESCRIPTION,
95 kOsMac,
96#if defined(OS_MACOSX)
97 // The switch exists only on OS X.
98 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
99#else
100 SINGLE_VALUE_TYPE("")
101#endif
102 },
103 {
[email protected]4bc5050c2010-11-18 17:55:54104 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05105 IDS_FLAGS_CONFLICTS_CHECK_NAME,
106 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
107 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19108 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05109 },
110 {
[email protected]4bc5050c2010-11-18 17:55:54111 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]9486c1f2010-10-14 19:52:12112 IDS_FLAGS_CLOUD_PRINT_PROXY_NAME,
113 IDS_FLAGS_CLOUD_PRINT_PROXY_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45114 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22115 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31116 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22117 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
118 // always have PDF rasterization available, so no flag needed there.
119#if !defined(GOOGLE_CHROME_BUILD)
120 kOsWin,
121#else
122 0,
[email protected]fa6d2a2f2010-11-30 21:47:19123#endif
[email protected]8a6ff28d2010-12-02 16:35:19124 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42125 },
[email protected]580939a2010-10-12 18:54:37126 {
[email protected]bb461532010-11-26 21:50:23127 "crxless-web-apps",
128 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
129 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
130 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19131 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23132 },
133 {
[email protected]96c6f4c2011-05-18 19:36:22134 "ignore-gpu-blacklist",
135 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
136 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
137 kOsAll,
138 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
139 },
140 {
[email protected]0110cf112011-07-02 00:39:43141 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22142 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
143 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
144 kOsAll,
145 SINGLE_VALUE_TYPE(switches::kForceCompositingMode)
146 },
147 {
[email protected]5963b772011-02-09 22:55:38148 "composited-layer-borders",
149 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
150 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
151 kOsAll,
152 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
153 },
154 {
[email protected]a8f1eaa2011-03-07 19:00:58155 "show-fps-counter",
156 IDS_FLAGS_SHOW_FPS_COUNTER,
157 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
158 kOsAll,
159 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
160 },
[email protected]8ff7f342011-05-25 01:49:47161 {
162 "disable-gpu-vsync",
163 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
164 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
165 kOsAll,
166 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
167 },
[email protected]deaba6d52011-09-23 14:47:12168 {
169 "disable-webgl",
170 IDS_FLAGS_DISABLE_WEBGL_NAME,
171 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
172 kOsAll,
173 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
174 },
[email protected]9de0ec12011-08-24 21:57:50175 // Exposed on all platforms until there is a workaround for easy access to
176 // the native print dialog for users that need it. Once that's done, revert
177 // back to:
178 // Only expose this for Chromium builds where users may not have the PDF
179 // plugin. Do not give Google Chrome users the option to disable it here.
180 // Also expose it for Chrome OS where print preview is still experimental.
[email protected]8d260e52010-10-13 01:03:05181 {
[email protected]4bc5050c2010-11-18 17:55:54182 "print-preview", // FLAGS:RECORD_UMA
[email protected]9486c1f2010-10-14 19:52:12183 IDS_FLAGS_PRINT_PREVIEW_NAME,
184 IDS_FLAGS_PRINT_PREVIEW_DESCRIPTION,
[email protected]b579afd2011-07-13 00:01:27185 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19186 SINGLE_VALUE_TYPE(switches::kEnablePrintPreview)
[email protected]2fe15fcb2010-10-21 20:39:53187 },
[email protected]d208f4d82011-05-23 21:52:03188 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53189 {
[email protected]e3791ce92011-08-09 01:03:32190 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40191 IDS_FLAGS_ENABLE_NACL_NAME,
192 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
193 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19194 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40195 },
196 {
[email protected]4bc5050c2010-11-18 17:55:54197 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32198 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
199 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
200 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19201 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32202 },
[email protected]3627b06d2010-11-12 16:36:16203 {
[email protected]cbe224d2011-08-04 22:12:49204 "apps-new-install-bubble",
205 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
206 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
207 kOsAll,
208 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
209 },
210 {
[email protected]4bc5050c2010-11-18 17:55:54211 "click-to-play", // FLAGS:RECORD_UMA
[email protected]3627b06d2010-11-12 16:36:16212 IDS_FLAGS_CLICK_TO_PLAY_NAME,
213 IDS_FLAGS_CLICK_TO_PLAY_DESCRIPTION,
214 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19215 SINGLE_VALUE_TYPE(switches::kEnableClickToPlay)
[email protected]3627b06d2010-11-12 16:36:16216 },
[email protected]80bd24e2010-11-30 09:34:38217 {
218 "disable-hyperlink-auditing",
219 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
220 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
221 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19222 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51223 },
224 {
225 "experimental-location-features", // FLAGS:RECORD_UMA
226 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
227 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
228 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19229 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
230 },
231 {
[email protected]04227962011-01-20 02:03:09232 "disable-interactive-form-validation",
233 IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_NAME,
234 IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_DESCRIPTION,
235 kOsAll,
236 SINGLE_VALUE_TYPE(switches::kDisableInteractiveFormValidation)
237 },
[email protected]8df51192011-01-22 20:05:03238 {
[email protected]07d490bc2011-03-07 17:05:26239 "focus-existing-tab-on-open", // FLAGS:RECORD_UMA
240 IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_NAME,
241 IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_DESCRIPTION,
242 kOsAll,
243 SINGLE_VALUE_TYPE(switches::kFocusExistingTabOnOpen)
244 },
[email protected]d5dcfb32011-03-19 00:49:24245 {
[email protected]5aea1862011-03-23 23:55:39246 "tab-groups-context-menu",
247 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
248 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
249 kOsWin,
250 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
251 },
[email protected]e9bf9d92011-03-31 20:57:15252 {
[email protected]f2557bd2011-06-01 02:33:07253 "preload-instant-search",
254 IDS_FLAGS_PRELOAD_INSTANT_SEARCH_NAME,
255 IDS_FLAGS_PRELOAD_INSTANT_SEARCH_DESCRIPTION,
256 kOsAll,
257 SINGLE_VALUE_TYPE(switches::kPreloadInstantSearch)
258 },
[email protected]354e33b2011-06-15 00:29:10259 {
260 "static-ip-config",
261 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
262 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
263 kOsCrOS,
264#if defined(OS_CHROMEOS)
265 // This switch exists only on Chrome OS.
266 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
267#else
268 SINGLE_VALUE_TYPE("")
269#endif
270 },
[email protected]3eb5728c2011-06-20 22:32:24271 {
272 "show-autofill-type-predictions",
273 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
274 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
275 kOsAll,
276 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
277 },
[email protected]bff4d3e2011-06-21 23:58:52278 {
[email protected]9a6180d7d2011-09-07 01:40:33279 "sync-tabs",
280 IDS_FLAGS_SYNC_TABS_NAME,
281 IDS_FLAGS_SYNC_TABS_DESCRIPTION,
[email protected]5b0ec7f2011-08-11 02:17:17282 kOsAll,
[email protected]9a6180d7d2011-09-07 01:40:33283 SINGLE_VALUE_TYPE(switches::kEnableSyncTabs)
[email protected]5b0ec7f2011-08-11 02:17:17284 },
285 {
[email protected]aae9eeb12011-10-21 21:59:26286 "sync-app-notifications",
287 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
288 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
289 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11290 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26291 },
292 {
[email protected]a22ebd812011-06-23 00:05:39293 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
294 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
295 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
296 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40297 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40298 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39299 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
300 },
[email protected]81a6b0b2011-06-24 17:55:40301 {
[email protected]ae1eb29a2011-08-17 17:50:57302 "prerender-from-omnibox", // FLAGS:RECORD_UMA
[email protected]81a6b0b2011-06-24 17:55:40303 IDS_FLAGS_PRERENDER_FROM_OMNIBOX_NAME,
304 IDS_FLAGS_PRERENDER_FROM_OMNIBOX_DESCRIPTION,
305 kOsAll,
[email protected]778ef7c2011-10-11 15:37:05306 MULTI_VALUE_TYPE(kPrerenderFromOmniboxChoices)
[email protected]81a6b0b2011-06-24 17:55:40307 },
[email protected]40916632011-07-02 01:11:01308 {
[email protected]845be522011-10-27 19:01:19309 "disable-panels",
[email protected]d5c14062011-10-27 00:02:13310 IDS_FLAGS_DISABLE_PANELS_NAME,
311 IDS_FLAGS_DISABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54312 kOsAll,
[email protected]d5c14062011-10-27 00:02:13313 SINGLE_VALUE_TYPE(switches::kDisablePanels)
[email protected]73fb1fc52011-07-09 00:06:54314 },
[email protected]e3749d12011-07-25 22:22:12315 {
[email protected]9931875b2011-11-02 00:19:48316 "disable-shortcuts-provider",
317 IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER,
318 IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER_DESCRIPTION,
[email protected]e3749d12011-07-25 22:22:12319 kOsAll,
[email protected]9931875b2011-11-02 00:19:48320 SINGLE_VALUE_TYPE(switches::kDisableShortcutsProvider)
[email protected]e3749d12011-07-25 22:22:12321 },
[email protected]1a2966b92011-08-09 06:50:19322#if defined(OS_CHROMEOS)
323 {
[email protected]cd681c42011-09-29 02:49:44324 "enable-bluetooth",
325 IDS_FLAGS_ENABLE_BLUETOOTH_NAME,
326 IDS_FLAGS_ENABLE_BLUETOOTH_DESCRIPTION,
327 kOsCrOS,
328 SINGLE_VALUE_TYPE(switches::kEnableBluetooth)
329 },
[email protected]1a2966b92011-08-09 06:50:19330#endif
[email protected]80eb4262011-08-03 16:10:41331 {
332 "memory-widget",
333 IDS_FLAGS_MEMORY_WIDGET_NAME,
334 IDS_FLAGS_MEMORY_WIDGET_DESCRIPTION,
335 kOsCrOS,
336#if defined(OS_CHROMEOS)
337 // This switch exists only on Chrome OS.
338 SINGLE_VALUE_TYPE(switches::kMemoryWidget)
339#else
340 SINGLE_VALUE_TYPE("")
341#endif
[email protected]a0e4b072011-08-17 01:47:07342 },
[email protected]a0e4b072011-08-17 01:47:07343 {
344 "downloads-new-ui", // FLAGS:RECORD_UMA
345 IDS_FLAGS_DOWNLOADS_NEW_UI_NAME,
346 IDS_FLAGS_DOWNLOADS_NEW_UI_DESCRIPTION,
347 kOsAll,
348 SINGLE_VALUE_TYPE(switches::kDownloadsNewUI)
349 },
[email protected]b7bb44f2011-09-01 05:17:03350 {
351 "enable-autologin",
352 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
353 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
354 kOsMac | kOsWin | kOsLinux,
355 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
356 },
[email protected]b9841172011-09-26 23:36:09357 {
358 "use-more-webui",
359 IDS_FLAGS_USE_MORE_WEBUI_NAME,
360 IDS_FLAGS_USE_MORE_WEBUI_DESCRIPTION,
361 kOsAll,
362 SINGLE_VALUE_TYPE(switches::kUseMoreWebUI)
363 },
[email protected]407a38f2011-11-23 18:28:29364 // TODO(flackr): Remove this flag and views screen locker when the WebUI
365 // locker is mature (crbug.com/105263).
[email protected]89c64cd2011-10-04 01:41:10366 {
[email protected]407a38f2011-11-23 18:28:29367 "disable-webui-lock-screen",
[email protected]d411c01d2011-10-18 16:00:27368 IDS_FLAGS_WEBUI_LOCK_NAME,
369 IDS_FLAGS_WEBUI_LOCK_DESCRIPTION,
370 kOsCrOS,
371#if defined(OS_CHROMEOS)
[email protected]407a38f2011-11-23 18:28:29372 SINGLE_VALUE_TYPE(switches::kDisableWebUILockScreen)
[email protected]d411c01d2011-10-18 16:00:27373#else
374 SINGLE_VALUE_TYPE("")
375#endif
376 },
377 {
[email protected]89c64cd2011-10-04 01:41:10378 "enable-ntp-bookmark-features",
379 IDS_FLAGS_ENABLE_NTP_BOOKMARK_FEATURES_NAME,
380 IDS_FLAGS_ENABLE_NTP_BOOKMARK_FEATURES_DESCRIPTION,
381 kOsAll,
382 SINGLE_VALUE_TYPE(switches::kEnableNTPBookmarkFeatures)
383 },
[email protected]f5da41d2011-10-08 17:40:07384 {
385 "enable-video-track",
386 IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME,
387 IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION,
388 kOsAll,
389 SINGLE_VALUE_TYPE(switches::kEnableVideoTrack)
390 },
[email protected]08b83362011-10-19 05:23:17391 {
392 "extension-alerts",
393 IDS_FLAGS_ENABLE_EXTENSION_ALERTS_NAME,
394 IDS_FLAGS_ENABLE_EXTENSION_ALERTS_DESCRIPTION,
395 kOsAll,
396 SINGLE_VALUE_TYPE(switches::kEnableExtensionAlerts)
397 },
[email protected]5a60c8b2011-10-19 20:14:29398 {
399 "enable-http-pipelining",
400 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
401 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
402 kOsAll,
403 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
404 },
[email protected]e3aaa93782011-10-26 16:04:28405#if defined(OS_CHROMEOS)
406 {
407 "enable-photo-editor",
408 IDS_FLAGS_ENABLE_PHOTO_EDITOR_NAME,
409 IDS_FLAGS_ENABLE_PHOTO_EDITOR_DESCRIPTION,
410 kOsCrOS,
411 SINGLE_VALUE_TYPE(switches::kEnablePhotoEditor)
412 },
413#endif
[email protected]6aa03b32011-10-27 21:44:44414 {
415 "enable-media-source",
416 IDS_FLAGS_ENABLE_MEDIA_SOURCE_NAME,
417 IDS_FLAGS_ENABLE_MEDIA_SOURCE_DESCRIPTION,
418 kOsAll,
419 SINGLE_VALUE_TYPE(switches::kEnableMediaSource)
420 },
[email protected]e4e68dbb2011-11-18 01:50:22421 {
422 "enable-pointer-lock",
423 IDS_FLAGS_ENABLE_POINTER_LOCK_NAME,
424 IDS_FLAGS_ENABLE_POINTER_LOCK_DESCRIPTION,
425 kOsAll,
426 SINGLE_VALUE_TYPE(switches::kEnablePointerLock)
427 },
[email protected]8cc10df2011-11-03 23:57:50428#if defined(USE_AURA)
429 {
430 "aura-windows",
431 IDS_FLAGS_AURA_WINDOWS_NAME,
432 IDS_FLAGS_AURA_WINDOWS_DESCRIPTION,
433 kOsWin | kOsLinux | kOsCrOS,
434 SINGLE_VALUE_TYPE(switches::kAuraWindows)
435 },
436#endif
[email protected]edb051d2011-11-24 23:20:51437 {
438 "enable-gamepad",
439 IDS_FLAGS_ENABLE_GAMEPAD_NAME,
440 IDS_FLAGS_ENABLE_GAMEPAD_DESCRIPTION,
441 kOsWin,
442 SINGLE_VALUE_TYPE(switches::kEnableGamepad)
443 },
[email protected]a0e4b072011-08-17 01:47:07444};
[email protected]ad2a3ded2010-08-27 13:19:05445
[email protected]a314ee5a2010-10-26 21:23:28446const Experiment* experiments = kExperiments;
447size_t num_experiments = arraysize(kExperiments);
448
[email protected]e2ddbc92010-10-15 20:02:07449// Stores and encapsulates the little state that about:flags has.
450class FlagsState {
451 public:
452 FlagsState() : needs_restart_(false) {}
453 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
454 bool IsRestartNeededToCommitChanges();
455 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28456 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07457 void RemoveFlagsSwitches(
458 std::map<std::string, CommandLine::StringType>* switch_list);
459 void reset();
460
461 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55462 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07463 return Singleton<FlagsState>::get();
464 }
465
466 private:
467 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53468 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07469
470 DISALLOW_COPY_AND_ASSIGN(FlagsState);
471};
472
[email protected]c7b7800a2010-10-07 18:51:35473// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:05474// in a set.
[email protected]1a47d7e2010-10-15 00:37:24475void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:05476 const ListValue* enabled_experiments = prefs->GetList(
477 prefs::kEnabledLabsExperiments);
478 if (!enabled_experiments)
479 return;
480
481 for (ListValue::const_iterator it = enabled_experiments->begin();
482 it != enabled_experiments->end();
483 ++it) {
484 std::string experiment_name;
485 if (!(*it)->GetAsString(&experiment_name)) {
486 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
487 continue;
488 }
489 result->insert(experiment_name);
490 }
491}
492
493// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:24494void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05495 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:38496 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
497 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:05498
499 experiments_list->Clear();
500 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
501 it != enabled_experiments.end();
502 ++it) {
503 experiments_list->Append(new StringValue(*it));
504 }
505}
506
[email protected]8a6ff28d2010-12-02 16:35:19507// Returns the name used in prefs for the choice at the specified index.
508std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:34509 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
510 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:19511 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
512 base::IntToString(index);
513}
514
515// Adds the internal names for the specified experiment to |names|.
516void AddInternalName(const Experiment& e, std::set<std::string>* names) {
517 if (e.type == Experiment::SINGLE_VALUE) {
518 names->insert(e.internal_name);
519 } else {
[email protected]2ce9c89752011-02-25 18:24:34520 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:19521 for (int i = 0; i < e.num_choices; ++i)
522 names->insert(NameForChoice(e, i));
523 }
524}
525
[email protected]28e35af2011-02-09 12:56:22526// Confirms that an experiment is valid, used in a DCHECK in
527// SanitizeList below.
528bool ValidateExperiment(const Experiment& e) {
529 switch (e.type) {
530 case Experiment::SINGLE_VALUE:
531 DCHECK_EQ(0, e.num_choices);
532 DCHECK(!e.choices);
533 break;
534 case Experiment::MULTI_VALUE:
535 DCHECK_GT(e.num_choices, 0);
536 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:53537 DCHECK(e.choices[0].command_line_switch);
538 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:22539 break;
540 default:
541 NOTREACHED();
542 }
543 return true;
544}
545
[email protected]ad2a3ded2010-08-27 13:19:05546// Removes all experiments from prefs::kEnabledLabsExperiments that are
547// unknown, to prevent this list to become very long as experiments are added
548// and removed.
549void SanitizeList(PrefService* prefs) {
550 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:22551 for (size_t i = 0; i < num_experiments; ++i) {
552 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:19553 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:22554 }
[email protected]ad2a3ded2010-08-27 13:19:05555
556 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24557 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05558
559 std::set<std::string> new_enabled_experiments;
560 std::set_intersection(
561 known_experiments.begin(), known_experiments.end(),
562 enabled_experiments.begin(), enabled_experiments.end(),
563 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
564
[email protected]1a47d7e2010-10-15 00:37:24565 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05566}
567
[email protected]1a47d7e2010-10-15 00:37:24568void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05569 PrefService* prefs, std::set<std::string>* result) {
570 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:24571 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:05572}
573
[email protected]a314ee5a2010-10-26 21:23:28574// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
575// enabled on the current platform.
576void GetSanitizedEnabledFlagsForCurrentPlatform(
577 PrefService* prefs, std::set<std::string>* result) {
578 GetSanitizedEnabledFlags(prefs, result);
579
580 // Filter out any experiments that aren't enabled on the current platform. We
581 // don't remove these from prefs else syncing to a platform with a different
582 // set of experiments would be lossy.
583 std::set<std::string> platform_experiments;
584 int current_platform = GetCurrentPlatform();
585 for (size_t i = 0; i < num_experiments; ++i) {
586 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:19587 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:28588 }
589
590 std::set<std::string> new_enabled_experiments;
591 std::set_intersection(
592 platform_experiments.begin(), platform_experiments.end(),
593 result->begin(), result->end(),
594 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
595
596 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05597}
598
[email protected]8a6ff28d2010-12-02 16:35:19599// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:19600Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:22601 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:34602 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:19603 ListValue* result = new ListValue;
604 for (int i = 0; i < experiment.num_choices; ++i) {
605 const Experiment::Choice& choice = experiment.choices[i];
606 DictionaryValue* value = new DictionaryValue;
607 std::string name = NameForChoice(experiment, i);
608 value->SetString("description",
609 l10n_util::GetStringUTF16(choice.description_id));
610 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:22611 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:19612 result->Append(value);
613 }
614 return result;
615}
616
[email protected]e2ddbc92010-10-15 20:02:07617} // namespace
618
[email protected]1a47d7e2010-10-15 00:37:24619void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:55620 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:05621}
622
[email protected]1a47d7e2010-10-15 00:37:24623ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:05624 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24625 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05626
627 int current_platform = GetCurrentPlatform();
628
629 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:28630 for (size_t i = 0; i < num_experiments; ++i) {
631 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:05632 if (!(experiment.supported_platforms & current_platform))
633 continue;
634
635 DictionaryValue* data = new DictionaryValue();
636 data->SetString("internal_name", experiment.internal_name);
637 data->SetString("name",
638 l10n_util::GetStringUTF16(experiment.visible_name_id));
639 data->SetString("description",
640 l10n_util::GetStringUTF16(
641 experiment.visible_description_id));
[email protected]ad2a3ded2010-08-27 13:19:05642
[email protected]28e35af2011-02-09 12:56:22643 switch (experiment.type) {
644 case Experiment::SINGLE_VALUE:
645 data->SetBoolean(
646 "enabled",
647 enabled_experiments.count(experiment.internal_name) > 0);
648 break;
649 case Experiment::MULTI_VALUE:
650 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
651 break;
652 default:
653 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:19654 }
655
[email protected]ad2a3ded2010-08-27 13:19:05656 experiments_data->Append(data);
657 }
658 return experiments_data;
659}
660
[email protected]ad2a3ded2010-08-27 13:19:05661bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:55662 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:05663}
664
665void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:35666 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:55667 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:07668}
669
670void RemoveFlagsSwitches(
671 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:55672 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:07673}
674
[email protected]a314ee5a2010-10-26 21:23:28675int GetCurrentPlatform() {
676#if defined(OS_MACOSX)
677 return kOsMac;
678#elif defined(OS_WIN)
679 return kOsWin;
680#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
681 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:21682#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:28683 return kOsLinux;
684#else
685#error Unknown platform
686#endif
687}
688
[email protected]4bc5050c2010-11-18 17:55:54689void RecordUMAStatistics(const PrefService* prefs) {
690 std::set<std::string> flags;
691 GetEnabledFlags(prefs, &flags);
692 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
693 ++it) {
694 std::string action("AboutFlags_");
695 action += *it;
696 UserMetrics::RecordComputedAction(action);
697 }
698 // Since flag metrics are recorded every startup, add a tick so that the
699 // stats can be made meaningful.
700 if (flags.size())
701 UserMetrics::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
[email protected]970b2fd2011-01-22 18:06:45702 UserMetrics::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:54703}
704
[email protected]e2ddbc92010-10-15 20:02:07705//////////////////////////////////////////////////////////////////////////////
706// FlagsState implementation.
707
708namespace {
709
710void FlagsState::ConvertFlagsToSwitches(
711 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:07712 if (command_line->HasSwitch(switches::kNoExperiments))
713 return;
714
715 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:00716
[email protected]a314ee5a2010-10-26 21:23:28717 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:07718
[email protected]a82744532011-02-11 16:15:53719 typedef std::map<std::string, std::pair<std::string, std::string> >
720 NameToSwitchAndValueMap;
721 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:19722 for (size_t i = 0; i < num_experiments; ++i) {
723 const Experiment& e = experiments[i];
724 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:53725 name_to_switch_map[e.internal_name] =
726 std::pair<std::string, std::string>(e.command_line_switch,
727 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:19728 } else {
729 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:53730 name_to_switch_map[NameForChoice(e, j)] =
731 std::pair<std::string, std::string>(
732 e.choices[j].command_line_switch,
733 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:19734 }
735 }
[email protected]e2ddbc92010-10-15 20:02:07736
737 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:53738 flags_switches_.insert(
739 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
740 std::string()));
[email protected]e2ddbc92010-10-15 20:02:07741 for (std::set<std::string>::iterator it = enabled_experiments.begin();
742 it != enabled_experiments.end();
743 ++it) {
744 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:53745 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:19746 name_to_switch_map.find(experiment_name);
747 if (name_to_switch_it == name_to_switch_map.end()) {
748 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:07749 continue;
[email protected]8a6ff28d2010-12-02 16:35:19750 }
[email protected]e2ddbc92010-10-15 20:02:07751
[email protected]a82744532011-02-11 16:15:53752 const std::pair<std::string, std::string>&
753 switch_and_value_pair = name_to_switch_it->second;
754
755 command_line->AppendSwitchASCII(switch_and_value_pair.first,
756 switch_and_value_pair.second);
757 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:07758 }
759 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:53760 flags_switches_.insert(
761 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
762 std::string()));
[email protected]e2ddbc92010-10-15 20:02:07763}
764
765bool FlagsState::IsRestartNeededToCommitChanges() {
766 return needs_restart_;
767}
768
769void FlagsState::SetExperimentEnabled(
770 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:05771 needs_restart_ = true;
772
[email protected]8a6ff28d2010-12-02 16:35:19773 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
774 if (at_index != std::string::npos) {
775 DCHECK(enable);
776 // We're being asked to enable a multi-choice experiment. Disable the
777 // currently selected choice.
778 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:22779 const std::string experiment_name = internal_name.substr(0, at_index);
780 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:19781
[email protected]28e35af2011-02-09 12:56:22782 // And enable the new choice, if it is not the default first choice.
783 if (internal_name != experiment_name + "@0") {
784 std::set<std::string> enabled_experiments;
785 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
786 enabled_experiments.insert(internal_name);
787 SetEnabledFlags(prefs, enabled_experiments);
788 }
[email protected]8a6ff28d2010-12-02 16:35:19789 return;
790 }
791
[email protected]ad2a3ded2010-08-27 13:19:05792 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24793 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05794
[email protected]8a6ff28d2010-12-02 16:35:19795 const Experiment* e = NULL;
796 for (size_t i = 0; i < num_experiments; ++i) {
797 if (experiments[i].internal_name == internal_name) {
798 e = experiments + i;
799 break;
800 }
801 }
802 DCHECK(e);
803
804 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:59805 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:19806 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:59807 else
[email protected]8a6ff28d2010-12-02 16:35:19808 enabled_experiments.erase(internal_name);
809 } else {
810 if (enable) {
811 // Enable the first choice.
812 enabled_experiments.insert(NameForChoice(*e, 0));
813 } else {
814 // Find the currently enabled choice and disable it.
815 for (int i = 0; i < e->num_choices; ++i) {
816 std::string choice_name = NameForChoice(*e, i);
817 if (enabled_experiments.find(choice_name) !=
818 enabled_experiments.end()) {
819 enabled_experiments.erase(choice_name);
820 // Continue on just in case there's a bug and more than one
821 // experiment for this choice was enabled.
822 }
823 }
824 }
825 }
[email protected]ad2a3ded2010-08-27 13:19:05826
[email protected]1a47d7e2010-10-15 00:37:24827 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05828}
829
[email protected]e2ddbc92010-10-15 20:02:07830void FlagsState::RemoveFlagsSwitches(
831 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:53832 for (std::map<std::string, std::string>::const_iterator
833 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
834 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:07835 }
836}
837
838void FlagsState::reset() {
839 needs_restart_ = false;
840 flags_switches_.clear();
841}
842
[email protected]38e46812011-05-09 20:49:22843} // namespace
[email protected]e2ddbc92010-10-15 20:02:07844
845namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:19846
847// WARNING: '@' is also used in the html file. If you update this constant you
848// also need to update the html file.
849const char kMultiSeparator[] = "@";
850
[email protected]e2ddbc92010-10-15 20:02:07851void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:55852 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:07853}
[email protected]a314ee5a2010-10-26 21:23:28854
855void SetExperiments(const Experiment* e, size_t count) {
856 if (!e) {
857 experiments = kExperiments;
858 num_experiments = arraysize(kExperiments);
859 } else {
860 experiments = e;
861 num_experiments = count;
862 }
863}
864
[email protected]8a6ff28d2010-12-02 16:35:19865const Experiment* GetExperiments(size_t* count) {
866 *count = num_experiments;
867 return experiments;
868}
869
[email protected]e2ddbc92010-10-15 20:02:07870} // namespace testing
871
[email protected]1a47d7e2010-10-15 00:37:24872} // namespace about_flags