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