blob: b67ee1c677b30b8310621e68f7a53f33c308a032 [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]0bc6c272012-07-17 03:32:0324#include "ui/app_list/app_list_switches.h"
[email protected]c051a1b2011-01-21 23:30:1725#include "ui/base/l10n/l10n_util.h"
[email protected]c9c73ad42012-04-18 03:35:5926#include "ui/base/ui_base_switches.h"
[email protected]c9e2cbbb2012-05-12 21:17:2727#include "ui/gl/gl_switches.h"
[email protected]ad2a3ded2010-08-27 13:19:0528
[email protected]dc04be7c2012-03-15 23:57:4929#if defined(USE_ASH)
[email protected]b65bdda2011-12-23 23:35:3130#include "ash/ash_switches.h"
[email protected]dc04be7c2012-03-15 23:57:4931#endif
32
33#if defined(USE_AURA)
[email protected]308aaa32012-03-12 13:14:5034#include "ui/aura/aura_switches.h"
[email protected]8cc10df2011-11-03 23:57:5035#endif
36
[email protected]7f6f44c2011-12-14 13:23:3837using content::UserMetricsAction;
38
[email protected]1a47d7e2010-10-15 00:37:2439namespace about_flags {
[email protected]ad2a3ded2010-08-27 13:19:0540
[email protected]8a6ff28d2010-12-02 16:35:1941// Macros to simplify specifying the type.
[email protected]a82744532011-02-11 16:15:5342#define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \
43 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0
44#define SINGLE_VALUE_TYPE(command_line_switch) \
45 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
46#define MULTI_VALUE_TYPE(choices) \
[email protected]0e6f56d2011-02-12 23:45:1547 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices)
[email protected]8a6ff28d2010-12-02 16:35:1948
[email protected]e2ddbc92010-10-15 20:02:0749namespace {
50
[email protected]9c7453d2012-01-21 00:45:4051const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS | kOsAndroid;
[email protected]ad2a3ded2010-08-27 13:19:0552
[email protected]cc3e2052011-12-20 01:01:4053// Adds a |StringValue| to |list| for each platform where |bitmask| indicates
54// whether the experiment is available on that platform.
55void AddOsStrings(unsigned bitmask, ListValue* list) {
56 struct {
57 unsigned bit;
58 const char* const name;
59 } kBitsToOs[] = {
60 {kOsMac, "Mac"},
61 {kOsWin, "Windows"},
62 {kOsLinux, "Linux"},
63 {kOsCrOS, "Chrome OS"},
64 };
65 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i)
66 if (bitmask & kBitsToOs[i].bit)
67 list->Append(new StringValue(kBitsToOs[i].name));
68}
69
[email protected]ba8164242010-11-16 21:31:0070// Names for former Chrome OS Labs experiments, shared with prefs migration
71// code.
72const char kMediaPlayerExperimentName[] = "media-player";
73const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
74const char kVerticalTabsExperimentName[] = "vertical-tabs";
75
[email protected]68317802012-06-07 19:13:2376const Experiment::Choice kOmniboxHistoryQuickProviderNewScoringChoices[] = {
77 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_AUTOMATIC, "", "" },
78 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_ENABLED,
79 switches::kOmniboxHistoryQuickProviderNewScoring,
80 switches::kOmniboxHistoryQuickProviderNewScoringEnabled },
81 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DISABLED,
82 switches::kOmniboxHistoryQuickProviderNewScoring,
83 switches::kOmniboxHistoryQuickProviderNewScoringDisabled }
84};
85
[email protected]128dc6c2012-06-22 20:30:3586const Experiment::Choice
87 kOmniboxHistoryQuickProviderReorderForInliningChoices[] = {
88 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_AUTOMATIC,
89 "",
90 "" },
91 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_ENABLED,
92 switches::kOmniboxHistoryQuickProviderReorderForInlining,
93 switches::kOmniboxHistoryQuickProviderReorderForInliningEnabled },
94 { IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DISABLED,
95 switches::kOmniboxHistoryQuickProviderReorderForInlining,
96 switches::kOmniboxHistoryQuickProviderReorderForInliningDisabled }
97};
98
[email protected]032d5e6c2012-02-17 17:53:5599const Experiment::Choice kOmniboxInlineHistoryQuickProviderChoices[] = {
100 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_AUTOMATIC, "", "" },
101 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_ALLOWED,
102 switches::kOmniboxInlineHistoryQuickProvider,
103 switches::kOmniboxInlineHistoryQuickProviderAllowed },
104 { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_PROHIBITED,
105 switches::kOmniboxInlineHistoryQuickProvider,
106 switches::kOmniboxInlineHistoryQuickProviderProhibited }
107};
108
[email protected]de023762012-07-26 17:10:17109const Experiment::Choice kFixedPositionCreatesStackingContextChoices[] = {
110 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
111 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
112 switches::kEnableFixedPositionCreatesStackingContext, ""},
113 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
114 switches::kDisableFixedPositionCreatesStackingContext, ""}
115};
116
[email protected]9b19cf82012-06-13 06:23:23117const Experiment::Choice kForceCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20118 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
119 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]9b19cf82012-06-13 06:23:23120 switches::kForceCompositingMode, ""},
[email protected]a45c69402012-06-24 16:32:20121 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]9b19cf82012-06-13 06:23:23122 switches::kDisableForceCompositingMode, ""}
123};
124
[email protected]72787e392012-03-23 05:55:43125const Experiment::Choice kThreadedCompositingModeChoices[] = {
[email protected]a45c69402012-06-24 16:32:20126 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
127 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]72787e392012-03-23 05:55:43128 switches::kDisableThreadedCompositing, ""},
[email protected]a45c69402012-06-24 16:32:20129 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]72787e392012-03-23 05:55:43130 switches::kEnableThreadedCompositing, ""}
131};
132
[email protected]347a0c72012-05-14 20:28:06133const Experiment::Choice kTouchOptimizedUIChoices[] = {
134 { IDS_FLAGS_TOUCH_OPTIMIZED_UI_AUTOMATIC, "", "" },
[email protected]a45c69402012-06-24 16:32:20135 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
[email protected]347a0c72012-05-14 20:28:06136 switches::kTouchOptimizedUI,
137 switches::kTouchOptimizedUIEnabled },
[email protected]a45c69402012-06-24 16:32:20138 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
[email protected]347a0c72012-05-14 20:28:06139 switches::kTouchOptimizedUI,
140 switches::kTouchOptimizedUIDisabled }
141};
142
[email protected]e4a81662012-06-25 23:57:07143const Experiment::Choice kPointerLockUIChoices[] = {
144 { IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
145 { IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
146 switches::kEnablePointerLock, ""},
147 { IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
148 switches::kDisablePointerLock, ""}
149};
150
[email protected]347a0c72012-05-14 20:28:06151
[email protected]4bc5050c2010-11-18 17:55:54152// RECORDING USER METRICS FOR FLAGS:
153// -----------------------------------------------------------------------------
154// The first line of the experiment is the internal name. If you'd like to
155// gather statistics about the usage of your flag, you should append a marker
156// comment to the end of the feature name, like so:
157// "my-special-feature", // FLAGS:RECORD_UMA
158//
159// After doing that, run //chrome/tools/extract_actions.py (see instructions at
160// the top of that file for details) to update the chromeactions.txt file, which
161// will enable UMA to record your feature flag.
162//
163// After your feature has shipped under a flag, you can locate the metrics
164// under the action name AboutFlags_internal-action-name. Actions are recorded
165// once per startup, so you should divide this number by AboutFlags_StartupTick
166// to get a sense of usage. Note that this will not be the same as number of
167// users with a given feature enabled because users can quit and relaunch
168// the application multiple times over a given time interval.
169// TODO(rsesek): See if there's a way to count per-user, rather than
170// per-startup.
171
[email protected]8a6ff28d2010-12-02 16:35:19172// To add a new experiment add to the end of kExperiments. There are two
173// distinct types of experiments:
174// . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE
175// macro for this type supplying the command line to the macro.
[email protected]28e35af2011-02-09 12:56:22176// . MULTI_VALUE: a list of choices, the first of which should correspond to a
177// deactivated state for this lab (i.e. no command line option). To specify
178// this type of experiment use the macro MULTI_VALUE_TYPE supplying it the
179// array of choices.
[email protected]8a6ff28d2010-12-02 16:35:19180// See the documentation of Experiment for details on the fields.
181//
182// When adding a new choice, add it to the end of the list.
[email protected]ad2a3ded2010-08-27 13:19:05183const Experiment kExperiments[] = {
184 {
[email protected]aac169d2011-03-18 19:53:03185 "expose-for-tabs", // FLAGS:RECORD_UMA
186 IDS_FLAGS_TABPOSE_NAME,
187 IDS_FLAGS_TABPOSE_DESCRIPTION,
188 kOsMac,
189#if defined(OS_MACOSX)
190 // The switch exists only on OS X.
191 SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs)
192#else
193 SINGLE_VALUE_TYPE("")
194#endif
195 },
196 {
[email protected]4bc5050c2010-11-18 17:55:54197 "conflicting-modules-check", // FLAGS:RECORD_UMA
[email protected]c1bbaa82010-11-08 11:17:05198 IDS_FLAGS_CONFLICTS_CHECK_NAME,
199 IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION,
200 kOsWin,
[email protected]8a6ff28d2010-12-02 16:35:19201 SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck)
[email protected]c1bbaa82010-11-08 11:17:05202 },
203 {
[email protected]4bc5050c2010-11-18 17:55:54204 "cloud-print-proxy", // FLAGS:RECORD_UMA
[email protected]dae7325b2011-12-21 20:56:54205 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME,
206 IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION,
[email protected]9f8872b32011-03-04 19:44:45207 // For a Chrome build, we know we have a PDF plug-in on Windows, so it's
[email protected]4fa24bf2011-08-20 02:15:22208 // fully enabled.
[email protected]5d10d57d2011-07-22 22:16:31209 // Otherwise, where we know Windows could be working if a viable PDF
[email protected]4fa24bf2011-08-20 02:15:22210 // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux
211 // always have PDF rasterization available, so no flag needed there.
212#if !defined(GOOGLE_CHROME_BUILD)
213 kOsWin,
214#else
215 0,
[email protected]fa6d2a2f2010-11-30 21:47:19216#endif
[email protected]8a6ff28d2010-12-02 16:35:19217 SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy)
[email protected]8b6588a2010-10-12 02:39:42218 },
[email protected]580939a2010-10-12 18:54:37219 {
[email protected]0209b442012-07-18 00:38:05220 "print-setting-reset", // FLAGS:RECORD_UMA
221 IDS_FLAGS_PRINT_SETTING_RESET_NAME,
222 IDS_FLAGS_PRINT_SETTING_RESET_DESCRIPTION,
223 kOsAll,
224 SINGLE_VALUE_TYPE(switches::kPrintSettingsReset)
225 },
226 {
[email protected]bb461532010-11-26 21:50:23227 "crxless-web-apps",
228 IDS_FLAGS_CRXLESS_WEB_APPS_NAME,
229 IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION,
230 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19231 SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps)
[email protected]bb461532010-11-26 21:50:23232 },
233 {
[email protected]96c6f4c2011-05-18 19:36:22234 "ignore-gpu-blacklist",
235 IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME,
236 IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION,
237 kOsAll,
238 SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist)
239 },
240 {
[email protected]0110cf112011-07-02 00:39:43241 "force-compositing-mode-2",
[email protected]96c6f4c2011-05-18 19:36:22242 IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME,
243 IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION,
[email protected]9b19cf82012-06-13 06:23:23244 kOsMac | kOsWin | kOsLinux,
245 MULTI_VALUE_TYPE(kForceCompositingModeChoices)
[email protected]96c6f4c2011-05-18 19:36:22246 },
247 {
[email protected]72787e392012-03-23 05:55:43248 "threaded-compositing-mode",
249 IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME,
250 IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59251 kOsAll,
[email protected]72787e392012-03-23 05:55:43252 MULTI_VALUE_TYPE(kThreadedCompositingModeChoices)
[email protected]644a1072012-03-16 09:29:59253 },
254 {
[email protected]81c64af62012-06-06 20:15:52255 "disable-accelerated-2d-canvas",
256 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_NAME,
257 IDS_FLAGS_DISABLE_ACCELERATED_2D_CANVAS_DESCRIPTION,
258 kOsAll,
259 SINGLE_VALUE_TYPE(switches::kDisableAccelerated2dCanvas)
260 },
261 {
[email protected]7aca2362012-07-10 20:17:08262 "disable-deferred-2d-canvas",
263 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_NAME,
264 IDS_FLAGS_DISABLE_DEFERRED_2D_CANVAS_DESCRIPTION,
265 kOsAll,
266 SINGLE_VALUE_TYPE(switches::kDisableDeferred2dCanvas)
267 },
268 {
[email protected]efcde132012-05-30 01:05:18269 "disable-threaded-animation",
270 IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME,
271 IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION,
[email protected]644a1072012-03-16 09:29:59272 kOsAll,
[email protected]efcde132012-05-30 01:05:18273 SINGLE_VALUE_TYPE(switches::kDisableThreadedAnimation)
[email protected]644a1072012-03-16 09:29:59274 },
275 {
[email protected]5963b772011-02-09 22:55:38276 "composited-layer-borders",
277 IDS_FLAGS_COMPOSITED_LAYER_BORDERS,
278 IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION,
279 kOsAll,
280 SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders)
281 },
282 {
[email protected]a8f1eaa2011-03-07 19:00:58283 "show-fps-counter",
284 IDS_FLAGS_SHOW_FPS_COUNTER,
285 IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION,
286 kOsAll,
287 SINGLE_VALUE_TYPE(switches::kShowFPSCounter)
288 },
[email protected]8ff7f342011-05-25 01:49:47289 {
[email protected]70c98a332011-12-21 20:51:52290 "accelerated-filters",
291 IDS_FLAGS_ACCELERATED_FILTERS,
292 IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION,
293 kOsAll,
294 SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters)
295 },
296 {
[email protected]8ff7f342011-05-25 01:49:47297 "disable-gpu-vsync",
298 IDS_FLAGS_DISABLE_GPU_VSYNC_NAME,
299 IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION,
300 kOsAll,
301 SINGLE_VALUE_TYPE(switches::kDisableGpuVsync)
302 },
[email protected]deaba6d52011-09-23 14:47:12303 {
304 "disable-webgl",
305 IDS_FLAGS_DISABLE_WEBGL_NAME,
306 IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION,
307 kOsAll,
308 SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
309 },
[email protected]09096e02012-05-24 11:12:04310 {
[email protected]96bcdc102012-05-24 23:42:10311 "fixed-position-creates-stacking-context",
312 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_NAME,
313 IDS_FLAGS_FIXED_POSITION_CREATES_STACKING_CONTEXT_DESCRIPTION,
314 kOsAll,
[email protected]de023762012-07-26 17:10:17315 MULTI_VALUE_TYPE(kFixedPositionCreatesStackingContextChoices)
[email protected]96bcdc102012-05-24 23:42:10316 },
[email protected]d208f4d82011-05-23 21:52:03317 // TODO(dspringer): When NaCl is on by default, remove this flag entry.
[email protected]2fe15fcb2010-10-21 20:39:53318 {
[email protected]e3791ce92011-08-09 01:03:32319 "enable-nacl", // FLAGS:RECORD_UMA
[email protected]4ff87d202010-11-06 01:28:40320 IDS_FLAGS_ENABLE_NACL_NAME,
321 IDS_FLAGS_ENABLE_NACL_DESCRIPTION,
322 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19323 SINGLE_VALUE_TYPE(switches::kEnableNaCl)
[email protected]4ff87d202010-11-06 01:28:40324 },
[email protected]b39c6d92012-01-31 16:38:41325 // TODO(halyavin): When exception handling is on by default, replace this
326 // flag with disable-nacl-exception-handling.
327 {
328 "enable-nacl-exception-handling", // FLAGS:RECORD_UMA
329 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME,
330 IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION,
331 kOsWin,
332 SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling)
333 },
[email protected]4ff87d202010-11-06 01:28:40334 {
[email protected]31a665e72012-03-11 12:37:46335 "nacl-gdb", // FLAGS:RECORD_UMA
336 IDS_FLAGS_NACL_GDB_NAME,
337 IDS_FLAGS_NACL_GDB_DESCRIPTION,
338 kOsWin,
339 SINGLE_VALUE_TYPE(switches::kNaClGdb)
340 },
341 {
[email protected]401b90792012-05-30 11:41:13342 "nacl-gdb-script", // FLAGS:RECORD_UMA
343 IDS_FLAGS_NACL_GDB_SCRIPT_NAME,
344 IDS_FLAGS_NACL_GDB_SCRIPT_DESCRIPTION,
345 kOsAll,
346 SINGLE_VALUE_TYPE(switches::kNaClGdbScript)
347 },
348 {
[email protected]7babd1c2012-08-08 20:35:29349 "enable-pnacl", // FLAGS:RECORD_UMA
350 IDS_FLAGS_ENABLE_PNACL_NAME,
351 IDS_FLAGS_ENABLE_PNACL_DESCRIPTION,
352 kOsAll,
353 SINGLE_VALUE_TYPE(switches::kEnablePnacl)
354 },
355 {
[email protected]4bc5050c2010-11-18 17:55:54356 "extension-apis", // FLAGS:RECORD_UMA
[email protected]11dd68cd52010-11-12 01:15:32357 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME,
358 IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION,
359 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19360 SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis)
[email protected]11dd68cd52010-11-12 01:15:32361 },
[email protected]3627b06d2010-11-12 16:36:16362 {
[email protected]cab18ef2012-04-27 07:22:03363 "action-box",
364 IDS_FLAGS_ACTION_BOX_NAME,
365 IDS_FLAGS_ACTION_BOX_DESCRIPTION,
366 kOsAll,
367 SINGLE_VALUE_TYPE(switches::kEnableActionBox),
368 },
369 {
[email protected]3a362432012-06-18 20:39:51370 "script-badges",
371 IDS_FLAGS_SCRIPT_BADGES_NAME,
372 IDS_FLAGS_SCRIPT_BADGES_DESCRIPTION,
373 kOsAll,
374 SINGLE_VALUE_TYPE(switches::kEnableScriptBadges),
375 },
376 {
[email protected]cbe224d2011-08-04 22:12:49377 "apps-new-install-bubble",
378 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME,
379 IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION,
380 kOsAll,
381 SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble)
382 },
383 {
[email protected]80bd24e2010-11-30 09:34:38384 "disable-hyperlink-auditing",
385 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME,
386 IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION,
387 kOsAll,
[email protected]8a6ff28d2010-12-02 16:35:19388 SINGLE_VALUE_TYPE(switches::kNoPings)
[email protected]feb28fef2010-12-01 10:52:51389 },
390 {
391 "experimental-location-features", // FLAGS:RECORD_UMA
392 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME,
393 IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION,
394 kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS.
[email protected]8a6ff28d2010-12-02 16:35:19395 SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures)
396 },
397 {
[email protected]5aea1862011-03-23 23:55:39398 "tab-groups-context-menu",
399 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME,
400 IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION,
401 kOsWin,
402 SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu)
403 },
[email protected]c94cebd2012-06-21 00:55:28404#if defined(OS_CHROMEOS)
405 {
406 "enable-instant-extended-api",
407 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API,
408 IDS_FLAGS_ENABLE_INSTANT_EXTENDED_API_DESCRIPTION,
409 kOsAll,
410 SINGLE_VALUE_TYPE(switches::kEnableInstantExtendedAPI)
411 },
412#endif
[email protected]e9bf9d92011-03-31 20:57:15413 {
[email protected]354e33b2011-06-15 00:29:10414 "static-ip-config",
415 IDS_FLAGS_STATIC_IP_CONFIG_NAME,
416 IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION,
417 kOsCrOS,
418#if defined(OS_CHROMEOS)
419 // This switch exists only on Chrome OS.
420 SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig)
421#else
422 SINGLE_VALUE_TYPE("")
423#endif
424 },
[email protected]3eb5728c2011-06-20 22:32:24425 {
426 "show-autofill-type-predictions",
427 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME,
428 IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION,
429 kOsAll,
430 SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions)
431 },
[email protected]bff4d3e2011-06-21 23:58:52432 {
[email protected]fdf4e252012-04-27 00:26:55433 "sync-tab-favicons",
434 IDS_FLAGS_SYNC_TAB_FAVICONS_NAME,
435 IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION,
436 kOsAll,
437 SINGLE_VALUE_TYPE(switches::kSyncTabFavicons)
438 },
439 {
[email protected]aae9eeb12011-10-21 21:59:26440 "sync-app-notifications",
441 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME,
442 IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION,
443 kOsAll,
[email protected]0b6fba82011-11-18 01:31:11444 SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications)
[email protected]aae9eeb12011-10-21 21:59:26445 },
446 {
[email protected]a22ebd812011-06-23 00:05:39447 "enable-smooth-scrolling", // FLAGS:RECORD_UMA
448 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME,
449 IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION,
450 // Can't expose the switch unless the code is compiled in.
[email protected]554b7062011-09-03 03:09:40451 // On by default for the Mac (different implementation in WebKit).
[email protected]554b7062011-09-03 03:09:40452 kOsWin | kOsLinux | kOsCrOS,
[email protected]a22ebd812011-06-23 00:05:39453 SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling)
454 },
[email protected]81a6b0b2011-06-24 17:55:40455 {
[email protected]68317802012-06-07 19:13:23456 "omnibox-history-quick-provider-new-scoring",
457 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_NAME,
458 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_NEW_SCORING_DESCRIPTION,
459 kOsAll,
460 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderNewScoringChoices)
461 },
462 {
[email protected]128dc6c2012-06-22 20:30:35463 "omnibox-history-quick-provider-reorder-for-inlining",
464 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_NAME,
465 IDS_FLAGS_OMNIBOX_HISTORY_QUICK_PROVIDER_REORDER_FOR_INLINING_DESCRIPTION,
466 kOsAll,
467 MULTI_VALUE_TYPE(kOmniboxHistoryQuickProviderReorderForInliningChoices)
468 },
469 {
[email protected]032d5e6c2012-02-17 17:53:55470 "omnibox-inline-history-quick-provider",
471 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME,
472 IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION,
473 kOsAll,
474 MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices)
475 },
476 {
[email protected]7e7a28092011-12-09 22:24:55477 "enable-panels",
478 IDS_FLAGS_ENABLE_PANELS_NAME,
479 IDS_FLAGS_ENABLE_PANELS_DESCRIPTION,
[email protected]73fb1fc52011-07-09 00:06:54480 kOsAll,
[email protected]7e7a28092011-12-09 22:24:55481 SINGLE_VALUE_TYPE(switches::kEnablePanels)
[email protected]73fb1fc52011-07-09 00:06:54482 },
[email protected]e3749d12011-07-25 22:22:12483 {
[email protected]27c14f02012-06-22 17:29:58484 // See http://crbug.com/120416 for how to remove this flag.
[email protected]6474b112012-05-04 19:35:27485 "save-page-as-mhtml", // FLAGS:RECORD_UMA
486 IDS_FLAGS_SAVE_PAGE_AS_MHTML_NAME,
487 IDS_FLAGS_SAVE_PAGE_AS_MHTML_DESCRIPTION,
488 kOsMac | kOsWin | kOsLinux,
489 SINGLE_VALUE_TYPE(switches::kSavePageAsMHTML)
490 },
491 {
[email protected]b7bb44f2011-09-01 05:17:03492 "enable-autologin",
493 IDS_FLAGS_ENABLE_AUTOLOGIN_NAME,
494 IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION,
495 kOsMac | kOsWin | kOsLinux,
496 SINGLE_VALUE_TYPE(switches::kEnableAutologin)
497 },
[email protected]b9841172011-09-26 23:36:09498 {
[email protected]bbadb112011-12-12 16:55:28499 "enable-http-pipelining",
500 IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME,
501 IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION,
502 kOsAll,
503 SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining)
504 },
[email protected]d411c01d2011-10-18 16:00:27505 {
[email protected]3231b612012-03-23 05:57:54506 "enable-spdy3",
507 IDS_FLAGS_ENABLE_SPDY3_NAME,
508 IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION,
509 kOsAll,
510 SINGLE_VALUE_TYPE(switches::kEnableSpdy3)
511 },
512 {
[email protected]27b3fe92012-03-21 05:35:06513 "enable-async-dns",
514 IDS_FLAGS_ENABLE_ASYNC_DNS_NAME,
515 IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32516 kOsWin | kOsMac | kOsLinux | kOsCrOS,
[email protected]27b3fe92012-03-21 05:35:06517 SINGLE_VALUE_TYPE(switches::kEnableAsyncDns)
518 },
519 {
[email protected]f5da41d2011-10-08 17:40:07520 "enable-video-track",
521 IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME,
522 IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION,
523 kOsAll,
524 SINGLE_VALUE_TYPE(switches::kEnableVideoTrack)
525 },
[email protected]08b83362011-10-19 05:23:17526 {
[email protected]6aa03b32011-10-27 21:44:44527 "enable-media-source",
528 IDS_FLAGS_ENABLE_MEDIA_SOURCE_NAME,
529 IDS_FLAGS_ENABLE_MEDIA_SOURCE_DESCRIPTION,
[email protected]ec9d0532012-03-21 05:55:32530 kOsAll,
[email protected]6aa03b32011-10-27 21:44:44531 SINGLE_VALUE_TYPE(switches::kEnableMediaSource)
532 },
[email protected]e4e68dbb2011-11-18 01:50:22533 {
[email protected]9f5b7822012-04-18 23:39:03534 "enable-encrypted-media",
535 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME,
536 IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION,
537 kOsAll,
538 SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia)
539 },
540 {
[email protected]e4e68dbb2011-11-18 01:50:22541 "enable-pointer-lock",
542 IDS_FLAGS_ENABLE_POINTER_LOCK_NAME,
543 IDS_FLAGS_ENABLE_POINTER_LOCK_DESCRIPTION,
544 kOsAll,
[email protected]e4a81662012-06-25 23:57:07545 MULTI_VALUE_TYPE(kPointerLockUIChoices)
[email protected]e4e68dbb2011-11-18 01:50:22546 },
[email protected]dc04be7c2012-03-15 23:57:49547#if defined(USE_ASH)
[email protected]8cc10df2011-11-03 23:57:50548 {
[email protected]57b8bb352012-01-11 05:11:46549 "aura-google-dialog-frames",
550 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME,
551 IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION,
552 kOsWin | kOsLinux | kOsCrOS,
553 SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames)
554 },
[email protected]dc04be7c2012-03-15 23:57:49555#endif
[email protected]eaae8b462012-01-20 22:20:39556 {
[email protected]db543d322011-12-15 20:40:15557 "per-tile-painting",
558 IDS_FLAGS_PER_TILE_PAINTING_NAME,
559 IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION,
560#if defined(USE_SKIA)
[email protected]a5b1b272012-01-06 20:44:37561 kOsMac | kOsLinux | kOsCrOS,
[email protected]db543d322011-12-15 20:40:15562#else
563 0,
564#endif
565 SINGLE_VALUE_TYPE(switches::kEnablePerTilePainting)
566 },
[email protected]bf88c032011-12-22 19:05:47567 {
568 "enable-javascript-harmony",
569 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME,
570 IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION,
571 kOsAll,
572 SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony")
573 },
[email protected]7e7f378a2012-01-05 14:35:37574 {
[email protected]85646172012-01-09 22:45:54575 "enable-tab-browser-dragging",
576 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME,
577 IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION,
578 kOsWin,
579 SINGLE_VALUE_TYPE(switches::kTabBrowserDragging)
580 },
581 {
[email protected]068b7b52012-02-27 12:41:44582 "disable-restore-session-state",
583 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME,
584 IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION,
[email protected]7e7f378a2012-01-05 14:35:37585 kOsAll,
[email protected]068b7b52012-02-27 12:41:44586 SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState)
[email protected]7e7f378a2012-01-05 14:35:37587 },
[email protected]88864db2012-01-18 20:56:35588 {
589 "disable-software-rasterizer",
590 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME,
591 IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION,
592#if defined(ENABLE_SWIFTSHADER)
593 kOsAll,
594#else
595 0,
596#endif
597 SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer)
598 },
[email protected]15a5d722012-01-23 09:11:14599 {
[email protected]8ea05a12012-05-02 09:17:47600 "enable-peer-connection",
601 IDS_FLAGS_PEER_CONNECTION_NAME,
602 IDS_FLAGS_PEER_CONNECTION_DESCRIPTION,
603 kOsAll,
604 SINGLE_VALUE_TYPE(switches::kEnablePeerConnection)
605 },
606 {
[email protected]d2edc6702012-01-30 09:13:16607 "enable-shadow-dom",
608 IDS_FLAGS_SHADOW_DOM_NAME,
609 IDS_FLAGS_SHADOW_DOM_DESCRIPTION,
610 kOsAll,
611 SINGLE_VALUE_TYPE(switches::kEnableShadowDOM)
612 },
[email protected]9860c68b2012-02-02 01:58:09613 {
[email protected]4961218f2012-02-23 10:11:07614 "enable-style-scoped",
615 IDS_FLAGS_STYLE_SCOPED_NAME,
616 IDS_FLAGS_STYLE_SCOPED_DESCRIPTION,
617 kOsAll,
618 SINGLE_VALUE_TYPE(switches::kEnableStyleScoped)
619 },
620 {
[email protected]ca7a3d792012-03-02 15:55:49621 "enable-css-regions",
622 IDS_FLAGS_CSS_REGIONS_NAME,
623 IDS_FLAGS_CSS_REGIONS_DESCRIPTION,
624 kOsAll,
625 SINGLE_VALUE_TYPE(switches::kEnableCssRegions)
626 },
627 {
[email protected]b63b9692012-07-25 02:38:01628 "enable-css-variables",
629 IDS_FLAGS_CSS_VARIABLES_NAME,
630 IDS_FLAGS_CSS_VARIABLES_DESCRIPTION,
631 kOsAll,
632 SINGLE_VALUE_TYPE(switches::kEnableCssVariables)
633 },
634 {
[email protected]9860c68b2012-02-02 01:58:09635 "enable-extension-activity-ui",
636 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME,
637 IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION,
638 kOsAll,
639 SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI)
[email protected]8bed69d2012-02-02 06:46:00640 },
[email protected]54ae4e92012-02-16 15:19:05641 {
[email protected]3e8befc2012-03-13 01:17:03642 "disable-ntp-other-sessions-menu",
[email protected]156f966332012-02-29 00:03:16643 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME,
644 IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION,
645 kOsAll,
[email protected]3e8befc2012-03-13 01:17:03646 SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu)
[email protected]156f966332012-02-29 00:03:16647 },
[email protected]dc04be7c2012-03-15 23:57:49648#if defined(USE_ASH)
[email protected]31cf1c52012-02-29 20:55:01649 {
[email protected]3cd198a22012-03-12 20:38:01650 "enable-ash-oak",
651 IDS_FLAGS_ENABLE_ASH_OAK_NAME,
652 IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION,
653 kOsAll,
654 SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak),
655 },
[email protected]31cf1c52012-02-29 20:55:01656#endif
[email protected]184ec592012-03-01 11:54:28657 {
658 "enable-devtools-experiments",
659 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME,
660 IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION,
661 kOsAll,
662 SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments)
663 },
[email protected]76d1854e2012-03-02 23:57:44664 {
665 "enable-suggestions-ntp",
666 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME,
667 IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION,
668 kOsAll,
669 SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage)
670 },
[email protected]a78ef9e2012-03-21 02:49:55671 {
[email protected]72267352012-07-20 20:14:47672 "enable-discovery-ntp",
673 IDS_FLAGS_ENABLE_NTP_DISCOVERY_NAME,
674 IDS_FLAGS_ENABLE_NTP_DISCOVERY_DESCRIPTION,
675 kOsAll,
676 SINGLE_VALUE_TYPE(switches::kEnableDiscoveryInNewTabPage)
677 },
678 {
[email protected]c447cac2012-08-05 02:41:40679 "enable-chrome-to-mobile", // FLAGS:RECORD_UMA
680 IDS_FLAGS_ENABLE_CHROME_TO_MOBILE_NAME,
681 IDS_FLAGS_ENABLE_CHROME_TO_MOBILE_DESCRIPTION,
[email protected]a78ef9e2012-03-21 02:49:55682 kOsAll,
[email protected]c447cac2012-08-05 02:41:40683 SINGLE_VALUE_TYPE(switches::kEnableChromeToMobile)
[email protected]a78ef9e2012-03-21 02:49:55684 },
[email protected]8e466dd2012-05-04 19:16:05685#if defined(GOOGLE_CHROME_BUILD)
[email protected]a3d54252012-04-05 20:04:13686 {
[email protected]37b928e2012-05-30 09:01:10687 "disable-asynchronous-spellchecking",
688 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING,
689 IDS_FLAGS_DISABLE_ASYNCHRONOUS_SPELLCHECKING_DESCRIPTION,
690 kOsWin | kOsLinux | kOsCrOS,
691 SINGLE_VALUE_TYPE(switches::kDisableAsynchronousSpellChecking)
[email protected]a3d54252012-04-05 20:04:13692 },
[email protected]8e466dd2012-05-04 19:16:05693#endif
[email protected]c9c73ad42012-04-18 03:35:59694 {
695 "touch-optimized-ui",
[email protected]347a0c72012-05-14 20:28:06696 IDS_FLAGS_TOUCH_OPTIMIZED_UI_NAME,
697 IDS_FLAGS_TOUCH_OPTIMIZED_UI_DESCRIPTION,
[email protected]f5364d22012-05-31 18:57:29698 kOsWin | kOsCrOS,
[email protected]347a0c72012-05-14 20:28:06699 MULTI_VALUE_TYPE(kTouchOptimizedUIChoices)
[email protected]c9c73ad42012-04-18 03:35:59700 },
[email protected]8a6aaa72012-04-20 20:53:58701 {
702 "enable-touch-events",
703 IDS_ENABLE_TOUCH_EVENTS_NAME,
704 IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION,
705 kOsAll,
706 SINGLE_VALUE_TYPE(switches::kEnableTouchEvents)
707 },
[email protected]0b60afa2012-04-19 17:36:39708#if defined(OS_CHROMEOS)
709 {
710 "no-discard-tabs",
711 IDS_FLAGS_NO_DISCARD_TABS_NAME,
712 IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION,
713 kOsCrOS,
714 SINGLE_VALUE_TYPE(switches::kNoDiscardTabs)
715 },
716#endif
[email protected]79be6d32012-04-24 20:47:44717 {
[email protected]9a5940d2012-04-27 19:16:23718 "allow-nacl-socket-api",
719 IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME,
720 IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION,
721 kOsAll,
722 SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*")
723 },
[email protected]85333732012-05-01 19:02:24724 {
[email protected]60673ad72012-05-02 06:16:33725 "stacked-tab-strip",
726 IDS_FLAGS_STACKED_TAB_STRIP_NAME,
727 IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION,
728 kOsWin,
729 SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip)
730 },
731 {
[email protected]4bd20202012-06-14 17:35:01732 "force-device-scale-factor",
[email protected]85333732012-05-01 19:02:24733 IDS_FLAGS_FORCE_HIGH_DPI_NAME,
734 IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION,
735 kOsCrOS,
[email protected]4bd20202012-06-14 17:35:01736 SINGLE_VALUE_TYPE_AND_VALUE(switches::kForceDeviceScaleFactor, "2")
[email protected]85333732012-05-01 19:02:24737 },
[email protected]adda89512012-07-26 17:01:54738 {
739 "enable-hidpi-pdf-plugin",
740 IDS_FLAGS_ENABLE_HIGH_DPI_PDF_PLUGIN_NAME,
741 IDS_FLAGS_ENABLE_HIGH_DPI_PDF_PLUGIN_DESCRIPTION,
742 kOsCrOS | kOsMac,
743 SINGLE_VALUE_TYPE(switches::kEnableHighDPIPDFPlugin)
744 },
[email protected]190349fd2012-05-02 00:10:47745#if defined(OS_CHROMEOS)
746 {
747 "allow-touchpad-three-finger-click",
748 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME,
749 IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION,
750 kOsCrOS,
751 SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick)
752 },
753#endif
[email protected]aab64e02012-05-03 19:24:16754 {
[email protected]83af85c772012-07-24 21:19:08755 "disable-client-oauth-signin",
756 IDS_FLAGS_DISABLE_CLIENT_OAUTH_SIGNIN_NAME,
757 IDS_FLAGS_DISABLE_CLIENT_OAUTH_SIGNIN_DESCRIPTION,
[email protected]aab64e02012-05-03 19:24:16758 kOsMac | kOsWin | kOsLinux,
[email protected]83af85c772012-07-24 21:19:08759 SINGLE_VALUE_TYPE(switches::kDisableClientOAuthSignin)
[email protected]aab64e02012-05-03 19:24:16760 },
[email protected]53520b1b2012-05-07 21:43:37761#if defined(USE_ASH)
762 {
[email protected]55444502012-05-10 15:43:53763 "show-launcher-alignment-menu",
764 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_NAME,
765 IDS_FLAGS_SHOW_LAUNCHER_ALIGNMENT_MENU_DESCRIPTION,
766 kOsAll,
767 SINGLE_VALUE_TYPE(switches::kShowLauncherAlignmentMenu)
768 },
[email protected]817ecd12012-05-16 18:36:53769 {
[email protected]73074742012-05-17 01:44:41770 "show-touch-hud",
771 IDS_FLAGS_SHOW_TOUCH_HUD_NAME,
772 IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION,
773 kOsAll,
774 SINGLE_VALUE_TYPE(ash::switches::kAshTouchHud)
775 },
776 {
[email protected]e154db32012-06-18 16:20:46777 "ash-notify-disabled",
778 IDS_FLAGS_DISABLE_ASH_NOTIFY_NAME,
779 IDS_FLAGS_DISABLE_ASH_NOTIFY_DESCRIPTION,
[email protected]817ecd12012-05-16 18:36:53780 kOsAll,
[email protected]e154db32012-06-18 16:20:46781 SINGLE_VALUE_TYPE(ash::switches::kAshNotifyDisabled),
[email protected]817ecd12012-05-16 18:36:53782 },
[email protected]9f0940b62012-05-23 22:56:35783 {
784 "enable-pinch",
785 IDS_FLAGS_ENABLE_PINCH_SCALE_NAME,
786 IDS_FLAGS_ENABLE_PINCH_SCALE_DESCRIPTION,
787 kOsAll,
788 SINGLE_VALUE_TYPE(switches::kEnablePinch),
789 },
[email protected]a8379312012-06-15 00:20:43790 {
791 "app-list-show-apps-only",
792 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_NAME,
793 IDS_FLAGS_ENABLE_APP_LIST_SHOW_APPS_ONLY_DESCRIPTION,
794 kOsAll,
[email protected]0bc6c272012-07-17 03:32:03795 SINGLE_VALUE_TYPE(app_list::switches::kAppListShowAppsOnly),
[email protected]a8379312012-06-15 00:20:43796 },
[email protected]6aee2592012-06-15 19:51:06797 {
[email protected]8f27a1c2012-08-06 22:53:13798 "ash-extended-desktop",
799 IDS_FLAGS_ENABLE_ASH_EXTENDED_DESKTOP_NAME,
800 IDS_FLAGS_ENABLE_ASH_EXTENDED_DESKTOP_DESCRIPTION,
[email protected]6aee2592012-06-15 19:51:06801 kOsAll,
[email protected]8f27a1c2012-08-06 22:53:13802 SINGLE_VALUE_TYPE(ash::switches::kAshExtendedDesktop)
[email protected]6aee2592012-06-15 19:51:06803 },
[email protected]73074742012-05-17 01:44:41804#endif // defined(USE_ASH)
[email protected]ed7b67f32012-05-28 10:12:28805#if defined(OS_CHROMEOS)
806 {
[email protected]a7668a12012-05-28 22:23:48807 "experimental-wallpaper-ui",
808 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_NAME,
809 IDS_FLAGS_EXPERIMENTAL_WALLPAPER_UI_DESCRIPTION,
810 kOsCrOS,
811 SINGLE_VALUE_TYPE(switches::kExperimentalWallpaperUI)
812 },
813 {
[email protected]898213072012-07-11 02:25:48814 "enable-drive-v2-api",
815 IDS_FLAGS_ENABLE_DRIVE_V2_API,
816 IDS_FLAGS_ENABLE_DRIVE_V2_API_DESCRIPTION,
817 kOsCrOS,
818 SINGLE_VALUE_TYPE(switches::kEnableDriveV2Api),
819 },
820 {
[email protected]02a8cb52012-08-06 22:21:12821 "use-leveldb-for-gdata",
822 IDS_FLAGS_USE_LEVELDB_FOR_GDATA_NAME,
823 IDS_FLAGS_USE_LEVELDB_FOR_GDATA_DESCRIPTION,
824 kOsCrOS,
825 SINGLE_VALUE_TYPE(switches::kUseLevelDBForGData),
826 },
827 {
[email protected]89ef50172012-07-24 21:58:38828 "disable-html5-camera",
829 IDS_FLAGS_DISABLE_HTML5_CAMERA,
830 IDS_FLAGS_DISABLE_HTML5_CAMERA_DESCRIPTION,
[email protected]ffc6f7b12012-07-04 09:11:33831 kOsCrOS,
[email protected]89ef50172012-07-24 21:58:38832 SINGLE_VALUE_TYPE(switches::kDisableHtml5Camera),
[email protected]ffc6f7b12012-07-04 09:11:33833 },
834 {
[email protected]e03dc78d2012-07-24 08:21:43835 "disable-new-oobe",
836 IDS_FLAGS_DISABLE_NEW_OOBE,
837 IDS_FLAGS_DISABLE_NEW_OOBE_DESCRIPTION,
[email protected]ed7b67f32012-05-28 10:12:28838 kOsCrOS,
[email protected]e03dc78d2012-07-24 08:21:43839 SINGLE_VALUE_TYPE(switches::kDisableNewOobe),
[email protected]ed7b67f32012-05-28 10:12:28840 },
[email protected]8b04a1652012-08-04 02:59:49841 {
842 "disable-boot-animation",
843 IDS_FLAGS_DISABLE_BOOT_ANIMATION,
844 IDS_FLAGS_DISABLE_BOOT_ANIMATION_DESCRIPTION,
845 kOsCrOS,
846 SINGLE_VALUE_TYPE(switches::kDisableBootAnimation),
847 },
[email protected]ed7b67f32012-05-28 10:12:28848#endif
[email protected]fc7a93c2012-06-08 20:25:39849 {
850 "enable-views-textfield",
851 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_NAME,
852 IDS_FLAGS_ENABLE_VIEWS_TEXTFIELD_DESCRIPTION,
853 kOsWin,
854 SINGLE_VALUE_TYPE(switches::kEnableViewsTextfield),
855 },
[email protected]bd0cd3bb2012-06-14 03:03:38856 {
[email protected]ef41b7ee2012-07-24 19:10:41857 "old-checkbox-style",
858 IDS_FLAGS_OLD_CHECKBOX_STYLE,
859 IDS_FLAGS_OLD_CHECKBOX_STYLE_DESCRIPTION,
860 kOsLinux | kOsCrOS,
861 SINGLE_VALUE_TYPE(switches::kOldCheckboxStyle),
862 },
863 {
[email protected]fcb88de2012-07-12 22:25:32864 "enable-frameless-constrained-dialogs",
865 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_NAME,
866 IDS_FLAGS_ENABLE_FRAMELESS_DIALOG_DESCRIPTION,
867 kOsWin | kOsCrOS,
868 SINGLE_VALUE_TYPE(switches::kEnableFramelessConstrainedDialogs),
869 },
870 {
[email protected]2faeaabd2012-06-15 01:05:02871 "disable-non-fullscreen-mouse-lock",
872 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_NAME,
873 IDS_FLAGS_DISABLE_NON_FULLSCREEN_MOUSE_LOCK_DESCRIPTION,
874 kOsAll,
875 SINGLE_VALUE_TYPE(switches::kDisableNonFullscreenMouseLock),
876 },
[email protected]7057b3e2012-06-18 19:19:16877#if defined(OS_CHROMEOS)
878 {
879 "enable-unsupported-bluetooth-devices",
880 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_NAME,
881 IDS_FLAGS_UNSUPPORTED_BLUETOOTH_DEVICES_DESCRIPTION,
882 kOsCrOS,
883 SINGLE_VALUE_TYPE(switches::kEnableUnsupportedBluetoothDevices)
884 },
885#endif
[email protected]7db8893a2012-07-26 00:49:40886 { "disable-accelerated-video-decode",
887 IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_NAME,
888 IDS_FLAGS_DISABLE_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
[email protected]66dcb0492012-06-18 22:32:15889 kOsAll,
[email protected]7db8893a2012-07-26 00:49:40890 SINGLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
[email protected]66dcb0492012-06-18 22:32:15891 },
[email protected]66ae9fc2012-06-19 21:33:52892#if defined(USE_ASH)
893 {
894 "ash-debug-shortcuts",
895 IDS_FLAGS_DEBUG_SHORTCUTS_NAME,
896 IDS_FLAGS_DEBUG_SHORTCUTS_DESCRIPTION,
897 kOsAll,
898 SINGLE_VALUE_TYPE(ash::switches::kAshDebugShortcuts),
899 },
900#endif
[email protected]37fee0942012-08-07 21:07:45901 {
902 "enable-website-settings", // FLAGS:RECORD_UMA
903 IDS_FLAGS_ENABLE_WEBSITE_SETTINGS_NAME,
904 IDS_FLAGS_ENABLE_WEBSITE_SETTINGS_DESCRIPTION,
905 kOsAll,
906 SINGLE_VALUE_TYPE(switches::kEnableWebsiteSettings),
907 },
[email protected]a0e4b072011-08-17 01:47:07908};
[email protected]ad2a3ded2010-08-27 13:19:05909
[email protected]a314ee5a2010-10-26 21:23:28910const Experiment* experiments = kExperiments;
911size_t num_experiments = arraysize(kExperiments);
912
[email protected]e2ddbc92010-10-15 20:02:07913// Stores and encapsulates the little state that about:flags has.
914class FlagsState {
915 public:
916 FlagsState() : needs_restart_(false) {}
917 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line);
918 bool IsRestartNeededToCommitChanges();
919 void SetExperimentEnabled(
[email protected]a314ee5a2010-10-26 21:23:28920 PrefService* prefs, const std::string& internal_name, bool enable);
[email protected]e2ddbc92010-10-15 20:02:07921 void RemoveFlagsSwitches(
922 std::map<std::string, CommandLine::StringType>* switch_list);
923 void reset();
924
925 // Returns the singleton instance of this class
[email protected]8e8bb6d2010-12-13 08:18:55926 static FlagsState* GetInstance() {
[email protected]e2ddbc92010-10-15 20:02:07927 return Singleton<FlagsState>::get();
928 }
929
930 private:
931 bool needs_restart_;
[email protected]a82744532011-02-11 16:15:53932 std::map<std::string, std::string> flags_switches_;
[email protected]e2ddbc92010-10-15 20:02:07933
934 DISALLOW_COPY_AND_ASSIGN(FlagsState);
935};
936
[email protected]c7b7800a2010-10-07 18:51:35937// Extracts the list of enabled lab experiments from preferences and stores them
[email protected]ad2a3ded2010-08-27 13:19:05938// in a set.
[email protected]1a47d7e2010-10-15 00:37:24939void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) {
[email protected]ad2a3ded2010-08-27 13:19:05940 const ListValue* enabled_experiments = prefs->GetList(
941 prefs::kEnabledLabsExperiments);
942 if (!enabled_experiments)
943 return;
944
945 for (ListValue::const_iterator it = enabled_experiments->begin();
946 it != enabled_experiments->end();
947 ++it) {
948 std::string experiment_name;
949 if (!(*it)->GetAsString(&experiment_name)) {
950 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments;
951 continue;
952 }
953 result->insert(experiment_name);
954 }
955}
956
957// Takes a set of enabled lab experiments
[email protected]1a47d7e2010-10-15 00:37:24958void SetEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:05959 PrefService* prefs, const std::set<std::string>& enabled_experiments) {
[email protected]1bc78422011-03-31 08:41:38960 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments);
961 ListValue* experiments_list = update.Get();
[email protected]ad2a3ded2010-08-27 13:19:05962
963 experiments_list->Clear();
964 for (std::set<std::string>::const_iterator it = enabled_experiments.begin();
965 it != enabled_experiments.end();
966 ++it) {
967 experiments_list->Append(new StringValue(*it));
968 }
969}
970
[email protected]8a6ff28d2010-12-02 16:35:19971// Returns the name used in prefs for the choice at the specified index.
972std::string NameForChoice(const Experiment& e, int index) {
[email protected]2ce9c89752011-02-25 18:24:34973 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
974 DCHECK_LT(index, e.num_choices);
[email protected]8a6ff28d2010-12-02 16:35:19975 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator +
976 base::IntToString(index);
977}
978
979// Adds the internal names for the specified experiment to |names|.
980void AddInternalName(const Experiment& e, std::set<std::string>* names) {
981 if (e.type == Experiment::SINGLE_VALUE) {
982 names->insert(e.internal_name);
983 } else {
[email protected]2ce9c89752011-02-25 18:24:34984 DCHECK_EQ(Experiment::MULTI_VALUE, e.type);
[email protected]8a6ff28d2010-12-02 16:35:19985 for (int i = 0; i < e.num_choices; ++i)
986 names->insert(NameForChoice(e, i));
987 }
988}
989
[email protected]28e35af2011-02-09 12:56:22990// Confirms that an experiment is valid, used in a DCHECK in
991// SanitizeList below.
992bool ValidateExperiment(const Experiment& e) {
993 switch (e.type) {
994 case Experiment::SINGLE_VALUE:
995 DCHECK_EQ(0, e.num_choices);
996 DCHECK(!e.choices);
997 break;
998 case Experiment::MULTI_VALUE:
999 DCHECK_GT(e.num_choices, 0);
1000 DCHECK(e.choices);
[email protected]a82744532011-02-11 16:15:531001 DCHECK(e.choices[0].command_line_switch);
1002 DCHECK_EQ('\0', e.choices[0].command_line_switch[0]);
[email protected]28e35af2011-02-09 12:56:221003 break;
1004 default:
1005 NOTREACHED();
1006 }
1007 return true;
1008}
1009
[email protected]ad2a3ded2010-08-27 13:19:051010// Removes all experiments from prefs::kEnabledLabsExperiments that are
1011// unknown, to prevent this list to become very long as experiments are added
1012// and removed.
1013void SanitizeList(PrefService* prefs) {
1014 std::set<std::string> known_experiments;
[email protected]28e35af2011-02-09 12:56:221015 for (size_t i = 0; i < num_experiments; ++i) {
1016 DCHECK(ValidateExperiment(experiments[i]));
[email protected]8a6ff28d2010-12-02 16:35:191017 AddInternalName(experiments[i], &known_experiments);
[email protected]28e35af2011-02-09 12:56:221018 }
[email protected]ad2a3ded2010-08-27 13:19:051019
1020 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241021 GetEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051022
1023 std::set<std::string> new_enabled_experiments;
1024 std::set_intersection(
1025 known_experiments.begin(), known_experiments.end(),
1026 enabled_experiments.begin(), enabled_experiments.end(),
1027 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1028
[email protected]4c8853f2012-07-23 01:29:161029 if (new_enabled_experiments != enabled_experiments)
1030 SetEnabledFlags(prefs, new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051031}
1032
[email protected]1a47d7e2010-10-15 00:37:241033void GetSanitizedEnabledFlags(
[email protected]ad2a3ded2010-08-27 13:19:051034 PrefService* prefs, std::set<std::string>* result) {
1035 SanitizeList(prefs);
[email protected]1a47d7e2010-10-15 00:37:241036 GetEnabledFlags(prefs, result);
[email protected]ad2a3ded2010-08-27 13:19:051037}
1038
[email protected]a314ee5a2010-10-26 21:23:281039// Variant of GetSanitizedEnabledFlags that also removes any flags that aren't
1040// enabled on the current platform.
1041void GetSanitizedEnabledFlagsForCurrentPlatform(
1042 PrefService* prefs, std::set<std::string>* result) {
1043 GetSanitizedEnabledFlags(prefs, result);
1044
1045 // Filter out any experiments that aren't enabled on the current platform. We
1046 // don't remove these from prefs else syncing to a platform with a different
1047 // set of experiments would be lossy.
1048 std::set<std::string> platform_experiments;
1049 int current_platform = GetCurrentPlatform();
1050 for (size_t i = 0; i < num_experiments; ++i) {
1051 if (experiments[i].supported_platforms & current_platform)
[email protected]8a6ff28d2010-12-02 16:35:191052 AddInternalName(experiments[i], &platform_experiments);
[email protected]a314ee5a2010-10-26 21:23:281053 }
1054
1055 std::set<std::string> new_enabled_experiments;
1056 std::set_intersection(
1057 platform_experiments.begin(), platform_experiments.end(),
1058 result->begin(), result->end(),
1059 std::inserter(new_enabled_experiments, new_enabled_experiments.begin()));
1060
1061 result->swap(new_enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051062}
1063
[email protected]8a6ff28d2010-12-02 16:35:191064// Returns the Value representing the choice data in the specified experiment.
[email protected]8a6ff28d2010-12-02 16:35:191065Value* CreateChoiceData(const Experiment& experiment,
[email protected]28e35af2011-02-09 12:56:221066 const std::set<std::string>& enabled_experiments) {
[email protected]2ce9c89752011-02-25 18:24:341067 DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type);
[email protected]8a6ff28d2010-12-02 16:35:191068 ListValue* result = new ListValue;
1069 for (int i = 0; i < experiment.num_choices; ++i) {
1070 const Experiment::Choice& choice = experiment.choices[i];
1071 DictionaryValue* value = new DictionaryValue;
1072 std::string name = NameForChoice(experiment, i);
1073 value->SetString("description",
1074 l10n_util::GetStringUTF16(choice.description_id));
1075 value->SetString("internal_name", name);
[email protected]28e35af2011-02-09 12:56:221076 value->SetBoolean("selected", enabled_experiments.count(name) > 0);
[email protected]8a6ff28d2010-12-02 16:35:191077 result->Append(value);
1078 }
1079 return result;
1080}
1081
[email protected]e2ddbc92010-10-15 20:02:071082} // namespace
1083
[email protected]1a47d7e2010-10-15 00:37:241084void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) {
[email protected]8e8bb6d2010-12-13 08:18:551085 FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line);
[email protected]ad2a3ded2010-08-27 13:19:051086}
1087
[email protected]1a47d7e2010-10-15 00:37:241088ListValue* GetFlagsExperimentsData(PrefService* prefs) {
[email protected]ad2a3ded2010-08-27 13:19:051089 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241090 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051091
1092 int current_platform = GetCurrentPlatform();
1093
1094 ListValue* experiments_data = new ListValue();
[email protected]a314ee5a2010-10-26 21:23:281095 for (size_t i = 0; i < num_experiments; ++i) {
1096 const Experiment& experiment = experiments[i];
[email protected]ad2a3ded2010-08-27 13:19:051097
1098 DictionaryValue* data = new DictionaryValue();
1099 data->SetString("internal_name", experiment.internal_name);
1100 data->SetString("name",
1101 l10n_util::GetStringUTF16(experiment.visible_name_id));
1102 data->SetString("description",
1103 l10n_util::GetStringUTF16(
1104 experiment.visible_description_id));
[email protected]cc3e2052011-12-20 01:01:401105 bool supported = !!(experiment.supported_platforms & current_platform);
1106 data->SetBoolean("supported", supported);
1107
1108 ListValue* supported_platforms = new ListValue();
1109 AddOsStrings(experiment.supported_platforms, supported_platforms);
1110 data->Set("supported_platforms", supported_platforms);
[email protected]ad2a3ded2010-08-27 13:19:051111
[email protected]28e35af2011-02-09 12:56:221112 switch (experiment.type) {
1113 case Experiment::SINGLE_VALUE:
1114 data->SetBoolean(
1115 "enabled",
1116 enabled_experiments.count(experiment.internal_name) > 0);
1117 break;
1118 case Experiment::MULTI_VALUE:
1119 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
1120 break;
1121 default:
1122 NOTREACHED();
[email protected]8a6ff28d2010-12-02 16:35:191123 }
1124
[email protected]ad2a3ded2010-08-27 13:19:051125 experiments_data->Append(data);
1126 }
1127 return experiments_data;
1128}
1129
[email protected]ad2a3ded2010-08-27 13:19:051130bool IsRestartNeededToCommitChanges() {
[email protected]8e8bb6d2010-12-13 08:18:551131 return FlagsState::GetInstance()->IsRestartNeededToCommitChanges();
[email protected]ad2a3ded2010-08-27 13:19:051132}
1133
1134void SetExperimentEnabled(
[email protected]c7b7800a2010-10-07 18:51:351135 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]8e8bb6d2010-12-13 08:18:551136 FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable);
[email protected]e2ddbc92010-10-15 20:02:071137}
1138
1139void RemoveFlagsSwitches(
1140 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]8e8bb6d2010-12-13 08:18:551141 FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list);
[email protected]e2ddbc92010-10-15 20:02:071142}
1143
[email protected]a314ee5a2010-10-26 21:23:281144int GetCurrentPlatform() {
1145#if defined(OS_MACOSX)
1146 return kOsMac;
1147#elif defined(OS_WIN)
1148 return kOsWin;
1149#elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check.
1150 return kOsCrOS;
[email protected]c92f4ed2011-10-21 19:50:211151#elif defined(OS_LINUX) || defined(OS_OPENBSD)
[email protected]a314ee5a2010-10-26 21:23:281152 return kOsLinux;
[email protected]9c7453d2012-01-21 00:45:401153#elif defined(OS_ANDROID)
1154 return kOsAndroid;
[email protected]a314ee5a2010-10-26 21:23:281155#else
1156#error Unknown platform
1157#endif
1158}
1159
[email protected]4bc5050c2010-11-18 17:55:541160void RecordUMAStatistics(const PrefService* prefs) {
1161 std::set<std::string> flags;
1162 GetEnabledFlags(prefs, &flags);
1163 for (std::set<std::string>::iterator it = flags.begin(); it != flags.end();
1164 ++it) {
1165 std::string action("AboutFlags_");
1166 action += *it;
[email protected]7f6f44c2011-12-14 13:23:381167 content::RecordComputedAction(action);
[email protected]4bc5050c2010-11-18 17:55:541168 }
1169 // Since flag metrics are recorded every startup, add a tick so that the
1170 // stats can be made meaningful.
1171 if (flags.size())
[email protected]7f6f44c2011-12-14 13:23:381172 content::RecordAction(UserMetricsAction("AboutFlags_StartupTick"));
1173 content::RecordAction(UserMetricsAction("StartupTick"));
[email protected]4bc5050c2010-11-18 17:55:541174}
1175
[email protected]e2ddbc92010-10-15 20:02:071176//////////////////////////////////////////////////////////////////////////////
1177// FlagsState implementation.
1178
1179namespace {
1180
1181void FlagsState::ConvertFlagsToSwitches(
1182 PrefService* prefs, CommandLine* command_line) {
[email protected]e2ddbc92010-10-15 20:02:071183 if (command_line->HasSwitch(switches::kNoExperiments))
1184 return;
1185
1186 std::set<std::string> enabled_experiments;
[email protected]ba8164242010-11-16 21:31:001187
[email protected]a314ee5a2010-10-26 21:23:281188 GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments);
[email protected]e2ddbc92010-10-15 20:02:071189
[email protected]a82744532011-02-11 16:15:531190 typedef std::map<std::string, std::pair<std::string, std::string> >
1191 NameToSwitchAndValueMap;
1192 NameToSwitchAndValueMap name_to_switch_map;
[email protected]8a6ff28d2010-12-02 16:35:191193 for (size_t i = 0; i < num_experiments; ++i) {
1194 const Experiment& e = experiments[i];
1195 if (e.type == Experiment::SINGLE_VALUE) {
[email protected]a82744532011-02-11 16:15:531196 name_to_switch_map[e.internal_name] =
1197 std::pair<std::string, std::string>(e.command_line_switch,
1198 e.command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191199 } else {
1200 for (int j = 0; j < e.num_choices; ++j)
[email protected]a82744532011-02-11 16:15:531201 name_to_switch_map[NameForChoice(e, j)] =
1202 std::pair<std::string, std::string>(
1203 e.choices[j].command_line_switch,
1204 e.choices[j].command_line_value);
[email protected]8a6ff28d2010-12-02 16:35:191205 }
1206 }
[email protected]e2ddbc92010-10-15 20:02:071207
1208 command_line->AppendSwitch(switches::kFlagSwitchesBegin);
[email protected]a82744532011-02-11 16:15:531209 flags_switches_.insert(
1210 std::pair<std::string, std::string>(switches::kFlagSwitchesBegin,
1211 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071212 for (std::set<std::string>::iterator it = enabled_experiments.begin();
1213 it != enabled_experiments.end();
1214 ++it) {
1215 const std::string& experiment_name = *it;
[email protected]a82744532011-02-11 16:15:531216 NameToSwitchAndValueMap::const_iterator name_to_switch_it =
[email protected]8a6ff28d2010-12-02 16:35:191217 name_to_switch_map.find(experiment_name);
1218 if (name_to_switch_it == name_to_switch_map.end()) {
1219 NOTREACHED();
[email protected]e2ddbc92010-10-15 20:02:071220 continue;
[email protected]8a6ff28d2010-12-02 16:35:191221 }
[email protected]e2ddbc92010-10-15 20:02:071222
[email protected]a82744532011-02-11 16:15:531223 const std::pair<std::string, std::string>&
1224 switch_and_value_pair = name_to_switch_it->second;
1225
1226 command_line->AppendSwitchASCII(switch_and_value_pair.first,
1227 switch_and_value_pair.second);
1228 flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second;
[email protected]e2ddbc92010-10-15 20:02:071229 }
1230 command_line->AppendSwitch(switches::kFlagSwitchesEnd);
[email protected]a82744532011-02-11 16:15:531231 flags_switches_.insert(
1232 std::pair<std::string, std::string>(switches::kFlagSwitchesEnd,
1233 std::string()));
[email protected]e2ddbc92010-10-15 20:02:071234}
1235
1236bool FlagsState::IsRestartNeededToCommitChanges() {
1237 return needs_restart_;
1238}
1239
1240void FlagsState::SetExperimentEnabled(
1241 PrefService* prefs, const std::string& internal_name, bool enable) {
[email protected]ad2a3ded2010-08-27 13:19:051242 needs_restart_ = true;
1243
[email protected]8a6ff28d2010-12-02 16:35:191244 size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator);
1245 if (at_index != std::string::npos) {
1246 DCHECK(enable);
1247 // We're being asked to enable a multi-choice experiment. Disable the
1248 // currently selected choice.
1249 DCHECK_NE(at_index, 0u);
[email protected]28e35af2011-02-09 12:56:221250 const std::string experiment_name = internal_name.substr(0, at_index);
1251 SetExperimentEnabled(prefs, experiment_name, false);
[email protected]8a6ff28d2010-12-02 16:35:191252
[email protected]28e35af2011-02-09 12:56:221253 // And enable the new choice, if it is not the default first choice.
1254 if (internal_name != experiment_name + "@0") {
1255 std::set<std::string> enabled_experiments;
1256 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
1257 enabled_experiments.insert(internal_name);
1258 SetEnabledFlags(prefs, enabled_experiments);
1259 }
[email protected]8a6ff28d2010-12-02 16:35:191260 return;
1261 }
1262
[email protected]ad2a3ded2010-08-27 13:19:051263 std::set<std::string> enabled_experiments;
[email protected]1a47d7e2010-10-15 00:37:241264 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051265
[email protected]8a6ff28d2010-12-02 16:35:191266 const Experiment* e = NULL;
1267 for (size_t i = 0; i < num_experiments; ++i) {
1268 if (experiments[i].internal_name == internal_name) {
1269 e = experiments + i;
1270 break;
1271 }
1272 }
1273 DCHECK(e);
1274
1275 if (e->type == Experiment::SINGLE_VALUE) {
[email protected]8a2713682011-08-19 10:36:591276 if (enable)
[email protected]8a6ff28d2010-12-02 16:35:191277 enabled_experiments.insert(internal_name);
[email protected]8a2713682011-08-19 10:36:591278 else
[email protected]8a6ff28d2010-12-02 16:35:191279 enabled_experiments.erase(internal_name);
1280 } else {
1281 if (enable) {
1282 // Enable the first choice.
1283 enabled_experiments.insert(NameForChoice(*e, 0));
1284 } else {
1285 // Find the currently enabled choice and disable it.
1286 for (int i = 0; i < e->num_choices; ++i) {
1287 std::string choice_name = NameForChoice(*e, i);
1288 if (enabled_experiments.find(choice_name) !=
1289 enabled_experiments.end()) {
1290 enabled_experiments.erase(choice_name);
1291 // Continue on just in case there's a bug and more than one
1292 // experiment for this choice was enabled.
1293 }
1294 }
1295 }
1296 }
[email protected]ad2a3ded2010-08-27 13:19:051297
[email protected]1a47d7e2010-10-15 00:37:241298 SetEnabledFlags(prefs, enabled_experiments);
[email protected]ad2a3ded2010-08-27 13:19:051299}
1300
[email protected]e2ddbc92010-10-15 20:02:071301void FlagsState::RemoveFlagsSwitches(
1302 std::map<std::string, CommandLine::StringType>* switch_list) {
[email protected]a82744532011-02-11 16:15:531303 for (std::map<std::string, std::string>::const_iterator
1304 it = flags_switches_.begin(); it != flags_switches_.end(); ++it) {
1305 switch_list->erase(it->first);
[email protected]e2ddbc92010-10-15 20:02:071306 }
1307}
1308
1309void FlagsState::reset() {
1310 needs_restart_ = false;
1311 flags_switches_.clear();
1312}
1313
[email protected]38e46812011-05-09 20:49:221314} // namespace
[email protected]e2ddbc92010-10-15 20:02:071315
1316namespace testing {
[email protected]8a6ff28d2010-12-02 16:35:191317
1318// WARNING: '@' is also used in the html file. If you update this constant you
1319// also need to update the html file.
1320const char kMultiSeparator[] = "@";
1321
[email protected]e2ddbc92010-10-15 20:02:071322void ClearState() {
[email protected]8e8bb6d2010-12-13 08:18:551323 FlagsState::GetInstance()->reset();
[email protected]e2ddbc92010-10-15 20:02:071324}
[email protected]a314ee5a2010-10-26 21:23:281325
1326void SetExperiments(const Experiment* e, size_t count) {
1327 if (!e) {
1328 experiments = kExperiments;
1329 num_experiments = arraysize(kExperiments);
1330 } else {
1331 experiments = e;
1332 num_experiments = count;
1333 }
1334}
1335
[email protected]8a6ff28d2010-12-02 16:35:191336const Experiment* GetExperiments(size_t* count) {
1337 *count = num_experiments;
1338 return experiments;
1339}
1340
[email protected]e2ddbc92010-10-15 20:02:071341} // namespace testing
1342
[email protected]1a47d7e2010-10-15 00:37:241343} // namespace about_flags