Skip to content

Commit

Permalink
14780: Always show full variation names.
Browse files Browse the repository at this point in the history
  • Loading branch information
iefremov committed May 7, 2021
1 parent b513671 commit 2634f12
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chromium_src/components/version_ui/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include_rules = [
"+../../../../components/version_ui",
"+components/version_ui",
]
36 changes: 36 additions & 0 deletions chromium_src/components/version_ui/version_handler_helper.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#define GetVariationsList GetVariationsList_ChromiumImpl
#include "../../../../components/version_ui/version_handler_helper.cc"
#undef GetVariationsList

namespace version_ui {

// Brave always shows full variations names instead of hashes.
std::unique_ptr<base::Value> GetVariationsList() {
std::vector<std::string> variations;
base::FieldTrial::ActiveGroups active_groups;
base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups);

const unsigned char kNonBreakingHyphenUTF8[] = {0xE2, 0x80, 0x91, '\0'};
const std::string kNonBreakingHyphenUTF8String(
reinterpret_cast<const char*>(kNonBreakingHyphenUTF8));
for (const auto& group : active_groups) {
std::string line = group.trial_name + ":" + group.group_name;
base::ReplaceChars(line, "-", kNonBreakingHyphenUTF8String, &line);
variations.push_back(line);
}

std::unique_ptr<base::ListValue> variations_list(new base::ListValue);
for (std::vector<std::string>::const_iterator it = variations.begin();
it != variations.end(); ++it) {
variations_list->AppendString(*it);
}

return std::move(variations_list);
}

} // namespace version_ui

0 comments on commit 2634f12

Please sign in to comment.