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

Unified Diff: chrome/browser/chromeos/login/screens/user_selection_screen.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: 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/chromeos/login/screens/user_selection_screen.cc
diff --git a/chrome/browser/chromeos/login/screens/user_selection_screen.cc b/chrome/browser/chromeos/login/screens/user_selection_screen.cc
index e96958985d4731076a09d317110efb56aebb8adb..bc79fee481a02c13be36e2e978d7a453394bab9f 100644
--- a/chrome/browser/chromeos/login/screens/user_selection_screen.cc
+++ b/chrome/browser/chromeos/login/screens/user_selection_screen.cc
@@ -4,8 +4,6 @@
#include "chrome/browser/chromeos/login/screens/user_selection_screen.h"
-#include <vector>
-
#include "ash/shell.h"
#include "base/location.h"
#include "base/logging.h"
@@ -70,19 +68,23 @@ void AddPublicSessionDetailsToUserDictionaryEntry(
public_session_recommended_locales ?
public_session_recommended_locales : &kEmptyRecommendedLocales;
- // Set |kKeyInitialLocales| to the list of available locales. This list
- // consists of the recommended locales, followed by all others.
- user_dict->Set(
- kKeyInitialLocales,
- GetUILanguageList(recommended_locales, std::string()).release());
-
- // Set |kKeyInitialLocale| to the initially selected locale. If the list of
- // recommended locales is not empty, select its first entry. Otherwise,
- // select the current UI locale.
- user_dict->SetString(kKeyInitialLocale,
- recommended_locales->empty() ?
- g_browser_process->GetApplicationLocale() :
- recommended_locales->front());
+ // Construct the list of available locales. This list consists of the
+ // recommended locales, followed by all others.
+ scoped_ptr<base::ListValue> available_locales =
+ GetUILanguageList(recommended_locales, std::string());
+
+ // Select the the first recommended locale that is actually available or the
+ // current UI locale if none of them are available.
+ const std::string selected_locale = FindMostRelevantLocale(
+ recommended_locales,
+ *available_locales.get(),
+ g_browser_process->GetApplicationLocale());
+
+ // Set |kKeyInitialLocales| to the list of available locales.
+ user_dict->Set(kKeyInitialLocales, available_locales.release());
+
+ // Set |kKeyInitialLocale| to the initially selected locale.
+ user_dict->SetString(kKeyInitialLocale, selected_locale);
// Set |kKeyInitialMultipleRecommendedLocales| to indicate whether the list
// of recommended locales contains at least two entries. This is used to

Powered by Google App Engine
This is Rietveld 408576698