OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/l10n_util.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 if (!optgroup_added) { | 160 if (!optgroup_added) { |
161 optgroup_added = true; | 161 optgroup_added = true; |
162 AddOptgroupOtherLayouts(input_methods_list.get()); | 162 AddOptgroupOtherLayouts(input_methods_list.get()); |
163 } | 163 } |
164 input_methods_list->Append(CreateInputMethodsEntry(*us_eng_descriptor, | 164 input_methods_list->Append(CreateInputMethodsEntry(*us_eng_descriptor, |
165 selected)); | 165 selected)); |
166 } | 166 } |
167 return input_methods_list.Pass(); | 167 return input_methods_list.Pass(); |
168 } | 168 } |
169 | 169 |
170 scoped_ptr<base::ListValue> GetKeyboardLayouts(const std::string& locale) { | |
Alexander Alekseev
2014/07/16 19:35:50
We have similar code for the Guest session:
https
bartfab (slow)
2014/07/21 14:49:13
The difference is that the code we have for guest
Alexander Alekseev
2014/07/21 17:06:56
Ah, I see what you are doing. Thank you for explan
Alexander Alekseev
2014/07/21 17:13:41
GetKeyboardLayouts() seems to be too general. We a
bartfab (slow)
2014/07/21 18:20:47
I called it GetKeyboardLayoutsForLocale(). After a
| |
171 input_method::InputMethodUtil* util = | |
172 input_method::InputMethodManager::Get()->GetInputMethodUtil(); | |
173 std::vector<std::string> layouts = util->GetHardwareLoginInputMethodIds(); | |
Alexander Alekseev
2014/07/21 17:06:56
May be GetHardwareInputMethodIds ? (not "Login")
U
bartfab (slow)
2014/07/21 18:20:47
Nice catch. Done.
| |
174 std::vector<std::string> layouts_from_locale; | |
175 util->GetInputMethodIdsFromLanguageCode(locale, | |
176 input_method::kKeyboardLayoutsOnly, | |
177 &layouts_from_locale); | |
178 layouts.insert(layouts.end(), layouts_from_locale.begin(), | |
179 layouts_from_locale.end()); | |
180 | |
181 std::string selected; | |
182 if (!layouts_from_locale.empty()) { | |
183 selected = | |
184 util->GetInputMethodDescriptorFromId(layouts_from_locale[0])->id(); | |
185 } | |
186 | |
187 scoped_ptr<base::ListValue> input_methods_list(new base::ListValue); | |
188 std::set<std::string> input_methods_added; | |
189 for (std::vector<std::string>::const_iterator it = layouts.begin(); | |
190 it != layouts.end(); ++it) { | |
191 const input_method::InputMethodDescriptor* ime = | |
192 util->GetInputMethodDescriptorFromId(*it); | |
193 if (!InsertString(ime->id(), input_methods_added)) | |
194 continue; | |
195 input_methods_list->Append(CreateInputMethodsEntry(*ime, selected)); | |
196 } | |
197 return input_methods_list.Pass(); | |
198 } | |
199 | |
170 } // namespace chromeos | 200 } // namespace chromeos |
OLD | NEW |