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