blob: 6155c6346f0d1d6508f3282c294bb6952bf64b10 [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]60dea122011-12-06 00:32:45155 "accelerated-drawing",
156 IDS_FLAGS_ACCELERATED_DRAWING_NAME,
157 IDS_FLAGS_ACCELERATED_DRAWING_DESCRIPTION,
158#if defined(USE_SKIA)
159 kOsAll,
160#else
161 0,
162#endif
163 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedDrawing)
164 },
165 {
[email protected]a8f1eaa2011-03-07 19:00:58166 "show-fps-counter",
167 IDS_FLAGS_SHOW_FPS_COUNTER,
168 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
169 kOsAll,
170 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
171 },
[email protected]8ff7f342011-05-25 01:49:47172 {
173 "disable-gpu-vsync",
174 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
175 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
176 kOsAll,
177 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
178 },
[email protected]deaba6d52011-09-23 14:47:12179 {
180 "disable-webgl",
181 IDS_FLAGS_DISABLE_WEBGL_NAME,
182 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
183 kOsAll,
184 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
185 },
[email protected]9de0ec12011-08-24 21:57:50186 // Exposed on all platforms until there is a workaround for easy access to
187 // the native print dialog for users that need it. Once that's done, revert
188 // back to:
189 // Only expose this for Chromium builds where users may not have the PDF
190 // plugin. Do not give Google Chrome users the option to disable it here.
191 // Also expose it for Chrome OS where print preview is still experimental.
[email protected]8d260e52010-10-13 01:03:05192 {
[email protected]4bc5050c2010-11-18 17:55:54193 "print-preview", // FLAGS:RECORD_UMA
[email protected]9486c1f2010-10-14 19:52:12194 IDS_FLAGS_PRINT_PREVIEW_NAME,
195 IDS_FLAGS_PRINT_PREVIEW_DESCRIPTION,
[email protected]b579afd2011-07-13 00:01:27196 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19197 SINGLE_VALUE_TYPE(switches::kEnablePrintPreview)
[email protected]2fe15fcb2010-10-21 20:39:53198 },
[email protected]d208f4d82011-05-23 21:52:03199 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53200 {
[email protected]e3791ce92011-08-09 01:03:32201 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40202 IDS_FLAGS_ENABLE_NACL_NAME,
203 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
204 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19205 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40206 },
207 {
[email protected]4bc5050c2010-11-18 17:55:54208 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32209 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
210 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
211 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19212 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32213 },
[email protected]3627b06d2010-11-12 16:36:16214 {
[email protected]cbe224d2011-08-04 22:12:49215 "apps-new-install-bubble",
216 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
217 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
218 kOsAll,
219 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
220 },
221 {
[email protected]4bc5050c2010-11-18 17:55:54222 "click-to-play", // FLAGS:RECORD_UMA
[email protected]3627b06d2010-11-12 16:36:16223 IDS_FLAGS_CLICK_TO_PLAY_NAME,
224 IDS_FLAGS_CLICK_TO_PLAY_DESCRIPTION,
225 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19226 SINGLE_VALUE_TYPE(switches::kEnableClickToPlay)
[email protected]3627b06d2010-11-12 16:36:16227 },
[email protected]80bd24e2010-11-30 09:34:38228 {
229 "disable-hyperlink-auditing",
230 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
231 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
232 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19233 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51234 },
235 {
236 "experimental-location-features", // FLAGS:RECORD_UMA
237 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
238 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
239 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19240 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
241 },
242 {
[email protected]04227962011-01-20 02:03:09243 "disable-interactive-form-validation",
244 IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_NAME,
245 IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_DESCRIPTION,
246 kOsAll,
247 SINGLE_VALUE_TYPE(switches::kDisableInteractiveFormValidation)
248 },
[email protected]8df51192011-01-22 20:05:03249 {
[email protected]07d490bc2011-03-07 17:05:26250 "focus-existing-tab-on-open", // FLAGS:RECORD_UMA
251 IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_NAME,
252 IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_DESCRIPTION,
253 kOsAll,
254 SINGLE_VALUE_TYPE(switches::kFocusExistingTabOnOpen)
255 },
[email protected]d5dcfb32011-03-19 00:49:24256 {
[email protected]5aea1862011-03-23 23:55:39257 "tab-groups-context-menu",
258 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
259 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
260 kOsWin,
261 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
262 },
[email protected]e9bf9d92011-03-31 20:57:15263 {
[email protected]f2557bd2011-06-01 02:33:07264 "preload-instant-search",
265 IDS_FLAGS_PRELOAD_INSTANT_SEARCH_NAME,
266 IDS_FLAGS_PRELOAD_INSTANT_SEARCH_DESCRIPTION,
267 kOsAll,
268 SINGLE_VALUE_TYPE(switches::kPreloadInstantSearch)
269 },
[email protected]354e33b2011-06-15 00:29:10270 {
271 "static-ip-config",
272 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
273 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
274 kOsCrOS,
275#if defined(OS_CHROMEOS)
276 // This switch exists only on Chrome OS.
277 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
278#else
279 SINGLE_VALUE_TYPE("")
280#endif
281 },
[email protected]3eb5728c2011-06-20 22:32:24282 {
283 "show-autofill-type-predictions",
284 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
285 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
286 kOsAll,
287 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
288 },
[email protected]bff4d3e2011-06-21 23:58:52289 {
[email protected]9a6180d7d2011-09-07 01:40:33290 "sync-tabs",
291 IDS_FLAGS_SYNC_TABS_NAME,
292 IDS_FLAGS_SYNC_TABS_DESCRIPTION,
[email protected]5b0ec7f2011-08-11 02:17:17293 kOsAll,
[email protected]9a6180d7d2011-09-07 01:40:33294 SINGLE_VALUE_TYPE(switches::kEnableSyncTabs)
[email protected]5b0ec7f2011-08-11 02:17:17295 },
296 {
[email protected]aae9eeb12011-10-21 21:59:26297 "sync-app-notifications",
298 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
299 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
300 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11301 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26302 },
303 {
[email protected]a22ebd812011-06-23 00:05:39304 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
305 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
306 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
307 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40308 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40309 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39310 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
311 },
[email protected]81a6b0b2011-06-24 17:55:40312 {
[email protected]ae1eb29a2011-08-17 17:50:57313 "prerender-from-omnibox", // FLAGS:RECORD_UMA
[email protected]81a6b0b2011-06-24 17:55:40314 IDS_FLAGS_PRERENDER_FROM_OMNIBOX_NAME,
315 IDS_FLAGS_PRERENDER_FROM_OMNIBOX_DESCRIPTION,
316 kOsAll,
[email protected]778ef7c2011-10-11 15:37:05317 MULTI_VALUE_TYPE(kPrerenderFromOmniboxChoices)
[email protected]81a6b0b2011-06-24 17:55:40318 },
[email protected]40916632011-07-02 01:11:01319 {
[email protected]7e7a28092011-12-09 22:24:55320 "enable-panels",
321 IDS_FLAGS_ENABLE_PANELS_NAME,
322 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54323 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55324 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54325 },
[email protected]e3749d12011-07-25 22:22:12326 {
[email protected]9931875b2011-11-02 00:19:48327 "disable-shortcuts-provider",
328 IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER,
329 IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER_DESCRIPTION,
[email protected]e3749d12011-07-25 22:22:12330 kOsAll,
[email protected]9931875b2011-11-02 00:19:48331 SINGLE_VALUE_TYPE(switches::kDisableShortcutsProvider)
[email protected]e3749d12011-07-25 22:22:12332 },
[email protected]1a2966b92011-08-09 06:50:19333#if defined(OS_CHROMEOS)
334 {
[email protected]cd681c42011-09-29 02:49:44335 "enable-bluetooth",
336 IDS_FLAGS_ENABLE_BLUETOOTH_NAME,
337 IDS_FLAGS_ENABLE_BLUETOOTH_DESCRIPTION,
338 kOsCrOS,
339 SINGLE_VALUE_TYPE(switches::kEnableBluetooth)
340 },
[email protected]1a2966b92011-08-09 06:50:19341#endif
[email protected]80eb4262011-08-03 16:10:41342 {
343 "memory-widget",
344 IDS_FLAGS_MEMORY_WIDGET_NAME,
345 IDS_FLAGS_MEMORY_WIDGET_DESCRIPTION,
346 kOsCrOS,
347#if defined(OS_CHROMEOS)
348 // This switch exists only on Chrome OS.
349 SINGLE_VALUE_TYPE(switches::kMemoryWidget)
350#else
351 SINGLE_VALUE_TYPE("")
352#endif
[email protected]a0e4b072011-08-17 01:47:07353 },
[email protected]a0e4b072011-08-17 01:47:07354 {
355 "downloads-new-ui", // FLAGS:RECORD_UMA
356 IDS_FLAGS_DOWNLOADS_NEW_UI_NAME,
357 IDS_FLAGS_DOWNLOADS_NEW_UI_DESCRIPTION,
358 kOsAll,
359 SINGLE_VALUE_TYPE(switches::kDownloadsNewUI)
360 },
[email protected]b7bb44f2011-09-01 05:17:03361 {
362 "enable-autologin",
363 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
364 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
365 kOsMac | kOsWin | kOsLinux,
366 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
367 },
[email protected]b9841172011-09-26 23:36:09368 {
369 "use-more-webui",
370 IDS_FLAGS_USE_MORE_WEBUI_NAME,
371 IDS_FLAGS_USE_MORE_WEBUI_DESCRIPTION,
372 kOsAll,
373 SINGLE_VALUE_TYPE(switches::kUseMoreWebUI)
374 },
[email protected]407a38f2011-11-23 18:28:29375 // TODO(flackr): Remove this flag and views screen locker when the WebUI
376 // locker is mature (crbug.com/105263).
[email protected]89c64cd2011-10-04 01:41:10377 {
[email protected]407a38f2011-11-23 18:28:29378 "disable-webui-lock-screen",
[email protected]d411c01d2011-10-18 16:00:27379 IDS_FLAGS_WEBUI_LOCK_NAME,
380 IDS_FLAGS_WEBUI_LOCK_DESCRIPTION,
381 kOsCrOS,
382#if defined(OS_CHROMEOS)
[email protected]407a38f2011-11-23 18:28:29383 SINGLE_VALUE_TYPE(switches::kDisableWebUILockScreen)
[email protected]d411c01d2011-10-18 16:00:27384#else
385 SINGLE_VALUE_TYPE("")
386#endif
387 },
388 {
[email protected]f5da41d2011-10-08 17:40:07389 "enable-video-track",
390 IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME,
391 IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION,
392 kOsAll,
393 SINGLE_VALUE_TYPE(switches::kEnableVideoTrack)
394 },
[email protected]08b83362011-10-19 05:23:17395 {
396 "extension-alerts",
397 IDS_FLAGS_ENABLE_EXTENSION_ALERTS_NAME,
398 IDS_FLAGS_ENABLE_EXTENSION_ALERTS_DESCRIPTION,
399 kOsAll,
400 SINGLE_VALUE_TYPE(switches::kEnableExtensionAlerts)
401 },
[email protected]6aa03b32011-10-27 21:44:44402 {
403 "enable-media-source",
404 IDS_FLAGS_ENABLE_MEDIA_SOURCE_NAME,
405 IDS_FLAGS_ENABLE_MEDIA_SOURCE_DESCRIPTION,
406 kOsAll,
407 SINGLE_VALUE_TYPE(switches::kEnableMediaSource)
408 },
[email protected]e4e68dbb2011-11-18 01:50:22409 {
410 "enable-pointer-lock",
411 IDS_FLAGS_ENABLE_POINTER_LOCK_NAME,
412 IDS_FLAGS_ENABLE_POINTER_LOCK_DESCRIPTION,
413 kOsAll,
414 SINGLE_VALUE_TYPE(switches::kEnablePointerLock)
415 },
[email protected]8cc10df2011-11-03 23:57:50416#if defined(USE_AURA)
417 {
[email protected]20cea592011-12-10 01:55:30418 "aura-workspace-manager",
419 IDS_FLAGS_AURA_WORKSPACE_MANAGER_NAME,
420 IDS_FLAGS_AURA_WORKSPACE_MANAGER_DESCRIPTION,
[email protected]8cc10df2011-11-03 23:57:50421 kOsWin | kOsLinux | kOsCrOS,
[email protected]20cea592011-12-10 01:55:30422 SINGLE_VALUE_TYPE(switches::kAuraWorkspaceManager)
[email protected]8cc10df2011-11-03 23:57:50423 },
[email protected]20cea592011-12-10 01:55:30424 {
425 "aura-translucent-frames",
426 IDS_FLAGS_AURA_TRANSLUCENT_FRAMES_NAME,
427 IDS_FLAGS_AURA_TRANSLUCENT_FRAMES_DESCRIPTION,
428 kOsWin | kOsLinux | kOsCrOS,
429 SINGLE_VALUE_TYPE(switches::kAuraTranslucentFrames)
430 },
431#endif // defined(USE_AURA)
[email protected]edb051d2011-11-24 23:20:51432 {
433 "enable-gamepad",
434 IDS_FLAGS_ENABLE_GAMEPAD_NAME,
435 IDS_FLAGS_ENABLE_GAMEPAD_DESCRIPTION,
[email protected]02580552011-12-08 02:36:26436 kOsMac | kOsWin,
[email protected]edb051d2011-11-24 23:20:51437 SINGLE_VALUE_TYPE(switches::kEnableGamepad)
438 },
[email protected]a0e4b072011-08-17 01:47:07439};
[email protected]ad2a3ded2010-08-27 13:19:05440
[email protected]a314ee5a2010-10-26 21:23:28441const Experiment* experiments = kExperiments;
442size_t num_experiments = arraysize(kExperiments);
443
[email protected]e2ddbc92010-10-15 20:02:07444// Stores and encapsulates the little state that about:flags has.
445class FlagsState {
446 public:
447 FlagsState() : needs_restart_(false) {}
448 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
449 bool IsRestartNeededToCommitChanges();
450 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28451 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07452 void RemoveFlagsSwitches(
453 std::map<std::string, CommandLine::StringType>* switch_list);
454 void reset();
455
456 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55457 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07458 return Singleton<FlagsState>::get();
459 }
460
461 private:
462 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53463 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07464
465 DISALLOW_COPY_AND_ASSIGN(FlagsState);
466};
467
[email protected]c7b7800a2010-10-07 18:51:35468// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:05469// in a set.
[email protected]1a47d7e2010-10-15 00:37:24470void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:05471 const ListValue* enabled_experiments = prefs->GetList(
472 prefs::kEnabledLabsExperiments);
473 if (!enabled_experiments)
474 return;
475
476 for (ListValue::const_iterator it = enabled_experiments->begin();
477 it != enabled_experiments->end();
478 ++it) {
479 std::string experiment_name;
480 if (!(*it)->GetAsString(&experiment_name)) {
481 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
482 continue;
483 }
484 result->insert(experiment_name);
485 }
486}
487
488// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:24489void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05490 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:38491 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
492 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:05493
494 experiments_list->Clear();
495 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
496 it != enabled_experiments.end();
497 ++it) {
498 experiments_list->Append(new StringValue(*it));
499 }
500}
501
[email protected]8a6ff28d2010-12-02 16:35:19502// Returns the name used in prefs for the choice at the specified index.
503std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:34504 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
505 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:19506 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
507 base::IntToString(index);
508}
509
510// Adds the internal names for the specified experiment to |names|.
511void AddInternalName(const Experiment& e, std::set<std::string>* names) {
512 if (e.type == Experiment::SINGLE_VALUE) {
513 names->insert(e.internal_name);
514 } else {
[email protected]2ce9c89752011-02-25 18:24:34515 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:19516 for (int i = 0; i < e.num_choices; ++i)
517 names->insert(NameForChoice(e, i));
518 }
519}
520
[email protected]28e35af2011-02-09 12:56:22521// Confirms that an experiment is valid, used in a DCHECK in
522// SanitizeList below.
523bool ValidateExperiment(const Experiment& e) {
524 switch (e.type) {
525 case Experiment::SINGLE_VALUE:
526 DCHECK_EQ(0, e.num_choices);
527 DCHECK(!e.choices);
528 break;
529 case Experiment::MULTI_VALUE:
530 DCHECK_GT(e.num_choices, 0);
531 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:53532 DCHECK(e.choices[0].command_line_switch);
533 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:22534 break;
535 default:
536 NOTREACHED();
537 }
538 return true;
539}
540
[email protected]ad2a3ded2010-08-27 13:19:05541// Removes all experiments from prefs::kEnabledLabsExperiments that are
542// unknown, to prevent this list to become very long as experiments are added
543// and removed.
544void SanitizeList(PrefService* prefs) {
545 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:22546 for (size_t i = 0; i < num_experiments; ++i) {
547 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:19548 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:22549 }
[email protected]ad2a3ded2010-08-27 13:19:05550
551 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24552 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05553
554 std::set<std::string> new_enabled_experiments;
555 std::set_intersection(
556 known_experiments.begin(), known_experiments.end(),
557 enabled_experiments.begin(), enabled_experiments.end(),
558 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
559
[email protected]1a47d7e2010-10-15 00:37:24560 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05561}
562
[email protected]1a47d7e2010-10-15 00:37:24563void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05564 PrefService* prefs, std::set<std::string>* result) {
565 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:24566 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:05567}
568
[email protected]a314ee5a2010-10-26 21:23:28569// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
570// enabled on the current platform.
571void GetSanitizedEnabledFlagsForCurrentPlatform(
572 PrefService* prefs, std::set<std::string>* result) {
573 GetSanitizedEnabledFlags(prefs, result);
574
575 // Filter out any experiments that aren't enabled on the current platform. We
576 // don't remove these from prefs else syncing to a platform with a different
577 // set of experiments would be lossy.
578 std::set<std::string> platform_experiments;
579 int current_platform = GetCurrentPlatform();
580 for (size_t i = 0; i < num_experiments; ++i) {
581 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:19582 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:28583 }
584
585 std::set<std::string> new_enabled_experiments;
586 std::set_intersection(
587 platform_experiments.begin(), platform_experiments.end(),
588 result->begin(), result->end(),
589 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
590
591 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05592}
593
[email protected]8a6ff28d2010-12-02 16:35:19594// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:19595Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:22596 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:34597 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:19598 ListValue* result = new ListValue;
599 for (int i = 0; i < experiment.num_choices; ++i) {
600 const Experiment::Choice& choice = experiment.choices[i];
601 DictionaryValue* value = new DictionaryValue;
602 std::string name = NameForChoice(experiment, i);
603 value->SetString("description",
604 l10n_util::GetStringUTF16(choice.description_id));
605 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:22606 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:19607 result->Append(value);
608 }
609 return result;
610}
611
[email protected]e2ddbc92010-10-15 20:02:07612} // namespace
613
[email protected]1a47d7e2010-10-15 00:37:24614void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:55615 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:05616}
617
[email protected]1a47d7e2010-10-15 00:37:24618ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:05619 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24620 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05621
622 int current_platform = GetCurrentPlatform();
623
624 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:28625 for (size_t i = 0; i < num_experiments; ++i) {
626 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:05627 if (!(experiment.supported_platforms & current_platform))
628 continue;
629
630 DictionaryValue* data = new DictionaryValue();
631 data->SetString("internal_name", experiment.internal_name);
632 data->SetString("name",
633 l10n_util::GetStringUTF16(experiment.visible_name_id));
634 data->SetString("description",
635 l10n_util::GetStringUTF16(
636 experiment.visible_description_id));
[email protected]ad2a3ded2010-08-27 13:19:05637
[email protected]28e35af2011-02-09 12:56:22638 switch (experiment.type) {
639 case Experiment::SINGLE_VALUE:
640 data->SetBoolean(
641 "enabled",
642 enabled_experiments.count(experiment.internal_name) > 0);
643 break;
644 case Experiment::MULTI_VALUE:
645 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
646 break;
647 default:
648 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:19649 }
650
[email protected]ad2a3ded2010-08-27 13:19:05651 experiments_data->Append(data);
652 }
653 return experiments_data;
654}
655
[email protected]ad2a3ded2010-08-27 13:19:05656bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:55657 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:05658}
659
660void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:35661 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:55662 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:07663}
664
665void RemoveFlagsSwitches(
666 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:55667 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:07668}
669
[email protected]a314ee5a2010-10-26 21:23:28670int GetCurrentPlatform() {
671#if defined(OS_MACOSX)
672 return kOsMac;
673#elif defined(OS_WIN)
674 return kOsWin;
675#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
676 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:21677#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:28678 return kOsLinux;
679#else
680#error Unknown platform
681#endif
682}
683
[email protected]4bc5050c2010-11-18 17:55:54684void RecordUMAStatistics(const PrefService* prefs) {
685 std::set<std::string> flags;
686 GetEnabledFlags(prefs, &flags);
687 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
688 ++it) {
689 std::string action("AboutFlags_");
690 action += *it;
691 UserMetrics::RecordComputedAction(action);
692 }
693 // Since flag metrics are recorded every startup, add a tick so that the
694 // stats can be made meaningful.
695 if (flags.size())
696 UserMetrics::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
[email protected]970b2fd2011-01-22 18:06:45697 UserMetrics::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:54698}
699
[email protected]e2ddbc92010-10-15 20:02:07700//////////////////////////////////////////////////////////////////////////////
701// FlagsState implementation.
702
703namespace {
704
705void FlagsState::ConvertFlagsToSwitches(
706 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:07707 if (command_line->HasSwitch(switches::kNoExperiments))
708 return;
709
710 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:00711
[email protected]a314ee5a2010-10-26 21:23:28712 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:07713
[email protected]a82744532011-02-11 16:15:53714 typedef std::map<std::string, std::pair<std::string, std::string> >
715 NameToSwitchAndValueMap;
716 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:19717 for (size_t i = 0; i < num_experiments; ++i) {
718 const Experiment& e = experiments[i];
719 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:53720 name_to_switch_map[e.internal_name] =
721 std::pair<std::string, std::string>(e.command_line_switch,
722 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:19723 } else {
724 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:53725 name_to_switch_map[NameForChoice(e, j)] =
726 std::pair<std::string, std::string>(
727 e.choices[j].command_line_switch,
728 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:19729 }
730 }
[email protected]e2ddbc92010-10-15 20:02:07731
732 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:53733 flags_switches_.insert(
734 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
735 std::string()));
[email protected]e2ddbc92010-10-15 20:02:07736 for (std::set<std::string>::iterator it = enabled_experiments.begin();
737 it != enabled_experiments.end();
738 ++it) {
739 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:53740 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:19741 name_to_switch_map.find(experiment_name);
742 if (name_to_switch_it == name_to_switch_map.end()) {
743 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:07744 continue;
[email protected]8a6ff28d2010-12-02 16:35:19745 }
[email protected]e2ddbc92010-10-15 20:02:07746
[email protected]a82744532011-02-11 16:15:53747 const std::pair<std::string, std::string>&
748 switch_and_value_pair = name_to_switch_it->second;
749
750 command_line->AppendSwitchASCII(switch_and_value_pair.first,
751 switch_and_value_pair.second);
752 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:07753 }
754 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:53755 flags_switches_.insert(
756 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
757 std::string()));
[email protected]e2ddbc92010-10-15 20:02:07758}
759
760bool FlagsState::IsRestartNeededToCommitChanges() {
761 return needs_restart_;
762}
763
764void FlagsState::SetExperimentEnabled(
765 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:05766 needs_restart_ = true;
767
[email protected]8a6ff28d2010-12-02 16:35:19768 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
769 if (at_index != std::string::npos) {
770 DCHECK(enable);
771 // We're being asked to enable a multi-choice experiment. Disable the
772 // currently selected choice.
773 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:22774 const std::string experiment_name = internal_name.substr(0, at_index);
775 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:19776
[email protected]28e35af2011-02-09 12:56:22777 // And enable the new choice, if it is not the default first choice.
778 if (internal_name != experiment_name + "@0") {
779 std::set<std::string> enabled_experiments;
780 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
781 enabled_experiments.insert(internal_name);
782 SetEnabledFlags(prefs, enabled_experiments);
783 }
[email protected]8a6ff28d2010-12-02 16:35:19784 return;
785 }
786
[email protected]ad2a3ded2010-08-27 13:19:05787 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:24788 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05789
[email protected]8a6ff28d2010-12-02 16:35:19790 const Experiment* e = NULL;
791 for (size_t i = 0; i < num_experiments; ++i) {
792 if (experiments[i].internal_name == internal_name) {
793 e = experiments + i;
794 break;
795 }
796 }
797 DCHECK(e);
798
799 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:59800 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:19801 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:59802 else
[email protected]8a6ff28d2010-12-02 16:35:19803 enabled_experiments.erase(internal_name);
804 } else {
805 if (enable) {
806 // Enable the first choice.
807 enabled_experiments.insert(NameForChoice(*e, 0));
808 } else {
809 // Find the currently enabled choice and disable it.
810 for (int i = 0; i < e->num_choices; ++i) {
811 std::string choice_name = NameForChoice(*e, i);
812 if (enabled_experiments.find(choice_name) !=
813 enabled_experiments.end()) {
814 enabled_experiments.erase(choice_name);
815 // Continue on just in case there's a bug and more than one
816 // experiment for this choice was enabled.
817 }
818 }
819 }
820 }
[email protected]ad2a3ded2010-08-27 13:19:05821
[email protected]1a47d7e2010-10-15 00:37:24822 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:05823}
824
[email protected]e2ddbc92010-10-15 20:02:07825void FlagsState::RemoveFlagsSwitches(
826 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:53827 for (std::map<std::string, std::string>::const_iterator
828 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
829 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:07830 }
831}
832
833void FlagsState::reset() {
834 needs_restart_ = false;
835 flags_switches_.clear();
836}
837
[email protected]38e46812011-05-09 20:49:22838} // namespace
[email protected]e2ddbc92010-10-15 20:02:07839
840namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:19841
842// WARNING: '@' is also used in the html file. If you update this constant you
843// also need to update the html file.
844const char kMultiSeparator[] = "@";
845
[email protected]e2ddbc92010-10-15 20:02:07846void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:55847 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:07848}
[email protected]a314ee5a2010-10-26 21:23:28849
850void SetExperiments(const Experiment* e, size_t count) {
851 if (!e) {
852 experiments = kExperiments;
853 num_experiments = arraysize(kExperiments);
854 } else {
855 experiments = e;
856 num_experiments = count;
857 }
858}
859
[email protected]8a6ff28d2010-12-02 16:35:19860const Experiment* GetExperiments(size_t* count) {
861 *count = num_experiments;
862 return experiments;
863}
864
[email protected]e2ddbc92010-10-15 20:02:07865} // namespace testing
866
[email protected]1a47d7e2010-10-15 00:37:24867} // namespace about_flags