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