BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / chromeos / input_method / input_method_util.cc
blob7bcfa25b07102930d83d40f96b16ddde4cd74c24
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/input_method/input_method_util.h"
7 #include <algorithm>
8 #include <functional>
9 #include <map>
10 #include <utility>
12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/prefs/pref_service.h"
15 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h"
18 #include "chrome/common/extensions/extension_constants.h"
20 // TODO(nona): move this header from this file.
21 #include "chrome/grit/generated_resources.h"
23 #include "ui/base/ime/chromeos/component_extension_ime_manager.h"
24 #include "ui/base/ime/chromeos/extension_ime_util.h"
26 // For SetHardwareKeyboardLayoutForTesting.
27 #include "ui/base/ime/chromeos/fake_input_method_delegate.h"
28 #include "ui/base/ime/chromeos/input_method_delegate.h"
29 #include "ui/base/ime/chromeos/input_method_whitelist.h"
31 #include "ui/base/l10n/l10n_util.h"
33 namespace {
35 // A mapping from an input method id to a resource id for a
36 // medium length language indicator.
37 // For those languages that want to display a slightly longer text in the
38 // "Your input method has changed to..." bubble than in the status tray.
39 // If an entry is not found in this table the short name is used.
40 const struct {
41 const char* engine_id;
42 const int resource_id;
43 } kMappingImeIdToMediumLenNameResourceId[] = {
44 { "hangul_2set", IDS_LANGUAGES_MEDIUM_LEN_NAME_KOREAN },
45 { "hangul_3set390", IDS_LANGUAGES_MEDIUM_LEN_NAME_KOREAN },
46 { "hangul_3setfinal", IDS_LANGUAGES_MEDIUM_LEN_NAME_KOREAN },
47 { "hangul_3setnoshift", IDS_LANGUAGES_MEDIUM_LEN_NAME_KOREAN },
48 { "hangul_3setromaja", IDS_LANGUAGES_MEDIUM_LEN_NAME_KOREAN },
49 { "zh-t-i0-pinyin", IDS_LANGUAGES_MEDIUM_LEN_NAME_CHINESE_SIMPLIFIED},
50 { "zh-t-i0-wubi-1986", IDS_LANGUAGES_MEDIUM_LEN_NAME_CHINESE_SIMPLIFIED },
51 { "zh-hant-t-i0-und", IDS_LANGUAGES_MEDIUM_LEN_NAME_CHINESE_TRADITIONAL },
52 { "zh-hant-t-i0-cangjie-1987",
53 IDS_LANGUAGES_MEDIUM_LEN_NAME_CHINESE_TRADITIONAL },
54 { "zh-hant-t-i0-cangjie-1987-x-m0-simplified",
55 IDS_LANGUAGES_MEDIUM_LEN_NAME_CHINESE_TRADITIONAL },
56 { extension_misc::kBrailleImeEngineId,
57 IDS_LANGUAGES_MEDIUM_LEN_NAME_BRAILLE },
59 const size_t kMappingImeIdToMediumLenNameResourceIdLen =
60 arraysize(kMappingImeIdToMediumLenNameResourceId);
62 // Due to asynchronous initialization of component extension manager,
63 // GetFirstLoginInputMethodIds may miss component extension IMEs. To enable
64 // component extension IME as the first loging input method, we have to prepare
65 // component extension IME IDs.
66 // Note: empty layout means the rule applies for all layouts.
67 const struct {
68 const char* locale;
69 const char* layout;
70 const char* engine_id;
71 } kDefaultInputMethodRecommendation[] = {
72 { "ja", "jp", "nacl_mozc_jp" },
73 { "ja", "", "nacl_mozc_us" },
74 { "zh-CN", "", "zh-t-i0-pinyin" },
75 { "zh-TW", "", "zh-hant-t-i0-und" },
76 { "th", "", "vkd_th" },
77 { "vi", "", "vkd_vi_tcvn" },
78 { "ru", "", "xkb:ru::rus" },
81 // The engine ID map for migration. This migration is for input method IDs from
82 // VPD so it's NOT a temporary migration.
83 const char* const kEngineIdMigrationMap[][2] = {
84 {"ime:jp:mozc_jp", "nacl_mozc_jp"},
85 {"ime:jp:mozc_us", "nacl_mozc_us"},
86 {"ime:ko:hangul_2set", "hangul_2set"},
87 {"ime:ko:hangul", "hangul_2set"},
88 {"ime:zh-t:array", "zh-hant-t-i0-array-1992"},
89 {"ime:zh-t:cangjie", "zh-hant-t-i0-cangjie-1987"},
90 {"ime:zh-t:dayi", "zh-hant-t-i0-dayi-1988"},
91 {"ime:zh-t:pinyin", "zh-hant-t-i0-pinyin"},
92 {"ime:zh-t:quick", "zh-hant-t-i0-cangjie-1987-x-m0-simplified"},
93 {"ime:zh-t:zhuyin", "zh-hant-t-i0-und"},
94 {"ime:zh:pinyin", "zh-t-i0-pinyin"},
95 {"ime:zh:wubi", "zh-t-i0-wubi-1986"},
96 {"m17n:", "vkd_"},
97 {"t13n:am", "am-t-i0-und"},
98 {"t13n:ar", "ar-t-i0-und"},
99 {"t13n:bn", "bn-t-i0-und"},
100 {"t13n:el", "el-t-i0-und"},
101 {"t13n:fa", "fa-t-i0-und"},
102 {"t13n:gu", "gu-t-i0-und"},
103 {"t13n:he", "he-t-i0-und"},
104 {"t13n:hi", "hi-t-i0-und"},
105 {"t13n:kn", "kn-t-i0-und"},
106 {"t13n:ml", "ml-t-i0-und"},
107 {"t13n:mr", "mr-t-i0-und"},
108 {"t13n:ne", "ne-t-i0-und"},
109 {"t13n:or", "or-t-i0-und"},
110 {"t13n:pa", "pa-t-i0-und"},
111 {"t13n:sa", "sa-t-i0-und"},
112 {"t13n:sr", "sr-t-i0-und"},
113 {"t13n:ta", "ta-t-i0-und"},
114 {"t13n:te", "te-t-i0-und"},
115 {"t13n:ti", "ti-t-i0-und"},
116 {"t13n:ur", "ur-t-i0-und"},
119 const struct EnglishToResouceId {
120 const char* english_string_from_ibus;
121 int resource_id;
122 } kEnglishToResourceIdArray[] = {
123 // For xkb-layouts.
124 {"xkb:am:phonetic:arm", IDS_STATUSBAR_LAYOUT_ARMENIAN_PHONETIC},
125 {"xkb:be::fra", IDS_STATUSBAR_LAYOUT_BELGIUM},
126 {"xkb:be::ger", IDS_STATUSBAR_LAYOUT_BELGIUM},
127 {"xkb:be::nld", IDS_STATUSBAR_LAYOUT_BELGIUM},
128 {"xkb:bg::bul", IDS_STATUSBAR_LAYOUT_BULGARIA},
129 {"xkb:bg:phonetic:bul", IDS_STATUSBAR_LAYOUT_BULGARIA_PHONETIC},
130 {"xkb:br::por", IDS_STATUSBAR_LAYOUT_BRAZIL},
131 {"xkb:by::bel", IDS_STATUSBAR_LAYOUT_BELARUSIAN},
132 {"xkb:ca::fra", IDS_STATUSBAR_LAYOUT_CANADA},
133 {"xkb:ca:eng:eng", IDS_STATUSBAR_LAYOUT_CANADA_ENGLISH},
134 {"xkb:ca:multix:fra", IDS_STATUSBAR_LAYOUT_CANADIAN_MULTILINGUAL},
135 {"xkb:ch::ger", IDS_STATUSBAR_LAYOUT_SWITZERLAND},
136 {"xkb:ch:fr:fra", IDS_STATUSBAR_LAYOUT_SWITZERLAND_FRENCH},
137 {"xkb:cz::cze", IDS_STATUSBAR_LAYOUT_CZECHIA},
138 {"xkb:cz:qwerty:cze", IDS_STATUSBAR_LAYOUT_CZECHIA_QWERTY},
139 {"xkb:de::ger", IDS_STATUSBAR_LAYOUT_GERMANY},
140 {"xkb:de:neo:ger", IDS_STATUSBAR_LAYOUT_GERMANY_NEO2},
141 {"xkb:dk::dan", IDS_STATUSBAR_LAYOUT_DENMARK},
142 {"xkb:ee::est", IDS_STATUSBAR_LAYOUT_ESTONIA},
143 {"xkb:es::spa", IDS_STATUSBAR_LAYOUT_SPAIN},
144 {"xkb:es:cat:cat", IDS_STATUSBAR_LAYOUT_SPAIN_CATALAN},
145 {"xkb:fo::fao", IDS_STATUSBAR_LAYOUT_FAROESE},
146 {"xkb:fi::fin", IDS_STATUSBAR_LAYOUT_FINLAND},
147 {"xkb:fr:bepo:fra", IDS_STATUSBAR_LAYOUT_FRANCE_BEPO},
148 {"xkb:fr::fra", IDS_STATUSBAR_LAYOUT_FRANCE},
149 {"xkb:gb:dvorak:eng", IDS_STATUSBAR_LAYOUT_UNITED_KINGDOM_DVORAK},
150 {"xkb:gb:extd:eng", IDS_STATUSBAR_LAYOUT_UNITED_KINGDOM},
151 {"xkb:ge::geo", IDS_STATUSBAR_LAYOUT_GEORGIAN},
152 {"xkb:gr::gre", IDS_STATUSBAR_LAYOUT_GREECE},
153 {"xkb:hr::scr", IDS_STATUSBAR_LAYOUT_CROATIA},
154 {"xkb:hu:qwerty:hun", IDS_STATUSBAR_LAYOUT_HUNGARY_QWERTY},
155 {"xkb:hu::hun", IDS_STATUSBAR_LAYOUT_HUNGARY},
156 {"xkb:ie::ga", IDS_STATUSBAR_LAYOUT_IRISH},
157 {"xkb:il::heb", IDS_STATUSBAR_LAYOUT_ISRAEL},
158 {"xkb:is::ice", IDS_STATUSBAR_LAYOUT_ICELANDIC},
159 {"xkb:it::ita", IDS_STATUSBAR_LAYOUT_ITALY},
160 {"xkb:jp::jpn", IDS_STATUSBAR_LAYOUT_JAPAN},
161 {"xkb:latam::spa", IDS_STATUSBAR_LAYOUT_LATIN_AMERICAN},
162 {"xkb:lt::lit", IDS_STATUSBAR_LAYOUT_LITHUANIA},
163 {"xkb:lv:apostrophe:lav", IDS_STATUSBAR_LAYOUT_LATVIA},
164 {"xkb:mk::mkd", IDS_STATUSBAR_LAYOUT_MACEDONIAN},
165 {"xkb:mn::mon", IDS_STATUSBAR_LAYOUT_MONGOLIAN},
166 {"xkb:nl::nld", IDS_STATUSBAR_LAYOUT_NETHERLANDS},
167 {"xkb:no::nob", IDS_STATUSBAR_LAYOUT_NORWAY},
168 {"xkb:pl::pol", IDS_STATUSBAR_LAYOUT_POLAND},
169 {"xkb:pt::por", IDS_STATUSBAR_LAYOUT_PORTUGAL},
170 {"xkb:ro::rum", IDS_STATUSBAR_LAYOUT_ROMANIA},
171 {"xkb:rs::srp", IDS_STATUSBAR_LAYOUT_SERBIA},
172 {"xkb:ru::rus", IDS_STATUSBAR_LAYOUT_RUSSIA},
173 {"xkb:ru:phonetic:rus", IDS_STATUSBAR_LAYOUT_RUSSIA_PHONETIC},
174 {"xkb:se::swe", IDS_STATUSBAR_LAYOUT_SWEDEN},
175 {"xkb:si::slv", IDS_STATUSBAR_LAYOUT_SLOVENIA},
176 {"xkb:sk::slo", IDS_STATUSBAR_LAYOUT_SLOVAKIA},
177 {"xkb:tr::tur", IDS_STATUSBAR_LAYOUT_TURKEY},
178 {"xkb:tr:f:tur", IDS_STATUSBAR_LAYOUT_TURKEY_F},
179 {"xkb:ua::ukr", IDS_STATUSBAR_LAYOUT_UKRAINE},
180 {"xkb:us::eng", IDS_STATUSBAR_LAYOUT_USA},
181 {"xkb:us::fil", IDS_STATUSBAR_LAYOUT_USA},
182 {"xkb:us::ind", IDS_STATUSBAR_LAYOUT_USA},
183 {"xkb:us::msa", IDS_STATUSBAR_LAYOUT_USA},
184 {"xkb:us:altgr-intl:eng", IDS_STATUSBAR_LAYOUT_USA_EXTENDED},
185 {"xkb:us:colemak:eng", IDS_STATUSBAR_LAYOUT_USA_COLEMAK},
186 {"xkb:us:dvorak:eng", IDS_STATUSBAR_LAYOUT_USA_DVORAK},
187 {"xkb:us:dvp:eng", IDS_STATUSBAR_LAYOUT_USA_DVP},
188 {"xkb:us:intl:eng", IDS_STATUSBAR_LAYOUT_USA_INTERNATIONAL},
189 {"xkb:us:intl:nld", IDS_STATUSBAR_LAYOUT_USA_INTERNATIONAL},
190 {"xkb:us:intl:por", IDS_STATUSBAR_LAYOUT_USA_INTERNATIONAL},
192 const size_t kEnglishToResourceIdArraySize =
193 arraysize(kEnglishToResourceIdArray);
195 const struct InputMethodNameMap {
196 const char* message_name;
197 int resource_id;
198 bool operator<(const InputMethodNameMap& other) const {
199 return strcmp(message_name, other.message_name) < 0;
201 } kInputMethodNameMap[] = {
202 {"__MSG_INPUTMETHOD_ARRAY__", IDS_IME_NAME_INPUTMETHOD_ARRAY},
203 {"__MSG_INPUTMETHOD_CANGJIE__", IDS_IME_NAME_INPUTMETHOD_CANGJIE},
204 {"__MSG_INPUTMETHOD_DAYI__", IDS_IME_NAME_INPUTMETHOD_DAYI},
205 {"__MSG_INPUTMETHOD_HANGUL_2_SET__", IDS_IME_NAME_INPUTMETHOD_HANGUL_2_SET},
206 {"__MSG_INPUTMETHOD_HANGUL_3_SET_390__",
207 IDS_IME_NAME_INPUTMETHOD_HANGUL_3_SET_390},
208 {"__MSG_INPUTMETHOD_HANGUL_3_SET_FINAL__",
209 IDS_IME_NAME_INPUTMETHOD_HANGUL_3_SET_FINAL},
210 {"__MSG_INPUTMETHOD_HANGUL_3_SET_NO_SHIFT__",
211 IDS_IME_NAME_INPUTMETHOD_HANGUL_3_SET_NO_SHIFT},
212 {"__MSG_INPUTMETHOD_HANGUL_AHNMATAE__",
213 IDS_IME_NAME_INPUTMETHOD_HANGUL_AHNMATAE},
214 {"__MSG_INPUTMETHOD_HANGUL_ROMAJA__",
215 IDS_IME_NAME_INPUTMETHOD_HANGUL_ROMAJA},
216 {"__MSG_INPUTMETHOD_HANGUL__", IDS_IME_NAME_INPUTMETHOD_HANGUL},
217 {"__MSG_INPUTMETHOD_MOZC_JP__", IDS_IME_NAME_INPUTMETHOD_MOZC_JP},
218 {"__MSG_INPUTMETHOD_MOZC_US__", IDS_IME_NAME_INPUTMETHOD_MOZC_US},
219 {"__MSG_INPUTMETHOD_PINYIN__", IDS_IME_NAME_INPUTMETHOD_PINYIN},
220 {"__MSG_INPUTMETHOD_QUICK__", IDS_IME_NAME_INPUTMETHOD_QUICK},
221 {"__MSG_INPUTMETHOD_TRADITIONAL_PINYIN__",
222 IDS_IME_NAME_INPUTMETHOD_TRADITIONAL_PINYIN},
223 {"__MSG_INPUTMETHOD_WUBI__", IDS_IME_NAME_INPUTMETHOD_WUBI},
224 {"__MSG_INPUTMETHOD_ZHUYIN__", IDS_IME_NAME_INPUTMETHOD_ZHUYIN},
225 {"__MSG_KEYBOARD_ARABIC__", IDS_IME_NAME_KEYBOARD_ARABIC},
226 {"__MSG_KEYBOARD_ARMENIAN_PHONETIC__",
227 IDS_IME_NAME_KEYBOARD_ARMENIAN_PHONETIC},
228 {"__MSG_KEYBOARD_BELARUSIAN__", IDS_IME_NAME_KEYBOARD_BELARUSIAN},
229 {"__MSG_KEYBOARD_BELGIAN__", IDS_IME_NAME_KEYBOARD_BELGIAN},
230 {"__MSG_KEYBOARD_BENGALI_PHONETIC__",
231 IDS_IME_NAME_KEYBOARD_BENGALI_PHONETIC},
232 {"__MSG_KEYBOARD_BRAZILIAN__", IDS_IME_NAME_KEYBOARD_BRAZILIAN},
233 {"__MSG_KEYBOARD_BULGARIAN_PHONETIC__",
234 IDS_IME_NAME_KEYBOARD_BULGARIAN_PHONETIC},
235 {"__MSG_KEYBOARD_BULGARIAN__", IDS_IME_NAME_KEYBOARD_BULGARIAN},
236 {"__MSG_KEYBOARD_CANADIAN_ENGLISH__",
237 IDS_IME_NAME_KEYBOARD_CANADIAN_ENGLISH},
238 {"__MSG_KEYBOARD_CANADIAN_FRENCH__", IDS_IME_NAME_KEYBOARD_CANADIAN_FRENCH},
239 {"__MSG_KEYBOARD_CANADIAN_MULTILINGUAL__",
240 IDS_IME_NAME_KEYBOARD_CANADIAN_MULTILINGUAL},
241 {"__MSG_KEYBOARD_CATALAN__", IDS_IME_NAME_KEYBOARD_CATALAN},
242 {"__MSG_KEYBOARD_CROATIAN__", IDS_IME_NAME_KEYBOARD_CROATIAN},
243 {"__MSG_KEYBOARD_CZECH_QWERTY__", IDS_IME_NAME_KEYBOARD_CZECH_QWERTY},
244 {"__MSG_KEYBOARD_CZECH__", IDS_IME_NAME_KEYBOARD_CZECH},
245 {"__MSG_KEYBOARD_DANISH__", IDS_IME_NAME_KEYBOARD_DANISH},
246 {"__MSG_KEYBOARD_DEVANAGARI_PHONETIC__",
247 IDS_IME_NAME_KEYBOARD_DEVANAGARI_PHONETIC},
248 {"__MSG_KEYBOARD_ESTONIAN__", IDS_IME_NAME_KEYBOARD_ESTONIAN},
249 {"__MSG_KEYBOARD_ETHIOPIC__", IDS_IME_NAME_KEYBOARD_ETHIOPIC},
250 {"__MSG_KEYBOARD_FAROESE__", IDS_IME_NAME_KEYBOARD_FAROESE},
251 {"__MSG_KEYBOARD_FINNISH__", IDS_IME_NAME_KEYBOARD_FINNISH},
252 {"__MSG_KEYBOARD_FRENCH_BEPO__", IDS_IME_NAME_KEYBOARD_FRENCH_BEPO},
253 {"__MSG_KEYBOARD_FRENCH__", IDS_IME_NAME_KEYBOARD_FRENCH},
254 {"__MSG_KEYBOARD_GEORGIAN__", IDS_IME_NAME_KEYBOARD_GEORGIAN},
255 {"__MSG_KEYBOARD_GERMAN_NEO_2__", IDS_IME_NAME_KEYBOARD_GERMAN_NEO_2},
256 {"__MSG_KEYBOARD_GERMAN__", IDS_IME_NAME_KEYBOARD_GERMAN},
257 {"__MSG_KEYBOARD_GREEK__", IDS_IME_NAME_KEYBOARD_GREEK},
258 {"__MSG_KEYBOARD_GUJARATI_PHONETIC__",
259 IDS_IME_NAME_KEYBOARD_GUJARATI_PHONETIC},
260 {"__MSG_KEYBOARD_HEBREW__", IDS_IME_NAME_KEYBOARD_HEBREW},
261 {"__MSG_KEYBOARD_HUNGARIAN_QWERTY__",
262 IDS_IME_NAME_KEYBOARD_HUNGARIAN_QWERTY},
263 {"__MSG_KEYBOARD_HUNGARIAN__", IDS_IME_NAME_KEYBOARD_HUNGARIAN},
264 {"__MSG_KEYBOARD_ICELANDIC__", IDS_IME_NAME_KEYBOARD_ICELANDIC},
265 {"__MSG_KEYBOARD_IRISH__", IDS_IME_NAME_KEYBOARD_IRISH},
266 {"__MSG_KEYBOARD_ITALIAN__", IDS_IME_NAME_KEYBOARD_ITALIAN},
267 {"__MSG_KEYBOARD_JAPANESE__", IDS_IME_NAME_KEYBOARD_JAPANESE},
268 {"__MSG_KEYBOARD_KANNADA_PHONETIC__",
269 IDS_IME_NAME_KEYBOARD_KANNADA_PHONETIC},
270 {"__MSG_KEYBOARD_KHMER__", IDS_IME_NAME_KEYBOARD_KHMER},
271 {"__MSG_KEYBOARD_LAO__", IDS_IME_NAME_KEYBOARD_LAO},
272 {"__MSG_KEYBOARD_LATIN_AMERICAN__", IDS_IME_NAME_KEYBOARD_LATIN_AMERICAN},
273 {"__MSG_KEYBOARD_LATVIAN__", IDS_IME_NAME_KEYBOARD_LATVIAN},
274 {"__MSG_KEYBOARD_LITHUANIAN__", IDS_IME_NAME_KEYBOARD_LITHUANIAN},
275 {"__MSG_KEYBOARD_MACEDONIAN__", IDS_IME_NAME_KEYBOARD_MACEDONIAN},
276 {"__MSG_KEYBOARD_MALAYALAM_PHONETIC__",
277 IDS_IME_NAME_KEYBOARD_MALAYALAM_PHONETIC},
278 {"__MSG_KEYBOARD_MALTESE__", IDS_IME_NAME_KEYBOARD_MALTESE},
279 {"__MSG_KEYBOARD_MONGOLIAN__", IDS_IME_NAME_KEYBOARD_MONGOLIAN},
280 {"__MSG_KEYBOARD_MYANMAR_MYANSAN__", IDS_IME_NAME_KEYBOARD_MYANMAR_MYANSAN},
281 {"__MSG_KEYBOARD_MYANMAR__", IDS_IME_NAME_KEYBOARD_MYANMAR},
282 {"__MSG_KEYBOARD_NEPALI_INSCRIPT__", IDS_IME_NAME_KEYBOARD_NEPALI_INSCRIPT},
283 {"__MSG_KEYBOARD_NEPALI_PHONETIC__", IDS_IME_NAME_KEYBOARD_NEPALI_PHONETIC},
284 {"__MSG_KEYBOARD_NETHERLANDS__", IDS_IME_NAME_KEYBOARD_NETHERLANDS},
285 {"__MSG_KEYBOARD_NORWEGIAN__", IDS_IME_NAME_KEYBOARD_NORWEGIAN},
286 {"__MSG_KEYBOARD_PERSIAN__", IDS_IME_NAME_KEYBOARD_PERSIAN},
287 {"__MSG_KEYBOARD_POLISH__", IDS_IME_NAME_KEYBOARD_POLISH},
288 {"__MSG_KEYBOARD_PORTUGUESE__", IDS_IME_NAME_KEYBOARD_PORTUGUESE},
289 {"__MSG_KEYBOARD_ROMANIAN_STANDARD__",
290 IDS_IME_NAME_KEYBOARD_ROMANIAN_STANDARD},
291 {"__MSG_KEYBOARD_ROMANIAN__", IDS_IME_NAME_KEYBOARD_ROMANIAN},
292 {"__MSG_KEYBOARD_RUSSIAN_PHONETIC_AATSEEL__",
293 IDS_IME_NAME_KEYBOARD_RUSSIAN_PHONETIC_AATSEEL},
294 {"__MSG_KEYBOARD_RUSSIAN_PHONETIC_YAZHERT__",
295 IDS_IME_NAME_KEYBOARD_RUSSIAN_PHONETIC_YAZHERT},
296 {"__MSG_KEYBOARD_RUSSIAN_PHONETIC__",
297 IDS_IME_NAME_KEYBOARD_RUSSIAN_PHONETIC},
298 {"__MSG_KEYBOARD_RUSSIAN__", IDS_IME_NAME_KEYBOARD_RUSSIAN},
299 {"__MSG_KEYBOARD_SERBIAN__", IDS_IME_NAME_KEYBOARD_SERBIAN},
300 {"__MSG_KEYBOARD_SINHALA__", IDS_IME_NAME_KEYBOARD_SINHALA},
301 {"__MSG_KEYBOARD_SLOVAKIAN__", IDS_IME_NAME_KEYBOARD_SLOVAKIAN},
302 {"__MSG_KEYBOARD_SLOVENIAN__", IDS_IME_NAME_KEYBOARD_SLOVENIAN},
303 {"__MSG_KEYBOARD_SORANIKURDISH_AR__",
304 IDS_IME_NAME_KEYBOARD_SORANIKURDISH_AR},
305 {"__MSG_KEYBOARD_SORANIKURDISH_EN__",
306 IDS_IME_NAME_KEYBOARD_SORANIKURDISH_EN},
307 {"__MSG_KEYBOARD_SPANISH__", IDS_IME_NAME_KEYBOARD_SPANISH},
308 {"__MSG_KEYBOARD_SWEDISH__", IDS_IME_NAME_KEYBOARD_SWEDISH},
309 {"__MSG_KEYBOARD_SWISS_FRENCH__", IDS_IME_NAME_KEYBOARD_SWISS_FRENCH},
310 {"__MSG_KEYBOARD_SWISS__", IDS_IME_NAME_KEYBOARD_SWISS},
311 {"__MSG_KEYBOARD_TAMIL_INSCRIPT__", IDS_IME_NAME_KEYBOARD_TAMIL_INSCRIPT},
312 {"__MSG_KEYBOARD_TAMIL_ITRANS__", IDS_IME_NAME_KEYBOARD_TAMIL_ITRANS},
313 {"__MSG_KEYBOARD_TAMIL_PHONETIC__", IDS_IME_NAME_KEYBOARD_TAMIL_PHONETIC},
314 {"__MSG_KEYBOARD_TAMIL_TAMIL99__", IDS_IME_NAME_KEYBOARD_TAMIL_TAMIL99},
315 {"__MSG_KEYBOARD_TAMIL_TYPEWRITER__",
316 IDS_IME_NAME_KEYBOARD_TAMIL_TYPEWRITER},
317 {"__MSG_KEYBOARD_TELUGU_PHONETIC__", IDS_IME_NAME_KEYBOARD_TELUGU_PHONETIC},
318 {"__MSG_KEYBOARD_THAI_KEDMANEE__", IDS_IME_NAME_KEYBOARD_THAI_KEDMANEE},
319 {"__MSG_KEYBOARD_THAI_PATTACHOTE__", IDS_IME_NAME_KEYBOARD_THAI_PATTACHOTE},
320 {"__MSG_KEYBOARD_THAI_TIS__", IDS_IME_NAME_KEYBOARD_THAI_TIS},
321 {"__MSG_KEYBOARD_TURKISH_F__", IDS_IME_NAME_KEYBOARD_TURKISH_F},
322 {"__MSG_KEYBOARD_TURKISH__", IDS_IME_NAME_KEYBOARD_TURKISH},
323 {"__MSG_KEYBOARD_UKRAINIAN__", IDS_IME_NAME_KEYBOARD_UKRAINIAN},
324 {"__MSG_KEYBOARD_UK_DVORAK__", IDS_IME_NAME_KEYBOARD_UK_DVORAK},
325 {"__MSG_KEYBOARD_UK__", IDS_IME_NAME_KEYBOARD_UK},
326 {"__MSG_KEYBOARD_US_COLEMAK__", IDS_IME_NAME_KEYBOARD_US_COLEMAK},
327 {"__MSG_KEYBOARD_US_DVORAK__", IDS_IME_NAME_KEYBOARD_US_DVORAK},
328 {"__MSG_KEYBOARD_US_DVP__", IDS_IME_NAME_KEYBOARD_US_DVP},
329 {"__MSG_KEYBOARD_US_EXTENDED__", IDS_IME_NAME_KEYBOARD_US_EXTENDED},
330 {"__MSG_KEYBOARD_US_INTERNATIONAL__",
331 IDS_IME_NAME_KEYBOARD_US_INTERNATIONAL},
332 {"__MSG_KEYBOARD_US__", IDS_IME_NAME_KEYBOARD_US},
333 {"__MSG_KEYBOARD_VIETNAMESE_TCVN__", IDS_IME_NAME_KEYBOARD_VIETNAMESE_TCVN},
334 {"__MSG_KEYBOARD_VIETNAMESE_TELEX__",
335 IDS_IME_NAME_KEYBOARD_VIETNAMESE_TELEX},
336 {"__MSG_KEYBOARD_VIETNAMESE_VIQR__", IDS_IME_NAME_KEYBOARD_VIETNAMESE_VIQR},
337 {"__MSG_KEYBOARD_VIETNAMESE_VNI__", IDS_IME_NAME_KEYBOARD_VIETNAMESE_VNI},
338 {"__MSG_TRANSLITERATION_AM__", IDS_IME_NAME_TRANSLITERATION_AM},
339 {"__MSG_TRANSLITERATION_AR__", IDS_IME_NAME_TRANSLITERATION_AR},
340 {"__MSG_TRANSLITERATION_BN__", IDS_IME_NAME_TRANSLITERATION_BN},
341 {"__MSG_TRANSLITERATION_EL__", IDS_IME_NAME_TRANSLITERATION_EL},
342 {"__MSG_TRANSLITERATION_FA__", IDS_IME_NAME_TRANSLITERATION_FA},
343 {"__MSG_TRANSLITERATION_GU__", IDS_IME_NAME_TRANSLITERATION_GU},
344 {"__MSG_TRANSLITERATION_HE__", IDS_IME_NAME_TRANSLITERATION_HE},
345 {"__MSG_TRANSLITERATION_HI__", IDS_IME_NAME_TRANSLITERATION_HI},
346 {"__MSG_TRANSLITERATION_KN__", IDS_IME_NAME_TRANSLITERATION_KN},
347 {"__MSG_TRANSLITERATION_ML__", IDS_IME_NAME_TRANSLITERATION_ML},
348 {"__MSG_TRANSLITERATION_MR__", IDS_IME_NAME_TRANSLITERATION_MR},
349 {"__MSG_TRANSLITERATION_NE__", IDS_IME_NAME_TRANSLITERATION_NE},
350 {"__MSG_TRANSLITERATION_OR__", IDS_IME_NAME_TRANSLITERATION_OR},
351 {"__MSG_TRANSLITERATION_PA__", IDS_IME_NAME_TRANSLITERATION_PA},
352 {"__MSG_TRANSLITERATION_SA__", IDS_IME_NAME_TRANSLITERATION_SA},
353 {"__MSG_TRANSLITERATION_SR__", IDS_IME_NAME_TRANSLITERATION_SR},
354 {"__MSG_TRANSLITERATION_TA__", IDS_IME_NAME_TRANSLITERATION_TA},
355 {"__MSG_TRANSLITERATION_TE__", IDS_IME_NAME_TRANSLITERATION_TE},
356 {"__MSG_TRANSLITERATION_TI__", IDS_IME_NAME_TRANSLITERATION_TI},
357 {"__MSG_TRANSLITERATION_UR__", IDS_IME_NAME_TRANSLITERATION_UR},
360 } // namespace
362 namespace chromeos {
364 namespace input_method {
366 InputMethodUtil::InputMethodUtil(InputMethodDelegate* delegate)
367 : delegate_(delegate) {
368 InputMethodDescriptors default_input_methods;
369 default_input_methods.push_back(GetFallbackInputMethodDescriptor());
370 ResetInputMethods(default_input_methods);
372 // Initialize a map from English string to Chrome string resource ID as well.
373 for (size_t i = 0; i < kEnglishToResourceIdArraySize; ++i) {
374 const EnglishToResouceId& map_entry = kEnglishToResourceIdArray[i];
375 const bool result = english_to_resource_id_.insert(std::make_pair(
376 map_entry.english_string_from_ibus, map_entry.resource_id)).second;
377 DCHECK(result) << "Duplicated string is found: "
378 << map_entry.english_string_from_ibus;
382 InputMethodUtil::~InputMethodUtil() {
385 std::string InputMethodUtil::GetLocalizedDisplayName(
386 const InputMethodDescriptor& descriptor) const {
387 // Localizes the input method name.
388 const std::string& disp = descriptor.name();
389 if (disp.find("__MSG_") == 0) {
390 const InputMethodNameMap* map = kInputMethodNameMap;
391 size_t map_size = arraysize(kInputMethodNameMap);
392 std::string name = base::ToUpperASCII(disp);
393 const InputMethodNameMap map_key = {name.c_str(), 0};
394 const InputMethodNameMap* p =
395 std::lower_bound(map, map + map_size, map_key);
396 if (p != map + map_size && name == p->message_name)
397 return l10n_util::GetStringUTF8(p->resource_id);
399 return disp;
402 bool InputMethodUtil::TranslateStringInternal(
403 const std::string& english_string, base::string16 *out_string) const {
404 DCHECK(out_string);
405 // |english_string| could be an input method id. So legacy xkb id is required
406 // to get the translated string.
407 std::string key_string = extension_ime_util::MaybeGetLegacyXkbId(
408 english_string);
409 HashType::const_iterator iter = english_to_resource_id_.find(key_string);
411 if (iter == english_to_resource_id_.end()) {
412 // TODO(yusukes): Write Autotest which checks if all display names and all
413 // property names for supported input methods are listed in the resource
414 // ID array (crosbug.com/4572).
415 LOG(ERROR) << "Resource ID is not found for: " << english_string
416 << ", " << key_string;
417 return false;
420 *out_string = delegate_->GetLocalizedString(iter->second);
421 return true;
424 base::string16 InputMethodUtil::TranslateString(
425 const std::string& english_string) const {
426 base::string16 localized_string;
427 if (TranslateStringInternal(english_string, &localized_string)) {
428 return localized_string;
430 return base::UTF8ToUTF16(english_string);
433 bool InputMethodUtil::IsValidInputMethodId(
434 const std::string& input_method_id) const {
435 // We can't check the component extension is whilelisted or not here because
436 // it might not be initialized.
437 return GetInputMethodDescriptorFromId(input_method_id) != NULL ||
438 extension_ime_util::IsComponentExtensionIME(input_method_id);
441 // static
442 bool InputMethodUtil::IsKeyboardLayout(const std::string& input_method_id) {
443 return base::StartsWith(input_method_id, "xkb:",
444 base::CompareCase::INSENSITIVE_ASCII) ||
445 extension_ime_util::IsKeyboardLayoutExtension(input_method_id);
448 std::string InputMethodUtil::GetKeyboardLayoutName(
449 const std::string& input_method_id) const {
450 InputMethodIdToDescriptorMap::const_iterator iter
451 = id_to_descriptor_.find(input_method_id);
452 return (iter == id_to_descriptor_.end()) ?
453 "" : iter->second.GetPreferredKeyboardLayout();
456 std::string InputMethodUtil::GetInputMethodDisplayNameFromId(
457 const std::string& input_method_id) const {
458 base::string16 display_name;
459 if (!extension_ime_util::IsExtensionIME(input_method_id) &&
460 TranslateStringInternal(input_method_id, &display_name)) {
461 return base::UTF16ToUTF8(display_name);
463 const InputMethodDescriptor* descriptor =
464 GetInputMethodDescriptorFromId(input_method_id);
465 if (descriptor)
466 return GetLocalizedDisplayName(*descriptor);
467 // Return an empty string if the input method is not found.
468 return "";
471 base::string16 InputMethodUtil::GetInputMethodShortName(
472 const InputMethodDescriptor& input_method) const {
473 // TODO(shuchen): remove this method, as the client can directly use
474 // input_method.GetIndicator().
475 return base::UTF8ToUTF16(input_method.GetIndicator());
478 base::string16 InputMethodUtil::GetInputMethodMediumName(
479 const InputMethodDescriptor& input_method) const {
480 // For the "Your input method has changed to..." bubble. In most cases
481 // it uses the same name as the short name, unless found in a table
482 // for medium length names.
483 for (size_t i = 0; i < kMappingImeIdToMediumLenNameResourceIdLen; ++i) {
484 if (extension_ime_util::GetInputMethodIDByEngineID(
485 kMappingImeIdToMediumLenNameResourceId[i].engine_id) ==
486 input_method.id()) {
487 return delegate_->GetLocalizedString(
488 kMappingImeIdToMediumLenNameResourceId[i].resource_id);
491 return GetInputMethodShortName(input_method);
494 base::string16 InputMethodUtil::GetInputMethodLongNameInternal(
495 const InputMethodDescriptor& input_method, bool short_name) const {
496 std::string localized_display_name = GetLocalizedDisplayName(input_method);
497 if (!localized_display_name.empty() && !IsKeyboardLayout(input_method.id())) {
498 // If the descriptor has a name, use it.
499 return base::UTF8ToUTF16(localized_display_name);
502 // We don't show language here. Name of keyboard layout or input method
503 // usually imply (or explicitly include) its language.
504 // Special case for German, French and Dutch: these languages have multiple
505 // keyboard layouts and share the same layout of keyboard (Belgian). We need
506 // to show explicitly the language for the layout.
507 DCHECK(!input_method.language_codes().empty());
508 const std::string language_code = input_method.language_codes().at(0);
510 base::string16 text = (short_name || localized_display_name.empty())
511 ? TranslateString(input_method.id())
512 : base::UTF8ToUTF16(localized_display_name);
513 if (language_code == "de" || language_code == "fr" || language_code == "nl") {
514 const base::string16 language_name = delegate_->GetDisplayLanguageName(
515 language_code);
516 text = language_name + base::UTF8ToUTF16(" - ") + text;
519 DCHECK(!text.empty());
520 return text;
524 base::string16 InputMethodUtil::GetInputMethodLongNameStripped(
525 const InputMethodDescriptor& input_method) const {
526 return GetInputMethodLongNameInternal(input_method, true /* short_name */);
529 base::string16 InputMethodUtil::GetInputMethodLongName(
530 const InputMethodDescriptor& input_method) const {
531 return GetInputMethodLongNameInternal(input_method, false /* short_name */);
534 const InputMethodDescriptor* InputMethodUtil::GetInputMethodDescriptorFromId(
535 const std::string& input_method_id) const {
536 InputMethodIdToDescriptorMap::const_iterator iter =
537 id_to_descriptor_.find(input_method_id);
538 if (iter == id_to_descriptor_.end())
539 return NULL;
540 return &(iter->second);
543 bool InputMethodUtil::GetInputMethodIdsFromLanguageCode(
544 const std::string& normalized_language_code,
545 InputMethodType type,
546 std::vector<std::string>* out_input_method_ids) const {
547 return GetInputMethodIdsFromLanguageCodeInternal(
548 language_code_to_ids_,
549 normalized_language_code, type, out_input_method_ids);
552 bool InputMethodUtil::GetInputMethodIdsFromLanguageCodeInternal(
553 const std::multimap<std::string, std::string>& language_code_to_ids,
554 const std::string& normalized_language_code,
555 InputMethodType type,
556 std::vector<std::string>* out_input_method_ids) const {
557 DCHECK(out_input_method_ids);
558 out_input_method_ids->clear();
560 bool result = false;
561 std::pair<LanguageCodeToIdsMap::const_iterator,
562 LanguageCodeToIdsMap::const_iterator> range =
563 language_code_to_ids.equal_range(normalized_language_code);
564 for (LanguageCodeToIdsMap::const_iterator iter = range.first;
565 iter != range.second; ++iter) {
566 const std::string& input_method_id = iter->second;
567 if ((type == kAllInputMethods) || IsKeyboardLayout(input_method_id)) {
568 out_input_method_ids->push_back(input_method_id);
569 result = true;
572 if ((type == kAllInputMethods) && !result) {
573 DVLOG(1) << "Unknown language code: " << normalized_language_code;
575 return result;
578 void InputMethodUtil::GetFirstLoginInputMethodIds(
579 const std::string& language_code,
580 const InputMethodDescriptor& preferred_input_method,
581 std::vector<std::string>* out_input_method_ids) const {
582 out_input_method_ids->clear();
584 // First, add the preferred keyboard layout (e.g. one used on the login
585 // screen or set in UserContext when starting a public session).
586 out_input_method_ids->push_back(preferred_input_method.id());
588 const std::string current_layout
589 = preferred_input_method.GetPreferredKeyboardLayout();
590 for (size_t i = 0; i < arraysize(kDefaultInputMethodRecommendation);
591 ++i) {
592 if (kDefaultInputMethodRecommendation[i].locale == language_code && (
593 !kDefaultInputMethodRecommendation[i].layout[0] ||
594 kDefaultInputMethodRecommendation[i].layout == current_layout)) {
595 out_input_method_ids->push_back(
596 extension_ime_util::GetInputMethodIDByEngineID(
597 kDefaultInputMethodRecommendation[i].engine_id));
598 return;
602 std::vector<std::string> input_method_ids;
603 GetInputMethodIdsFromLanguageCode(
604 language_code, kAllInputMethods, &input_method_ids);
605 // Uses the first input method as the most popular one.
606 if (input_method_ids.size() > 0 &&
607 preferred_input_method.id() != input_method_ids[0]) {
608 out_input_method_ids->push_back(input_method_ids[0]);
612 void InputMethodUtil::GetLanguageCodesFromInputMethodIds(
613 const std::vector<std::string>& input_method_ids,
614 std::vector<std::string>* out_language_codes) const {
615 out_language_codes->clear();
617 for (size_t i = 0; i < input_method_ids.size(); ++i) {
618 const std::string& input_method_id = input_method_ids[i];
619 const InputMethodDescriptor* input_method =
620 GetInputMethodDescriptorFromId(input_method_id);
621 if (!input_method) {
622 DVLOG(1) << "Unknown input method ID: " << input_method_ids[i];
623 continue;
625 DCHECK(!input_method->language_codes().empty());
626 const std::string language_code = input_method->language_codes().at(0);
627 // Add it if it's not already present.
628 if (std::count(out_language_codes->begin(), out_language_codes->end(),
629 language_code) == 0) {
630 out_language_codes->push_back(language_code);
635 std::string InputMethodUtil::GetLanguageDefaultInputMethodId(
636 const std::string& language_code) {
637 std::vector<std::string> candidates;
638 GetInputMethodIdsFromLanguageCode(
639 language_code, input_method::kKeyboardLayoutsOnly, &candidates);
640 if (candidates.size())
641 return candidates.front();
643 return std::string();
646 std::string InputMethodUtil::MigrateInputMethod(
647 const std::string& input_method_id) {
648 std::string engine_id = input_method_id;
649 // Migrates some Engine IDs from VPD.
650 for (size_t j = 0; j < arraysize(kEngineIdMigrationMap); ++j) {
651 size_t pos = engine_id.find(kEngineIdMigrationMap[j][0]);
652 if (pos == 0) {
653 engine_id.replace(0,
654 strlen(kEngineIdMigrationMap[j][0]),
655 kEngineIdMigrationMap[j][1]);
656 break;
659 // Migrates the extension IDs.
660 std::string id =
661 extension_ime_util::GetInputMethodIDByEngineID(engine_id);
662 if (extension_ime_util::IsComponentExtensionIME(id)) {
663 std::string id_new = extension_ime_util::GetInputMethodIDByEngineID(
664 extension_ime_util::GetComponentIDByInputMethodID(id));
665 if (extension_ime_util::IsComponentExtensionIME(id_new))
666 id = id_new;
668 return id;
671 bool InputMethodUtil::MigrateInputMethods(
672 std::vector<std::string>* input_method_ids) {
673 bool rewritten = false;
674 std::vector<std::string>& ids = *input_method_ids;
675 for (size_t i = 0; i < ids.size(); ++i) {
676 std::string id = MigrateInputMethod(ids[i]);
677 if (id != ids[i]) {
678 ids[i] = id;
679 rewritten = true;
682 if (rewritten) {
683 // Removes the duplicates.
684 std::vector<std::string> new_ids;
685 for (size_t i = 0; i < ids.size(); ++i) {
686 if (std::find(new_ids.begin(), new_ids.end(), ids[i]) == new_ids.end())
687 new_ids.push_back(ids[i]);
689 ids.swap(new_ids);
691 return rewritten;
694 void InputMethodUtil::UpdateHardwareLayoutCache() {
695 DCHECK(thread_checker_.CalledOnValidThread());
696 hardware_layouts_.clear();
697 hardware_login_layouts_.clear();
698 if (cached_hardware_layouts_.empty()) {
699 cached_hardware_layouts_ =
700 base::SplitString(delegate_->GetHardwareKeyboardLayouts(), ",",
701 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
703 hardware_layouts_ = cached_hardware_layouts_;
704 MigrateInputMethods(&hardware_layouts_);
706 for (size_t i = 0; i < hardware_layouts_.size(); ++i) {
707 if (IsLoginKeyboard(hardware_layouts_[i]))
708 hardware_login_layouts_.push_back(hardware_layouts_[i]);
711 if (hardware_login_layouts_.empty()) {
712 // This is totally fine if |hardware_layouts_| is empty. The hardware
713 // keyboard layout is not stored if startup_manifest.json
714 // (OEM customization data) is not present (ex. Cr48 doen't have that file).
715 // So need to make sure |hardware_login_layouts_| is not empty, and
716 // |hardware_layouts_| contains at least one login layout.
717 std::string fallback_id = GetFallbackInputMethodDescriptor().id();
718 hardware_layouts_.insert(hardware_layouts_.begin(), fallback_id);
719 hardware_login_layouts_.push_back(fallback_id);
723 void InputMethodUtil::SetHardwareKeyboardLayoutForTesting(
724 const std::string& layout) {
725 delegate_->SetHardwareKeyboardLayoutForTesting(layout);
726 cached_hardware_layouts_.clear();
727 UpdateHardwareLayoutCache();
730 const std::vector<std::string>&
731 InputMethodUtil::GetHardwareInputMethodIds() {
732 DCHECK(thread_checker_.CalledOnValidThread());
733 UpdateHardwareLayoutCache();
734 return hardware_layouts_;
737 const std::vector<std::string>&
738 InputMethodUtil::GetHardwareLoginInputMethodIds() {
739 DCHECK(thread_checker_.CalledOnValidThread());
740 UpdateHardwareLayoutCache();
741 return hardware_login_layouts_;
744 bool InputMethodUtil::IsLoginKeyboard(const std::string& input_method_id)
745 const {
746 const InputMethodDescriptor* ime =
747 GetInputMethodDescriptorFromId(input_method_id);
748 return ime ? ime->is_login_keyboard() : false;
751 void InputMethodUtil::AppendInputMethods(const InputMethodDescriptors& imes) {
752 for (size_t i = 0; i < imes.size(); ++i) {
753 const InputMethodDescriptor& input_method = imes[i];
754 DCHECK(!input_method.language_codes().empty());
755 const std::vector<std::string>& language_codes =
756 input_method.language_codes();
757 id_to_descriptor_[input_method.id()] = input_method;
759 typedef LanguageCodeToIdsMap::const_iterator It;
760 for (size_t j = 0; j < language_codes.size(); ++j) {
761 std::pair<It, It> range =
762 language_code_to_ids_.equal_range(language_codes[j]);
763 It it = range.first;
764 for (; it != range.second; ++it) {
765 if (it->second == input_method.id())
766 break;
768 if (it == range.second)
769 language_code_to_ids_.insert(
770 std::make_pair(language_codes[j], input_method.id()));
775 void InputMethodUtil::ResetInputMethods(const InputMethodDescriptors& imes) {
776 // Clear the existing maps.
777 language_code_to_ids_.clear();
778 id_to_descriptor_.clear();
780 AppendInputMethods(imes);
783 void InputMethodUtil::InitXkbInputMethodsForTesting() {
784 cached_hardware_layouts_.clear();
785 ResetInputMethods(*(InputMethodWhitelist().GetSupportedInputMethods()));
788 const InputMethodUtil::InputMethodIdToDescriptorMap&
789 InputMethodUtil::GetIdToDesciptorMapForTesting() {
790 return id_to_descriptor_;
793 InputMethodDescriptor InputMethodUtil::GetFallbackInputMethodDescriptor() {
794 std::vector<std::string> layouts;
795 layouts.push_back("us");
796 std::vector<std::string> languages;
797 languages.push_back("en-US");
798 return InputMethodDescriptor(
799 extension_ime_util::GetInputMethodIDByEngineID("xkb:us::eng"),
801 "US",
802 layouts,
803 languages,
804 true, // login keyboard.
805 GURL(), // options page, not available.
806 GURL()); // input view page, not available.
809 } // namespace input_method
810 } // namespace chromeos