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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <iterator> | 9 #include <iterator> |
10 #include <map> | 10 #include <map> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 void AddOptgroupOtherLayouts(base::ListValue* input_methods_list) { | 71 void AddOptgroupOtherLayouts(base::ListValue* input_methods_list) { |
72 std::unique_ptr<base::DictionaryValue> optgroup(new base::DictionaryValue); | 72 std::unique_ptr<base::DictionaryValue> optgroup(new base::DictionaryValue); |
73 optgroup->SetString( | 73 optgroup->SetString( |
74 "optionGroupName", | 74 "optionGroupName", |
75 l10n_util::GetStringUTF16(IDS_OOBE_OTHER_KEYBOARD_LAYOUTS)); | 75 l10n_util::GetStringUTF16(IDS_OOBE_OTHER_KEYBOARD_LAYOUTS)); |
76 input_methods_list->Append(std::move(optgroup)); | 76 input_methods_list->Append(std::move(optgroup)); |
77 } | 77 } |
78 | 78 |
79 base::DictionaryValue* CreateLanguageEntry( | 79 std::unique_ptr<base::DictionaryValue> CreateLanguageEntry( |
80 const std::string& language_code, | 80 const std::string& language_code, |
81 const base::string16& language_display_name, | 81 const base::string16& language_display_name, |
82 const base::string16& language_native_display_name) { | 82 const base::string16& language_native_display_name) { |
83 base::string16 display_name = language_display_name; | 83 base::string16 display_name = language_display_name; |
84 const bool markup_removal = | 84 const bool markup_removal = |
85 base::i18n::UnadjustStringForLocaleDirection(&display_name); | 85 base::i18n::UnadjustStringForLocaleDirection(&display_name); |
86 DCHECK(markup_removal); | 86 DCHECK(markup_removal); |
87 | 87 |
88 const bool has_rtl_chars = | 88 const bool has_rtl_chars = |
89 base::i18n::StringContainsStrongRTLChars(display_name); | 89 base::i18n::StringContainsStrongRTLChars(display_name); |
90 const std::string directionality = has_rtl_chars ? "rtl" : "ltr"; | 90 const std::string directionality = has_rtl_chars ? "rtl" : "ltr"; |
91 | 91 |
92 std::unique_ptr<base::DictionaryValue> dictionary( | 92 auto dictionary = base::MakeUnique<base::DictionaryValue>(); |
93 new base::DictionaryValue()); | |
94 dictionary->SetString("code", language_code); | 93 dictionary->SetString("code", language_code); |
95 dictionary->SetString("displayName", language_display_name); | 94 dictionary->SetString("displayName", language_display_name); |
96 dictionary->SetString("textDirection", directionality); | 95 dictionary->SetString("textDirection", directionality); |
97 dictionary->SetString("nativeDisplayName", language_native_display_name); | 96 dictionary->SetString("nativeDisplayName", language_native_display_name); |
98 return dictionary.release(); | 97 return dictionary; |
99 } | 98 } |
100 | 99 |
101 // Gets the list of languages with |descriptors| based on |base_language_codes|. | 100 // Gets the list of languages with |descriptors| based on |base_language_codes|. |
102 // The |most_relevant_language_codes| will be first in the list. If | 101 // The |most_relevant_language_codes| will be first in the list. If |
103 // |insert_divider| is true, an entry with its "code" attribute set to | 102 // |insert_divider| is true, an entry with its "code" attribute set to |
104 // kMostRelevantLanguagesDivider is placed between the most relevant languages | 103 // kMostRelevantLanguagesDivider is placed between the most relevant languages |
105 // and all others. | 104 // and all others. |
106 std::unique_ptr<base::ListValue> GetLanguageList( | 105 std::unique_ptr<base::ListValue> GetLanguageList( |
107 const input_method::InputMethodDescriptors& descriptors, | 106 const input_method::InputMethodDescriptors& descriptors, |
108 const std::vector<std::string>& base_language_codes, | 107 const std::vector<std::string>& base_language_codes, |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 std::unique_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { | 596 std::unique_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { |
598 const input_method::InputMethodDescriptor current_input_method = | 597 const input_method::InputMethodDescriptor current_input_method = |
599 input_method::InputMethodManager::Get() | 598 input_method::InputMethodManager::Get() |
600 ->GetActiveIMEState() | 599 ->GetActiveIMEState() |
601 ->GetCurrentInputMethod(); | 600 ->GetCurrentInputMethod(); |
602 return CreateInputMethodsEntry(current_input_method, | 601 return CreateInputMethodsEntry(current_input_method, |
603 current_input_method.id()); | 602 current_input_method.id()); |
604 } | 603 } |
605 | 604 |
606 } // namespace chromeos | 605 } // namespace chromeos |
OLD | NEW |