Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4119)

Unified Diff: chrome/browser/ui/webui/chromeos/login/l10n_util.cc

Issue 483523005: Default to current UI locale when recommended locales are invalid (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix code that was not actually working. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/chromeos/login/l10n_util.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/l10n_util.cc b/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
index 76ddcfe28a50bde43f74ef4857852d42e460c8c8..a766f90bcf9bea61654c3d21fe6e7863f864d51d 100644
--- a/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
+++ b/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
@@ -370,6 +370,32 @@ scoped_ptr<base::ListValue> GetUILanguageList(
return languages_list.Pass();
}
+std::string FindMostRelevantLocale(
+ const std::vector<std::string>& most_relevant_language_codes,
+ const base::ListValue& available_locales,
+ const std::string& fallback_locale) {
+ for (std::vector<std::string>::const_iterator most_relevant_it =
+ most_relevant_language_codes.begin();
+ most_relevant_it != most_relevant_language_codes.end();
+ ++most_relevant_it) {
+ for (base::ListValue::const_iterator available_it =
+ available_locales.begin();
+ available_it != available_locales.end(); ++available_it) {
+ base::DictionaryValue* dict;
+ std::string available_locale;
+ if (!(*available_it)->GetAsDictionary(&dict) ||
+ !dict->GetString("value", &available_locale)) {
+ NOTREACHED();
+ continue;
+ }
+ if (available_locale == *most_relevant_it)
+ return *most_relevant_it;
+ }
+ }
+
+ return fallback_locale;
+}
+
scoped_ptr<base::ListValue> GetAcceptLanguageList() {
// Collect the language codes from the supported accept-languages.
const std::string app_locale = g_browser_process->GetApplicationLocale();
@@ -464,7 +490,7 @@ void GetKeyboardLayoutsForLocale(
base::PostTaskAndReplyWithResult(
background_task_runner,
FROM_HERE,
- base::Bind(get_application_locale, locale, false /* set_icu_locale*/ ),
+ base::Bind(get_application_locale, locale, false /* set_icu_locale */),
base::Bind(&GetKeyboardLayoutsForResolvedLocale, callback));
}

Powered by Google App Engine
This is Rietveld 408576698