blob: 3751805dfa62b9891f93305dd9e992c5e2b6abd8 [file] [log] [blame]
[email protected]9c66adc2012-01-05 02:10:161// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ad2a3ded2010-08-27 13:19:052// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]1a47d7e2010-10-15 00:37:245#include "chrome/browser/about_flags.h"
[email protected]ad2a3ded2010-08-27 13:19:056
7#include <algorithm>
8#include <iterator>
9#include <map>
10#include <set>
11
[email protected]ad2a3ded2010-08-27 13:19:0512#include "base/command_line.h"
[email protected]3b63f8f42011-03-28 01:54:1513#include "base/memory/singleton.h"
[email protected]8a6ff28d2010-12-02 16:35:1914#include "base/string_number_conversions.h"
[email protected]d208f4d82011-05-23 21:52:0315#include "base/utf_string_conversions.h"
[email protected]ad2a3ded2010-08-27 13:19:0516#include "base/values.h"
[email protected]ad2a3ded2010-08-27 13:19:0517#include "chrome/browser/prefs/pref_service.h"
[email protected]1bc78422011-03-31 08:41:3818#include "chrome/browser/prefs/scoped_user_pref_update.h"
[email protected]d208f4d82011-05-23 21:52:0319#include "chrome/common/chrome_content_client.h"
[email protected]ad2a3ded2010-08-27 13:19:0520#include "chrome/common/chrome_switches.h"
21#include "chrome/common/pref_names.h"
[email protected]7f6f44c2011-12-14 13:23:3822#include "content/public/browser/user_metrics.h"
[email protected]ad2a3ded2010-08-27 13:19:0523#include "grit/generated_resources.h"
[email protected]e2e8e322012-09-12 04:37:0224#include "media/base/media_switches.h"
[email protected]0bc6c272012-07-17 03:32:0325#include "ui/app_list/app_list_switches.h"
[email protected]c051a1b2011-01-21 23:30:1726#include "ui/base/l10n/l10n_util.h"
[email protected]c9c73ad42012-04-18 03:35:5927#include "ui/base/ui_base_switches.h"
[email protected]c9e2cbbb2012-05-12 21:17:2728#include "ui/gl/gl_switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0529
[email protected]dc04be7c2012-03-15 23:57:4930#if defined(USE_ASH)
[email protected]b65bdda2011-12-23 23:35:3131#include "ash/ash_switches.h"
[email protected]dc04be7c2012-03-15 23:57:4932#endif
33
34#if defined(USE_AURA)
[email protected]308aaa32012-03-12 13:14:5035#include "ui/aura/aura_switches.h"
[email protected]8cc10df2011-11-03 23:57:5036#endif
37
[email protected]7f6f44c2011-12-14 13:23:3838using content::UserMetricsAction;
39
[email protected]1a47d7e2010-10-15 00:37:2440namespace about_flags {
[email protected]ad2a3ded2010-08-27 13:19:0541
[email protected]8a6ff28d2010-12-02 16:35:1942// Macros to simplify specifying the type.
[email protected]a82744532011-02-11 16:15:5343#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
44 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0
45#define SINGLE_VALUE_TYPE(command_line_switch) \
46 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
47#define MULTI_VALUE_TYPE(choices) \
[email protected]0e6f56d2011-02-12 23:45:1548 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices)
[email protected]8a6ff28d2010-12-02 16:35:1949
[email protected]e2ddbc92010-10-15 20:02:0750namespace {
51
[email protected]9c7453d2012-01-21 00:45:4052const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS | kOsAndroid;
[email protected]ad2a3ded2010-08-27 13:19:0553
[email protected]cc3e2052011-12-20 01:01:4054// Adds a |StringValue| to |list| for each platform where |bitmask| indicates
55// whether the experiment is available on that platform.
56void AddOsStrings(unsigned bitmask, ListValue* list) {
57 struct {
58 unsigned bit;
59 const char* const name;
60 } kBitsToOs[] = {
61 {kOsMac, "Mac"},
62 {kOsWin, "Windows"},
63 {kOsLinux, "Linux"},
64 {kOsCrOS, "Chrome OS"},
65 };
66 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i)
67 if (bitmask & kBitsToOs[i].bit)
68 list->Append(new StringValue(kBitsToOs[i].name));
69}
70
[email protected]ba8164242010-11-16 21:31:0071// Names for former Chrome OS Labs experiments, shared with prefs migration
72// code.
73const char kMediaPlayerExperimentName[] = "media-player";
74const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
75const char kVerticalTabsExperimentName[] = "vertical-tabs";
76
[email protected]68317802012-06-07 19:13:2377const Experiment::Choice kOmniboxHistoryQuickProviderNewScoringChoices[] = {
78 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_AUTOMATIC, "", "" },
79 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_ENABLED,
80 switches::kOmniboxHistoryQuickProviderNewScoring,
81 switches::kOmniboxHistoryQuickProviderNewScoringEnabled },
82 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DISABLED,
83 switches::kOmniboxHistoryQuickProviderNewScoring,
84 switches::kOmniboxHistoryQuickProviderNewScoringDisabled }
85};
86
[email protected]128dc6c2012-06-22 20:30:3587const Experiment::Choice
88 kOmniboxHistoryQuickProviderReorderForInliningChoices[] = {
89 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_AUTOMATIC,
90 "",
91 "" },
92 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_ENABLED,
93 switches::kOmniboxHistoryQuickProviderReorderForInlining,
94 switches::kOmniboxHistoryQuickProviderReorderForInliningEnabled },
95 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DISABLED,
96 switches::kOmniboxHistoryQuickProviderReorderForInlining,
97 switches::kOmniboxHistoryQuickProviderReorderForInliningDisabled }
98};
99
[email protected]032d5e6c2012-02-17 17:53:55100const Experiment::Choice kOmniboxInlineHistoryQuickProviderChoices[] = {
101 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_AUTOMATIC, "", "" },
102 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_ALLOWED,
103 switches::kOmniboxInlineHistoryQuickProvider,
104 switches::kOmniboxInlineHistoryQuickProviderAllowed },
105 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_PROHIBITED,
106 switches::kOmniboxInlineHistoryQuickProvider,
107 switches::kOmniboxInlineHistoryQuickProviderProhibited }
108};
109
[email protected]de023762012-07-26 17:10:17110const Experiment::Choice kFixedPositionCreatesStackingContextChoices[] = {
111 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
112 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
113 switches::kEnableFixedPositionCreatesStackingContext, ""},
114 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
115 switches::kDisableFixedPositionCreatesStackingContext, ""}
116};
117
[email protected]9b19cf82012-06-13 06:23:23118const Experiment::Choice kForceCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20119 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
120 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]9b19cf82012-06-13 06:23:23121 switches::kForceCompositingMode, ""},
[email protected]a45c69402012-06-24 16:32:20122 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]9b19cf82012-06-13 06:23:23123 switches::kDisableForceCompositingMode, ""}
124};
125
[email protected]72787e392012-03-23 05:55:43126const Experiment::Choice kThreadedCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20127 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
128 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]72787e392012-03-23 05:55:43129 switches::kDisableThreadedCompositing, ""},
[email protected]a45c69402012-06-24 16:32:20130 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]72787e392012-03-23 05:55:43131 switches::kEnableThreadedCompositing, ""}
132};
133
[email protected]347a0c72012-05-14 20:28:06134const Experiment::Choice kTouchOptimizedUIChoices[] = {
135 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_AUTOMATIC, "", "" },
[email protected]a45c69402012-06-24 16:32:20136 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]347a0c72012-05-14 20:28:06137 switches::kTouchOptimizedUI,
138 switches::kTouchOptimizedUIEnabled },
[email protected]a45c69402012-06-24 16:32:20139 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]347a0c72012-05-14 20:28:06140 switches::kTouchOptimizedUI,
141 switches::kTouchOptimizedUIDisabled }
142};
143
[email protected]026876f32012-08-22 23:53:40144const Experiment::Choice kAsyncDnsChoices[] = {
145 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
146 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
147 switches::kDisableAsyncDns, ""},
148 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
149 switches::kEnableAsyncDns, ""}
150};
151
[email protected]347a0c72012-05-14 20:28:06152
[email protected]4bc5050c2010-11-18 17:55:54153// RECORDING USER METRICS FOR FLAGS:
154// -----------------------------------------------------------------------------
155// The first line of the experiment is the internal name. If you'd like to
156// gather statistics about the usage of your flag, you should append a marker
157// comment to the end of the feature name, like so:
158// "my-special-feature", // FLAGS:RECORD_UMA
159//
160// After doing that, run //chrome/tools/extract_actions.py (see instructions at
161// the top of that file for details) to update the chromeactions.txt file, which
162// will enable UMA to record your feature flag.
163//
164// After your feature has shipped under a flag, you can locate the metrics
165// under the action name AboutFlags_internal-action-name. Actions are recorded
166// once per startup, so you should divide this number by AboutFlags_StartupTick
167// to get a sense of usage. Note that this will not be the same as number of
168// users with a given feature enabled because users can quit and relaunch
169// the application multiple times over a given time interval.
170// TODO(rsesek): See if there's a way to count per-user, rather than
171// per-startup.
172
[email protected]8a6ff28d2010-12-02 16:35:19173// To add a new experiment add to the end of kExperiments. There are two
174// distinct types of experiments:
175// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
176// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:22177// . MULTI_VALUE: a list of choices, the first of which should correspond to a
178// deactivated state for this lab (i.e. no command line option). To specify
179// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
180// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:19181// See the documentation of Experiment for details on the fields.
182//
183// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:05184const Experiment kExperiments[] = {
185 {
[email protected]aac169d2011-03-18 19:53:03186 "expose-for-tabs", // FLAGS:RECORD_UMA
187 IDS_FLAGS_TABPOSE_NAME,
188 IDS_FLAGS_TABPOSE_DESCRIPTION,
189 kOsMac,
190#if defined(OS_MACOSX)
191 // The switch exists only on OS X.
192 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
193#else
194 SINGLE_VALUE_TYPE("")
195#endif
196 },
197 {
[email protected]4bc5050c2010-11-18 17:55:54198 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05199 IDS_FLAGS_CONFLICTS_CHECK_NAME,
200 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
201 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19202 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05203 },
204 {
[email protected]4bc5050c2010-11-18 17:55:54205 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]dae7325b2011-12-21 20:56:54206 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME,
207 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45208 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22209 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31210 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22211 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
212 // always have PDF rasterization available, so no flag needed there.
213#if !defined(GOOGLE_CHROME_BUILD)
214 kOsWin,
215#else
216 0,
[email protected]fa6d2a2f2010-11-30 21:47:19217#endif
[email protected]8a6ff28d2010-12-02 16:35:19218 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42219 },
[email protected]60d77bd2012-08-22 00:10:07220#if defined(OS_WIN)
221 {
222 "print-raster",
223 IDS_FLAGS_PRINT_RASTER_NAME,
224 IDS_FLAGS_PRINT_RASTER_DESCRIPTION,
225 kOsWin,
226 SINGLE_VALUE_TYPE(switches::kPrintRaster)
227 },
228#endif // OS_WIN
[email protected]0209b442012-07-18 00:38:05229 {
[email protected]bb461532010-11-26 21:50:23230 "crxless-web-apps",
231 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
232 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
233 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19234 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23235 },
236 {
[email protected]96c6f4c2011-05-18 19:36:22237 "ignore-gpu-blacklist",
238 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
239 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
240 kOsAll,
241 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
242 },
243 {
[email protected]0110cf112011-07-02 00:39:43244 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22245 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
246 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
[email protected]9b19cf82012-06-13 06:23:23247 kOsMac | kOsWin | kOsLinux,
248 MULTI_VALUE_TYPE(kForceCompositingModeChoices)
[email protected]96c6f4c2011-05-18 19:36:22249 },
250 {
[email protected]72787e392012-03-23 05:55:43251 "threaded-compositing-mode",
252 IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME,
253 IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59254 kOsAll,
[email protected]72787e392012-03-23 05:55:43255 MULTI_VALUE_TYPE(kThreadedCompositingModeChoices)
[email protected]644a1072012-03-16 09:29:59256 },
257 {
[email protected]81c64af62012-06-06 20:15:52258 "disable-accelerated-2d-canvas",
259 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_NAME,
260 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_DESCRIPTION,
261 kOsAll,
262 SINGLE_VALUE_TYPE(switches::kDisableAccelerated2dCanvas)
263 },
264 {
[email protected]69cffc82012-08-10 13:27:27265 "disable-deferred-2d-canvas",
266 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_NAME,
267 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_DESCRIPTION,
268 kOsAll,
269 SINGLE_VALUE_TYPE(switches::kDisableDeferred2dCanvas)
270 },
271 {
[email protected]efcde132012-05-30 01:05:18272 "disable-threaded-animation",
273 IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME,
274 IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59275 kOsAll,
[email protected]efcde132012-05-30 01:05:18276 SINGLE_VALUE_TYPE(switches::kDisableThreadedAnimation)
[email protected]644a1072012-03-16 09:29:59277 },
278 {
[email protected]5963b772011-02-09 22:55:38279 "composited-layer-borders",
280 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
281 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
282 kOsAll,
283 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
284 },
285 {
[email protected]a8f1eaa2011-03-07 19:00:58286 "show-fps-counter",
287 IDS_FLAGS_SHOW_FPS_COUNTER,
288 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
289 kOsAll,
290 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
291 },
[email protected]8ff7f342011-05-25 01:49:47292 {
[email protected]70c98a332011-12-21 20:51:52293 "accelerated-filters",
294 IDS_FLAGS_ACCELERATED_FILTERS,
295 IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION,
296 kOsAll,
297 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters)
298 },
299 {
[email protected]8ff7f342011-05-25 01:49:47300 "disable-gpu-vsync",
301 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
302 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
303 kOsAll,
304 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
305 },
[email protected]deaba6d52011-09-23 14:47:12306 {
307 "disable-webgl",
308 IDS_FLAGS_DISABLE_WEBGL_NAME,
309 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
310 kOsAll,
311 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
312 },
[email protected]09096e02012-05-24 11:12:04313 {
[email protected]96bcdc102012-05-24 23:42:10314 "fixed-position-creates-stacking-context",
315 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_NAME,
316 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_DESCRIPTION,
317 kOsAll,
[email protected]de023762012-07-26 17:10:17318 MULTI_VALUE_TYPE(kFixedPositionCreatesStackingContextChoices)
[email protected]96bcdc102012-05-24 23:42:10319 },
[email protected]d208f4d82011-05-23 21:52:03320 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53321 {
[email protected]e3791ce92011-08-09 01:03:32322 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40323 IDS_FLAGS_ENABLE_NACL_NAME,
324 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
325 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19326 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40327 },
[email protected]b39c6d92012-01-31 16:38:41328 // TODO(halyavin): When exception handling is on by default, replace this
329 // flag with disable-nacl-exception-handling.
330 {
331 "enable-nacl-exception-handling", // FLAGS:RECORD_UMA
332 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME,
333 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION,
[email protected]bf2c61b2012-08-30 16:37:04334 kOsAll,
[email protected]b39c6d92012-01-31 16:38:41335 SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling)
336 },
[email protected]4ff87d202010-11-06 01:28:40337 {
[email protected]9addd1c2012-09-15 14:28:24338 "enable-nacl-debug", // FLAGS:RECORD_UMA
339 IDS_FLAGS_ENABLE_NACL_DEBUG_NAME,
340 IDS_FLAGS_ENABLE_NACL_DEBUG_DESCRIPTION,
[email protected]401b90792012-05-30 11:41:13341 kOsAll,
[email protected]9addd1c2012-09-15 14:28:24342 SINGLE_VALUE_TYPE(switches::kEnableNaClDebug)
[email protected]401b90792012-05-30 11:41:13343 },
344 {
[email protected]7babd1c2012-08-08 20:35:29345 "enable-pnacl", // FLAGS:RECORD_UMA
346 IDS_FLAGS_ENABLE_PNACL_NAME,
347 IDS_FLAGS_ENABLE_PNACL_DESCRIPTION,
348 kOsAll,
349 SINGLE_VALUE_TYPE(switches::kEnablePnacl)
350 },
351 {
[email protected]d3a8cfc2012-09-14 18:31:38352 "enable-scripted-speech", // FLAGS:RECORD_UMA
353 IDS_FLAGS_ENABLE_SCRIPTED_SPEECH_NAME,
354 IDS_FLAGS_ENABLE_SCRIPTED_SPEECH_DESCRIPTION,
355 kOsAll,
356 SINGLE_VALUE_TYPE(switches::kEnableScriptedSpeech)
357 },
358 {
[email protected]4bc5050c2010-11-18 17:55:54359 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32360 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
361 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
362 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19363 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32364 },
[email protected]3627b06d2010-11-12 16:36:16365 {
[email protected]f5b7e462012-09-12 00:37:49366 "action-box",
[email protected]cab18ef2012-04-27 07:22:03367 IDS_FLAGS_ACTION_BOX_NAME,
368 IDS_FLAGS_ACTION_BOX_DESCRIPTION,
369 kOsAll,
[email protected]f5b7e462012-09-12 00:37:49370 SINGLE_VALUE_TYPE(switches::kEnableActionBox),
[email protected]cab18ef2012-04-27 07:22:03371 },
372 {
[email protected]3a362432012-06-18 20:39:51373 "script-badges",
374 IDS_FLAGS_SCRIPT_BADGES_NAME,
375 IDS_FLAGS_SCRIPT_BADGES_DESCRIPTION,
376 kOsAll,
377 SINGLE_VALUE_TYPE(switches::kEnableScriptBadges),
378 },
379 {
[email protected]cbe224d2011-08-04 22:12:49380 "apps-new-install-bubble",
381 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
382 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
383 kOsAll,
384 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
385 },
386 {
[email protected]80bd24e2010-11-30 09:34:38387 "disable-hyperlink-auditing",
388 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
389 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
390 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19391 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51392 },
393 {
394 "experimental-location-features", // FLAGS:RECORD_UMA
395 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
396 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
397 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19398 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
399 },
400 {
[email protected]5aea1862011-03-23 23:55:39401 "tab-groups-context-menu",
402 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
403 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
404 kOsWin,
405 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
406 },
[email protected]c94cebd2012-06-21 00:55:28407#if defined(OS_CHROMEOS)
408 {
409 "enable-instant-extended-api",
410 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API,
411 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API_DESCRIPTION,
412 kOsAll,
413 SINGLE_VALUE_TYPE(switches::kEnableInstantExtendedAPI)
414 },
415#endif
[email protected]e9bf9d92011-03-31 20:57:15416 {
[email protected]354e33b2011-06-15 00:29:10417 "static-ip-config",
418 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
419 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
420 kOsCrOS,
421#if defined(OS_CHROMEOS)
422 // This switch exists only on Chrome OS.
423 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
424#else
425 SINGLE_VALUE_TYPE("")
426#endif
427 },
[email protected]3eb5728c2011-06-20 22:32:24428 {
429 "show-autofill-type-predictions",
430 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
431 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
432 kOsAll,
433 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
434 },
[email protected]bff4d3e2011-06-21 23:58:52435 {
[email protected]fdf4e252012-04-27 00:26:55436 "sync-tab-favicons",
437 IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
438 IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
439 kOsAll,
440 SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
441 },
442 {
[email protected]aae9eeb12011-10-21 21:59:26443 "sync-app-notifications",
444 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
445 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
446 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11447 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26448 },
449 {
[email protected]e755a382012-09-13 17:16:35450 "enable-gesture-tap-highlight",
451 IDS_FLAGS_ENABLE_GESTURE_TAP_HIGHLIGHTING_NAME,
452 IDS_FLAGS_ENABLE_GESTURE_TAP_HIGHLIGHTING_DESCRIPTION,
453 kOsLinux | kOsCrOS,
454 SINGLE_VALUE_TYPE(switches::kEnableGestureTapHighlight)
455 },
456 {
[email protected]a22ebd812011-06-23 00:05:39457 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
458 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
459 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
460 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40461 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40462 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39463 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
464 },
[email protected]81a6b0b2011-06-24 17:55:40465 {
[email protected]68317802012-06-07 19:13:23466 "omnibox-history-quick-provider-new-scoring",
467 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_NAME,
468 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DESCRIPTION,
469 kOsAll,
470 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderNewScoringChoices)
471 },
472 {
[email protected]128dc6c2012-06-22 20:30:35473 "omnibox-history-quick-provider-reorder-for-inlining",
474 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_NAME,
475 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DESCRIPTION,
476 kOsAll,
477 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderReorderForInliningChoices)
478 },
479 {
[email protected]032d5e6c2012-02-17 17:53:55480 "omnibox-inline-history-quick-provider",
481 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME,
482 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION,
483 kOsAll,
484 MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices)
485 },
486 {
[email protected]7e7a28092011-12-09 22:24:55487 "enable-panels",
488 IDS_FLAGS_ENABLE_PANELS_NAME,
489 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54490 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55491 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54492 },
[email protected]e3749d12011-07-25 22:22:12493 {
[email protected]27c14f02012-06-22 17:29:58494 // See http://crbug.com/120416 for how to remove this flag.
[email protected]6474b112012-05-04 19:35:27495 "save-page-as-mhtml", // FLAGS:RECORD_UMA
496 IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME,
497 IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION,
498 kOsMac | kOsWin | kOsLinux,
499 SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)
500 },
501 {
[email protected]b7bb44f2011-09-01 05:17:03502 "enable-autologin",
503 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
504 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
505 kOsMac | kOsWin | kOsLinux,
506 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
507 },
[email protected]b9841172011-09-26 23:36:09508 {
[email protected]bbadb112011-12-12 16:55:28509 "enable-http-pipelining",
510 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
511 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
512 kOsAll,
513 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
514 },
[email protected]d411c01d2011-10-18 16:00:27515 {
[email protected]3231b612012-03-23 05:57:54516 "enable-spdy3",
517 IDS_FLAGS_ENABLE_SPDY3_NAME,
518 IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION,
519 kOsAll,
520 SINGLE_VALUE_TYPE(switches::kEnableSpdy3)
521 },
522 {
[email protected]27b3fe92012-03-21 05:35:06523 "enable-async-dns",
524 IDS_FLAGS_ENABLE_ASYNC_DNS_NAME,
525 IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION,
[email protected]85594c142012-09-11 18:02:46526 kOsWin | kOsMac | kOsLinux | kOsCrOS,
[email protected]026876f32012-08-22 23:53:40527 MULTI_VALUE_TYPE(kAsyncDnsChoices)
[email protected]27b3fe92012-03-21 05:35:06528 },
529 {
[email protected]1eb93802012-09-11 18:57:56530 "disable-media-source",
[email protected]da43c082012-09-07 18:56:11531 IDS_FLAGS_DISABLE_MEDIA_SOURCE_NAME,
532 IDS_FLAGS_DISABLE_MEDIA_SOURCE_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32533 kOsAll,
[email protected]da43c082012-09-07 18:56:11534 SINGLE_VALUE_TYPE(switches::kDisableMediaSource)
[email protected]6aa03b32011-10-27 21:44:44535 },
[email protected]e4e68dbb2011-11-18 01:50:22536 {
[email protected]9f5b7822012-04-18 23:39:03537 "enable-encrypted-media",
538 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME,
539 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION,
540 kOsAll,
541 SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia)
542 },
[email protected]dc04be7c2012-03-15 23:57:49543#if defined(USE_ASH)
[email protected]8cc10df2011-11-03 23:57:50544 {
[email protected]57b8bb352012-01-11 05:11:46545 "aura-google-dialog-frames",
546 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME,
547 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION,
548 kOsWin | kOsLinux | kOsCrOS,
549 SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames)
550 },
[email protected]dc04be7c2012-03-15 23:57:49551#endif
[email protected]eaae8b462012-01-20 22:20:39552 {
[email protected]db543d322011-12-15 20:40:15553 "per-tile-painting",
554 IDS_FLAGS_PER_TILE_PAINTING_NAME,
555 IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION,
556#if defined(USE_SKIA)
[email protected]a5b1b272012-01-06 20:44:37557 kOsMac | kOsLinux | kOsCrOS,
[email protected]db543d322011-12-15 20:40:15558#else
559 0,
560#endif
561 SINGLE_VALUE_TYPE(switches::kEnablePerTilePainting)
562 },
[email protected]bf88c032011-12-22 19:05:47563 {
564 "enable-javascript-harmony",
565 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME,
566 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION,
567 kOsAll,
568 SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony")
569 },
[email protected]7e7f378a2012-01-05 14:35:37570 {
[email protected]85646172012-01-09 22:45:54571 "enable-tab-browser-dragging",
572 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME,
573 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION,
574 kOsWin,
575 SINGLE_VALUE_TYPE(switches::kTabBrowserDragging)
576 },
577 {
[email protected]068b7b52012-02-27 12:41:44578 "disable-restore-session-state",
579 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME,
580 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION,
[email protected]7e7f378a2012-01-05 14:35:37581 kOsAll,
[email protected]068b7b52012-02-27 12:41:44582 SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState)
[email protected]7e7f378a2012-01-05 14:35:37583 },
[email protected]88864db2012-01-18 20:56:35584 {
585 "disable-software-rasterizer",
586 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME,
587 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION,
588#if defined(ENABLE_SWIFTSHADER)
589 kOsAll,
590#else
591 0,
592#endif
593 SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer)
594 },
[email protected]15a5d722012-01-23 09:11:14595 {
[email protected]ff7b6dd2012-09-15 20:20:03596 "enable-experimental-webkit-features",
597 IDS_FLAGS_EXPERIMENTAL_WEBKIT_FEATURES_NAME,
598 IDS_FLAGS_EXPERIMENTAL_WEBKIT_FEATURES_DESCRIPTION,
[email protected]d2edc6702012-01-30 09:13:16599 kOsAll,
[email protected]ff7b6dd2012-09-15 20:20:03600 SINGLE_VALUE_TYPE(switches::kEnableExperimentalWebKitFeatures)
[email protected]ca7a3d792012-03-02 15:55:49601 },
602 {
[email protected]0f95a252012-09-13 22:30:04603 "enable-css-shaders",
604 IDS_FLAGS_CSS_SHADERS_NAME,
605 IDS_FLAGS_CSS_SHADERS_DESCRIPTION,
606 kOsAll,
607 SINGLE_VALUE_TYPE(switches::kEnableCssShaders)
608 },
609 {
[email protected]9860c68b2012-02-02 01:58:09610 "enable-extension-activity-ui",
611 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME,
612 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION,
613 kOsAll,
614 SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI)
[email protected]8bed69d2012-02-02 06:46:00615 },
[email protected]54ae4e92012-02-16 15:19:05616 {
[email protected]3e8befc2012-03-13 01:17:03617 "disable-ntp-other-sessions-menu",
[email protected]156f966332012-02-29 00:03:16618 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME,
619 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION,
620 kOsAll,
[email protected]3e8befc2012-03-13 01:17:03621 SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu)
[email protected]156f966332012-02-29 00:03:16622 },
[email protected]dc04be7c2012-03-15 23:57:49623#if defined(USE_ASH)
[email protected]31cf1c52012-02-29 20:55:01624 {
[email protected]3cd198a22012-03-12 20:38:01625 "enable-ash-oak",
626 IDS_FLAGS_ENABLE_ASH_OAK_NAME,
627 IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION,
628 kOsAll,
629 SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak),
630 },
[email protected]31cf1c52012-02-29 20:55:01631#endif
[email protected]184ec592012-03-01 11:54:28632 {
633 "enable-devtools-experiments",
634 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME,
635 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION,
636 kOsAll,
637 SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments)
638 },
[email protected]76d1854e2012-03-02 23:57:44639 {
640 "enable-suggestions-ntp",
641 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME,
642 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION,
643 kOsAll,
644 SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage)
645 },
[email protected]a78ef9e2012-03-21 02:49:55646 {
[email protected]72267352012-07-20 20:14:47647 "enable-discovery-ntp",
648 IDS_FLAGS_ENABLE_NTP_DISCOVERY_NAME,
649 IDS_FLAGS_ENABLE_NTP_DISCOVERY_DESCRIPTION,
650 kOsAll,
651 SINGLE_VALUE_TYPE(switches::kEnableDiscoveryInNewTabPage)
652 },
[email protected]8e466dd2012-05-04 19:16:05653#if defined(GOOGLE_CHROME_BUILD)
[email protected]a3d54252012-04-05 20:04:13654 {
[email protected]37b928e2012-05-30 09:01:10655 "disable-asynchronous-spellchecking",
656 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING,
657 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING_DESCRIPTION,
658 kOsWin | kOsLinux | kOsCrOS,
659 SINGLE_VALUE_TYPE(switches::kDisableAsynchronousSpellChecking)
[email protected]a3d54252012-04-05 20:04:13660 },
[email protected]8e466dd2012-05-04 19:16:05661#endif
[email protected]c9c73ad42012-04-18 03:35:59662 {
663 "touch-optimized-ui",
[email protected]347a0c72012-05-14 20:28:06664 IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME,
665 IDS_FLAGS_TOUCH_OPTIMIZED_UI_DESCRIPTION,
[email protected]c71fe6402012-08-15 15:22:55666 kOsWin,
[email protected]347a0c72012-05-14 20:28:06667 MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
[email protected]c9c73ad42012-04-18 03:35:59668 },
[email protected]8a6aaa72012-04-20 20:53:58669 {
[email protected]f6f82832012-09-04 17:12:04670 "enable-webkit-text-subpixel-positioning",
671 IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_NAME,
672 IDS_FLAGS_ENABLE_WEBKIT_TEXT_SUBPIXEL_POSITIONING_DESCRIPTION,
673 kOsCrOS,
674 SINGLE_VALUE_TYPE(switches::kEnableWebkitTextSubpixelPositioning)
675 },
676 {
[email protected]8a6aaa72012-04-20 20:53:58677 "enable-touch-events",
678 IDS_ENABLE_TOUCH_EVENTS_NAME,
679 IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
680 kOsAll,
681 SINGLE_VALUE_TYPE(switches::kEnableTouchEvents)
682 },
[email protected]0b60afa2012-04-19 17:36:39683#if defined(OS_CHROMEOS)
684 {
[email protected]7c4a9bc2012-09-11 22:10:05685 "enable-background-loader",
686 IDS_ENABLE_BACKLOADER_NAME,
687 IDS_ENABLE_BACKLOADER_DESCRIPTION,
688 kOsCrOS,
689 SINGLE_VALUE_TYPE(switches::kEnableBackgroundLoader)
690 },
691 {
[email protected]c5667b282012-08-31 00:32:50692 "enable-bezel-touch",
693 IDS_ENABLE_BEZEL_TOUCH_NAME,
694 IDS_ENABLE_BEZEL_TOUCH_DESCRIPTION,
[email protected]1995d80d2012-08-23 02:58:47695 kOsCrOS,
[email protected]c5667b282012-08-31 00:32:50696 SINGLE_VALUE_TYPE(switches::kEnableBezelTouch)
[email protected]1995d80d2012-08-23 02:58:47697 },
698 {
[email protected]0b60afa2012-04-19 17:36:39699 "no-discard-tabs",
700 IDS_FLAGS_NO_DISCARD_TABS_NAME,
701 IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION,
702 kOsCrOS,
703 SINGLE_VALUE_TYPE(switches::kNoDiscardTabs)
704 },
705#endif
[email protected]79be6d32012-04-24 20:47:44706 {
[email protected]9a5940d2012-04-27 19:16:23707 "allow-nacl-socket-api",
708 IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME,
709 IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION,
710 kOsAll,
711 SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*")
712 },
[email protected]85333732012-05-01 19:02:24713 {
[email protected]60673ad72012-05-02 06:16:33714 "stacked-tab-strip",
715 IDS_FLAGS_STACKED_TAB_STRIP_NAME,
716 IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION,
717 kOsWin,
718 SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip)
719 },
720 {
[email protected]4bd20202012-06-14 17:35:01721 "force-device-scale-factor",
[email protected]85333732012-05-01 19:02:24722 IDS_FLAGS_FORCE_HIGH_DPI_NAME,
723 IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION,
724 kOsCrOS,
[email protected]4bd20202012-06-14 17:35:01725 SINGLE_VALUE_TYPE_AND_VALUE(switches::kForceDeviceScaleFactor, "2")
[email protected]85333732012-05-01 19:02:24726 },
[email protected]190349fd2012-05-02 00:10:47727#if defined(OS_CHROMEOS)
728 {
729 "allow-touchpad-three-finger-click",
730 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME,
731 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION,
732 kOsCrOS,
733 SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick)
734 },
735#endif
[email protected]aab64e02012-05-03 19:24:16736 {
[email protected]d3ace932012-08-09 15:39:34737 "enable-client-oauth-signin",
738 IDS_FLAGS_ENABLE_CLIENT_OAUTH_SIGNIN_NAME,
739 IDS_FLAGS_ENABLE_CLIENT_OAUTH_SIGNIN_DESCRIPTION,
[email protected]aab64e02012-05-03 19:24:16740 kOsMac | kOsWin | kOsLinux,
[email protected]d3ace932012-08-09 15:39:34741 SINGLE_VALUE_TYPE(switches::kEnableClientOAuthSignin)
[email protected]aab64e02012-05-03 19:24:16742 },
[email protected]53520b1b2012-05-07 21:43:37743#if defined(USE_ASH)
744 {
[email protected]55444502012-05-10 15:43:53745 "show-launcher-alignment-menu",
746 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_NAME,
747 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION,
748 kOsAll,
749 SINGLE_VALUE_TYPE(switches::kShowLauncherAlignmentMenu)
750 },
[email protected]817ecd12012-05-16 18:36:53751 {
[email protected]73074742012-05-17 01:44:41752 "show-touch-hud",
753 IDS_FLAGS_SHOW_TOUCH_HUD_NAME,
754 IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION,
755 kOsAll,
756 SINGLE_VALUE_TYPE(ash::switches::kAshTouchHud)
757 },
758 {
[email protected]e154db32012-06-18 16:20:46759 "ash-notify-disabled",
760 IDS_FLAGS_DISABLE_ASH_NOTIFY_NAME,
761 IDS_FLAGS_DISABLE_ASH_NOTIFY_DESCRIPTION,
[email protected]817ecd12012-05-16 18:36:53762 kOsAll,
[email protected]e154db32012-06-18 16:20:46763 SINGLE_VALUE_TYPE(ash::switches::kAshNotifyDisabled),
[email protected]817ecd12012-05-16 18:36:53764 },
[email protected]9f0940b62012-05-23 22:56:35765 {
766 "enable-pinch",
767 IDS_FLAGS_ENABLE_PINCH_SCALE_NAME,
768 IDS_FLAGS_ENABLE_PINCH_SCALE_DESCRIPTION,
769 kOsAll,
770 SINGLE_VALUE_TYPE(switches::kEnablePinch),
771 },
[email protected]a8379312012-06-15 00:20:43772 {
773 "app-list-show-apps-only",
774 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_NAME,
775 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_DESCRIPTION,
776 kOsAll,
[email protected]0bc6c272012-07-17 03:32:03777 SINGLE_VALUE_TYPE(app_list::switches::kAppListShowAppsOnly),
[email protected]a8379312012-06-15 00:20:43778 },
[email protected]73074742012-05-17 01:44:41779#endif // defined(USE_ASH)
[email protected]ed7b67f32012-05-28 10:12:28780#if defined(OS_CHROMEOS)
781 {
[email protected]5064c562012-09-05 18:15:27782 "disable-new-wallpaper-picker-ui",
783 IDS_FLAGS_DISABLE_NEW_WALLPAPER_UI_NAME,
784 IDS_FLAGS_DISABLE_NEW_WALLPAPER_UI_DESCRIPTION,
[email protected]a7668a12012-05-28 22:23:48785 kOsCrOS,
[email protected]5064c562012-09-05 18:15:27786 SINGLE_VALUE_TYPE(switches::kDisableNewWallpaperUI)
[email protected]a7668a12012-05-28 22:23:48787 },
788 {
[email protected]898213072012-07-11 02:25:48789 "enable-drive-v2-api",
790 IDS_FLAGS_ENABLE_DRIVE_V2_API,
791 IDS_FLAGS_ENABLE_DRIVE_V2_API_DESCRIPTION,
792 kOsCrOS,
793 SINGLE_VALUE_TYPE(switches::kEnableDriveV2Api),
794 },
795 {
[email protected]02a8cb52012-08-06 22:21:12796 "use-leveldb-for-gdata",
797 IDS_FLAGS_USE_LEVELDB_FOR_GDATA_NAME,
798 IDS_FLAGS_USE_LEVELDB_FOR_GDATA_DESCRIPTION,
799 kOsCrOS,
800 SINGLE_VALUE_TYPE(switches::kUseLevelDBForGData),
801 },
802 {
[email protected]89ef50172012-07-24 21:58:38803 "disable-html5-camera",
804 IDS_FLAGS_DISABLE_HTML5_CAMERA,
805 IDS_FLAGS_DISABLE_HTML5_CAMERA_DESCRIPTION,
[email protected]ffc6f7b12012-07-04 09:11:33806 kOsCrOS,
[email protected]89ef50172012-07-24 21:58:38807 SINGLE_VALUE_TYPE(switches::kDisableHtml5Camera),
[email protected]ffc6f7b12012-07-04 09:11:33808 },
809 {
[email protected]e03dc78d2012-07-24 08:21:43810 "disable-new-oobe",
811 IDS_FLAGS_DISABLE_NEW_OOBE,
812 IDS_FLAGS_DISABLE_NEW_OOBE_DESCRIPTION,
[email protected]ed7b67f32012-05-28 10:12:28813 kOsCrOS,
[email protected]e03dc78d2012-07-24 08:21:43814 SINGLE_VALUE_TYPE(switches::kDisableNewOobe),
[email protected]ed7b67f32012-05-28 10:12:28815 },
[email protected]8b04a1652012-08-04 02:59:49816 {
[email protected]f59324d2012-09-17 19:41:47817 "disable-factory-reset",
818 IDS_FLAGS_DISABLE_FACTORY_RESET,
819 IDS_FLAGS_DISABLE_FACTORY_RESET_DESCRIPTION,
820 kOsCrOS,
821 SINGLE_VALUE_TYPE(switches::kDisableFactoryReset),
822 },
823 {
[email protected]8b04a1652012-08-04 02:59:49824 "disable-boot-animation",
825 IDS_FLAGS_DISABLE_BOOT_ANIMATION,
826 IDS_FLAGS_DISABLE_BOOT_ANIMATION_DESCRIPTION,
827 kOsCrOS,
828 SINGLE_VALUE_TYPE(switches::kDisableBootAnimation),
829 },
[email protected]95058572012-08-20 14:57:29830 {
[email protected]b4557192012-09-19 11:29:58831 "disable-boot-animation2",
832 IDS_FLAGS_DISABLE_BOOT_ANIMATION2,
833 IDS_FLAGS_DISABLE_BOOT_ANIMATION2_DESCRIPTION,
834 kOsCrOS,
835 SINGLE_VALUE_TYPE(ash::switches::kAshDisableBootAnimation2),
836 },
837 {
[email protected]6885b732012-09-05 20:47:58838 "disable-workspace2",
839 IDS_FLAGS_DISABLE_WORKSPACE2,
840 IDS_FLAGS_DISABLE_WORKSPACE2_DESCRIPTION,
[email protected]95058572012-08-20 14:57:29841 kOsCrOS,
[email protected]6885b732012-09-05 20:47:58842 SINGLE_VALUE_TYPE(ash::switches::kAshDisableWorkspace2),
[email protected]95058572012-08-20 14:57:29843 },
[email protected]ed7b67f32012-05-28 10:12:28844#endif
[email protected]fc7a93c2012-06-08 20:25:39845 {
846 "enable-views-textfield",
847 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_NAME,
848 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_DESCRIPTION,
849 kOsWin,
850 SINGLE_VALUE_TYPE(switches::kEnableViewsTextfield),
851 },
[email protected]bd0cd3bb2012-06-14 03:03:38852 {
[email protected]ef41b7ee2012-07-24 19:10:41853 "old-checkbox-style",
854 IDS_FLAGS_OLD_CHECKBOX_STYLE,
855 IDS_FLAGS_OLD_CHECKBOX_STYLE_DESCRIPTION,
856 kOsLinux | kOsCrOS,
857 SINGLE_VALUE_TYPE(switches::kOldCheckboxStyle),
858 },
859 {
[email protected]fcb88de2012-07-12 22:25:32860 "enable-frameless-constrained-dialogs",
861 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_NAME,
862 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_DESCRIPTION,
863 kOsWin | kOsCrOS,
864 SINGLE_VALUE_TYPE(switches::kEnableFramelessConstrainedDialogs),
865 },
[email protected]7057b3e2012-06-18 19:19:16866#if defined(OS_CHROMEOS)
867 {
868 "enable-unsupported-bluetooth-devices",
869 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_NAME,
870 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_DESCRIPTION,
871 kOsCrOS,
872 SINGLE_VALUE_TYPE(switches::kEnableUnsupportedBluetoothDevices)
873 },
874#endif
[email protected]7db8893a2012-07-26 00:49:40875 { "disable-accelerated-video-decode",
876 IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_NAME,
877 IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
[email protected]66dcb0492012-06-18 22:32:15878 kOsAll,
[email protected]7db8893a2012-07-26 00:49:40879 SINGLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
[email protected]66dcb0492012-06-18 22:32:15880 },
[email protected]66ae9fc2012-06-19 21:33:52881#if defined(USE_ASH)
882 {
883 "ash-debug-shortcuts",
884 IDS_FLAGS_DEBUG_SHORTCUTS_NAME,
885 IDS_FLAGS_DEBUG_SHORTCUTS_DESCRIPTION,
886 kOsAll,
887 SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts),
888 },
889#endif
[email protected]37fee0942012-08-07 21:07:45890 {
[email protected]9a8e9352012-08-24 00:45:17891 "disable-website-settings", // FLAGS:RECORD_UMA
892 IDS_FLAGS_DISABLE_WEBSITE_SETTINGS_NAME,
893 IDS_FLAGS_DISABLE_WEBSITE_SETTINGS_DESCRIPTION,
[email protected]37fee0942012-08-07 21:07:45894 kOsAll,
[email protected]9a8e9352012-08-24 00:45:17895 SINGLE_VALUE_TYPE(switches::kDisableWebsiteSettings),
[email protected]37fee0942012-08-07 21:07:45896 },
[email protected]ad3f6d22012-08-29 02:34:19897 {
[email protected]e2e8e322012-09-12 04:37:02898 "enable-webaudio-input",
899 IDS_FLAGS_ENABLE_WEBAUDIO_INPUT_NAME,
900 IDS_FLAGS_ENABLE_WEBAUDIO_INPUT_DESCRIPTION,
901 kOsAll,
902 SINGLE_VALUE_TYPE(switches::kEnableWebAudioInput),
903 },
904 {
[email protected]ad3f6d22012-08-29 02:34:19905 "enable-contacts",
906 IDS_FLAGS_ENABLE_CONTACTS_NAME,
907 IDS_FLAGS_ENABLE_CONTACTS_DESCRIPTION,
908 kOsCrOS,
909 SINGLE_VALUE_TYPE(switches::kEnableContacts)
910 },
[email protected]1d9bb9cd2012-08-28 22:02:50911#if defined(USE_ASH)
912 { "ash-enable-advanced-gestures",
913 IDS_FLAGS_ENABLE_ADVANCED_GESTURES_NAME,
914 IDS_FLAGS_ENABLE_ADVANCED_GESTURES_DESCRIPTION,
915 kOsCrOS,
916 SINGLE_VALUE_TYPE(ash::switches::kAshEnableAdvancedGestures),
917 },
918#endif
[email protected]9b7ab882012-09-10 23:46:36919#if defined(OS_CHROMEOS)
920 {
921 "enable-request-tablet-site",
922 IDS_FLAGS_ENABLE_REQUEST_TABLET_SITE_NAME,
923 IDS_FLAGS_ENABLE_REQUEST_TABLET_SITE_DESCRIPTION,
924 kOsCrOS,
925 SINGLE_VALUE_TYPE(switches::kEnableRequestTabletSite)
926 },
927#endif
[email protected]a0e4b072011-08-17 01:47:07928};
[email protected]ad2a3ded2010-08-27 13:19:05929
[email protected]a314ee5a2010-10-26 21:23:28930const Experiment* experiments = kExperiments;
931size_t num_experiments = arraysize(kExperiments);
932
[email protected]e2ddbc92010-10-15 20:02:07933// Stores and encapsulates the little state that about:flags has.
934class FlagsState {
935 public:
936 FlagsState() : needs_restart_(false) {}
937 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
938 bool IsRestartNeededToCommitChanges();
939 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28940 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07941 void RemoveFlagsSwitches(
942 std::map<std::string, CommandLine::StringType>* switch_list);
943 void reset();
944
945 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55946 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07947 return Singleton<FlagsState>::get();
948 }
949
950 private:
951 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53952 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07953
954 DISALLOW_COPY_AND_ASSIGN(FlagsState);
955};
956
[email protected]c7b7800a2010-10-07 18:51:35957// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:05958// in a set.
[email protected]1a47d7e2010-10-15 00:37:24959void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:05960 const ListValue* enabled_experiments = prefs->GetList(
961 prefs::kEnabledLabsExperiments);
962 if (!enabled_experiments)
963 return;
964
965 for (ListValue::const_iterator it = enabled_experiments->begin();
966 it != enabled_experiments->end();
967 ++it) {
968 std::string experiment_name;
969 if (!(*it)->GetAsString(&experiment_name)) {
970 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
971 continue;
972 }
973 result->insert(experiment_name);
974 }
975}
976
977// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:24978void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05979 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:38980 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
981 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:05982
983 experiments_list->Clear();
984 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
985 it != enabled_experiments.end();
986 ++it) {
987 experiments_list->Append(new StringValue(*it));
988 }
989}
990
[email protected]8a6ff28d2010-12-02 16:35:19991// Returns the name used in prefs for the choice at the specified index.
992std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:34993 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
994 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:19995 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
996 base::IntToString(index);
997}
998
999// Adds the internal names for the specified experiment to |names|.
1000void AddInternalName(const Experiment& e, std::set<std::string>* names) {
1001 if (e.type == Experiment::SINGLE_VALUE) {
1002 names->insert(e.internal_name);
1003 } else {
[email protected]2ce9c89752011-02-25 18:24:341004 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:191005 for (int i = 0; i < e.num_choices; ++i)
1006 names->insert(NameForChoice(e, i));
1007 }
1008}
1009
[email protected]28e35af2011-02-09 12:56:221010// Confirms that an experiment is valid, used in a DCHECK in
1011// SanitizeList below.
1012bool ValidateExperiment(const Experiment& e) {
1013 switch (e.type) {
1014 case Experiment::SINGLE_VALUE:
1015 DCHECK_EQ(0, e.num_choices);
1016 DCHECK(!e.choices);
1017 break;
1018 case Experiment::MULTI_VALUE:
1019 DCHECK_GT(e.num_choices, 0);
1020 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:531021 DCHECK(e.choices[0].command_line_switch);
1022 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:221023 break;
1024 default:
1025 NOTREACHED();
1026 }
1027 return true;
1028}
1029
[email protected]ad2a3ded2010-08-27 13:19:051030// Removes all experiments from prefs::kEnabledLabsExperiments that are
1031// unknown, to prevent this list to become very long as experiments are added
1032// and removed.
1033void SanitizeList(PrefService* prefs) {
1034 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:221035 for (size_t i = 0; i < num_experiments; ++i) {
1036 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:191037 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:221038 }
[email protected]ad2a3ded2010-08-27 13:19:051039
1040 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241041 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051042
1043 std::set<std::string> new_enabled_experiments;
1044 std::set_intersection(
1045 known_experiments.begin(), known_experiments.end(),
1046 enabled_experiments.begin(), enabled_experiments.end(),
1047 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1048
[email protected]4c8853f2012-07-23 01:29:161049 if (new_enabled_experiments != enabled_experiments)
1050 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051051}
1052
[email protected]1a47d7e2010-10-15 00:37:241053void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:051054 PrefService* prefs, std::set<std::string>* result) {
1055 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:241056 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:051057}
1058
[email protected]a314ee5a2010-10-26 21:23:281059// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
1060// enabled on the current platform.
1061void GetSanitizedEnabledFlagsForCurrentPlatform(
1062 PrefService* prefs, std::set<std::string>* result) {
1063 GetSanitizedEnabledFlags(prefs, result);
1064
1065 // Filter out any experiments that aren't enabled on the current platform. We
1066 // don't remove these from prefs else syncing to a platform with a different
1067 // set of experiments would be lossy.
1068 std::set<std::string> platform_experiments;
1069 int current_platform = GetCurrentPlatform();
1070 for (size_t i = 0; i < num_experiments; ++i) {
1071 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:191072 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:281073 }
1074
1075 std::set<std::string> new_enabled_experiments;
1076 std::set_intersection(
1077 platform_experiments.begin(), platform_experiments.end(),
1078 result->begin(), result->end(),
1079 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1080
1081 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051082}
1083
[email protected]8a6ff28d2010-12-02 16:35:191084// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:191085Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:221086 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:341087 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:191088 ListValue* result = new ListValue;
1089 for (int i = 0; i < experiment.num_choices; ++i) {
1090 const Experiment::Choice& choice = experiment.choices[i];
1091 DictionaryValue* value = new DictionaryValue;
1092 std::string name = NameForChoice(experiment, i);
1093 value->SetString("description",
1094 l10n_util::GetStringUTF16(choice.description_id));
1095 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:221096 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:191097 result->Append(value);
1098 }
1099 return result;
1100}
1101
[email protected]e2ddbc92010-10-15 20:02:071102} // namespace
1103
[email protected]1a47d7e2010-10-15 00:37:241104void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:551105 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:051106}
1107
[email protected]1a47d7e2010-10-15 00:37:241108ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:051109 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241110 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051111
1112 int current_platform = GetCurrentPlatform();
1113
1114 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:281115 for (size_t i = 0; i < num_experiments; ++i) {
1116 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:051117
1118 DictionaryValue* data = new DictionaryValue();
1119 data->SetString("internal_name", experiment.internal_name);
1120 data->SetString("name",
1121 l10n_util::GetStringUTF16(experiment.visible_name_id));
1122 data->SetString("description",
1123 l10n_util::GetStringUTF16(
1124 experiment.visible_description_id));
[email protected]cc3e2052011-12-20 01:01:401125 bool supported = !!(experiment.supported_platforms & current_platform);
1126 data->SetBoolean("supported", supported);
1127
1128 ListValue* supported_platforms = new ListValue();
1129 AddOsStrings(experiment.supported_platforms, supported_platforms);
1130 data->Set("supported_platforms", supported_platforms);
[email protected]ad2a3ded2010-08-27 13:19:051131
[email protected]28e35af2011-02-09 12:56:221132 switch (experiment.type) {
1133 case Experiment::SINGLE_VALUE:
1134 data->SetBoolean(
1135 "enabled",
1136 enabled_experiments.count(experiment.internal_name) > 0);
1137 break;
1138 case Experiment::MULTI_VALUE:
1139 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
1140 break;
1141 default:
1142 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:191143 }
1144
[email protected]ad2a3ded2010-08-27 13:19:051145 experiments_data->Append(data);
1146 }
1147 return experiments_data;
1148}
1149
[email protected]ad2a3ded2010-08-27 13:19:051150bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:551151 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:051152}
1153
1154void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:351155 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:551156 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:071157}
1158
1159void RemoveFlagsSwitches(
1160 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:551161 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:071162}
1163
[email protected]a314ee5a2010-10-26 21:23:281164int GetCurrentPlatform() {
1165#if defined(OS_MACOSX)
1166 return kOsMac;
1167#elif defined(OS_WIN)
1168 return kOsWin;
1169#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
1170 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:211171#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:281172 return kOsLinux;
[email protected]9c7453d2012-01-21 00:45:401173#elif defined(OS_ANDROID)
1174 return kOsAndroid;
[email protected]a314ee5a2010-10-26 21:23:281175#else
1176#error Unknown platform
1177#endif
1178}
1179
[email protected]4bc5050c2010-11-18 17:55:541180void RecordUMAStatistics(const PrefService* prefs) {
1181 std::set<std::string> flags;
1182 GetEnabledFlags(prefs, &flags);
1183 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
1184 ++it) {
1185 std::string action("AboutFlags_");
1186 action += *it;
[email protected]7f6f44c2011-12-14 13:23:381187 content::RecordComputedAction(action);
[email protected]4bc5050c2010-11-18 17:55:541188 }
1189 // Since flag metrics are recorded every startup, add a tick so that the
1190 // stats can be made meaningful.
1191 if (flags.size())
[email protected]7f6f44c2011-12-14 13:23:381192 content::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
1193 content::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:541194}
1195
[email protected]e2ddbc92010-10-15 20:02:071196//////////////////////////////////////////////////////////////////////////////
1197// FlagsState implementation.
1198
1199namespace {
1200
1201void FlagsState::ConvertFlagsToSwitches(
1202 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:071203 if (command_line->HasSwitch(switches::kNoExperiments))
1204 return;
1205
1206 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:001207
[email protected]a314ee5a2010-10-26 21:23:281208 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:071209
[email protected]a82744532011-02-11 16:15:531210 typedef std::map<std::string, std::pair<std::string, std::string> >
1211 NameToSwitchAndValueMap;
1212 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:191213 for (size_t i = 0; i < num_experiments; ++i) {
1214 const Experiment& e = experiments[i];
1215 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:531216 name_to_switch_map[e.internal_name] =
1217 std::pair<std::string, std::string>(e.command_line_switch,
1218 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191219 } else {
1220 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:531221 name_to_switch_map[NameForChoice(e, j)] =
1222 std::pair<std::string, std::string>(
1223 e.choices[j].command_line_switch,
1224 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191225 }
1226 }
[email protected]e2ddbc92010-10-15 20:02:071227
1228 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:531229 flags_switches_.insert(
1230 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
1231 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071232 for (std::set<std::string>::iterator it = enabled_experiments.begin();
1233 it != enabled_experiments.end();
1234 ++it) {
1235 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:531236 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:191237 name_to_switch_map.find(experiment_name);
1238 if (name_to_switch_it == name_to_switch_map.end()) {
1239 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:071240 continue;
[email protected]8a6ff28d2010-12-02 16:35:191241 }
[email protected]e2ddbc92010-10-15 20:02:071242
[email protected]a82744532011-02-11 16:15:531243 const std::pair<std::string, std::string>&
1244 switch_and_value_pair = name_to_switch_it->second;
1245
1246 command_line->AppendSwitchASCII(switch_and_value_pair.first,
1247 switch_and_value_pair.second);
1248 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:071249 }
1250 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:531251 flags_switches_.insert(
1252 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
1253 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071254}
1255
1256bool FlagsState::IsRestartNeededToCommitChanges() {
1257 return needs_restart_;
1258}
1259
1260void FlagsState::SetExperimentEnabled(
1261 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:051262 needs_restart_ = true;
1263
[email protected]8a6ff28d2010-12-02 16:35:191264 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
1265 if (at_index != std::string::npos) {
1266 DCHECK(enable);
1267 // We're being asked to enable a multi-choice experiment. Disable the
1268 // currently selected choice.
1269 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:221270 const std::string experiment_name = internal_name.substr(0, at_index);
1271 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:191272
[email protected]28e35af2011-02-09 12:56:221273 // And enable the new choice, if it is not the default first choice.
1274 if (internal_name != experiment_name + "@0") {
1275 std::set<std::string> enabled_experiments;
1276 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
1277 enabled_experiments.insert(internal_name);
1278 SetEnabledFlags(prefs, enabled_experiments);
1279 }
[email protected]8a6ff28d2010-12-02 16:35:191280 return;
1281 }
1282
[email protected]ad2a3ded2010-08-27 13:19:051283 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241284 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051285
[email protected]8a6ff28d2010-12-02 16:35:191286 const Experiment* e = NULL;
1287 for (size_t i = 0; i < num_experiments; ++i) {
1288 if (experiments[i].internal_name == internal_name) {
1289 e = experiments + i;
1290 break;
1291 }
1292 }
1293 DCHECK(e);
1294
1295 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:591296 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:191297 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:591298 else
[email protected]8a6ff28d2010-12-02 16:35:191299 enabled_experiments.erase(internal_name);
1300 } else {
1301 if (enable) {
1302 // Enable the first choice.
1303 enabled_experiments.insert(NameForChoice(*e, 0));
1304 } else {
1305 // Find the currently enabled choice and disable it.
1306 for (int i = 0; i < e->num_choices; ++i) {
1307 std::string choice_name = NameForChoice(*e, i);
1308 if (enabled_experiments.find(choice_name) !=
1309 enabled_experiments.end()) {
1310 enabled_experiments.erase(choice_name);
1311 // Continue on just in case there's a bug and more than one
1312 // experiment for this choice was enabled.
1313 }
1314 }
1315 }
1316 }
[email protected]ad2a3ded2010-08-27 13:19:051317
[email protected]1a47d7e2010-10-15 00:37:241318 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051319}
1320
[email protected]e2ddbc92010-10-15 20:02:071321void FlagsState::RemoveFlagsSwitches(
1322 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:531323 for (std::map<std::string, std::string>::const_iterator
1324 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
1325 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:071326 }
1327}
1328
1329void FlagsState::reset() {
1330 needs_restart_ = false;
1331 flags_switches_.clear();
1332}
1333
[email protected]38e46812011-05-09 20:49:221334} // namespace
[email protected]e2ddbc92010-10-15 20:02:071335
1336namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:191337
1338// WARNING: '@' is also used in the html file. If you update this constant you
1339// also need to update the html file.
1340const char kMultiSeparator[] = "@";
1341
[email protected]e2ddbc92010-10-15 20:02:071342void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:551343 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:071344}
[email protected]a314ee5a2010-10-26 21:23:281345
1346void SetExperiments(const Experiment* e, size_t count) {
1347 if (!e) {
1348 experiments = kExperiments;
1349 num_experiments = arraysize(kExperiments);
1350 } else {
1351 experiments = e;
1352 num_experiments = count;
1353 }
1354}
1355
[email protected]8a6ff28d2010-12-02 16:35:191356const Experiment* GetExperiments(size_t* count) {
1357 *count = num_experiments;
1358 return experiments;
1359}
1360
[email protected]e2ddbc92010-10-15 20:02:071361} // namespace testing
1362
[email protected]1a47d7e2010-10-15 00:37:241363} // namespace about_flags