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

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: Avoid implicit cast from unsigned to bool 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
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/resources/flags.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Adds a |StringValue| to |list| for each platform where |bitmask| indicates
46 // whether the experiment is available on that platform.
47 void AddOsStrings(unsigned bitmask, ListValue* list) {
48 struct {
49 unsigned bit;
50 const char* const name;
51 } kBitsToOs[] = {
52 {kOsMac, "Mac"},
53 {kOsWin, "Windows"},
54 {kOsLinux, "Linux"},
55 {kOsCrOS, "Chrome OS"},
56 };
57 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i)
58 if (bitmask & kBitsToOs[i].bit)
59 list->Append(new StringValue(kBitsToOs[i].name));
60 }
61
45 // Names for former Chrome OS Labs experiments, shared with prefs migration 62 // Names for former Chrome OS Labs experiments, shared with prefs migration
46 // code. 63 // code.
47 const char kMediaPlayerExperimentName[] = "media-player"; 64 const char kMediaPlayerExperimentName[] = "media-player";
48 const char kAdvancedFileSystemExperimentName[] = "advanced-file-system"; 65 const char kAdvancedFileSystemExperimentName[] = "advanced-file-system";
49 const char kVerticalTabsExperimentName[] = "vertical-tabs"; 66 const char kVerticalTabsExperimentName[] = "vertical-tabs";
50 67
51 const Experiment::Choice kPrerenderFromOmniboxChoices[] = { 68 const Experiment::Choice kPrerenderFromOmniboxChoices[] = {
52 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_AUTOMATIC, "", "" }, 69 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_AUTOMATIC, "", "" },
53 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_ENABLED, switches::kPrerenderFromOmnibox, 70 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_ENABLED, switches::kPrerenderFromOmnibox,
54 switches::kPrerenderFromOmniboxSwitchValueEnabled }, 71 switches::kPrerenderFromOmniboxSwitchValueEnabled },
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 641
625 ListValue* GetFlagsExperimentsData(PrefService* prefs) { 642 ListValue* GetFlagsExperimentsData(PrefService* prefs) {
626 std::set<std::string> enabled_experiments; 643 std::set<std::string> enabled_experiments;
627 GetSanitizedEnabledFlags(prefs, &enabled_experiments); 644 GetSanitizedEnabledFlags(prefs, &enabled_experiments);
628 645
629 int current_platform = GetCurrentPlatform(); 646 int current_platform = GetCurrentPlatform();
630 647
631 ListValue* experiments_data = new ListValue(); 648 ListValue* experiments_data = new ListValue();
632 for (size_t i = 0; i < num_experiments; ++i) { 649 for (size_t i = 0; i < num_experiments; ++i) {
633 const Experiment& experiment = experiments[i]; 650 const Experiment& experiment = experiments[i];
634 if (!(experiment.supported_platforms & current_platform))
635 continue;
636 651
637 DictionaryValue* data = new DictionaryValue(); 652 DictionaryValue* data = new DictionaryValue();
638 data->SetString("internal_name", experiment.internal_name); 653 data->SetString("internal_name", experiment.internal_name);
639 data->SetString("name", 654 data->SetString("name",
640 l10n_util::GetStringUTF16(experiment.visible_name_id)); 655 l10n_util::GetStringUTF16(experiment.visible_name_id));
641 data->SetString("description", 656 data->SetString("description",
642 l10n_util::GetStringUTF16( 657 l10n_util::GetStringUTF16(
643 experiment.visible_description_id)); 658 experiment.visible_description_id));
659 bool supported = !!(experiment.supported_platforms & current_platform);
Tyler Breisacher (Chromium) 2011/12/19 23:23:26 This should fix the compile error on Windows: warn
660 data->SetBoolean("supported", supported);
661
662 ListValue* supported_platforms = new ListValue();
663 AddOsStrings(experiment.supported_platforms, supported_platforms);
664 data->Set("supported_platforms", supported_platforms);
644 665
645 switch (experiment.type) { 666 switch (experiment.type) {
646 case Experiment::SINGLE_VALUE: 667 case Experiment::SINGLE_VALUE:
647 data->SetBoolean( 668 data->SetBoolean(
648 "enabled", 669 "enabled",
649 enabled_experiments.count(experiment.internal_name) > 0); 670 enabled_experiments.count(experiment.internal_name) > 0);
650 break; 671 break;
651 case Experiment::MULTI_VALUE: 672 case Experiment::MULTI_VALUE:
652 data->Set("choices", CreateChoiceData(experiment, enabled_experiments)); 673 data->Set("choices", CreateChoiceData(experiment, enabled_experiments));
653 break; 674 break;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 } 886 }
866 887
867 const Experiment* GetExperiments(size_t* count) { 888 const Experiment* GetExperiments(size_t* count) {
868 *count = num_experiments; 889 *count = num_experiments;
869 return experiments; 890 return experiments;
870 } 891 }
871 892
872 } // namespace testing 893 } // namespace testing
873 894
874 } // namespace about_flags 895 } // namespace about_flags
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/resources/flags.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698