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

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

Issue 2109063002: ChromeOS: GetKeyboardLayoutsForResolvedLocale() should default to requested locale. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 88c1b6daf873ef7e3511e895456c877251a2bb54..49a7aa84aa29c766d4ed94e545adcc4172df417c 100644
--- a/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
+++ b/chrome/browser/ui/webui/chromeos/login/l10n_util.cc
@@ -282,27 +282,38 @@ std::unique_ptr<base::ListValue> GetLanguageList(
return language_list;
}
+// Note: this method updates |selected_locale| only if it is empty.
+void GetAndMergeKeyboardLayoutsForLocale(input_method::InputMethodUtil* util,
+ const std::string& locale,
+ std::string* selected_locale,
+ std::vector<std::string>* layouts) {
Shu Chen 2016/06/29 13:10:37 Please remove potential duplicates in |layouts|.
Alexander Alekseev 2016/06/29 23:00:46 Duplicates are removed on lines 318-327 below. We
+ std::vector<std::string> layouts_from_locale;
+ util->GetInputMethodIdsFromLanguageCode(
+ locale, input_method::kKeyboardLayoutsOnly, &layouts_from_locale);
+ layouts->insert(layouts->end(), layouts_from_locale.begin(),
+ layouts_from_locale.end());
+ if (selected_locale->empty() && !layouts_from_locale.empty()) {
+ *selected_locale =
+ util->GetInputMethodDescriptorFromId(layouts_from_locale[0])->id();
+ }
+}
+
// Invokes |callback| with a list of keyboard layouts that can be used for
// |resolved_locale|.
void GetKeyboardLayoutsForResolvedLocale(
+ const std::string& requested_locale,
const GetKeyboardLayoutsForLocaleCallback& callback,
const std::string& resolved_locale) {
input_method::InputMethodUtil* util =
input_method::InputMethodManager::Get()->GetInputMethodUtil();
std::vector<std::string> layouts = util->GetHardwareInputMethodIds();
- std::vector<std::string> layouts_from_locale;
- util->GetInputMethodIdsFromLanguageCode(
- resolved_locale,
- input_method::kKeyboardLayoutsOnly,
- &layouts_from_locale);
- layouts.insert(layouts.end(), layouts_from_locale.begin(),
- layouts_from_locale.end());
+ // "Selected" will be set from the fist non-empty list.
std::string selected;
Shu Chen 2016/06/29 13:10:37 |selected| is unused?
Alexander Alekseev 2016/06/29 23:00:46 See line 327 below.
- if (!layouts_from_locale.empty()) {
- selected =
- util->GetInputMethodDescriptorFromId(layouts_from_locale[0])->id();
- }
+ GetAndMergeKeyboardLayoutsForLocale(util, requested_locale, &selected,
+ &layouts);
+ GetAndMergeKeyboardLayoutsForLocale(util, resolved_locale, &selected,
+ &layouts);
std::unique_ptr<base::ListValue> input_methods_list(new base::ListValue);
std::set<std::string> input_methods_added;
@@ -579,10 +590,9 @@ void GetKeyboardLayoutsForLocale(
std::string (*get_application_locale)(const std::string&, bool) =
&l10n_util::GetApplicationLocale;
base::PostTaskAndReplyWithResult(
- background_task_runner.get(),
- FROM_HERE,
+ background_task_runner.get(), FROM_HERE,
base::Bind(get_application_locale, locale, false /* set_icu_locale */),
- base::Bind(&GetKeyboardLayoutsForResolvedLocale, callback));
+ base::Bind(&GetKeyboardLayoutsForResolvedLocale, locale, callback));
}
std::unique_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698