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