Commit 2f6d521e authored by Ce Chen's avatar Ce Chen Committed by Commit Bot

Add a finch flag to force model locale constraint when fetching on

device head suggest model from omaha servier.

This will allow us to experiment with different model later.

Bug: 925072
Change-Id: I53acf02b6a942cea04197d8fc7f12ac40b7ee3e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1807564Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Commit-Queue: Ce Chen <cch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697282}
parent 0c11093c
......@@ -10,6 +10,7 @@
#include <vector>
#include "base/files/file_util.h"
#include "base/metrics/field_trial_params.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "chrome/browser/browser_process.h"
......@@ -31,12 +32,18 @@ const uint8_t kOnDeviceHeadSuggestPublicKeySHA256[32] = {
// letters and removes all hyphens and underscores in the locale string,
// e.g. "en-US" -> "ENUS".
std::string GetNormalizedLocale() {
std::string locale = g_browser_process->GetApplicationLocale();
std::string locale = base::GetFieldTrialParamValueByFeature(
omnibox::kOnDeviceHeadProvider, "ForceModelLocaleConstraint");
if (locale.empty())
locale = g_browser_process->GetApplicationLocale();
for (const auto c : "-_")
locale.erase(std::remove(locale.begin(), locale.end(), c), locale.end());
std::transform(locale.begin(), locale.end(), locale.begin(),
[](char c) -> char { return base::ToUpperASCII(c); });
VLOG(1) << "On Device Head Component will fetch model for locale: " << locale;
return locale;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment