blob: 2ad644fcbdad7a891ce4faa2895ad87842410a40 [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]c08950d22011-10-13 22:20:2923#include "content/public/common/content_switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0524#include "grit/generated_resources.h"
[email protected]c051a1b2011-01-21 23:30:1725#include "ui/base/l10n/l10n_util.h"
[email protected]8ff7f342011-05-25 01:49:4726#include "ui/gfx/gl/gl_switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0527
[email protected]1a47d7e2010-10-15 00:37:2428namespace about_flags {
[email protected]ad2a3ded2010-08-27 13:19:0529
[email protected]8a6ff28d2010-12-02 16:35:1930// Macros to simplify specifying the type.
[email protected]a82744532011-02-11 16:15:5331#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
32 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0
33#define SINGLE_VALUE_TYPE(command_line_switch) \
34 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
35#define MULTI_VALUE_TYPE(choices) \
[email protected]0e6f56d2011-02-12 23:45:1536 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices)
[email protected]8a6ff28d2010-12-02 16:35:1937
[email protected]e2ddbc92010-10-15 20:02:0738namespace {
39
[email protected]a314ee5a2010-10-26 21:23:2840const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS;
[email protected]ad2a3ded2010-08-27 13:19:0541
[email protected]ba8164242010-11-16 21:31:0042// Names for former Chrome OS Labs experiments, shared with prefs migration
43// code.
44const char kMediaPlayerExperimentName[] = "media-player";
45const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
46const char kVerticalTabsExperimentName[] = "vertical-tabs";
47
[email protected]778ef7c2011-10-11 15:37:0548const Experiment::Choice kPrerenderFromOmniboxChoices[] = {
49 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_AUTOMATIC, "", "" },
50 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_ENABLED, switches::kPrerenderFromOmnibox,
51 switches::kPrerenderFromOmniboxSwitchValueEnabled },
52 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_DISABLED, switches::kPrerenderFromOmnibox,
53 switches::kPrerenderFromOmniboxSwitchValueDisabled }
54};
55
[email protected]4bc5050c2010-11-18 17:55:5456// RECORDING USER METRICS FOR FLAGS:
57// -----------------------------------------------------------------------------
58// The first line of the experiment is the internal name. If you'd like to
59// gather statistics about the usage of your flag, you should append a marker
60// comment to the end of the feature name, like so:
61// "my-special-feature", // FLAGS:RECORD_UMA
62//
63// After doing that, run //chrome/tools/extract_actions.py (see instructions at
64// the top of that file for details) to update the chromeactions.txt file, which
65// will enable UMA to record your feature flag.
66//
67// After your feature has shipped under a flag, you can locate the metrics
68// under the action name AboutFlags_internal-action-name. Actions are recorded
69// once per startup, so you should divide this number by AboutFlags_StartupTick
70// to get a sense of usage. Note that this will not be the same as number of
71// users with a given feature enabled because users can quit and relaunch
72// the application multiple times over a given time interval.
73// TODO(rsesek): See if there's a way to count per-user, rather than
74// per-startup.
75
[email protected]8a6ff28d2010-12-02 16:35:1976// To add a new experiment add to the end of kExperiments. There are two
77// distinct types of experiments:
78// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
79// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:2280// . MULTI_VALUE: a list of choices, the first of which should correspond to a
81// deactivated state for this lab (i.e. no command line option). To specify
82// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
83// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:1984// See the documentation of Experiment for details on the fields.
85//
86// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:0587const Experiment kExperiments[] = {
88 {
[email protected]aac169d2011-03-18 19:53:0389 "expose-for-tabs", // FLAGS:RECORD_UMA
90 IDS_FLAGS_TABPOSE_NAME,
91 IDS_FLAGS_TABPOSE_DESCRIPTION,
92 kOsMac,
93#if defined(OS_MACOSX)
94 // The switch exists only on OS X.
95 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
96#else
97 SINGLE_VALUE_TYPE("")
98#endif
99 },
100 {
[email protected]4bc5050c2010-11-18 17:55:54101 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05102 IDS_FLAGS_CONFLICTS_CHECK_NAME,
103 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
104 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19105 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05106 },
107 {
[email protected]4bc5050c2010-11-18 17:55:54108 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]9486c1f2010-10-14 19:52:12109 IDS_FLAGS_CLOUD_PRINT_PROXY_NAME,
110 IDS_FLAGS_CLOUD_PRINT_PROXY_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45111 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22112 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31113 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22114 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
115 // always have PDF rasterization available, so no flag needed there.
116#if !defined(GOOGLE_CHROME_BUILD)
117 kOsWin,
118#else
119 0,
[email protected]fa6d2a2f2010-11-30 21:47:19120#endif
[email protected]8a6ff28d2010-12-02 16:35:19121 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42122 },
[email protected]580939a2010-10-12 18:54:37123 {
[email protected]bb461532010-11-26 21:50:23124 "crxless-web-apps",
125 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
126 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
127 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19128 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23129 },
130 {
[email protected]f72d0c62011-08-31 16:27:44131 "lazy-background-pages",
132 IDS_FLAGS_LAZY_BACKGROUND_PAGES_NAME,
133 IDS_FLAGS_LAZY_BACKGROUND_PAGES_DESCRIPTION,
134 kOsAll,
135 SINGLE_VALUE_TYPE(switches::kEnableLazyBackgroundPages)
136 },
137 {
[email protected]96c6f4c2011-05-18 19:36:22138 "ignore-gpu-blacklist",
139 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
140 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
141 kOsAll,
142 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
143 },
144 {
[email protected]0110cf112011-07-02 00:39:43145 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22146 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
147 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
148 kOsAll,
149 SINGLE_VALUE_TYPE(switches::kForceCompositingMode)
150 },
151 {
[email protected]5963b772011-02-09 22:55:38152 "composited-layer-borders",
153 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
154 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
155 kOsAll,
156 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
157 },
158 {
[email protected]a8f1eaa2011-03-07 19:00:58159 "show-fps-counter",
160 IDS_FLAGS_SHOW_FPS_COUNTER,
161 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
162 kOsAll,
163 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
164 },
[email protected]8ff7f342011-05-25 01:49:47165 {
166 "disable-gpu-vsync",
167 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
168 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
169 kOsAll,
170 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
171 },
[email protected]deaba6d52011-09-23 14:47:12172 {
173 "disable-webgl",
174 IDS_FLAGS_DISABLE_WEBGL_NAME,
175 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
176 kOsAll,
177 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
178 },
[email protected]9de0ec12011-08-24 21:57:50179 // Exposed on all platforms until there is a workaround for easy access to
180 // the native print dialog for users that need it. Once that's done, revert
181 // back to:
182 // Only expose this for Chromium builds where users may not have the PDF
183 // plugin. Do not give Google Chrome users the option to disable it here.
184 // Also expose it for Chrome OS where print preview is still experimental.
[email protected]8d260e52010-10-13 01:03:05185 {
[email protected]4bc5050c2010-11-18 17:55:54186 "print-preview", // FLAGS:RECORD_UMA
[email protected]9486c1f2010-10-14 19:52:12187 IDS_FLAGS_PRINT_PREVIEW_NAME,
188 IDS_FLAGS_PRINT_PREVIEW_DESCRIPTION,
[email protected]b579afd2011-07-13 00:01:27189 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19190 SINGLE_VALUE_TYPE(switches::kEnablePrintPreview)
[email protected]2fe15fcb2010-10-21 20:39:53191 },
[email protected]d208f4d82011-05-23 21:52:03192 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53193 {
[email protected]e3791ce92011-08-09 01:03:32194 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40195 IDS_FLAGS_ENABLE_NACL_NAME,
196 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
197 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19198 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40199 },
200 {
[email protected]4bc5050c2010-11-18 17:55:54201 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32202 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
203 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
204 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19205 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32206 },
[email protected]3627b06d2010-11-12 16:36:16207 {
[email protected]cbe224d2011-08-04 22:12:49208 "apps-new-install-bubble",
209 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
210 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
211 kOsAll,
212 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
213 },
214 {
[email protected]4bc5050c2010-11-18 17:55:54215 "click-to-play", // FLAGS:RECORD_UMA
[email protected]3627b06d2010-11-12 16:36:16216 IDS_FLAGS_CLICK_TO_PLAY_NAME,
217 IDS_FLAGS_CLICK_TO_PLAY_DESCRIPTION,
218 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19219 SINGLE_VALUE_TYPE(switches::kEnableClickToPlay)
[email protected]3627b06d2010-11-12 16:36:16220 },
[email protected]80bd24e2010-11-30 09:34:38221 {
222 "disable-hyperlink-auditing",
223 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
224 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
225 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19226 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51227 },
228 {
229 "experimental-location-features", // FLAGS:RECORD_UMA
230 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
231 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
232 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19233 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
234 },
235 {
[email protected]4c6452d2011-01-12 08:47:57236 "block-reading-third-party-cookies",
237 IDS_FLAGS_BLOCK_ALL_THIRD_PARTY_COOKIES_NAME,
238 IDS_FLAGS_BLOCK_ALL_THIRD_PARTY_COOKIES_DESCRIPTION,
239 kOsAll,
240 SINGLE_VALUE_TYPE(switches::kBlockReadingThirdPartyCookies)
241 },
[email protected]04227962011-01-20 02:03:09242 {
243 "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 {
264 "ppapi-flash-in-process",
265 IDS_FLAGS_PPAPI_FLASH_IN_PROCESS_NAME,
266 IDS_FLAGS_PPAPI_FLASH_IN_PROCESS_DESCRIPTION,
[email protected]f2d3ce0d2011-04-01 18:19:30267 kOsAll,
[email protected]e9bf9d92011-03-31 20:57:15268 SINGLE_VALUE_TYPE(switches::kPpapiFlashInProcess)
269 },
[email protected]ce5737142011-04-14 23:35:09270 {
[email protected]f2557bd2011-06-01 02:33:07271 "preload-instant-search",
272 IDS_FLAGS_PRELOAD_INSTANT_SEARCH_NAME,
273 IDS_FLAGS_PRELOAD_INSTANT_SEARCH_DESCRIPTION,
274 kOsAll,
275 SINGLE_VALUE_TYPE(switches::kPreloadInstantSearch)
276 },
[email protected]354e33b2011-06-15 00:29:10277 {
278 "static-ip-config",
279 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
280 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
281 kOsCrOS,
282#if defined(OS_CHROMEOS)
283 // This switch exists only on Chrome OS.
284 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
285#else
286 SINGLE_VALUE_TYPE("")
287#endif
288 },
[email protected]3eb5728c2011-06-20 22:32:24289 {
290 "show-autofill-type-predictions",
291 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
292 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
293 kOsAll,
294 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
295 },
[email protected]bff4d3e2011-06-21 23:58:52296 {
[email protected]9a6180d7d2011-09-07 01:40:33297 "sync-tabs",
298 IDS_FLAGS_SYNC_TABS_NAME,
299 IDS_FLAGS_SYNC_TABS_DESCRIPTION,
[email protected]5b0ec7f2011-08-11 02:17:17300 kOsAll,
[email protected]9a6180d7d2011-09-07 01:40:33301 SINGLE_VALUE_TYPE(switches::kEnableSyncTabs)
[email protected]5b0ec7f2011-08-11 02:17:17302 },
303 {
[email protected]d9e33092011-09-01 03:34:05304 "sync-search-engines",
305 IDS_FLAGS_SYNC_SEARCH_ENGINES_NAME,
306 IDS_FLAGS_SYNC_SEARCH_ENGINES_DESCRIPTION,
307 kOsAll,
308 SINGLE_VALUE_TYPE(switches::kEnableSyncSearchEngines)
309 },
310 {
[email protected]aae9eeb12011-10-21 21:59:26311 "sync-app-notifications",
312 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
313 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
314 kOsAll,
315 SINGLE_VALUE_TYPE(switches::kEnableSyncAppNotifications)
316 },
317 {
[email protected]a22ebd812011-06-23 00:05:39318 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
319 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
320 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
321 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40322 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40323 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39324 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
325 },
[email protected]81a6b0b2011-06-24 17:55:40326 {
[email protected]ae1eb29a2011-08-17 17:50:57327 "prerender-from-omnibox", // FLAGS:RECORD_UMA
[email protected]81a6b0b2011-06-24 17:55:40328 IDS_FLAGS_PRERENDER_FROM_OMNIBOX_NAME,
329 IDS_FLAGS_PRERENDER_FROM_OMNIBOX_DESCRIPTION,
330 kOsAll,
[email protected]778ef7c2011-10-11 15:37:05331 MULTI_VALUE_TYPE(kPrerenderFromOmniboxChoices)
[email protected]81a6b0b2011-06-24 17:55:40332 },
[email protected]40916632011-07-02 01:11:01333 {
[email protected]73fb1fc52011-07-09 00:06:54334 "panels",
335 IDS_FLAGS_ENABLE_PANELS_NAME,
336 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
337 kOsAll,
338 SINGLE_VALUE_TYPE(switches::kEnablePanels)
339 },
[email protected]e3749d12011-07-25 22:22:12340 {
341 "enable-shortcuts-provider",
342 IDS_FLAGS_ENABLE_SHORTCUTS_PROVIDER,
343 IDS_FLAGS_ENABLE_SHORTCUTS_PROVIDER_DESCRIPTION,
344 kOsAll,
345 SINGLE_VALUE_TYPE(switches::kEnableShortcutsProvider)
346 },
[email protected]1a2966b92011-08-09 06:50:19347#if defined(OS_CHROMEOS)
348 {
[email protected]35d16db2011-08-26 00:13:12349 "enable-archives",
350 IDS_FILE_BROWSER_MOUNT_ARCHIVE,
351 IDS_FILE_MANAGER,
352 kOsCrOS,
353 SINGLE_VALUE_TYPE(switches::kEnableArchives)
354 },
[email protected]cd681c42011-09-29 02:49:44355 {
356 "enable-bluetooth",
357 IDS_FLAGS_ENABLE_BLUETOOTH_NAME,
358 IDS_FLAGS_ENABLE_BLUETOOTH_DESCRIPTION,
359 kOsCrOS,
360 SINGLE_VALUE_TYPE(switches::kEnableBluetooth)
361 },
[email protected]1a2966b92011-08-09 06:50:19362#endif
[email protected]80eb4262011-08-03 16:10:41363 {
364 "memory-widget",
365 IDS_FLAGS_MEMORY_WIDGET_NAME,
366 IDS_FLAGS_MEMORY_WIDGET_DESCRIPTION,
367 kOsCrOS,
368#if defined(OS_CHROMEOS)
369 // This switch exists only on Chrome OS.
370 SINGLE_VALUE_TYPE(switches::kMemoryWidget)
371#else
372 SINGLE_VALUE_TYPE("")
373#endif
[email protected]a0e4b072011-08-17 01:47:07374 },
[email protected]6ec18e62011-09-10 00:28:18375#if defined(TOUCH_UI)
376 {
377 "touchui-views-desktop",
378 IDS_FLAGS_DISABLE_VIEWS_DESKTOP_NAME,
379 IDS_FLAGS_DISABLE_VIEWS_DESKTOP_DESCRIPTION,
380 kOsCrOS,
381 SINGLE_VALUE_TYPE_AND_VALUE(switches::kViewsDesktop, "disabled")
382 },
383#endif
[email protected]a0e4b072011-08-17 01:47:07384 {
385 "downloads-new-ui", // FLAGS:RECORD_UMA
386 IDS_FLAGS_DOWNLOADS_NEW_UI_NAME,
387 IDS_FLAGS_DOWNLOADS_NEW_UI_DESCRIPTION,
388 kOsAll,
389 SINGLE_VALUE_TYPE(switches::kDownloadsNewUI)
390 },
[email protected]b7bb44f2011-09-01 05:17:03391 {
392 "enable-autologin",
393 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
394 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
395 kOsMac | kOsWin | kOsLinux,
396 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
397 },
[email protected]b9841172011-09-26 23:36:09398 {
399 "use-more-webui",
400 IDS_FLAGS_USE_MORE_WEBUI_NAME,
401 IDS_FLAGS_USE_MORE_WEBUI_DESCRIPTION,
402 kOsAll,
403 SINGLE_VALUE_TYPE(switches::kUseMoreWebUI)
404 },
[email protected]89c64cd2011-10-04 01:41:10405 {
[email protected]d411c01d2011-10-18 16:00:27406 "webui-lock-screen",
407 IDS_FLAGS_WEBUI_LOCK_NAME,
408 IDS_FLAGS_WEBUI_LOCK_DESCRIPTION,
409 kOsCrOS,
410#if defined(OS_CHROMEOS)
411 SINGLE_VALUE_TYPE(switches::kWebUILockScreen)
412#else
413 SINGLE_VALUE_TYPE("")
414#endif
415 },
416 {
[email protected]89c64cd2011-10-04 01:41:10417 "enable-ntp-bookmark-features",
418 IDS_FLAGS_ENABLE_NTP_BOOKMARK_FEATURES_NAME,
419 IDS_FLAGS_ENABLE_NTP_BOOKMARK_FEATURES_DESCRIPTION,
420 kOsAll,
421 SINGLE_VALUE_TYPE(switches::kEnableNTPBookmarkFeatures)
422 },
[email protected]f5da41d2011-10-08 17:40:07423 {
424 "enable-video-track",
425 IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME,
426 IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION,
427 kOsAll,
428 SINGLE_VALUE_TYPE(switches::kEnableVideoTrack)
429 },
[email protected]08b83362011-10-19 05:23:17430 {
431 "extension-alerts",
432 IDS_FLAGS_ENABLE_EXTENSION_ALERTS_NAME,
433 IDS_FLAGS_ENABLE_EXTENSION_ALERTS_DESCRIPTION,
434 kOsAll,
435 SINGLE_VALUE_TYPE(switches::kEnableExtensionAlerts)
436 },
[email protected]5a60c8b2011-10-19 20:14:29437 {
438 "enable-http-pipelining",
439 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
440 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
441 kOsAll,
442 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
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