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 <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 if (!optgroup_added) { | 397 if (!optgroup_added) { |
398 optgroup_added = true; | 398 optgroup_added = true; |
399 AddOptgroupOtherLayouts(input_methods_list.get()); | 399 AddOptgroupOtherLayouts(input_methods_list.get()); |
400 } | 400 } |
401 input_methods_list->Append(CreateInputMethodsEntry(*us_eng_descriptor, | 401 input_methods_list->Append(CreateInputMethodsEntry(*us_eng_descriptor, |
402 selected)); | 402 selected)); |
403 } | 403 } |
404 return input_methods_list.Pass(); | 404 return input_methods_list.Pass(); |
405 } | 405 } |
406 | 406 |
| 407 scoped_ptr<base::ListValue> GetKeyboardLayoutsForLocale( |
| 408 const std::string& locale) { |
| 409 input_method::InputMethodUtil* util = |
| 410 input_method::InputMethodManager::Get()->GetInputMethodUtil(); |
| 411 std::vector<std::string> layouts = util->GetHardwareInputMethodIds(); |
| 412 std::vector<std::string> layouts_from_locale; |
| 413 util->GetInputMethodIdsFromLanguageCode( |
| 414 l10n_util::GetApplicationLocale(locale), |
| 415 input_method::kKeyboardLayoutsOnly, |
| 416 &layouts_from_locale); |
| 417 layouts.insert(layouts.end(), layouts_from_locale.begin(), |
| 418 layouts_from_locale.end()); |
| 419 |
| 420 std::string selected; |
| 421 if (!layouts_from_locale.empty()) { |
| 422 selected = |
| 423 util->GetInputMethodDescriptorFromId(layouts_from_locale[0])->id(); |
| 424 } |
| 425 |
| 426 scoped_ptr<base::ListValue> input_methods_list(new base::ListValue); |
| 427 std::set<std::string> input_methods_added; |
| 428 for (std::vector<std::string>::const_iterator it = layouts.begin(); |
| 429 it != layouts.end(); ++it) { |
| 430 const input_method::InputMethodDescriptor* ime = |
| 431 util->GetInputMethodDescriptorFromId(*it); |
| 432 if (!InsertString(ime->id(), input_methods_added)) |
| 433 continue; |
| 434 input_methods_list->Append(CreateInputMethodsEntry(*ime, selected)); |
| 435 } |
| 436 return input_methods_list.Pass(); |
| 437 } |
| 438 |
407 } // namespace chromeos | 439 } // namespace chromeos |
OLD | NEW |