[email protected] | 9c66adc | 2012-01-05 02:10:16 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 5 | #include "chrome/browser/about_flags.h" |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 6 | |
| 7 | #include <algorithm> |
| 8 | #include <iterator> |
| 9 | #include <map> |
| 10 | #include <set> |
| 11 | |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 12 | #include "base/command_line.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 13 | #include "base/memory/singleton.h" |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 14 | #include "base/string_number_conversions.h" |
[email protected] | d208f4d8 | 2011-05-23 21:52:03 | [diff] [blame] | 15 | #include "base/utf_string_conversions.h" |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 16 | #include "base/values.h" |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 17 | #include "chrome/browser/prefs/pref_service.h" |
[email protected] | 1bc7842 | 2011-03-31 08:41:38 | [diff] [blame] | 18 | #include "chrome/browser/prefs/scoped_user_pref_update.h" |
[email protected] | d208f4d8 | 2011-05-23 21:52:03 | [diff] [blame] | 19 | #include "chrome/common/chrome_content_client.h" |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 20 | #include "chrome/common/chrome_switches.h" |
| 21 | #include "chrome/common/pref_names.h" |
[email protected] | 7f6f44c | 2011-12-14 13:23:38 | [diff] [blame] | 22 | #include "content/public/browser/user_metrics.h" |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 23 | #include "grit/generated_resources.h" |
[email protected] | c051a1b | 2011-01-21 23:30:17 | [diff] [blame] | 24 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | c9c73ad4 | 2012-04-18 03:35:59 | [diff] [blame] | 25 | #include "ui/base/ui_base_switches.h" |
[email protected] | 8ff7f34 | 2011-05-25 01:49:47 | [diff] [blame] | 26 | #include "ui/gfx/gl/gl_switches.h" |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 27 | |
[email protected] | dc04be7c | 2012-03-15 23:57:49 | [diff] [blame] | 28 | #if defined(USE_ASH) |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 29 | #include "ash/ash_switches.h" |
[email protected] | dc04be7c | 2012-03-15 23:57:49 | [diff] [blame] | 30 | #endif |
| 31 | |
| 32 | #if defined(USE_AURA) |
[email protected] | 308aaa3 | 2012-03-12 13:14:50 | [diff] [blame] | 33 | #include "ui/aura/aura_switches.h" |
[email protected] | 8cc10df | 2011-11-03 23:57:50 | [diff] [blame] | 34 | #endif |
| 35 | |
[email protected] | 7f6f44c | 2011-12-14 13:23:38 | [diff] [blame] | 36 | using content::UserMetricsAction; |
| 37 | |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 38 | namespace about_flags { |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 39 | |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 40 | // Macros to simplify specifying the type. |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 41 | #define SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, switch_value) \ |
| 42 | Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0 |
| 43 | #define SINGLE_VALUE_TYPE(command_line_switch) \ |
| 44 | SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "") |
| 45 | #define MULTI_VALUE_TYPE(choices) \ |
[email protected] | 0e6f56d | 2011-02-12 23:45:15 | [diff] [blame] | 46 | Experiment::MULTI_VALUE, "", "", choices, arraysize(choices) |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 47 | |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 48 | namespace { |
| 49 | |
[email protected] | 9c7453d | 2012-01-21 00:45:40 | [diff] [blame] | 50 | const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS | kOsAndroid; |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 51 | |
[email protected] | cc3e205 | 2011-12-20 01:01:40 | [diff] [blame] | 52 | // Adds a |StringValue| to |list| for each platform where |bitmask| indicates |
| 53 | // whether the experiment is available on that platform. |
| 54 | void AddOsStrings(unsigned bitmask, ListValue* list) { |
| 55 | struct { |
| 56 | unsigned bit; |
| 57 | const char* const name; |
| 58 | } kBitsToOs[] = { |
| 59 | {kOsMac, "Mac"}, |
| 60 | {kOsWin, "Windows"}, |
| 61 | {kOsLinux, "Linux"}, |
| 62 | {kOsCrOS, "Chrome OS"}, |
| 63 | }; |
| 64 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i) |
| 65 | if (bitmask & kBitsToOs[i].bit) |
| 66 | list->Append(new StringValue(kBitsToOs[i].name)); |
| 67 | } |
| 68 | |
[email protected] | ba816424 | 2010-11-16 21:31:00 | [diff] [blame] | 69 | // Names for former Chrome OS Labs experiments, shared with prefs migration |
| 70 | // code. |
| 71 | const char kMediaPlayerExperimentName[] = "media-player"; |
| 72 | const char kAdvancedFileSystemExperimentName[] = "advanced-file-system"; |
| 73 | const char kVerticalTabsExperimentName[] = "vertical-tabs"; |
| 74 | |
[email protected] | 032d5e6c | 2012-02-17 17:53:55 | [diff] [blame] | 75 | const Experiment::Choice kOmniboxInlineHistoryQuickProviderChoices[] = { |
| 76 | { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_AUTOMATIC, "", "" }, |
| 77 | { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_ALLOWED, |
| 78 | switches::kOmniboxInlineHistoryQuickProvider, |
| 79 | switches::kOmniboxInlineHistoryQuickProviderAllowed }, |
| 80 | { IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_PROHIBITED, |
| 81 | switches::kOmniboxInlineHistoryQuickProvider, |
| 82 | switches::kOmniboxInlineHistoryQuickProviderProhibited } |
| 83 | }; |
| 84 | |
[email protected] | 72787e39 | 2012-03-23 05:55:43 | [diff] [blame] | 85 | const Experiment::Choice kThreadedCompositingModeChoices[] = { |
| 86 | { IDS_FLAGS_THREADED_COMPOSITING_MODE_DEFAULT, "", "" }, |
| 87 | { IDS_FLAGS_THREADED_COMPOSITING_MODE_DISABLED, |
| 88 | switches::kDisableThreadedCompositing, ""}, |
| 89 | { IDS_FLAGS_THREADED_COMPOSITING_MODE_ENABLED, |
| 90 | switches::kEnableThreadedCompositing, ""} |
| 91 | }; |
| 92 | |
[email protected] | 4bc5050c | 2010-11-18 17:55:54 | [diff] [blame] | 93 | // RECORDING USER METRICS FOR FLAGS: |
| 94 | // ----------------------------------------------------------------------------- |
| 95 | // The first line of the experiment is the internal name. If you'd like to |
| 96 | // gather statistics about the usage of your flag, you should append a marker |
| 97 | // comment to the end of the feature name, like so: |
| 98 | // "my-special-feature", // FLAGS:RECORD_UMA |
| 99 | // |
| 100 | // After doing that, run //chrome/tools/extract_actions.py (see instructions at |
| 101 | // the top of that file for details) to update the chromeactions.txt file, which |
| 102 | // will enable UMA to record your feature flag. |
| 103 | // |
| 104 | // After your feature has shipped under a flag, you can locate the metrics |
| 105 | // under the action name AboutFlags_internal-action-name. Actions are recorded |
| 106 | // once per startup, so you should divide this number by AboutFlags_StartupTick |
| 107 | // to get a sense of usage. Note that this will not be the same as number of |
| 108 | // users with a given feature enabled because users can quit and relaunch |
| 109 | // the application multiple times over a given time interval. |
| 110 | // TODO(rsesek): See if there's a way to count per-user, rather than |
| 111 | // per-startup. |
| 112 | |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 113 | // To add a new experiment add to the end of kExperiments. There are two |
| 114 | // distinct types of experiments: |
| 115 | // . SINGLE_VALUE: experiment is either on or off. Use the SINGLE_VALUE_TYPE |
| 116 | // macro for this type supplying the command line to the macro. |
[email protected] | 28e35af | 2011-02-09 12:56:22 | [diff] [blame] | 117 | // . MULTI_VALUE: a list of choices, the first of which should correspond to a |
| 118 | // deactivated state for this lab (i.e. no command line option). To specify |
| 119 | // this type of experiment use the macro MULTI_VALUE_TYPE supplying it the |
| 120 | // array of choices. |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 121 | // See the documentation of Experiment for details on the fields. |
| 122 | // |
| 123 | // When adding a new choice, add it to the end of the list. |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 124 | const Experiment kExperiments[] = { |
| 125 | { |
[email protected] | aac169d | 2011-03-18 19:53:03 | [diff] [blame] | 126 | "expose-for-tabs", // FLAGS:RECORD_UMA |
| 127 | IDS_FLAGS_TABPOSE_NAME, |
| 128 | IDS_FLAGS_TABPOSE_DESCRIPTION, |
| 129 | kOsMac, |
| 130 | #if defined(OS_MACOSX) |
| 131 | // The switch exists only on OS X. |
| 132 | SINGLE_VALUE_TYPE(switches::kEnableExposeForTabs) |
| 133 | #else |
| 134 | SINGLE_VALUE_TYPE("") |
| 135 | #endif |
| 136 | }, |
| 137 | { |
[email protected] | 4bc5050c | 2010-11-18 17:55:54 | [diff] [blame] | 138 | "conflicting-modules-check", // FLAGS:RECORD_UMA |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 139 | IDS_FLAGS_CONFLICTS_CHECK_NAME, |
| 140 | IDS_FLAGS_CONFLICTS_CHECK_DESCRIPTION, |
| 141 | kOsWin, |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 142 | SINGLE_VALUE_TYPE(switches::kConflictingModulesCheck) |
[email protected] | c1bbaa8 | 2010-11-08 11:17:05 | [diff] [blame] | 143 | }, |
| 144 | { |
[email protected] | 4bc5050c | 2010-11-18 17:55:54 | [diff] [blame] | 145 | "cloud-print-proxy", // FLAGS:RECORD_UMA |
[email protected] | dae7325b | 2011-12-21 20:56:54 | [diff] [blame] | 146 | IDS_FLAGS_CLOUD_PRINT_CONNECTOR_NAME, |
| 147 | IDS_FLAGS_CLOUD_PRINT_CONNECTOR_DESCRIPTION, |
[email protected] | 9f8872b3 | 2011-03-04 19:44:45 | [diff] [blame] | 148 | // For a Chrome build, we know we have a PDF plug-in on Windows, so it's |
[email protected] | 4fa24bf | 2011-08-20 02:15:22 | [diff] [blame] | 149 | // fully enabled. |
[email protected] | 5d10d57d | 2011-07-22 22:16:31 | [diff] [blame] | 150 | // Otherwise, where we know Windows could be working if a viable PDF |
[email protected] | 4fa24bf | 2011-08-20 02:15:22 | [diff] [blame] | 151 | // plug-in could be supplied, we'll keep the lab enabled. Mac and Linux |
| 152 | // always have PDF rasterization available, so no flag needed there. |
| 153 | #if !defined(GOOGLE_CHROME_BUILD) |
| 154 | kOsWin, |
| 155 | #else |
| 156 | 0, |
[email protected] | fa6d2a2f | 2010-11-30 21:47:19 | [diff] [blame] | 157 | #endif |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 158 | SINGLE_VALUE_TYPE(switches::kEnableCloudPrintProxy) |
[email protected] | 8b6588a | 2010-10-12 02:39:42 | [diff] [blame] | 159 | }, |
[email protected] | 580939a | 2010-10-12 18:54:37 | [diff] [blame] | 160 | { |
[email protected] | bb46153 | 2010-11-26 21:50:23 | [diff] [blame] | 161 | "crxless-web-apps", |
| 162 | IDS_FLAGS_CRXLESS_WEB_APPS_NAME, |
| 163 | IDS_FLAGS_CRXLESS_WEB_APPS_DESCRIPTION, |
| 164 | kOsAll, |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 165 | SINGLE_VALUE_TYPE(switches::kEnableCrxlessWebApps) |
[email protected] | bb46153 | 2010-11-26 21:50:23 | [diff] [blame] | 166 | }, |
| 167 | { |
[email protected] | 96c6f4c | 2011-05-18 19:36:22 | [diff] [blame] | 168 | "ignore-gpu-blacklist", |
| 169 | IDS_FLAGS_IGNORE_GPU_BLACKLIST_NAME, |
| 170 | IDS_FLAGS_IGNORE_GPU_BLACKLIST_DESCRIPTION, |
| 171 | kOsAll, |
| 172 | SINGLE_VALUE_TYPE(switches::kIgnoreGpuBlacklist) |
| 173 | }, |
| 174 | { |
[email protected] | 0110cf11 | 2011-07-02 00:39:43 | [diff] [blame] | 175 | "force-compositing-mode-2", |
[email protected] | 96c6f4c | 2011-05-18 19:36:22 | [diff] [blame] | 176 | IDS_FLAGS_FORCE_COMPOSITING_MODE_NAME, |
| 177 | IDS_FLAGS_FORCE_COMPOSITING_MODE_DESCRIPTION, |
| 178 | kOsAll, |
| 179 | SINGLE_VALUE_TYPE(switches::kForceCompositingMode) |
| 180 | }, |
| 181 | { |
[email protected] | 72787e39 | 2012-03-23 05:55:43 | [diff] [blame] | 182 | "threaded-compositing-mode", |
| 183 | IDS_FLAGS_THREADED_COMPOSITING_MODE_NAME, |
| 184 | IDS_FLAGS_THREADED_COMPOSITING_MODE_DESCRIPTION, |
[email protected] | 644a107 | 2012-03-16 09:29:59 | [diff] [blame] | 185 | kOsAll, |
[email protected] | 72787e39 | 2012-03-23 05:55:43 | [diff] [blame] | 186 | MULTI_VALUE_TYPE(kThreadedCompositingModeChoices) |
[email protected] | 644a107 | 2012-03-16 09:29:59 | [diff] [blame] | 187 | }, |
| 188 | { |
[email protected] | 7d2e053 | 2012-03-23 22:03:31 | [diff] [blame] | 189 | "disable-threaded-animation", |
| 190 | IDS_FLAGS_DISABLE_THREADED_ANIMATION_NAME, |
| 191 | IDS_FLAGS_DISABLE_THREADED_ANIMATION_DESCRIPTION, |
[email protected] | 644a107 | 2012-03-16 09:29:59 | [diff] [blame] | 192 | kOsAll, |
[email protected] | 7d2e053 | 2012-03-23 22:03:31 | [diff] [blame] | 193 | SINGLE_VALUE_TYPE(switches::kDisableThreadedAnimation) |
[email protected] | 644a107 | 2012-03-16 09:29:59 | [diff] [blame] | 194 | }, |
| 195 | { |
[email protected] | 5963b77 | 2011-02-09 22:55:38 | [diff] [blame] | 196 | "composited-layer-borders", |
| 197 | IDS_FLAGS_COMPOSITED_LAYER_BORDERS, |
| 198 | IDS_FLAGS_COMPOSITED_LAYER_BORDERS_DESCRIPTION, |
| 199 | kOsAll, |
| 200 | SINGLE_VALUE_TYPE(switches::kShowCompositedLayerBorders) |
| 201 | }, |
| 202 | { |
[email protected] | a8f1eaa | 2011-03-07 19:00:58 | [diff] [blame] | 203 | "show-fps-counter", |
| 204 | IDS_FLAGS_SHOW_FPS_COUNTER, |
| 205 | IDS_FLAGS_SHOW_FPS_COUNTER_DESCRIPTION, |
| 206 | kOsAll, |
| 207 | SINGLE_VALUE_TYPE(switches::kShowFPSCounter) |
| 208 | }, |
[email protected] | 8ff7f34 | 2011-05-25 01:49:47 | [diff] [blame] | 209 | { |
[email protected] | 70c98a33 | 2011-12-21 20:51:52 | [diff] [blame] | 210 | "accelerated-filters", |
| 211 | IDS_FLAGS_ACCELERATED_FILTERS, |
| 212 | IDS_FLAGS_ACCELERATED_FILTERS_DESCRIPTION, |
| 213 | kOsAll, |
| 214 | SINGLE_VALUE_TYPE(switches::kEnableAcceleratedFilters) |
| 215 | }, |
| 216 | { |
[email protected] | 8ff7f34 | 2011-05-25 01:49:47 | [diff] [blame] | 217 | "disable-gpu-vsync", |
| 218 | IDS_FLAGS_DISABLE_GPU_VSYNC_NAME, |
| 219 | IDS_FLAGS_DISABLE_GPU_VSYNC_DESCRIPTION, |
| 220 | kOsAll, |
| 221 | SINGLE_VALUE_TYPE(switches::kDisableGpuVsync) |
| 222 | }, |
[email protected] | deaba6d5 | 2011-09-23 14:47:12 | [diff] [blame] | 223 | { |
| 224 | "disable-webgl", |
| 225 | IDS_FLAGS_DISABLE_WEBGL_NAME, |
| 226 | IDS_FLAGS_DISABLE_WEBGL_DESCRIPTION, |
| 227 | kOsAll, |
| 228 | SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL) |
| 229 | }, |
[email protected] | d208f4d8 | 2011-05-23 21:52:03 | [diff] [blame] | 230 | // TODO(dspringer): When NaCl is on by default, remove this flag entry. |
[email protected] | 2fe15fcb | 2010-10-21 20:39:53 | [diff] [blame] | 231 | { |
[email protected] | e3791ce9 | 2011-08-09 01:03:32 | [diff] [blame] | 232 | "enable-nacl", // FLAGS:RECORD_UMA |
[email protected] | 4ff87d20 | 2010-11-06 01:28:40 | [diff] [blame] | 233 | IDS_FLAGS_ENABLE_NACL_NAME, |
| 234 | IDS_FLAGS_ENABLE_NACL_DESCRIPTION, |
| 235 | kOsAll, |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 236 | SINGLE_VALUE_TYPE(switches::kEnableNaCl) |
[email protected] | 4ff87d20 | 2010-11-06 01:28:40 | [diff] [blame] | 237 | }, |
[email protected] | b39c6d9 | 2012-01-31 16:38:41 | [diff] [blame] | 238 | // TODO(halyavin): When exception handling is on by default, replace this |
| 239 | // flag with disable-nacl-exception-handling. |
| 240 | { |
| 241 | "enable-nacl-exception-handling", // FLAGS:RECORD_UMA |
| 242 | IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_NAME, |
| 243 | IDS_FLAGS_ENABLE_NACL_EXCEPTION_HANDLING_DESCRIPTION, |
| 244 | kOsWin, |
| 245 | SINGLE_VALUE_TYPE(switches::kEnableNaClExceptionHandling) |
| 246 | }, |
[email protected] | 4ff87d20 | 2010-11-06 01:28:40 | [diff] [blame] | 247 | { |
[email protected] | 31a665e7 | 2012-03-11 12:37:46 | [diff] [blame] | 248 | "nacl-gdb", // FLAGS:RECORD_UMA |
| 249 | IDS_FLAGS_NACL_GDB_NAME, |
| 250 | IDS_FLAGS_NACL_GDB_DESCRIPTION, |
| 251 | kOsWin, |
| 252 | SINGLE_VALUE_TYPE(switches::kNaClGdb) |
| 253 | }, |
| 254 | { |
[email protected] | 4bc5050c | 2010-11-18 17:55:54 | [diff] [blame] | 255 | "extension-apis", // FLAGS:RECORD_UMA |
[email protected] | 11dd68cd5 | 2010-11-12 01:15:32 | [diff] [blame] | 256 | IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_NAME, |
| 257 | IDS_FLAGS_EXPERIMENTAL_EXTENSION_APIS_DESCRIPTION, |
| 258 | kOsAll, |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 259 | SINGLE_VALUE_TYPE(switches::kEnableExperimentalExtensionApis) |
[email protected] | 11dd68cd5 | 2010-11-12 01:15:32 | [diff] [blame] | 260 | }, |
[email protected] | 3627b06d | 2010-11-12 16:36:16 | [diff] [blame] | 261 | { |
[email protected] | f3c06962 | 2012-04-24 07:10:34 | [diff] [blame] | 262 | "browser-actions-for-all", |
| 263 | IDS_FLAGS_BROWSER_ACTIONS_FOR_ALL_NAME, |
| 264 | IDS_FLAGS_BROWSER_ACTIONS_FOR_ALL_DESCRIPTION, |
| 265 | kOsAll, |
| 266 | SINGLE_VALUE_TYPE(switches::kEnableBrowserActionsForAll), |
| 267 | }, |
| 268 | { |
[email protected] | cab18ef | 2012-04-27 07:22:03 | [diff] [blame] | 269 | "action-box", |
| 270 | IDS_FLAGS_ACTION_BOX_NAME, |
| 271 | IDS_FLAGS_ACTION_BOX_DESCRIPTION, |
| 272 | kOsAll, |
| 273 | SINGLE_VALUE_TYPE(switches::kEnableActionBox), |
| 274 | }, |
| 275 | { |
[email protected] | cbe224d | 2011-08-04 22:12:49 | [diff] [blame] | 276 | "apps-new-install-bubble", |
| 277 | IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_NAME, |
| 278 | IDS_FLAGS_APPS_NEW_INSTALL_BUBBLE_DESCRIPTION, |
| 279 | kOsAll, |
| 280 | SINGLE_VALUE_TYPE(switches::kAppsNewInstallBubble) |
| 281 | }, |
| 282 | { |
[email protected] | 80bd24e | 2010-11-30 09:34:38 | [diff] [blame] | 283 | "disable-hyperlink-auditing", |
| 284 | IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_NAME, |
| 285 | IDS_FLAGS_DISABLE_HYPERLINK_AUDITING_DESCRIPTION, |
| 286 | kOsAll, |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 287 | SINGLE_VALUE_TYPE(switches::kNoPings) |
[email protected] | feb28fef | 2010-12-01 10:52:51 | [diff] [blame] | 288 | }, |
| 289 | { |
| 290 | "experimental-location-features", // FLAGS:RECORD_UMA |
| 291 | IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_NAME, |
| 292 | IDS_FLAGS_EXPERIMENTAL_LOCATION_FEATURES_DESCRIPTION, |
| 293 | kOsMac | kOsWin | kOsLinux, // Currently does nothing on CrOS. |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 294 | SINGLE_VALUE_TYPE(switches::kExperimentalLocationFeatures) |
| 295 | }, |
| 296 | { |
[email protected] | 0422796 | 2011-01-20 02:03:09 | [diff] [blame] | 297 | "disable-interactive-form-validation", |
| 298 | IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_NAME, |
| 299 | IDS_FLAGS_DISABLE_INTERACTIVE_FORM_VALIDATION_DESCRIPTION, |
| 300 | kOsAll, |
| 301 | SINGLE_VALUE_TYPE(switches::kDisableInteractiveFormValidation) |
| 302 | }, |
[email protected] | 8df5119 | 2011-01-22 20:05:03 | [diff] [blame] | 303 | { |
[email protected] | 07d490bc | 2011-03-07 17:05:26 | [diff] [blame] | 304 | "focus-existing-tab-on-open", // FLAGS:RECORD_UMA |
| 305 | IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_NAME, |
| 306 | IDS_FLAGS_FOCUS_EXISTING_TAB_ON_OPEN_DESCRIPTION, |
| 307 | kOsAll, |
| 308 | SINGLE_VALUE_TYPE(switches::kFocusExistingTabOnOpen) |
| 309 | }, |
[email protected] | d5dcfb3 | 2011-03-19 00:49:24 | [diff] [blame] | 310 | { |
[email protected] | 5aea186 | 2011-03-23 23:55:39 | [diff] [blame] | 311 | "tab-groups-context-menu", |
| 312 | IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_NAME, |
| 313 | IDS_FLAGS_TAB_GROUPS_CONTEXT_MENU_DESCRIPTION, |
| 314 | kOsWin, |
| 315 | SINGLE_VALUE_TYPE(switches::kEnableTabGroupsContextMenu) |
| 316 | }, |
[email protected] | e9bf9d9 | 2011-03-31 20:57:15 | [diff] [blame] | 317 | { |
[email protected] | f2557bd | 2011-06-01 02:33:07 | [diff] [blame] | 318 | "preload-instant-search", |
| 319 | IDS_FLAGS_PRELOAD_INSTANT_SEARCH_NAME, |
| 320 | IDS_FLAGS_PRELOAD_INSTANT_SEARCH_DESCRIPTION, |
| 321 | kOsAll, |
| 322 | SINGLE_VALUE_TYPE(switches::kPreloadInstantSearch) |
| 323 | }, |
[email protected] | 354e33b | 2011-06-15 00:29:10 | [diff] [blame] | 324 | { |
| 325 | "static-ip-config", |
| 326 | IDS_FLAGS_STATIC_IP_CONFIG_NAME, |
| 327 | IDS_FLAGS_STATIC_IP_CONFIG_DESCRIPTION, |
| 328 | kOsCrOS, |
| 329 | #if defined(OS_CHROMEOS) |
| 330 | // This switch exists only on Chrome OS. |
| 331 | SINGLE_VALUE_TYPE(switches::kEnableStaticIPConfig) |
| 332 | #else |
| 333 | SINGLE_VALUE_TYPE("") |
| 334 | #endif |
| 335 | }, |
[email protected] | 3eb5728c | 2011-06-20 22:32:24 | [diff] [blame] | 336 | { |
| 337 | "show-autofill-type-predictions", |
| 338 | IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME, |
| 339 | IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION, |
| 340 | kOsAll, |
| 341 | SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions) |
| 342 | }, |
[email protected] | bff4d3e | 2011-06-21 23:58:52 | [diff] [blame] | 343 | { |
[email protected] | 9a6180d7d | 2011-09-07 01:40:33 | [diff] [blame] | 344 | "sync-tabs", |
| 345 | IDS_FLAGS_SYNC_TABS_NAME, |
| 346 | IDS_FLAGS_SYNC_TABS_DESCRIPTION, |
[email protected] | 5b0ec7f | 2011-08-11 02:17:17 | [diff] [blame] | 347 | kOsAll, |
[email protected] | 9a6180d7d | 2011-09-07 01:40:33 | [diff] [blame] | 348 | SINGLE_VALUE_TYPE(switches::kEnableSyncTabs) |
[email protected] | 5b0ec7f | 2011-08-11 02:17:17 | [diff] [blame] | 349 | }, |
| 350 | { |
[email protected] | fdf4e25 | 2012-04-27 00:26:55 | [diff] [blame] | 351 | "sync-tab-favicons", |
| 352 | IDS_FLAGS_SYNC_TAB_FAVICONS_NAME, |
| 353 | IDS_FLAGS_SYNC_TAB_FAVICONS_DESCRIPTION, |
| 354 | kOsAll, |
| 355 | SINGLE_VALUE_TYPE(switches::kSyncTabFavicons) |
| 356 | }, |
| 357 | { |
[email protected] | aae9eeb1 | 2011-10-21 21:59:26 | [diff] [blame] | 358 | "sync-app-notifications", |
| 359 | IDS_FLAGS_SYNC_APP_NOTIFICATIONS_NAME, |
| 360 | IDS_FLAGS_SYNC_APP_NOTIFICATIONS_DESCRIPTION, |
| 361 | kOsAll, |
[email protected] | 0b6fba8 | 2011-11-18 01:31:11 | [diff] [blame] | 362 | SINGLE_VALUE_TYPE(switches::kDisableSyncAppNotifications) |
[email protected] | aae9eeb1 | 2011-10-21 21:59:26 | [diff] [blame] | 363 | }, |
| 364 | { |
[email protected] | a22ebd81 | 2011-06-23 00:05:39 | [diff] [blame] | 365 | "enable-smooth-scrolling", // FLAGS:RECORD_UMA |
| 366 | IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_NAME, |
| 367 | IDS_FLAGS_ENABLE_SMOOTH_SCROLLING_DESCRIPTION, |
| 368 | // Can't expose the switch unless the code is compiled in. |
[email protected] | 554b706 | 2011-09-03 03:09:40 | [diff] [blame] | 369 | // On by default for the Mac (different implementation in WebKit). |
[email protected] | 554b706 | 2011-09-03 03:09:40 | [diff] [blame] | 370 | kOsWin | kOsLinux | kOsCrOS, |
[email protected] | a22ebd81 | 2011-06-23 00:05:39 | [diff] [blame] | 371 | SINGLE_VALUE_TYPE(switches::kEnableSmoothScrolling) |
| 372 | }, |
[email protected] | 81a6b0b | 2011-06-24 17:55:40 | [diff] [blame] | 373 | { |
[email protected] | 032d5e6c | 2012-02-17 17:53:55 | [diff] [blame] | 374 | "omnibox-inline-history-quick-provider", |
| 375 | IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_NAME, |
| 376 | IDS_FLAGS_OMNIBOX_INLINE_HISTORY_QUICK_PROVIDER_DESCRIPTION, |
| 377 | kOsAll, |
| 378 | MULTI_VALUE_TYPE(kOmniboxInlineHistoryQuickProviderChoices) |
| 379 | }, |
| 380 | { |
[email protected] | 7e7a2809 | 2011-12-09 22:24:55 | [diff] [blame] | 381 | "enable-panels", |
| 382 | IDS_FLAGS_ENABLE_PANELS_NAME, |
| 383 | IDS_FLAGS_ENABLE_PANELS_DESCRIPTION, |
[email protected] | 73fb1fc5 | 2011-07-09 00:06:54 | [diff] [blame] | 384 | kOsAll, |
[email protected] | 7e7a2809 | 2011-12-09 22:24:55 | [diff] [blame] | 385 | SINGLE_VALUE_TYPE(switches::kEnablePanels) |
[email protected] | 73fb1fc5 | 2011-07-09 00:06:54 | [diff] [blame] | 386 | }, |
[email protected] | e3749d1 | 2011-07-25 22:22:12 | [diff] [blame] | 387 | { |
[email protected] | 9931875b | 2011-11-02 00:19:48 | [diff] [blame] | 388 | "disable-shortcuts-provider", |
| 389 | IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER, |
| 390 | IDS_FLAGS_DISABLE_SHORTCUTS_PROVIDER_DESCRIPTION, |
[email protected] | e3749d1 | 2011-07-25 22:22:12 | [diff] [blame] | 391 | kOsAll, |
[email protected] | 9931875b | 2011-11-02 00:19:48 | [diff] [blame] | 392 | SINGLE_VALUE_TYPE(switches::kDisableShortcutsProvider) |
[email protected] | e3749d1 | 2011-07-25 22:22:12 | [diff] [blame] | 393 | }, |
[email protected] | 80eb426 | 2011-08-03 16:10:41 | [diff] [blame] | 394 | { |
[email protected] | a0e4b07 | 2011-08-17 01:47:07 | [diff] [blame] | 395 | "downloads-new-ui", // FLAGS:RECORD_UMA |
| 396 | IDS_FLAGS_DOWNLOADS_NEW_UI_NAME, |
| 397 | IDS_FLAGS_DOWNLOADS_NEW_UI_DESCRIPTION, |
| 398 | kOsAll, |
| 399 | SINGLE_VALUE_TYPE(switches::kDownloadsNewUI) |
| 400 | }, |
[email protected] | b7bb44f | 2011-09-01 05:17:03 | [diff] [blame] | 401 | { |
| 402 | "enable-autologin", |
| 403 | IDS_FLAGS_ENABLE_AUTOLOGIN_NAME, |
| 404 | IDS_FLAGS_ENABLE_AUTOLOGIN_DESCRIPTION, |
| 405 | kOsMac | kOsWin | kOsLinux, |
| 406 | SINGLE_VALUE_TYPE(switches::kEnableAutologin) |
| 407 | }, |
[email protected] | b984117 | 2011-09-26 23:36:09 | [diff] [blame] | 408 | { |
[email protected] | bbadb11 | 2011-12-12 16:55:28 | [diff] [blame] | 409 | "enable-http-pipelining", |
| 410 | IDS_FLAGS_ENABLE_HTTP_PIPELINING_NAME, |
| 411 | IDS_FLAGS_ENABLE_HTTP_PIPELINING_DESCRIPTION, |
| 412 | kOsAll, |
| 413 | SINGLE_VALUE_TYPE(switches::kEnableHttpPipelining) |
| 414 | }, |
[email protected] | d411c01d | 2011-10-18 16:00:27 | [diff] [blame] | 415 | { |
[email protected] | 3231b61 | 2012-03-23 05:57:54 | [diff] [blame] | 416 | "enable-spdy3", |
| 417 | IDS_FLAGS_ENABLE_SPDY3_NAME, |
| 418 | IDS_FLAGS_ENABLE_SPDY3_DESCRIPTION, |
| 419 | kOsAll, |
| 420 | SINGLE_VALUE_TYPE(switches::kEnableSpdy3) |
| 421 | }, |
| 422 | { |
[email protected] | 27b3fe9 | 2012-03-21 05:35:06 | [diff] [blame] | 423 | "enable-async-dns", |
| 424 | IDS_FLAGS_ENABLE_ASYNC_DNS_NAME, |
| 425 | IDS_FLAGS_ENABLE_ASYNC_DNS_DESCRIPTION, |
[email protected] | ec9d053 | 2012-03-21 05:55:32 | [diff] [blame] | 426 | kOsWin | kOsMac | kOsLinux | kOsCrOS, |
[email protected] | 27b3fe9 | 2012-03-21 05:35:06 | [diff] [blame] | 427 | SINGLE_VALUE_TYPE(switches::kEnableAsyncDns) |
| 428 | }, |
| 429 | { |
[email protected] | f5da41d | 2011-10-08 17:40:07 | [diff] [blame] | 430 | "enable-video-track", |
| 431 | IDS_FLAGS_ENABLE_VIDEO_TRACK_NAME, |
| 432 | IDS_FLAGS_ENABLE_VIDEO_TRACK_DESCRIPTION, |
| 433 | kOsAll, |
| 434 | SINGLE_VALUE_TYPE(switches::kEnableVideoTrack) |
| 435 | }, |
[email protected] | 08b8336 | 2011-10-19 05:23:17 | [diff] [blame] | 436 | { |
[email protected] | 6aa03b3 | 2011-10-27 21:44:44 | [diff] [blame] | 437 | "enable-media-source", |
| 438 | IDS_FLAGS_ENABLE_MEDIA_SOURCE_NAME, |
| 439 | IDS_FLAGS_ENABLE_MEDIA_SOURCE_DESCRIPTION, |
[email protected] | ec9d053 | 2012-03-21 05:55:32 | [diff] [blame] | 440 | kOsAll, |
[email protected] | 6aa03b3 | 2011-10-27 21:44:44 | [diff] [blame] | 441 | SINGLE_VALUE_TYPE(switches::kEnableMediaSource) |
| 442 | }, |
[email protected] | e4e68dbb | 2011-11-18 01:50:22 | [diff] [blame] | 443 | { |
[email protected] | 9f5b782 | 2012-04-18 23:39:03 | [diff] [blame] | 444 | "enable-encrypted-media", |
| 445 | IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_NAME, |
| 446 | IDS_FLAGS_ENABLE_ENCRYPTED_MEDIA_DESCRIPTION, |
| 447 | kOsAll, |
| 448 | SINGLE_VALUE_TYPE(switches::kEnableEncryptedMedia) |
| 449 | }, |
| 450 | { |
[email protected] | e4e68dbb | 2011-11-18 01:50:22 | [diff] [blame] | 451 | "enable-pointer-lock", |
| 452 | IDS_FLAGS_ENABLE_POINTER_LOCK_NAME, |
| 453 | IDS_FLAGS_ENABLE_POINTER_LOCK_DESCRIPTION, |
| 454 | kOsAll, |
| 455 | SINGLE_VALUE_TYPE(switches::kEnablePointerLock) |
| 456 | }, |
[email protected] | dc04be7c | 2012-03-15 23:57:49 | [diff] [blame] | 457 | #if defined(USE_ASH) |
[email protected] | 8cc10df | 2011-11-03 23:57:50 | [diff] [blame] | 458 | { |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 459 | "aura-google-dialog-frames", |
| 460 | IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_NAME, |
| 461 | IDS_FLAGS_AURA_GOOGLE_DIALOG_FRAMES_DESCRIPTION, |
| 462 | kOsWin | kOsLinux | kOsCrOS, |
| 463 | SINGLE_VALUE_TYPE(ash::switches::kAuraGoogleDialogFrames) |
| 464 | }, |
[email protected] | dc04be7c | 2012-03-15 23:57:49 | [diff] [blame] | 465 | #endif |
| 466 | #if defined(USE_AURA) |
[email protected] | 308aaa3 | 2012-03-12 13:14:50 | [diff] [blame] | 467 | { |
| 468 | "aura-disable-hold-mouse-moves", |
| 469 | IDS_FLAGS_AURA_DISABLE_HOLD_MOUSE_MOVES_NAME, |
| 470 | IDS_FLAGS_AURA_DISABLE_HOLD_MOUSE_MOVES_DESCRIPTION, |
| 471 | kOsWin | kOsLinux | kOsCrOS, |
| 472 | SINGLE_VALUE_TYPE(switches::kAuraDisableHoldMouseMoves) |
| 473 | }, |
[email protected] | eaae8b46 | 2012-01-20 22:20:39 | [diff] [blame] | 474 | #endif // defined(USE_AURA) |
| 475 | { |
| 476 | "enable-gamepad", |
| 477 | IDS_FLAGS_ENABLE_GAMEPAD_NAME, |
| 478 | IDS_FLAGS_ENABLE_GAMEPAD_DESCRIPTION, |
| 479 | kOsAll, |
| 480 | SINGLE_VALUE_TYPE(switches::kEnableGamepad) |
| 481 | }, |
[email protected] | db543d32 | 2011-12-15 20:40:15 | [diff] [blame] | 482 | { |
| 483 | "per-tile-painting", |
| 484 | IDS_FLAGS_PER_TILE_PAINTING_NAME, |
| 485 | IDS_FLAGS_PER_TILE_PAINTING_DESCRIPTION, |
| 486 | #if defined(USE_SKIA) |
[email protected] | a5b1b27 | 2012-01-06 20:44:37 | [diff] [blame] | 487 | kOsMac | kOsLinux | kOsCrOS, |
[email protected] | db543d32 | 2011-12-15 20:40:15 | [diff] [blame] | 488 | #else |
| 489 | 0, |
| 490 | #endif |
| 491 | SINGLE_VALUE_TYPE(switches::kEnablePerTilePainting) |
| 492 | }, |
[email protected] | bf88c03 | 2011-12-22 19:05:47 | [diff] [blame] | 493 | { |
| 494 | "enable-javascript-harmony", |
| 495 | IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_NAME, |
| 496 | IDS_FLAGS_ENABLE_JAVASCRIPT_HARMONY_DESCRIPTION, |
| 497 | kOsAll, |
| 498 | SINGLE_VALUE_TYPE_AND_VALUE(switches::kJavaScriptFlags, "--harmony") |
| 499 | }, |
[email protected] | 7e7f378a | 2012-01-05 14:35:37 | [diff] [blame] | 500 | { |
[email protected] | 8564617 | 2012-01-09 22:45:54 | [diff] [blame] | 501 | "enable-tab-browser-dragging", |
| 502 | IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_NAME, |
| 503 | IDS_FLAGS_ENABLE_TAB_BROWSER_DRAGGING_DESCRIPTION, |
| 504 | kOsWin, |
| 505 | SINGLE_VALUE_TYPE(switches::kTabBrowserDragging) |
| 506 | }, |
| 507 | { |
[email protected] | 068b7b5 | 2012-02-27 12:41:44 | [diff] [blame] | 508 | "disable-restore-session-state", |
| 509 | IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_NAME, |
| 510 | IDS_FLAGS_DISABLE_RESTORE_SESSION_STATE_DESCRIPTION, |
[email protected] | 7e7f378a | 2012-01-05 14:35:37 | [diff] [blame] | 511 | kOsAll, |
[email protected] | 068b7b5 | 2012-02-27 12:41:44 | [diff] [blame] | 512 | SINGLE_VALUE_TYPE(switches::kDisableRestoreSessionState) |
[email protected] | 7e7f378a | 2012-01-05 14:35:37 | [diff] [blame] | 513 | }, |
[email protected] | 88864db | 2012-01-18 20:56:35 | [diff] [blame] | 514 | { |
| 515 | "disable-software-rasterizer", |
| 516 | IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_NAME, |
| 517 | IDS_FLAGS_DISABLE_SOFTWARE_RASTERIZER_DESCRIPTION, |
| 518 | #if defined(ENABLE_SWIFTSHADER) |
| 519 | kOsAll, |
| 520 | #else |
| 521 | 0, |
| 522 | #endif |
| 523 | SINGLE_VALUE_TYPE(switches::kDisableSoftwareRasterizer) |
| 524 | }, |
[email protected] | 15a5d72 | 2012-01-23 09:11:14 | [diff] [blame] | 525 | { |
| 526 | "enable-media-stream", |
| 527 | IDS_FLAGS_MEDIA_STREAM_NAME, |
| 528 | IDS_FLAGS_MEDIA_STREAM_DESCRIPTION, |
[email protected] | fa82b677 | 2012-02-20 13:19:05 | [diff] [blame] | 529 | kOsAll, |
[email protected] | 15a5d72 | 2012-01-23 09:11:14 | [diff] [blame] | 530 | SINGLE_VALUE_TYPE(switches::kEnableMediaStream) |
| 531 | }, |
[email protected] | f5ec724 | 2012-01-27 07:15:15 | [diff] [blame] | 532 | { |
[email protected] | d2edc670 | 2012-01-30 09:13:16 | [diff] [blame] | 533 | "enable-shadow-dom", |
| 534 | IDS_FLAGS_SHADOW_DOM_NAME, |
| 535 | IDS_FLAGS_SHADOW_DOM_DESCRIPTION, |
| 536 | kOsAll, |
| 537 | SINGLE_VALUE_TYPE(switches::kEnableShadowDOM) |
| 538 | }, |
[email protected] | 9860c68b | 2012-02-02 01:58:09 | [diff] [blame] | 539 | { |
[email protected] | 4961218f | 2012-02-23 10:11:07 | [diff] [blame] | 540 | "enable-style-scoped", |
| 541 | IDS_FLAGS_STYLE_SCOPED_NAME, |
| 542 | IDS_FLAGS_STYLE_SCOPED_DESCRIPTION, |
| 543 | kOsAll, |
| 544 | SINGLE_VALUE_TYPE(switches::kEnableStyleScoped) |
| 545 | }, |
| 546 | { |
[email protected] | ca7a3d79 | 2012-03-02 15:55:49 | [diff] [blame] | 547 | "enable-css-regions", |
| 548 | IDS_FLAGS_CSS_REGIONS_NAME, |
| 549 | IDS_FLAGS_CSS_REGIONS_DESCRIPTION, |
| 550 | kOsAll, |
| 551 | SINGLE_VALUE_TYPE(switches::kEnableCssRegions) |
| 552 | }, |
| 553 | { |
[email protected] | 8bed69d | 2012-02-02 06:46:00 | [diff] [blame] | 554 | "ntp-app-install-hint", |
| 555 | IDS_FLAGS_APP_INSTALL_HINT_NAME, |
| 556 | IDS_FLAGS_APP_INSTALL_HINT_DESCRIPTION, |
| 557 | kOsAll, |
| 558 | SINGLE_VALUE_TYPE(switches::kNtpAppInstallHint) |
| 559 | }, |
| 560 | { |
[email protected] | 9860c68b | 2012-02-02 01:58:09 | [diff] [blame] | 561 | "enable-extension-activity-ui", |
| 562 | IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_NAME, |
| 563 | IDS_FLAGS_ENABLE_EXTENSION_ACTIVITY_UI_DESCRIPTION, |
| 564 | kOsAll, |
| 565 | SINGLE_VALUE_TYPE(switches::kEnableExtensionActivityUI) |
[email protected] | 8bed69d | 2012-02-02 06:46:00 | [diff] [blame] | 566 | }, |
[email protected] | 54ae4e9 | 2012-02-16 15:19:05 | [diff] [blame] | 567 | { |
| 568 | "webui-task-manager", |
| 569 | IDS_FLAGS_WEBUI_TASK_MANAGER_NAME, |
| 570 | IDS_FLAGS_WEBUI_TASK_MANAGER_DESCRIPTION, |
| 571 | kOsAll, |
| 572 | SINGLE_VALUE_TYPE(switches::kWebUITaskManager) |
| 573 | }, |
[email protected] | 156f96633 | 2012-02-29 00:03:16 | [diff] [blame] | 574 | { |
[email protected] | 3e8befc | 2012-03-13 01:17:03 | [diff] [blame] | 575 | "disable-ntp-other-sessions-menu", |
[email protected] | 156f96633 | 2012-02-29 00:03:16 | [diff] [blame] | 576 | IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_NAME, |
| 577 | IDS_FLAGS_NTP_OTHER_SESSIONS_MENU_DESCRIPTION, |
| 578 | kOsAll, |
[email protected] | 3e8befc | 2012-03-13 01:17:03 | [diff] [blame] | 579 | SINGLE_VALUE_TYPE(switches::kDisableNTPOtherSessionsMenu) |
[email protected] | 156f96633 | 2012-02-29 00:03:16 | [diff] [blame] | 580 | }, |
[email protected] | dc04be7c | 2012-03-15 23:57:49 | [diff] [blame] | 581 | #if defined(USE_ASH) |
[email protected] | 31cf1c5 | 2012-02-29 20:55:01 | [diff] [blame] | 582 | { |
[email protected] | 3cd198a2 | 2012-03-12 20:38:01 | [diff] [blame] | 583 | "enable-ash-oak", |
| 584 | IDS_FLAGS_ENABLE_ASH_OAK_NAME, |
| 585 | IDS_FLAGS_ENABLE_ASH_OAK_DESCRIPTION, |
| 586 | kOsAll, |
| 587 | SINGLE_VALUE_TYPE(ash::switches::kAshEnableOak), |
| 588 | }, |
[email protected] | 31cf1c5 | 2012-02-29 20:55:01 | [diff] [blame] | 589 | #endif |
[email protected] | 184ec59 | 2012-03-01 11:54:28 | [diff] [blame] | 590 | { |
| 591 | "enable-devtools-experiments", |
| 592 | IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_NAME, |
| 593 | IDS_FLAGS_ENABLE_DEVTOOLS_EXPERIMENTS_DESCRIPTION, |
| 594 | kOsAll, |
| 595 | SINGLE_VALUE_TYPE(switches::kEnableDevToolsExperiments) |
| 596 | }, |
[email protected] | 76d1854e | 2012-03-02 23:57:44 | [diff] [blame] | 597 | { |
| 598 | "enable-suggestions-ntp", |
| 599 | IDS_FLAGS_NTP_SUGGESTIONS_PAGE_NAME, |
| 600 | IDS_FLAGS_NTP_SUGGESTIONS_PAGE_DESCRIPTION, |
| 601 | kOsAll, |
| 602 | SINGLE_VALUE_TYPE(switches::kEnableSuggestionsTabPage) |
| 603 | }, |
[email protected] | a78ef9e | 2012-03-21 02:49:55 | [diff] [blame] | 604 | { |
[email protected] | 0b777be2 | 2012-04-03 04:42:24 | [diff] [blame] | 605 | "disable-chrome-to-mobile", // FLAGS:RECORD_UMA |
| 606 | IDS_FLAGS_DISABLE_CHROME_TO_MOBILE_NAME, |
| 607 | IDS_FLAGS_DISABLE_CHROME_TO_MOBILE_DESCRIPTION, |
[email protected] | a78ef9e | 2012-03-21 02:49:55 | [diff] [blame] | 608 | kOsAll, |
[email protected] | 0b777be2 | 2012-04-03 04:42:24 | [diff] [blame] | 609 | SINGLE_VALUE_TYPE(switches::kDisableChromeToMobile) |
[email protected] | a78ef9e | 2012-03-21 02:49:55 | [diff] [blame] | 610 | }, |
[email protected] | a3d5425 | 2012-04-05 20:04:13 | [diff] [blame] | 611 | #if defined(GOOGLE_CHROME_BUILD) |
| 612 | { |
| 613 | "enable-asynchronous-spellchecking", |
| 614 | IDS_FLAGS_ENABLE_ASYNCHRONOUS_SPELLCHECKING, |
| 615 | IDS_FLAGS_ENABLE_ASYNCHRONOUS_SPELLCHECKING_DESCRIPTION, |
| 616 | kOsAll, |
| 617 | SINGLE_VALUE_TYPE(switches::kEnableAsynchronousSpellChecking) |
| 618 | }, |
| 619 | #endif |
[email protected] | c9c73ad4 | 2012-04-18 03:35:59 | [diff] [blame] | 620 | { |
| 621 | "touch-optimized-ui", |
| 622 | IDS_TOUCH_OPTIMIZED_UI_NAME, |
| 623 | IDS_TOUCH_OPTIMIZED_UI_DESCRIPTION, |
| 624 | kOsAll, |
| 625 | SINGLE_VALUE_TYPE(switches::kTouchOptimizedUI) |
| 626 | }, |
[email protected] | 8a6aaa7 | 2012-04-20 20:53:58 | [diff] [blame] | 627 | { |
| 628 | "enable-touch-events", |
| 629 | IDS_ENABLE_TOUCH_EVENTS_NAME, |
| 630 | IDS_ENABLE_TOUCH_EVENTS_DESCRIPTION, |
| 631 | kOsAll, |
| 632 | SINGLE_VALUE_TYPE(switches::kEnableTouchEvents) |
| 633 | }, |
[email protected] | 0b60afa | 2012-04-19 17:36:39 | [diff] [blame] | 634 | #if defined(OS_CHROMEOS) |
| 635 | { |
| 636 | "no-discard-tabs", |
| 637 | IDS_FLAGS_NO_DISCARD_TABS_NAME, |
| 638 | IDS_FLAGS_NO_DISCARD_TABS_DESCRIPTION, |
| 639 | kOsCrOS, |
| 640 | SINGLE_VALUE_TYPE(switches::kNoDiscardTabs) |
| 641 | }, |
| 642 | #endif |
[email protected] | 79be6d3 | 2012-04-24 20:47:44 | [diff] [blame] | 643 | { |
[email protected] | f92fce5f | 2012-04-24 21:05:16 | [diff] [blame] | 644 | "enable-sync-signin", |
[email protected] | 79be6d3 | 2012-04-24 20:47:44 | [diff] [blame] | 645 | IDS_ENABLE_SYNC_SIGNIN_NAME, |
| 646 | IDS_ENABLE_SYNC_SIGNIN_DESCRIPTION, |
| 647 | kOsAll, |
| 648 | SINGLE_VALUE_TYPE(switches::kEnableSyncSignin) |
| 649 | }, |
[email protected] | 6d947a60 | 2012-04-24 23:12:11 | [diff] [blame] | 650 | { |
| 651 | "enable-platform-apps", |
| 652 | IDS_FLAGS_ENABLE_PLATFORM_APPS_NAME, |
| 653 | IDS_FLAGS_ENABLE_PLATFORM_APPS_DESCRIPTION, |
| 654 | kOsAll, |
| 655 | SINGLE_VALUE_TYPE(switches::kEnablePlatformApps) |
[email protected] | 9a5940d | 2012-04-27 19:16:23 | [diff] [blame] | 656 | }, |
| 657 | { |
| 658 | "allow-nacl-socket-api", |
| 659 | IDS_FLAGS_ALLOW_NACL_SOCKET_API_NAME, |
| 660 | IDS_FLAGS_ALLOW_NACL_SOCKET_API_DESCRIPTION, |
| 661 | kOsAll, |
| 662 | SINGLE_VALUE_TYPE_AND_VALUE(switches::kAllowNaClSocketAPI, "*") |
| 663 | }, |
[email protected] | 8533373 | 2012-05-01 19:02:24 | [diff] [blame] | 664 | { |
[email protected] | 60673ad7 | 2012-05-02 06:16:33 | [diff] [blame^] | 665 | "stacked-tab-strip", |
| 666 | IDS_FLAGS_STACKED_TAB_STRIP_NAME, |
| 667 | IDS_FLAGS_STACKED_TAB_STRIP_DESCRIPTION, |
| 668 | kOsWin, |
| 669 | SINGLE_VALUE_TYPE(switches::kEnableStackedTabStrip) |
| 670 | }, |
| 671 | { |
[email protected] | 8533373 | 2012-05-01 19:02:24 | [diff] [blame] | 672 | "default-device-scale-factor", |
| 673 | IDS_FLAGS_FORCE_HIGH_DPI_NAME, |
| 674 | IDS_FLAGS_FORCE_HIGH_DPI_DESCRIPTION, |
| 675 | kOsCrOS, |
| 676 | SINGLE_VALUE_TYPE_AND_VALUE(switches::kDefaultDeviceScaleFactor, "2") |
| 677 | }, |
[email protected] | 190349fd | 2012-05-02 00:10:47 | [diff] [blame] | 678 | #if defined(OS_CHROMEOS) |
| 679 | { |
| 680 | "allow-touchpad-three-finger-click", |
| 681 | IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_NAME, |
| 682 | IDS_FLAGS_ALLOW_TOUCHPAD_THREE_FINGER_CLICK_DESCRIPTION, |
| 683 | kOsCrOS, |
| 684 | SINGLE_VALUE_TYPE(switches::kEnableTouchpadThreeFingerClick) |
| 685 | }, |
| 686 | #endif |
[email protected] | a0e4b07 | 2011-08-17 01:47:07 | [diff] [blame] | 687 | }; |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 688 | |
[email protected] | a314ee5a | 2010-10-26 21:23:28 | [diff] [blame] | 689 | const Experiment* experiments = kExperiments; |
| 690 | size_t num_experiments = arraysize(kExperiments); |
| 691 | |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 692 | // Stores and encapsulates the little state that about:flags has. |
| 693 | class FlagsState { |
| 694 | public: |
| 695 | FlagsState() : needs_restart_(false) {} |
| 696 | void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line); |
| 697 | bool IsRestartNeededToCommitChanges(); |
| 698 | void SetExperimentEnabled( |
[email protected] | a314ee5a | 2010-10-26 21:23:28 | [diff] [blame] | 699 | PrefService* prefs, const std::string& internal_name, bool enable); |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 700 | void RemoveFlagsSwitches( |
| 701 | std::map<std::string, CommandLine::StringType>* switch_list); |
| 702 | void reset(); |
| 703 | |
| 704 | // Returns the singleton instance of this class |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 705 | static FlagsState* GetInstance() { |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 706 | return Singleton<FlagsState>::get(); |
| 707 | } |
| 708 | |
| 709 | private: |
| 710 | bool needs_restart_; |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 711 | std::map<std::string, std::string> flags_switches_; |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 712 | |
| 713 | DISALLOW_COPY_AND_ASSIGN(FlagsState); |
| 714 | }; |
| 715 | |
[email protected] | c7b7800a | 2010-10-07 18:51:35 | [diff] [blame] | 716 | // Extracts the list of enabled lab experiments from preferences and stores them |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 717 | // in a set. |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 718 | void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) { |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 719 | const ListValue* enabled_experiments = prefs->GetList( |
| 720 | prefs::kEnabledLabsExperiments); |
| 721 | if (!enabled_experiments) |
| 722 | return; |
| 723 | |
| 724 | for (ListValue::const_iterator it = enabled_experiments->begin(); |
| 725 | it != enabled_experiments->end(); |
| 726 | ++it) { |
| 727 | std::string experiment_name; |
| 728 | if (!(*it)->GetAsString(&experiment_name)) { |
| 729 | LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments; |
| 730 | continue; |
| 731 | } |
| 732 | result->insert(experiment_name); |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | // Takes a set of enabled lab experiments |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 737 | void SetEnabledFlags( |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 738 | PrefService* prefs, const std::set<std::string>& enabled_experiments) { |
[email protected] | 1bc7842 | 2011-03-31 08:41:38 | [diff] [blame] | 739 | ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments); |
| 740 | ListValue* experiments_list = update.Get(); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 741 | |
| 742 | experiments_list->Clear(); |
| 743 | for (std::set<std::string>::const_iterator it = enabled_experiments.begin(); |
| 744 | it != enabled_experiments.end(); |
| 745 | ++it) { |
| 746 | experiments_list->Append(new StringValue(*it)); |
| 747 | } |
| 748 | } |
| 749 | |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 750 | // Returns the name used in prefs for the choice at the specified index. |
| 751 | std::string NameForChoice(const Experiment& e, int index) { |
[email protected] | 2ce9c8975 | 2011-02-25 18:24:34 | [diff] [blame] | 752 | DCHECK_EQ(Experiment::MULTI_VALUE, e.type); |
| 753 | DCHECK_LT(index, e.num_choices); |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 754 | return std::string(e.internal_name) + about_flags::testing::kMultiSeparator + |
| 755 | base::IntToString(index); |
| 756 | } |
| 757 | |
| 758 | // Adds the internal names for the specified experiment to |names|. |
| 759 | void AddInternalName(const Experiment& e, std::set<std::string>* names) { |
| 760 | if (e.type == Experiment::SINGLE_VALUE) { |
| 761 | names->insert(e.internal_name); |
| 762 | } else { |
[email protected] | 2ce9c8975 | 2011-02-25 18:24:34 | [diff] [blame] | 763 | DCHECK_EQ(Experiment::MULTI_VALUE, e.type); |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 764 | for (int i = 0; i < e.num_choices; ++i) |
| 765 | names->insert(NameForChoice(e, i)); |
| 766 | } |
| 767 | } |
| 768 | |
[email protected] | 28e35af | 2011-02-09 12:56:22 | [diff] [blame] | 769 | // Confirms that an experiment is valid, used in a DCHECK in |
| 770 | // SanitizeList below. |
| 771 | bool ValidateExperiment(const Experiment& e) { |
| 772 | switch (e.type) { |
| 773 | case Experiment::SINGLE_VALUE: |
| 774 | DCHECK_EQ(0, e.num_choices); |
| 775 | DCHECK(!e.choices); |
| 776 | break; |
| 777 | case Experiment::MULTI_VALUE: |
| 778 | DCHECK_GT(e.num_choices, 0); |
| 779 | DCHECK(e.choices); |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 780 | DCHECK(e.choices[0].command_line_switch); |
| 781 | DCHECK_EQ('\0', e.choices[0].command_line_switch[0]); |
[email protected] | 28e35af | 2011-02-09 12:56:22 | [diff] [blame] | 782 | break; |
| 783 | default: |
| 784 | NOTREACHED(); |
| 785 | } |
| 786 | return true; |
| 787 | } |
| 788 | |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 789 | // Removes all experiments from prefs::kEnabledLabsExperiments that are |
| 790 | // unknown, to prevent this list to become very long as experiments are added |
| 791 | // and removed. |
| 792 | void SanitizeList(PrefService* prefs) { |
| 793 | std::set<std::string> known_experiments; |
[email protected] | 28e35af | 2011-02-09 12:56:22 | [diff] [blame] | 794 | for (size_t i = 0; i < num_experiments; ++i) { |
| 795 | DCHECK(ValidateExperiment(experiments[i])); |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 796 | AddInternalName(experiments[i], &known_experiments); |
[email protected] | 28e35af | 2011-02-09 12:56:22 | [diff] [blame] | 797 | } |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 798 | |
| 799 | std::set<std::string> enabled_experiments; |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 800 | GetEnabledFlags(prefs, &enabled_experiments); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 801 | |
| 802 | std::set<std::string> new_enabled_experiments; |
| 803 | std::set_intersection( |
| 804 | known_experiments.begin(), known_experiments.end(), |
| 805 | enabled_experiments.begin(), enabled_experiments.end(), |
| 806 | std::inserter(new_enabled_experiments, new_enabled_experiments.begin())); |
| 807 | |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 808 | SetEnabledFlags(prefs, new_enabled_experiments); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 809 | } |
| 810 | |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 811 | void GetSanitizedEnabledFlags( |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 812 | PrefService* prefs, std::set<std::string>* result) { |
| 813 | SanitizeList(prefs); |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 814 | GetEnabledFlags(prefs, result); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 815 | } |
| 816 | |
[email protected] | a314ee5a | 2010-10-26 21:23:28 | [diff] [blame] | 817 | // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't |
| 818 | // enabled on the current platform. |
| 819 | void GetSanitizedEnabledFlagsForCurrentPlatform( |
| 820 | PrefService* prefs, std::set<std::string>* result) { |
| 821 | GetSanitizedEnabledFlags(prefs, result); |
| 822 | |
| 823 | // Filter out any experiments that aren't enabled on the current platform. We |
| 824 | // don't remove these from prefs else syncing to a platform with a different |
| 825 | // set of experiments would be lossy. |
| 826 | std::set<std::string> platform_experiments; |
| 827 | int current_platform = GetCurrentPlatform(); |
| 828 | for (size_t i = 0; i < num_experiments; ++i) { |
| 829 | if (experiments[i].supported_platforms & current_platform) |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 830 | AddInternalName(experiments[i], &platform_experiments); |
[email protected] | a314ee5a | 2010-10-26 21:23:28 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | std::set<std::string> new_enabled_experiments; |
| 834 | std::set_intersection( |
| 835 | platform_experiments.begin(), platform_experiments.end(), |
| 836 | result->begin(), result->end(), |
| 837 | std::inserter(new_enabled_experiments, new_enabled_experiments.begin())); |
| 838 | |
| 839 | result->swap(new_enabled_experiments); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 840 | } |
| 841 | |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 842 | // Returns the Value representing the choice data in the specified experiment. |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 843 | Value* CreateChoiceData(const Experiment& experiment, |
[email protected] | 28e35af | 2011-02-09 12:56:22 | [diff] [blame] | 844 | const std::set<std::string>& enabled_experiments) { |
[email protected] | 2ce9c8975 | 2011-02-25 18:24:34 | [diff] [blame] | 845 | DCHECK_EQ(Experiment::MULTI_VALUE, experiment.type); |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 846 | ListValue* result = new ListValue; |
| 847 | for (int i = 0; i < experiment.num_choices; ++i) { |
| 848 | const Experiment::Choice& choice = experiment.choices[i]; |
| 849 | DictionaryValue* value = new DictionaryValue; |
| 850 | std::string name = NameForChoice(experiment, i); |
| 851 | value->SetString("description", |
| 852 | l10n_util::GetStringUTF16(choice.description_id)); |
| 853 | value->SetString("internal_name", name); |
[email protected] | 28e35af | 2011-02-09 12:56:22 | [diff] [blame] | 854 | value->SetBoolean("selected", enabled_experiments.count(name) > 0); |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 855 | result->Append(value); |
| 856 | } |
| 857 | return result; |
| 858 | } |
| 859 | |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 860 | } // namespace |
| 861 | |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 862 | void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line) { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 863 | FlagsState::GetInstance()->ConvertFlagsToSwitches(prefs, command_line); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 864 | } |
| 865 | |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 866 | ListValue* GetFlagsExperimentsData(PrefService* prefs) { |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 867 | std::set<std::string> enabled_experiments; |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 868 | GetSanitizedEnabledFlags(prefs, &enabled_experiments); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 869 | |
| 870 | int current_platform = GetCurrentPlatform(); |
| 871 | |
| 872 | ListValue* experiments_data = new ListValue(); |
[email protected] | a314ee5a | 2010-10-26 21:23:28 | [diff] [blame] | 873 | for (size_t i = 0; i < num_experiments; ++i) { |
| 874 | const Experiment& experiment = experiments[i]; |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 875 | |
| 876 | DictionaryValue* data = new DictionaryValue(); |
| 877 | data->SetString("internal_name", experiment.internal_name); |
| 878 | data->SetString("name", |
| 879 | l10n_util::GetStringUTF16(experiment.visible_name_id)); |
| 880 | data->SetString("description", |
| 881 | l10n_util::GetStringUTF16( |
| 882 | experiment.visible_description_id)); |
[email protected] | cc3e205 | 2011-12-20 01:01:40 | [diff] [blame] | 883 | bool supported = !!(experiment.supported_platforms & current_platform); |
| 884 | data->SetBoolean("supported", supported); |
| 885 | |
| 886 | ListValue* supported_platforms = new ListValue(); |
| 887 | AddOsStrings(experiment.supported_platforms, supported_platforms); |
| 888 | data->Set("supported_platforms", supported_platforms); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 889 | |
[email protected] | 28e35af | 2011-02-09 12:56:22 | [diff] [blame] | 890 | switch (experiment.type) { |
| 891 | case Experiment::SINGLE_VALUE: |
| 892 | data->SetBoolean( |
| 893 | "enabled", |
| 894 | enabled_experiments.count(experiment.internal_name) > 0); |
| 895 | break; |
| 896 | case Experiment::MULTI_VALUE: |
| 897 | data->Set("choices", CreateChoiceData(experiment, enabled_experiments)); |
| 898 | break; |
| 899 | default: |
| 900 | NOTREACHED(); |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 901 | } |
| 902 | |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 903 | experiments_data->Append(data); |
| 904 | } |
| 905 | return experiments_data; |
| 906 | } |
| 907 | |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 908 | bool IsRestartNeededToCommitChanges() { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 909 | return FlagsState::GetInstance()->IsRestartNeededToCommitChanges(); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | void SetExperimentEnabled( |
[email protected] | c7b7800a | 2010-10-07 18:51:35 | [diff] [blame] | 913 | PrefService* prefs, const std::string& internal_name, bool enable) { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 914 | FlagsState::GetInstance()->SetExperimentEnabled(prefs, internal_name, enable); |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 915 | } |
| 916 | |
| 917 | void RemoveFlagsSwitches( |
| 918 | std::map<std::string, CommandLine::StringType>* switch_list) { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 919 | FlagsState::GetInstance()->RemoveFlagsSwitches(switch_list); |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 920 | } |
| 921 | |
[email protected] | a314ee5a | 2010-10-26 21:23:28 | [diff] [blame] | 922 | int GetCurrentPlatform() { |
| 923 | #if defined(OS_MACOSX) |
| 924 | return kOsMac; |
| 925 | #elif defined(OS_WIN) |
| 926 | return kOsWin; |
| 927 | #elif defined(OS_CHROMEOS) // Needs to be before the OS_LINUX check. |
| 928 | return kOsCrOS; |
[email protected] | c92f4ed | 2011-10-21 19:50:21 | [diff] [blame] | 929 | #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
[email protected] | a314ee5a | 2010-10-26 21:23:28 | [diff] [blame] | 930 | return kOsLinux; |
[email protected] | 9c7453d | 2012-01-21 00:45:40 | [diff] [blame] | 931 | #elif defined(OS_ANDROID) |
| 932 | return kOsAndroid; |
[email protected] | a314ee5a | 2010-10-26 21:23:28 | [diff] [blame] | 933 | #else |
| 934 | #error Unknown platform |
| 935 | #endif |
| 936 | } |
| 937 | |
[email protected] | 4bc5050c | 2010-11-18 17:55:54 | [diff] [blame] | 938 | void RecordUMAStatistics(const PrefService* prefs) { |
| 939 | std::set<std::string> flags; |
| 940 | GetEnabledFlags(prefs, &flags); |
| 941 | for (std::set<std::string>::iterator it = flags.begin(); it != flags.end(); |
| 942 | ++it) { |
| 943 | std::string action("AboutFlags_"); |
| 944 | action += *it; |
[email protected] | 7f6f44c | 2011-12-14 13:23:38 | [diff] [blame] | 945 | content::RecordComputedAction(action); |
[email protected] | 4bc5050c | 2010-11-18 17:55:54 | [diff] [blame] | 946 | } |
| 947 | // Since flag metrics are recorded every startup, add a tick so that the |
| 948 | // stats can be made meaningful. |
| 949 | if (flags.size()) |
[email protected] | 7f6f44c | 2011-12-14 13:23:38 | [diff] [blame] | 950 | content::RecordAction(UserMetricsAction("AboutFlags_StartupTick")); |
| 951 | content::RecordAction(UserMetricsAction("StartupTick")); |
[email protected] | 4bc5050c | 2010-11-18 17:55:54 | [diff] [blame] | 952 | } |
| 953 | |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 954 | ////////////////////////////////////////////////////////////////////////////// |
| 955 | // FlagsState implementation. |
| 956 | |
| 957 | namespace { |
| 958 | |
| 959 | void FlagsState::ConvertFlagsToSwitches( |
| 960 | PrefService* prefs, CommandLine* command_line) { |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 961 | if (command_line->HasSwitch(switches::kNoExperiments)) |
| 962 | return; |
| 963 | |
| 964 | std::set<std::string> enabled_experiments; |
[email protected] | ba816424 | 2010-11-16 21:31:00 | [diff] [blame] | 965 | |
[email protected] | a314ee5a | 2010-10-26 21:23:28 | [diff] [blame] | 966 | GetSanitizedEnabledFlagsForCurrentPlatform(prefs, &enabled_experiments); |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 967 | |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 968 | typedef std::map<std::string, std::pair<std::string, std::string> > |
| 969 | NameToSwitchAndValueMap; |
| 970 | NameToSwitchAndValueMap name_to_switch_map; |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 971 | for (size_t i = 0; i < num_experiments; ++i) { |
| 972 | const Experiment& e = experiments[i]; |
| 973 | if (e.type == Experiment::SINGLE_VALUE) { |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 974 | name_to_switch_map[e.internal_name] = |
| 975 | std::pair<std::string, std::string>(e.command_line_switch, |
| 976 | e.command_line_value); |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 977 | } else { |
| 978 | for (int j = 0; j < e.num_choices; ++j) |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 979 | name_to_switch_map[NameForChoice(e, j)] = |
| 980 | std::pair<std::string, std::string>( |
| 981 | e.choices[j].command_line_switch, |
| 982 | e.choices[j].command_line_value); |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 983 | } |
| 984 | } |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 985 | |
| 986 | command_line->AppendSwitch(switches::kFlagSwitchesBegin); |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 987 | flags_switches_.insert( |
| 988 | std::pair<std::string, std::string>(switches::kFlagSwitchesBegin, |
| 989 | std::string())); |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 990 | for (std::set<std::string>::iterator it = enabled_experiments.begin(); |
| 991 | it != enabled_experiments.end(); |
| 992 | ++it) { |
| 993 | const std::string& experiment_name = *it; |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 994 | NameToSwitchAndValueMap::const_iterator name_to_switch_it = |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 995 | name_to_switch_map.find(experiment_name); |
| 996 | if (name_to_switch_it == name_to_switch_map.end()) { |
| 997 | NOTREACHED(); |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 998 | continue; |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 999 | } |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 1000 | |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 1001 | const std::pair<std::string, std::string>& |
| 1002 | switch_and_value_pair = name_to_switch_it->second; |
| 1003 | |
| 1004 | command_line->AppendSwitchASCII(switch_and_value_pair.first, |
| 1005 | switch_and_value_pair.second); |
| 1006 | flags_switches_[switch_and_value_pair.first] = switch_and_value_pair.second; |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 1007 | } |
| 1008 | command_line->AppendSwitch(switches::kFlagSwitchesEnd); |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 1009 | flags_switches_.insert( |
| 1010 | std::pair<std::string, std::string>(switches::kFlagSwitchesEnd, |
| 1011 | std::string())); |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | bool FlagsState::IsRestartNeededToCommitChanges() { |
| 1015 | return needs_restart_; |
| 1016 | } |
| 1017 | |
| 1018 | void FlagsState::SetExperimentEnabled( |
| 1019 | PrefService* prefs, const std::string& internal_name, bool enable) { |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 1020 | needs_restart_ = true; |
| 1021 | |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 1022 | size_t at_index = internal_name.find(about_flags::testing::kMultiSeparator); |
| 1023 | if (at_index != std::string::npos) { |
| 1024 | DCHECK(enable); |
| 1025 | // We're being asked to enable a multi-choice experiment. Disable the |
| 1026 | // currently selected choice. |
| 1027 | DCHECK_NE(at_index, 0u); |
[email protected] | 28e35af | 2011-02-09 12:56:22 | [diff] [blame] | 1028 | const std::string experiment_name = internal_name.substr(0, at_index); |
| 1029 | SetExperimentEnabled(prefs, experiment_name, false); |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 1030 | |
[email protected] | 28e35af | 2011-02-09 12:56:22 | [diff] [blame] | 1031 | // And enable the new choice, if it is not the default first choice. |
| 1032 | if (internal_name != experiment_name + "@0") { |
| 1033 | std::set<std::string> enabled_experiments; |
| 1034 | GetSanitizedEnabledFlags(prefs, &enabled_experiments); |
| 1035 | enabled_experiments.insert(internal_name); |
| 1036 | SetEnabledFlags(prefs, enabled_experiments); |
| 1037 | } |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 1038 | return; |
| 1039 | } |
| 1040 | |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 1041 | std::set<std::string> enabled_experiments; |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 1042 | GetSanitizedEnabledFlags(prefs, &enabled_experiments); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 1043 | |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 1044 | const Experiment* e = NULL; |
| 1045 | for (size_t i = 0; i < num_experiments; ++i) { |
| 1046 | if (experiments[i].internal_name == internal_name) { |
| 1047 | e = experiments + i; |
| 1048 | break; |
| 1049 | } |
| 1050 | } |
| 1051 | DCHECK(e); |
| 1052 | |
| 1053 | if (e->type == Experiment::SINGLE_VALUE) { |
[email protected] | 8a271368 | 2011-08-19 10:36:59 | [diff] [blame] | 1054 | if (enable) |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 1055 | enabled_experiments.insert(internal_name); |
[email protected] | 8a271368 | 2011-08-19 10:36:59 | [diff] [blame] | 1056 | else |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 1057 | enabled_experiments.erase(internal_name); |
| 1058 | } else { |
| 1059 | if (enable) { |
| 1060 | // Enable the first choice. |
| 1061 | enabled_experiments.insert(NameForChoice(*e, 0)); |
| 1062 | } else { |
| 1063 | // Find the currently enabled choice and disable it. |
| 1064 | for (int i = 0; i < e->num_choices; ++i) { |
| 1065 | std::string choice_name = NameForChoice(*e, i); |
| 1066 | if (enabled_experiments.find(choice_name) != |
| 1067 | enabled_experiments.end()) { |
| 1068 | enabled_experiments.erase(choice_name); |
| 1069 | // Continue on just in case there's a bug and more than one |
| 1070 | // experiment for this choice was enabled. |
| 1071 | } |
| 1072 | } |
| 1073 | } |
| 1074 | } |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 1075 | |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 1076 | SetEnabledFlags(prefs, enabled_experiments); |
[email protected] | ad2a3ded | 2010-08-27 13:19:05 | [diff] [blame] | 1077 | } |
| 1078 | |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 1079 | void FlagsState::RemoveFlagsSwitches( |
| 1080 | std::map<std::string, CommandLine::StringType>* switch_list) { |
[email protected] | a8274453 | 2011-02-11 16:15:53 | [diff] [blame] | 1081 | for (std::map<std::string, std::string>::const_iterator |
| 1082 | it = flags_switches_.begin(); it != flags_switches_.end(); ++it) { |
| 1083 | switch_list->erase(it->first); |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | void FlagsState::reset() { |
| 1088 | needs_restart_ = false; |
| 1089 | flags_switches_.clear(); |
| 1090 | } |
| 1091 | |
[email protected] | 38e4681 | 2011-05-09 20:49:22 | [diff] [blame] | 1092 | } // namespace |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 1093 | |
| 1094 | namespace testing { |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 1095 | |
| 1096 | // WARNING: '@' is also used in the html file. If you update this constant you |
| 1097 | // also need to update the html file. |
| 1098 | const char kMultiSeparator[] = "@"; |
| 1099 | |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 1100 | void ClearState() { |
[email protected] | 8e8bb6d | 2010-12-13 08:18:55 | [diff] [blame] | 1101 | FlagsState::GetInstance()->reset(); |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 1102 | } |
[email protected] | a314ee5a | 2010-10-26 21:23:28 | [diff] [blame] | 1103 | |
| 1104 | void SetExperiments(const Experiment* e, size_t count) { |
| 1105 | if (!e) { |
| 1106 | experiments = kExperiments; |
| 1107 | num_experiments = arraysize(kExperiments); |
| 1108 | } else { |
| 1109 | experiments = e; |
| 1110 | num_experiments = count; |
| 1111 | } |
| 1112 | } |
| 1113 | |
[email protected] | 8a6ff28d | 2010-12-02 16:35:19 | [diff] [blame] | 1114 | const Experiment* GetExperiments(size_t* count) { |
| 1115 | *count = num_experiments; |
| 1116 | return experiments; |
| 1117 | } |
| 1118 | |
[email protected] | e2ddbc9 | 2010-10-15 20:02:07 | [diff] [blame] | 1119 | } // namespace testing |
| 1120 | |
[email protected] | 1a47d7e | 2010-10-15 00:37:24 | [diff] [blame] | 1121 | } // namespace about_flags |