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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 return input_method.Pass(); | 52 return input_method.Pass(); |
53 } | 53 } |
54 | 54 |
55 // Returns true if element was inserted. | 55 // Returns true if element was inserted. |
56 bool InsertString(const std::string& str, std::set<std::string>* to) { | 56 bool InsertString(const std::string& str, std::set<std::string>* to) { |
57 const std::pair<std::set<std::string>::iterator, bool> result = | 57 const std::pair<std::set<std::string>::iterator, bool> result = |
58 to->insert(str); | 58 to->insert(str); |
59 return result.second; | 59 return result.second; |
60 } | 60 } |
61 | 61 |
| 62 #if !defined(USE_ATHENA) |
| 63 // TODO(dpolukhin): crbug.com/407579 |
62 void AddOptgroupOtherLayouts(base::ListValue* input_methods_list) { | 64 void AddOptgroupOtherLayouts(base::ListValue* input_methods_list) { |
63 scoped_ptr<base::DictionaryValue> optgroup(new base::DictionaryValue); | 65 scoped_ptr<base::DictionaryValue> optgroup(new base::DictionaryValue); |
64 optgroup->SetString( | 66 optgroup->SetString( |
65 "optionGroupName", | 67 "optionGroupName", |
66 l10n_util::GetStringUTF16(IDS_OOBE_OTHER_KEYBOARD_LAYOUTS)); | 68 l10n_util::GetStringUTF16(IDS_OOBE_OTHER_KEYBOARD_LAYOUTS)); |
67 input_methods_list->Append(optgroup.release()); | 69 input_methods_list->Append(optgroup.release()); |
68 } | 70 } |
| 71 #endif |
69 | 72 |
70 // TODO(zork): Remove this blacklist when fonts are added to Chrome OS. | 73 // TODO(zork): Remove this blacklist when fonts are added to Chrome OS. |
71 // see: crbug.com/240586 | 74 // see: crbug.com/240586 |
72 bool IsBlacklisted(const std::string& language_code) { | 75 bool IsBlacklisted(const std::string& language_code) { |
73 return language_code == "si"; // Sinhala | 76 return language_code == "si"; // Sinhala |
74 } | 77 } |
75 | 78 |
76 // Gets the list of languages with |descriptors| based on |base_language_codes|. | 79 // Gets the list of languages with |descriptors| based on |base_language_codes|. |
77 // The |most_relevant_language_codes| will be first in the list. If | 80 // The |most_relevant_language_codes| will be first in the list. If |
78 // |insert_divider| is true, an entry with its "code" attribute set to | 81 // |insert_divider| is true, an entry with its "code" attribute set to |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 *input_method::InputMethodManager::Get()->GetSupportedInputMethods(), | 408 *input_method::InputMethodManager::Get()->GetSupportedInputMethods(), |
406 accept_language_codes, | 409 accept_language_codes, |
407 StartupCustomizationDocument::GetInstance()->configured_locales(), | 410 StartupCustomizationDocument::GetInstance()->configured_locales(), |
408 false); | 411 false); |
409 } | 412 } |
410 | 413 |
411 scoped_ptr<base::ListValue> GetAndActivateLoginKeyboardLayouts( | 414 scoped_ptr<base::ListValue> GetAndActivateLoginKeyboardLayouts( |
412 const std::string& locale, | 415 const std::string& locale, |
413 const std::string& selected) { | 416 const std::string& selected) { |
414 scoped_ptr<base::ListValue> input_methods_list(new base::ListValue); | 417 scoped_ptr<base::ListValue> input_methods_list(new base::ListValue); |
| 418 #if !defined(USE_ATHENA) |
| 419 // TODO(dpolukhin): crbug.com/407579 |
415 input_method::InputMethodManager* manager = | 420 input_method::InputMethodManager* manager = |
416 input_method::InputMethodManager::Get(); | 421 input_method::InputMethodManager::Get(); |
417 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); | 422 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); |
418 | 423 |
419 const std::vector<std::string>& hardware_login_input_methods = | 424 const std::vector<std::string>& hardware_login_input_methods = |
420 util->GetHardwareLoginInputMethodIds(); | 425 util->GetHardwareLoginInputMethodIds(); |
421 | 426 |
422 manager->GetActiveIMEState()->EnableLoginLayouts( | 427 manager->GetActiveIMEState()->EnableLoginLayouts( |
423 locale, hardware_login_input_methods); | 428 locale, hardware_login_input_methods); |
424 | 429 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 const input_method::InputMethodDescriptor* us_eng_descriptor = | 468 const input_method::InputMethodDescriptor* us_eng_descriptor = |
464 util->GetInputMethodDescriptorFromId(us_keyboard_id); | 469 util->GetInputMethodDescriptorFromId(us_keyboard_id); |
465 DCHECK(us_eng_descriptor); | 470 DCHECK(us_eng_descriptor); |
466 if (!optgroup_added) { | 471 if (!optgroup_added) { |
467 optgroup_added = true; | 472 optgroup_added = true; |
468 AddOptgroupOtherLayouts(input_methods_list.get()); | 473 AddOptgroupOtherLayouts(input_methods_list.get()); |
469 } | 474 } |
470 input_methods_list->Append(CreateInputMethodsEntry(*us_eng_descriptor, | 475 input_methods_list->Append(CreateInputMethodsEntry(*us_eng_descriptor, |
471 selected).release()); | 476 selected).release()); |
472 } | 477 } |
| 478 #endif |
473 return input_methods_list.Pass(); | 479 return input_methods_list.Pass(); |
474 } | 480 } |
475 | 481 |
476 void GetKeyboardLayoutsForLocale( | 482 void GetKeyboardLayoutsForLocale( |
477 const GetKeyboardLayoutsForLocaleCallback& callback, | 483 const GetKeyboardLayoutsForLocaleCallback& callback, |
478 const std::string& locale) { | 484 const std::string& locale) { |
479 base::SequencedWorkerPool* worker_pool = | 485 base::SequencedWorkerPool* worker_pool = |
480 content::BrowserThread::GetBlockingPool(); | 486 content::BrowserThread::GetBlockingPool(); |
481 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 487 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
482 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | 488 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( |
(...skipping 14 matching lines...) Expand all Loading... |
497 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { | 503 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { |
498 const input_method::InputMethodDescriptor current_input_method = | 504 const input_method::InputMethodDescriptor current_input_method = |
499 input_method::InputMethodManager::Get() | 505 input_method::InputMethodManager::Get() |
500 ->GetActiveIMEState() | 506 ->GetActiveIMEState() |
501 ->GetCurrentInputMethod(); | 507 ->GetCurrentInputMethod(); |
502 return CreateInputMethodsEntry(current_input_method, | 508 return CreateInputMethodsEntry(current_input_method, |
503 current_input_method.id()); | 509 current_input_method.id()); |
504 } | 510 } |
505 | 511 |
506 } // namespace chromeos | 512 } // namespace chromeos |
OLD | NEW |