Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Side by Side Diff: chrome/browser/about_flags.cc

Issue 8898039: Show all experiments, even those that are unavailable on the current platform (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update wording and colors Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/about_flags.h" 5 #include "chrome/browser/about_flags.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 24 matching lines...) Expand all
35 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0 35 Experiment::SINGLE_VALUE, command_line_switch, switch_value, NULL, 0
36 #define SINGLE_VALUE_TYPE(command_line_switch) \ 36 #define SINGLE_VALUE_TYPE(command_line_switch) \
37 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "") 37 SINGLE_VALUE_TYPE_AND_VALUE(command_line_switch, "")
38 #define MULTI_VALUE_TYPE(choices) \ 38 #define MULTI_VALUE_TYPE(choices) \
39 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices) 39 Experiment::MULTI_VALUE, "", "", choices, arraysize(choices)
40 40
41 namespace { 41 namespace {
42 42
43 const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS; 43 const unsigned kOsAll = kOsMac | kOsWin | kOsLinux | kOsCrOS;
44 44
45 std::map<int, std::string> nameMap;
Nico 2011/12/16 20:25:07 Global non-pods need both static initialization an
46
47 std::map<int, std::string> OSNames() {
48 if (nameMap.empty()) {
49 nameMap[kOsMac] = "Mac";
50 nameMap[kOsWin] = "Windows";
51 nameMap[kOsLinux] = "Linux";
52 nameMap[kOsCrOS] = "Chrome OS";
Nico 2011/12/16 20:25:07 std::map<int, ...> with less than many keys is alm
53 }
54 return nameMap;
55 }
56
45 // Names for former Chrome OS Labs experiments, shared with prefs migration 57 // Names for former Chrome OS Labs experiments, shared with prefs migration
46 // code. 58 // code.
47 const char kMediaPlayerExperimentName[] = "media-player"; 59 const char kMediaPlayerExperimentName[] = "media-player";
48 const char kAdvancedFileSystemExperimentName[] = "advanced-file-system"; 60 const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
49 const char kVerticalTabsExperimentName[] = "vertical-tabs"; 61 const char kVerticalTabsExperimentName[] = "vertical-tabs";
50 62
51 const Experiment::Choice kPrerenderFromOmniboxChoices[] = { 63 const Experiment::Choice kPrerenderFromOmniboxChoices[] = {
52 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_AUTOMATIC, "", "" }, 64 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_AUTOMATIC, "", "" },
53 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_ENABLED, switches::kPrerenderFromOmnibox, 65 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_ENABLED, switches::kPrerenderFromOmnibox,
54 switches::kPrerenderFromOmniboxSwitchValueEnabled }, 66 switches::kPrerenderFromOmniboxSwitchValueEnabled },
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 636
625 ListValue* GetFlagsExperimentsData(PrefService* prefs) { 637 ListValue* GetFlagsExperimentsData(PrefService* prefs) {
626 std::set<std::string> enabled_experiments; 638 std::set<std::string> enabled_experiments;
627 GetSanitizedEnabledFlags(prefs, &enabled_experiments); 639 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
628 640
629 int current_platform = GetCurrentPlatform(); 641 int current_platform = GetCurrentPlatform();
630 642
631 ListValue* experiments_data = new ListValue(); 643 ListValue* experiments_data = new ListValue();
632 for (size_t i = 0; i < num_experiments; ++i) { 644 for (size_t i = 0; i < num_experiments; ++i) {
633 const Experiment& experiment = experiments[i]; 645 const Experiment& experiment = experiments[i];
634 if (!(experiment.supported_platforms & current_platform))
635 continue;
636 646
637 DictionaryValue* data = new DictionaryValue(); 647 DictionaryValue* data = new DictionaryValue();
638 data->SetString("internal_name", experiment.internal_name); 648 data->SetString("internal_name", experiment.internal_name);
639 data->SetString("name", 649 data->SetString("name",
640 l10n_util::GetStringUTF16(experiment.visible_name_id)); 650 l10n_util::GetStringUTF16(experiment.visible_name_id));
641 data->SetString("description", 651 data->SetString("description",
642 l10n_util::GetStringUTF16( 652 l10n_util::GetStringUTF16(
643 experiment.visible_description_id)); 653 experiment.visible_description_id));
654 bool supported = experiment.supported_platforms & current_platform;
655 data->SetBoolean("supported", supported);
656
657 ListValue* supported_platforms = new ListValue();
658 std::map<int, std::string> os_names = OSNames();
659 for (std::map<int, std::string>::const_iterator iter = os_names.begin();
660 iter != os_names.end(); ++iter) {
661 if (experiment.supported_platforms & iter->first) {
662 supported_platforms->Append(new StringValue(iter->second));
663 }
664 }
Nico 2011/12/16 20:25:07 supported_platforms->Append(new StringValue("Mac")
Tyler Breisacher (Chromium) 2011/12/16 21:18:11 Wouldn't that append all four platforms to every s
Nico 2011/12/16 21:38:04 Ah, right. Either write the function you have abov
665 data->Set("supported_platforms", supported_platforms);
644 666
645 switch (experiment.type) { 667 switch (experiment.type) {
646 case Experiment::SINGLE_VALUE: 668 case Experiment::SINGLE_VALUE:
647 data->SetBoolean( 669 data->SetBoolean(
648 "enabled", 670 "enabled",
649 enabled_experiments.count(experiment.internal_name) > 0); 671 enabled_experiments.count(experiment.internal_name) > 0);
650 break; 672 break;
651 case Experiment::MULTI_VALUE: 673 case Experiment::MULTI_VALUE:
652 data->Set("choices", CreateChoiceData(experiment, enabled_experiments)); 674 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
653 break; 675 break;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 } 887 }
866 888
867 const Experiment* GetExperiments(size_t* count) { 889 const Experiment* GetExperiments(size_t* count) {
868 *count = num_experiments; 890 *count = num_experiments;
869 return experiments; 891 return experiments;
870 } 892 }
871 893
872 } // namespace testing 894 } // namespace testing
873 895
874 } // namespace about_flags 896 } // namespace about_flags
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698