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