Show all experiments, even those that are unavailable on the current platform
BUG=53560
TEST=Go to about:flags, check that all experiments are shown, with a list of the platforms where each one can run.
Review URL: http://codereview.chromium.org/8898039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115054 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index caf4b10..2f3edba 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -44,6 +44,23 @@
const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS;
+// Adds a |StringValue| to |list| for each platform where |bitmask| indicates
+// whether the experiment is available on that platform.
+void AddOsStrings(unsigned bitmask, ListValue* list) {
+ struct {
+ unsigned bit;
+ const char* const name;
+ } kBitsToOs[] = {
+ {kOsMac, "Mac"},
+ {kOsWin, "Windows"},
+ {kOsLinux, "Linux"},
+ {kOsCrOS, "Chrome OS"},
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i)
+ if (bitmask & kBitsToOs[i].bit)
+ list->Append(new StringValue(kBitsToOs[i].name));
+}
+
// Names for former Chrome OS Labs experiments, shared with prefs migration
// code.
const char kMediaPlayerExperimentName[] = "media-player";
@@ -671,8 +688,6 @@
ListValue* experiments_data = new ListValue();
for (size_t i = 0; i < num_experiments; ++i) {
const Experiment& experiment = experiments[i];
- if (!(experiment.supported_platforms & current_platform))
- continue;
DictionaryValue* data = new DictionaryValue();
data->SetString("internal_name", experiment.internal_name);
@@ -681,6 +696,12 @@
data->SetString("description",
l10n_util::GetStringUTF16(
experiment.visible_description_id));
+ bool supported = !!(experiment.supported_platforms & current_platform);
+ data->SetBoolean("supported", supported);
+
+ ListValue* supported_platforms = new ListValue();
+ AddOsStrings(experiment.supported_platforms, supported_platforms);
+ data->Set("supported_platforms", supported_platforms);
switch (experiment.type) {
case Experiment::SINGLE_VALUE: