| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/version_ui/version_handler_helper.h" | 5 #include "components/version_ui/version_handler_helper.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "components/variations/active_field_trials.h" | 12 #include "components/variations/active_field_trials.h" |
| 13 | 13 |
| 14 namespace version_ui { | 14 namespace version_ui { |
| 15 | 15 |
| 16 scoped_ptr<base::Value> GetVariationsList() { | 16 std::vector<std::string> GetVariations() { |
| 17 std::vector<std::string> variations; | 17 std::vector<std::string> variations; |
| 18 #if !defined(NDEBUG) | 18 #if !defined(NDEBUG) |
| 19 base::FieldTrial::ActiveGroups active_groups; | 19 base::FieldTrial::ActiveGroups active_groups; |
| 20 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups); | 20 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups); |
| 21 | 21 |
| 22 const unsigned char kNonBreakingHyphenUTF8[] = {0xE2, 0x80, 0x91, '\0'}; | 22 const unsigned char kNonBreakingHyphenUTF8[] = {0xE2, 0x80, 0x91, '\0'}; |
| 23 const std::string kNonBreakingHyphenUTF8String( | 23 const std::string kNonBreakingHyphenUTF8String( |
| 24 reinterpret_cast<const char*>(kNonBreakingHyphenUTF8)); | 24 reinterpret_cast<const char*>(kNonBreakingHyphenUTF8)); |
| 25 for (const auto& group : active_groups) { | 25 for (const auto& group : active_groups) { |
| 26 std::string line = group.trial_name + ":" + group.group_name; | 26 std::string line = group.trial_name + ":" + group.group_name; |
| 27 base::ReplaceChars(line, "-", kNonBreakingHyphenUTF8String, &line); | 27 base::ReplaceChars(line, "-", kNonBreakingHyphenUTF8String, &line); |
| 28 variations.push_back(line); | 28 variations.push_back(line); |
| 29 } | 29 } |
| 30 #else | 30 #else |
| 31 // In release mode, display the hashes only. | 31 // In release mode, display the hashes only. |
| 32 variations::GetFieldTrialActiveGroupIdsAsStrings(&variations); | 32 variations::GetFieldTrialActiveGroupIdsAsStrings(&variations); |
| 33 #endif | 33 #endif |
| 34 return variations; |
| 35 } |
| 34 | 36 |
| 37 #if defined(OS_IOS) |
| 38 scoped_ptr<base::Value> GetVariationsList() { |
| 39 std::vector<std::string> variations = GetVariations(); |
| 35 scoped_ptr<base::ListValue> variations_list(new base::ListValue); | 40 scoped_ptr<base::ListValue> variations_list(new base::ListValue); |
| 36 for (std::vector<std::string>::const_iterator it = variations.begin(); | 41 for (std::vector<std::string>::const_iterator it = variations.begin(); |
| 37 it != variations.end(); ++it) { | 42 it != variations.end(); ++it) { |
| 38 variations_list->Append(new base::StringValue(*it)); | 43 variations_list->Append(new base::StringValue(*it)); |
| 39 } | 44 } |
| 40 | 45 |
| 41 return variations_list.Pass(); | 46 return variations_list.Pass(); |
| 42 } | 47 } |
| 48 #endif |
| 43 | 49 |
| 44 } // namespace version_ui | 50 } // namespace version_ui |
| OLD | NEW |