OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 private: | 668 private: |
669 bool needs_restart_; | 669 bool needs_restart_; |
670 std::map<std::string, std::string> flags_switches_; | 670 std::map<std::string, std::string> flags_switches_; |
671 | 671 |
672 DISALLOW_COPY_AND_ASSIGN(FlagsState); | 672 DISALLOW_COPY_AND_ASSIGN(FlagsState); |
673 }; | 673 }; |
674 | 674 |
675 // Extracts the list of enabled lab experiments from preferences and stores them | 675 // Extracts the list of enabled lab experiments from preferences and stores them |
676 // in a set. | 676 // in a set. |
677 void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) { | 677 void GetEnabledFlags(const PrefService* prefs, std::set<std::string>* result) { |
678 #if defined(OS_ANDROID) | |
679 NOTIMPLEMENTED() << "Experimental labs aren't supported on Android."; | |
Andrew T Wilson (Slow)
2012/03/27 17:33:16
I think it would be ideal if you could remove abou
Yaron
2012/03/27 19:06:52
Done.
| |
680 #else | |
678 const ListValue* enabled_experiments = prefs->GetList( | 681 const ListValue* enabled_experiments = prefs->GetList( |
679 prefs::kEnabledLabsExperiments); | 682 prefs::kEnabledLabsExperiments); |
680 if (!enabled_experiments) | 683 if (!enabled_experiments) |
681 return; | 684 return; |
682 | 685 |
683 for (ListValue::const_iterator it = enabled_experiments->begin(); | 686 for (ListValue::const_iterator it = enabled_experiments->begin(); |
684 it != enabled_experiments->end(); | 687 it != enabled_experiments->end(); |
685 ++it) { | 688 ++it) { |
686 std::string experiment_name; | 689 std::string experiment_name; |
687 if (!(*it)->GetAsString(&experiment_name)) { | 690 if (!(*it)->GetAsString(&experiment_name)) { |
688 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments; | 691 LOG(WARNING) << "Invalid entry in " << prefs::kEnabledLabsExperiments; |
689 continue; | 692 continue; |
690 } | 693 } |
691 result->insert(experiment_name); | 694 result->insert(experiment_name); |
692 } | 695 } |
696 #endif // #if defined(OS_ANDROID) | |
693 } | 697 } |
694 | 698 |
695 // Takes a set of enabled lab experiments | 699 // Takes a set of enabled lab experiments |
696 void SetEnabledFlags( | 700 void SetEnabledFlags( |
697 PrefService* prefs, const std::set<std::string>& enabled_experiments) { | 701 PrefService* prefs, const std::set<std::string>& enabled_experiments) { |
702 #if defined(OS_ANDROID) | |
703 NOTIMPLEMENTED() << "Experimental labs aren't supported on Android."; | |
704 #else | |
698 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments); | 705 ListPrefUpdate update(prefs, prefs::kEnabledLabsExperiments); |
699 ListValue* experiments_list = update.Get(); | 706 ListValue* experiments_list = update.Get(); |
700 | 707 |
701 experiments_list->Clear(); | 708 experiments_list->Clear(); |
702 for (std::set<std::string>::const_iterator it = enabled_experiments.begin(); | 709 for (std::set<std::string>::const_iterator it = enabled_experiments.begin(); |
703 it != enabled_experiments.end(); | 710 it != enabled_experiments.end(); |
704 ++it) { | 711 ++it) { |
705 experiments_list->Append(new StringValue(*it)); | 712 experiments_list->Append(new StringValue(*it)); |
706 } | 713 } |
714 #endif // #if defined(OS_ANDROID) | |
707 } | 715 } |
708 | 716 |
709 // Returns the name used in prefs for the choice at the specified index. | 717 // Returns the name used in prefs for the choice at the specified index. |
710 std::string NameForChoice(const Experiment& e, int index) { | 718 std::string NameForChoice(const Experiment& e, int index) { |
711 DCHECK_EQ(Experiment::MULTI_VALUE, e.type); | 719 DCHECK_EQ(Experiment::MULTI_VALUE, e.type); |
712 DCHECK_LT(index, e.num_choices); | 720 DCHECK_LT(index, e.num_choices); |
713 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator + | 721 return std::string(e.internal_name) + about_flags::testing::kMultiSeparator + |
714 base::IntToString(index); | 722 base::IntToString(index); |
715 } | 723 } |
716 | 724 |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1071 } | 1079 } |
1072 | 1080 |
1073 const Experiment* GetExperiments(size_t* count) { | 1081 const Experiment* GetExperiments(size_t* count) { |
1074 *count = num_experiments; | 1082 *count = num_experiments; |
1075 return experiments; | 1083 return experiments; |
1076 } | 1084 } |
1077 | 1085 |
1078 } // namespace testing | 1086 } // namespace testing |
1079 | 1087 |
1080 } // namespace about_flags | 1088 } // namespace about_flags |
OLD | NEW |