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