Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 void AddOsStrings(unsigned bitmask, ListValue* list) { | |
|
Nico
2011/12/17 03:34:27
Needs a very short comment above it describing wha
Tyler Breisacher (Chromium)
2011/12/17 04:20:34
Done. Although writing the comment is making me th
Nico
2011/12/17 05:14:20
It's fine either way I think
| |
| 46 struct { | |
| 47 unsigned bit; | |
| 48 const char str[10]; | |
|
Tyler Breisacher (Chromium)
2011/12/17 03:29:01
This "10" is super ugly. Without it, I get a compi
Nico
2011/12/17 03:34:27
const char* const str
Also, "name" is probably be
Tyler Breisacher (Chromium)
2011/12/17 04:20:34
Done.
| |
| 49 } kBitsToOs[] = { | |
| 50 {kOsMac, "Mac"}, | |
| 51 {kOsWin, "Windows"}, | |
| 52 {kOsLinux, "Linux"}, | |
| 53 {kOsCrOS, "Chrome OS"}, | |
| 54 }; | |
| 55 for (unsigned i = 0; i < ARRAYSIZE_UNSAFE(kBitsToOs); ++i) | |
|
Nico
2011/12/17 03:34:27
does "int" not work?
Tyler Breisacher (Chromium)
2011/12/17 04:20:34
chrome/browser/about_flags.cc:59: error: compariso
| |
| 56 if (bitmask & kBitsToOs[i].bit) | |
| 57 list->Append(new StringValue(kBitsToOs[i].str)); | |
| 58 } | |
| 59 | |
| 45 // Names for former Chrome OS Labs experiments, shared with prefs migration | 60 // Names for former Chrome OS Labs experiments, shared with prefs migration |
| 46 // code. | 61 // code. |
| 47 const char kMediaPlayerExperimentName[] = "media-player"; | 62 const char kMediaPlayerExperimentName[] = "media-player"; |
| 48 const char kAdvancedFileSystemExperimentName[] = "advanced-file-system"; | 63 const char kAdvancedFileSystemExperimentName[] = "advanced-file-system"; |
| 49 const char kVerticalTabsExperimentName[] = "vertical-tabs"; | 64 const char kVerticalTabsExperimentName[] = "vertical-tabs"; |
| 50 | 65 |
| 51 const Experiment::Choice kPrerenderFromOmniboxChoices[] = { | 66 const Experiment::Choice kPrerenderFromOmniboxChoices[] = { |
| 52 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_AUTOMATIC, "", "" }, | 67 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_AUTOMATIC, "", "" }, |
| 53 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_ENABLED, switches::kPrerenderFromOmnibox, | 68 { IDS_FLAGS_PRERENDER_FROM_OMNIBOX_ENABLED, switches::kPrerenderFromOmnibox, |
| 54 switches::kPrerenderFromOmniboxSwitchValueEnabled }, | 69 switches::kPrerenderFromOmniboxSwitchValueEnabled }, |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 624 | 639 |
| 625 ListValue* GetFlagsExperimentsData(PrefService* prefs) { | 640 ListValue* GetFlagsExperimentsData(PrefService* prefs) { |
| 626 std::set<std::string> enabled_experiments; | 641 std::set<std::string> enabled_experiments; |
| 627 GetSanitizedEnabledFlags(prefs, &enabled_experiments); | 642 GetSanitizedEnabledFlags(prefs, &enabled_experiments); |
| 628 | 643 |
| 629 int current_platform = GetCurrentPlatform(); | 644 int current_platform = GetCurrentPlatform(); |
| 630 | 645 |
| 631 ListValue* experiments_data = new ListValue(); | 646 ListValue* experiments_data = new ListValue(); |
| 632 for (size_t i = 0; i < num_experiments; ++i) { | 647 for (size_t i = 0; i < num_experiments; ++i) { |
| 633 const Experiment& experiment = experiments[i]; | 648 const Experiment& experiment = experiments[i]; |
| 634 if (!(experiment.supported_platforms & current_platform)) | |
| 635 continue; | |
| 636 | 649 |
| 637 DictionaryValue* data = new DictionaryValue(); | 650 DictionaryValue* data = new DictionaryValue(); |
| 638 data->SetString("internal_name", experiment.internal_name); | 651 data->SetString("internal_name", experiment.internal_name); |
| 639 data->SetString("name", | 652 data->SetString("name", |
| 640 l10n_util::GetStringUTF16(experiment.visible_name_id)); | 653 l10n_util::GetStringUTF16(experiment.visible_name_id)); |
| 641 data->SetString("description", | 654 data->SetString("description", |
| 642 l10n_util::GetStringUTF16( | 655 l10n_util::GetStringUTF16( |
| 643 experiment.visible_description_id)); | 656 experiment.visible_description_id)); |
| 657 bool supported = experiment.supported_platforms & current_platform; | |
| 658 data->SetBoolean("supported", supported); | |
| 659 | |
| 660 ListValue* supported_platforms = new ListValue(); | |
| 661 AddOsStrings(experiment.supported_platforms, supported_platforms); | |
| 662 data->Set("supported_platforms", supported_platforms); | |
| 644 | 663 |
| 645 switch (experiment.type) { | 664 switch (experiment.type) { |
| 646 case Experiment::SINGLE_VALUE: | 665 case Experiment::SINGLE_VALUE: |
| 647 data->SetBoolean( | 666 data->SetBoolean( |
| 648 "enabled", | 667 "enabled", |
| 649 enabled_experiments.count(experiment.internal_name) > 0); | 668 enabled_experiments.count(experiment.internal_name) > 0); |
| 650 break; | 669 break; |
| 651 case Experiment::MULTI_VALUE: | 670 case Experiment::MULTI_VALUE: |
| 652 data->Set("choices", CreateChoiceData(experiment, enabled_experiments)); | 671 data->Set("choices", CreateChoiceData(experiment, enabled_experiments)); |
| 653 break; | 672 break; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 865 } | 884 } |
| 866 | 885 |
| 867 const Experiment* GetExperiments(size_t* count) { | 886 const Experiment* GetExperiments(size_t* count) { |
| 868 *count = num_experiments; | 887 *count = num_experiments; |
| 869 return experiments; | 888 return experiments; |
| 870 } | 889 } |
| 871 | 890 |
| 872 } // namespace testing | 891 } // namespace testing |
| 873 | 892 |
| 874 } // namespace about_flags | 893 } // namespace about_flags |
| OLD | NEW |