OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/version_ui/version_handler_helper.h" | |
6 | |
7 #include <vector> | |
8 | |
9 #include "base/metrics/field_trial.h" | |
10 #include "base/strings/string_util.h" | |
11 #include "base/values.h" | |
12 #include "components/variations/active_field_trials.h" | |
13 | |
14 namespace version_ui { | |
15 | |
16 scoped_ptr<base::Value> GetVariationsList() { | |
17 std::vector<std::string> variations; | |
18 #if !defined(NDEBUG) | |
19 base::FieldTrial::ActiveGroups active_groups; | |
20 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups); | |
21 | |
22 const unsigned char kNonBreakingHyphenUTF8[] = {0xE2, 0x80, 0x91, '\0'}; | |
23 const std::string kNonBreakingHyphenUTF8String( | |
24 reinterpret_cast<const char*>(kNonBreakingHyphenUTF8)); | |
25 for (size_t i = 0; i < active_groups.size(); ++i) { | |
26 std::string line = | |
27 active_groups[i].trial_name + ":" + active_groups[i].group_name; | |
28 base::ReplaceChars(line, "-", kNonBreakingHyphenUTF8String, &line); | |
29 variations.push_back(line); | |
30 } | |
31 #else | |
32 // In release mode, display the hashes only. | |
33 variations::GetFieldTrialActiveGroupIdsAsStrings(&variations); | |
34 #endif | |
35 | |
36 scoped_ptr<base::ListValue> variations_list(new base::ListValue); | |
37 for (std::vector<std::string>::const_iterator it = variations.begin(); | |
38 it != variations.end(); ++it) { | |
Dan Beam
2015/10/26 18:44:51
nit: can we just to for ( : )?
droger
2015/10/27 10:06:49
Done.
| |
39 variations_list->Append(new base::StringValue(*it)); | |
40 } | |
41 | |
42 return variations_list.Pass(); | |
43 } | |
44 | |
45 } // namespace version_ui | |
OLD | NEW |