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 26 matching lines...) Expand all Loading... |
37 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
38 | 38 |
39 namespace chromeos { | 39 namespace chromeos { |
40 | 40 |
41 const char kMostRelevantLanguagesDivider[] = "MOST_RELEVANT_LANGUAGES_DIVIDER"; | 41 const char kMostRelevantLanguagesDivider[] = "MOST_RELEVANT_LANGUAGES_DIVIDER"; |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 const char kSequenceToken[] = "chromeos_login_l10n_util"; | 45 const char kSequenceToken[] = "chromeos_login_l10n_util"; |
46 | 46 |
47 scoped_ptr<base::DictionaryValue> CreateInputMethodsEntry( | 47 std::unique_ptr<base::DictionaryValue> CreateInputMethodsEntry( |
48 const input_method::InputMethodDescriptor& method, | 48 const input_method::InputMethodDescriptor& method, |
49 const std::string selected) { | 49 const std::string selected) { |
50 input_method::InputMethodUtil* util = | 50 input_method::InputMethodUtil* util = |
51 input_method::InputMethodManager::Get()->GetInputMethodUtil(); | 51 input_method::InputMethodManager::Get()->GetInputMethodUtil(); |
52 const std::string& ime_id = method.id(); | 52 const std::string& ime_id = method.id(); |
53 scoped_ptr<base::DictionaryValue> input_method(new base::DictionaryValue); | 53 std::unique_ptr<base::DictionaryValue> input_method( |
| 54 new base::DictionaryValue); |
54 input_method->SetString("value", ime_id); | 55 input_method->SetString("value", ime_id); |
55 input_method->SetString( | 56 input_method->SetString( |
56 "title", util->GetInputMethodLongNameStripped(method)); | 57 "title", util->GetInputMethodLongNameStripped(method)); |
57 input_method->SetBoolean("selected", ime_id == selected); | 58 input_method->SetBoolean("selected", ime_id == selected); |
58 return input_method; | 59 return input_method; |
59 } | 60 } |
60 | 61 |
61 // Returns true if element was inserted. | 62 // Returns true if element was inserted. |
62 bool InsertString(const std::string& str, std::set<std::string>* to) { | 63 bool InsertString(const std::string& str, std::set<std::string>* to) { |
63 const std::pair<std::set<std::string>::iterator, bool> result = | 64 const std::pair<std::set<std::string>::iterator, bool> result = |
64 to->insert(str); | 65 to->insert(str); |
65 return result.second; | 66 return result.second; |
66 } | 67 } |
67 | 68 |
68 void AddOptgroupOtherLayouts(base::ListValue* input_methods_list) { | 69 void AddOptgroupOtherLayouts(base::ListValue* input_methods_list) { |
69 scoped_ptr<base::DictionaryValue> optgroup(new base::DictionaryValue); | 70 std::unique_ptr<base::DictionaryValue> optgroup(new base::DictionaryValue); |
70 optgroup->SetString( | 71 optgroup->SetString( |
71 "optionGroupName", | 72 "optionGroupName", |
72 l10n_util::GetStringUTF16(IDS_OOBE_OTHER_KEYBOARD_LAYOUTS)); | 73 l10n_util::GetStringUTF16(IDS_OOBE_OTHER_KEYBOARD_LAYOUTS)); |
73 input_methods_list->Append(optgroup.release()); | 74 input_methods_list->Append(optgroup.release()); |
74 } | 75 } |
75 | 76 |
76 base::DictionaryValue* CreateLanguageEntry( | 77 base::DictionaryValue* CreateLanguageEntry( |
77 const std::string& language_code, | 78 const std::string& language_code, |
78 const base::string16& language_display_name, | 79 const base::string16& language_display_name, |
79 const base::string16& language_native_display_name) { | 80 const base::string16& language_native_display_name) { |
80 base::string16 display_name = language_display_name; | 81 base::string16 display_name = language_display_name; |
81 const bool markup_removal = | 82 const bool markup_removal = |
82 base::i18n::UnadjustStringForLocaleDirection(&display_name); | 83 base::i18n::UnadjustStringForLocaleDirection(&display_name); |
83 DCHECK(markup_removal); | 84 DCHECK(markup_removal); |
84 | 85 |
85 const bool has_rtl_chars = | 86 const bool has_rtl_chars = |
86 base::i18n::StringContainsStrongRTLChars(display_name); | 87 base::i18n::StringContainsStrongRTLChars(display_name); |
87 const std::string directionality = has_rtl_chars ? "rtl" : "ltr"; | 88 const std::string directionality = has_rtl_chars ? "rtl" : "ltr"; |
88 | 89 |
89 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue()); | 90 std::unique_ptr<base::DictionaryValue> dictionary( |
| 91 new base::DictionaryValue()); |
90 dictionary->SetString("code", language_code); | 92 dictionary->SetString("code", language_code); |
91 dictionary->SetString("displayName", language_display_name); | 93 dictionary->SetString("displayName", language_display_name); |
92 dictionary->SetString("textDirection", directionality); | 94 dictionary->SetString("textDirection", directionality); |
93 dictionary->SetString("nativeDisplayName", language_native_display_name); | 95 dictionary->SetString("nativeDisplayName", language_native_display_name); |
94 return dictionary.release(); | 96 return dictionary.release(); |
95 } | 97 } |
96 | 98 |
97 // Gets the list of languages with |descriptors| based on |base_language_codes|. | 99 // Gets the list of languages with |descriptors| based on |base_language_codes|. |
98 // The |most_relevant_language_codes| will be first in the list. If | 100 // The |most_relevant_language_codes| will be first in the list. If |
99 // |insert_divider| is true, an entry with its "code" attribute set to | 101 // |insert_divider| is true, an entry with its "code" attribute set to |
100 // kMostRelevantLanguagesDivider is placed between the most relevant languages | 102 // kMostRelevantLanguagesDivider is placed between the most relevant languages |
101 // and all others. | 103 // and all others. |
102 scoped_ptr<base::ListValue> GetLanguageList( | 104 std::unique_ptr<base::ListValue> GetLanguageList( |
103 const input_method::InputMethodDescriptors& descriptors, | 105 const input_method::InputMethodDescriptors& descriptors, |
104 const std::vector<std::string>& base_language_codes, | 106 const std::vector<std::string>& base_language_codes, |
105 const std::vector<std::string>& most_relevant_language_codes, | 107 const std::vector<std::string>& most_relevant_language_codes, |
106 bool insert_divider) { | 108 bool insert_divider) { |
107 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 109 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
108 | 110 |
109 std::set<std::string> language_codes; | 111 std::set<std::string> language_codes; |
110 // Collect the language codes from the supported input methods. | 112 // Collect the language codes from the supported input methods. |
111 for (size_t i = 0; i < descriptors.size(); ++i) { | 113 for (size_t i = 0; i < descriptors.size(); ++i) { |
112 const input_method::InputMethodDescriptor& descriptor = descriptors[i]; | 114 const input_method::InputMethodDescriptor& descriptor = descriptors[i]; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // |most_relevant_locales_display_names| is not empty. | 255 // |most_relevant_locales_display_names| is not empty. |
254 divider16 = base::ASCIIToUTF16(kMostRelevantLanguagesDivider); | 256 divider16 = base::ASCIIToUTF16(kMostRelevantLanguagesDivider); |
255 out_display_names.push_back(divider16); | 257 out_display_names.push_back(divider16); |
256 } | 258 } |
257 | 259 |
258 std::copy(display_names.begin(), | 260 std::copy(display_names.begin(), |
259 display_names.end(), | 261 display_names.end(), |
260 std::back_inserter(out_display_names)); | 262 std::back_inserter(out_display_names)); |
261 | 263 |
262 // Build the language list from the language map. | 264 // Build the language list from the language map. |
263 scoped_ptr<base::ListValue> language_list(new base::ListValue()); | 265 std::unique_ptr<base::ListValue> language_list(new base::ListValue()); |
264 for (size_t i = 0; i < out_display_names.size(); ++i) { | 266 for (size_t i = 0; i < out_display_names.size(); ++i) { |
265 // Sets the directionality of the display language name. | 267 // Sets the directionality of the display language name. |
266 base::string16 display_name(out_display_names[i]); | 268 base::string16 display_name(out_display_names[i]); |
267 if (insert_divider && display_name == divider16) { | 269 if (insert_divider && display_name == divider16) { |
268 // Insert divider. | 270 // Insert divider. |
269 base::DictionaryValue* dictionary = new base::DictionaryValue(); | 271 base::DictionaryValue* dictionary = new base::DictionaryValue(); |
270 dictionary->SetString("code", kMostRelevantLanguagesDivider); | 272 dictionary->SetString("code", kMostRelevantLanguagesDivider); |
271 language_list->Append(dictionary); | 273 language_list->Append(dictionary); |
272 continue; | 274 continue; |
273 } | 275 } |
(...skipping 21 matching lines...) Expand all Loading... |
295 &layouts_from_locale); | 297 &layouts_from_locale); |
296 layouts.insert(layouts.end(), layouts_from_locale.begin(), | 298 layouts.insert(layouts.end(), layouts_from_locale.begin(), |
297 layouts_from_locale.end()); | 299 layouts_from_locale.end()); |
298 | 300 |
299 std::string selected; | 301 std::string selected; |
300 if (!layouts_from_locale.empty()) { | 302 if (!layouts_from_locale.empty()) { |
301 selected = | 303 selected = |
302 util->GetInputMethodDescriptorFromId(layouts_from_locale[0])->id(); | 304 util->GetInputMethodDescriptorFromId(layouts_from_locale[0])->id(); |
303 } | 305 } |
304 | 306 |
305 scoped_ptr<base::ListValue> input_methods_list(new base::ListValue); | 307 std::unique_ptr<base::ListValue> input_methods_list(new base::ListValue); |
306 std::set<std::string> input_methods_added; | 308 std::set<std::string> input_methods_added; |
307 for (std::vector<std::string>::const_iterator it = layouts.begin(); | 309 for (std::vector<std::string>::const_iterator it = layouts.begin(); |
308 it != layouts.end(); ++it) { | 310 it != layouts.end(); ++it) { |
309 const input_method::InputMethodDescriptor* ime = | 311 const input_method::InputMethodDescriptor* ime = |
310 util->GetInputMethodDescriptorFromId(*it); | 312 util->GetInputMethodDescriptorFromId(*it); |
311 if (!InsertString(ime->id(), &input_methods_added)) | 313 if (!InsertString(ime->id(), &input_methods_added)) |
312 continue; | 314 continue; |
313 input_methods_list->Append( | 315 input_methods_list->Append( |
314 CreateInputMethodsEntry(*ime, selected).release()); | 316 CreateInputMethodsEntry(*ime, selected).release()); |
315 } | 317 } |
(...skipping 11 matching lines...) Expand all Loading... |
327 if (!l10n_util::CheckAndResolveLocale(requested_locale, &resolved_locale)) | 329 if (!l10n_util::CheckAndResolveLocale(requested_locale, &resolved_locale)) |
328 return loaded_locale; | 330 return loaded_locale; |
329 | 331 |
330 if (resolved_locale == loaded_locale) | 332 if (resolved_locale == loaded_locale) |
331 return requested_locale; | 333 return requested_locale; |
332 | 334 |
333 return loaded_locale; | 335 return loaded_locale; |
334 } | 336 } |
335 | 337 |
336 void ResolveLanguageListOnBlockingPool( | 338 void ResolveLanguageListOnBlockingPool( |
337 scoped_ptr<chromeos::locale_util::LanguageSwitchResult> | 339 std::unique_ptr<chromeos::locale_util::LanguageSwitchResult> |
338 language_switch_result, | 340 language_switch_result, |
339 const scoped_refptr<base::TaskRunner> task_runner, | 341 const scoped_refptr<base::TaskRunner> task_runner, |
340 const UILanguageListResolvedCallback& resolved_callback) { | 342 const UILanguageListResolvedCallback& resolved_callback) { |
341 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 343 DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
342 | 344 |
343 std::string selected_language; | 345 std::string selected_language; |
344 if (!language_switch_result) { | 346 if (!language_switch_result) { |
345 selected_language = | 347 selected_language = |
346 StartupCustomizationDocument::GetInstance()->initial_locale_default(); | 348 StartupCustomizationDocument::GetInstance()->initial_locale_default(); |
347 } else { | 349 } else { |
(...skipping 10 matching lines...) Expand all Loading... |
358 selected_language = language_switch_result->loaded_locale; | 360 selected_language = language_switch_result->loaded_locale; |
359 } | 361 } |
360 } | 362 } |
361 const std::string selected_code = | 363 const std::string selected_code = |
362 selected_language.empty() ? g_browser_process->GetApplicationLocale() | 364 selected_language.empty() ? g_browser_process->GetApplicationLocale() |
363 : selected_language; | 365 : selected_language; |
364 | 366 |
365 const std::string list_locale = | 367 const std::string list_locale = |
366 language_switch_result ? language_switch_result->loaded_locale | 368 language_switch_result ? language_switch_result->loaded_locale |
367 : g_browser_process->GetApplicationLocale(); | 369 : g_browser_process->GetApplicationLocale(); |
368 scoped_ptr<base::ListValue> language_list( | 370 std::unique_ptr<base::ListValue> language_list( |
369 chromeos::GetUILanguageList(nullptr, selected_code)); | 371 chromeos::GetUILanguageList(nullptr, selected_code)); |
370 | 372 |
371 task_runner->PostTask( | 373 task_runner->PostTask( |
372 FROM_HERE, base::Bind(resolved_callback, base::Passed(&language_list), | 374 FROM_HERE, base::Bind(resolved_callback, base::Passed(&language_list), |
373 list_locale, selected_language)); | 375 list_locale, selected_language)); |
374 } | 376 } |
375 | 377 |
376 void AdjustUILanguageList(const std::string& selected, | 378 void AdjustUILanguageList(const std::string& selected, |
377 base::ListValue* languages_list) { | 379 base::ListValue* languages_list) { |
378 for (size_t i = 0; i < languages_list->GetSize(); ++i) { | 380 for (size_t i = 0; i < languages_list->GetSize(); ++i) { |
(...skipping 23 matching lines...) Expand all Loading... |
402 language_info->SetString("value", value); | 404 language_info->SetString("value", value); |
403 language_info->SetString("title", display_name); | 405 language_info->SetString("title", display_name); |
404 if (value == selected) | 406 if (value == selected) |
405 language_info->SetBoolean("selected", true); | 407 language_info->SetBoolean("selected", true); |
406 } | 408 } |
407 } | 409 } |
408 | 410 |
409 } // namespace | 411 } // namespace |
410 | 412 |
411 void ResolveUILanguageList( | 413 void ResolveUILanguageList( |
412 scoped_ptr<chromeos::locale_util::LanguageSwitchResult> | 414 std::unique_ptr<chromeos::locale_util::LanguageSwitchResult> |
413 language_switch_result, | 415 language_switch_result, |
414 const UILanguageListResolvedCallback& callback) { | 416 const UILanguageListResolvedCallback& callback) { |
415 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 417 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
416 | 418 |
417 content::BrowserThread::GetBlockingPool()->PostTask( | 419 content::BrowserThread::GetBlockingPool()->PostTask( |
418 FROM_HERE, base::Bind(&ResolveLanguageListOnBlockingPool, | 420 FROM_HERE, base::Bind(&ResolveLanguageListOnBlockingPool, |
419 base::Passed(&language_switch_result), | 421 base::Passed(&language_switch_result), |
420 base::ThreadTaskRunnerHandle::Get(), callback)); | 422 base::ThreadTaskRunnerHandle::Get(), callback)); |
421 } | 423 } |
422 | 424 |
423 scoped_ptr<base::ListValue> GetMinimalUILanguageList() { | 425 std::unique_ptr<base::ListValue> GetMinimalUILanguageList() { |
424 const std::string application_locale = | 426 const std::string application_locale = |
425 g_browser_process->GetApplicationLocale(); | 427 g_browser_process->GetApplicationLocale(); |
426 base::string16 language_native_display_name = | 428 base::string16 language_native_display_name = |
427 l10n_util::GetDisplayNameForLocale( | 429 l10n_util::GetDisplayNameForLocale( |
428 application_locale, application_locale, true); | 430 application_locale, application_locale, true); |
429 | 431 |
430 scoped_ptr<base::ListValue> language_list(new base::ListValue()); | 432 std::unique_ptr<base::ListValue> language_list(new base::ListValue()); |
431 language_list->Append(CreateLanguageEntry(application_locale, | 433 language_list->Append(CreateLanguageEntry(application_locale, |
432 language_native_display_name, | 434 language_native_display_name, |
433 language_native_display_name)); | 435 language_native_display_name)); |
434 AdjustUILanguageList(std::string(), language_list.get()); | 436 AdjustUILanguageList(std::string(), language_list.get()); |
435 return language_list; | 437 return language_list; |
436 } | 438 } |
437 | 439 |
438 scoped_ptr<base::ListValue> GetUILanguageList( | 440 std::unique_ptr<base::ListValue> GetUILanguageList( |
439 const std::vector<std::string>* most_relevant_language_codes, | 441 const std::vector<std::string>* most_relevant_language_codes, |
440 const std::string& selected) { | 442 const std::string& selected) { |
441 ComponentExtensionIMEManager* manager = | 443 ComponentExtensionIMEManager* manager = |
442 input_method::InputMethodManager::Get() | 444 input_method::InputMethodManager::Get() |
443 ->GetComponentExtensionIMEManager(); | 445 ->GetComponentExtensionIMEManager(); |
444 input_method::InputMethodDescriptors descriptors = | 446 input_method::InputMethodDescriptors descriptors = |
445 manager->GetXkbIMEAsInputMethodDescriptor(); | 447 manager->GetXkbIMEAsInputMethodDescriptor(); |
446 scoped_ptr<base::ListValue> languages_list(GetLanguageList( | 448 std::unique_ptr<base::ListValue> languages_list(GetLanguageList( |
447 descriptors, | 449 descriptors, l10n_util::GetAvailableLocales(), |
448 l10n_util::GetAvailableLocales(), | |
449 most_relevant_language_codes | 450 most_relevant_language_codes |
450 ? *most_relevant_language_codes | 451 ? *most_relevant_language_codes |
451 : StartupCustomizationDocument::GetInstance()->configured_locales(), | 452 : StartupCustomizationDocument::GetInstance()->configured_locales(), |
452 true)); | 453 true)); |
453 AdjustUILanguageList(selected, languages_list.get()); | 454 AdjustUILanguageList(selected, languages_list.get()); |
454 return languages_list; | 455 return languages_list; |
455 } | 456 } |
456 | 457 |
457 std::string FindMostRelevantLocale( | 458 std::string FindMostRelevantLocale( |
458 const std::vector<std::string>& most_relevant_language_codes, | 459 const std::vector<std::string>& most_relevant_language_codes, |
(...skipping 14 matching lines...) Expand all Loading... |
473 continue; | 474 continue; |
474 } | 475 } |
475 if (available_locale == *most_relevant_it) | 476 if (available_locale == *most_relevant_it) |
476 return *most_relevant_it; | 477 return *most_relevant_it; |
477 } | 478 } |
478 } | 479 } |
479 | 480 |
480 return fallback_locale; | 481 return fallback_locale; |
481 } | 482 } |
482 | 483 |
483 scoped_ptr<base::ListValue> GetAcceptLanguageList() { | 484 std::unique_ptr<base::ListValue> GetAcceptLanguageList() { |
484 // Collect the language codes from the supported accept-languages. | 485 // Collect the language codes from the supported accept-languages. |
485 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 486 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
486 std::vector<std::string> accept_language_codes; | 487 std::vector<std::string> accept_language_codes; |
487 l10n_util::GetAcceptLanguagesForLocale(app_locale, &accept_language_codes); | 488 l10n_util::GetAcceptLanguagesForLocale(app_locale, &accept_language_codes); |
488 return GetLanguageList( | 489 return GetLanguageList( |
489 *input_method::InputMethodManager::Get()->GetSupportedInputMethods(), | 490 *input_method::InputMethodManager::Get()->GetSupportedInputMethods(), |
490 accept_language_codes, | 491 accept_language_codes, |
491 StartupCustomizationDocument::GetInstance()->configured_locales(), | 492 StartupCustomizationDocument::GetInstance()->configured_locales(), |
492 false); | 493 false); |
493 } | 494 } |
494 | 495 |
495 scoped_ptr<base::ListValue> GetAndActivateLoginKeyboardLayouts( | 496 std::unique_ptr<base::ListValue> GetAndActivateLoginKeyboardLayouts( |
496 const std::string& locale, | 497 const std::string& locale, |
497 const std::string& selected, | 498 const std::string& selected, |
498 bool activate_keyboards) { | 499 bool activate_keyboards) { |
499 scoped_ptr<base::ListValue> input_methods_list(new base::ListValue); | 500 std::unique_ptr<base::ListValue> input_methods_list(new base::ListValue); |
500 input_method::InputMethodManager* manager = | 501 input_method::InputMethodManager* manager = |
501 input_method::InputMethodManager::Get(); | 502 input_method::InputMethodManager::Get(); |
502 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); | 503 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); |
503 | 504 |
504 const std::vector<std::string>& hardware_login_input_methods = | 505 const std::vector<std::string>& hardware_login_input_methods = |
505 util->GetHardwareLoginInputMethodIds(); | 506 util->GetHardwareLoginInputMethodIds(); |
506 | 507 |
507 if (activate_keyboards) { | 508 if (activate_keyboards) { |
508 DCHECK( | 509 DCHECK( |
509 ProfileHelper::IsSigninProfile(ProfileManager::GetActiveUserProfile())); | 510 ProfileHelper::IsSigninProfile(ProfileManager::GetActiveUserProfile())); |
510 manager->GetActiveIMEState()->EnableLoginLayouts( | 511 manager->GetActiveIMEState()->EnableLoginLayouts( |
511 locale, hardware_login_input_methods); | 512 locale, hardware_login_input_methods); |
512 } | 513 } |
513 | 514 |
514 scoped_ptr<input_method::InputMethodDescriptors> input_methods( | 515 std::unique_ptr<input_method::InputMethodDescriptors> input_methods( |
515 manager->GetActiveIMEState()->GetActiveInputMethods()); | 516 manager->GetActiveIMEState()->GetActiveInputMethods()); |
516 std::set<std::string> input_methods_added; | 517 std::set<std::string> input_methods_added; |
517 | 518 |
518 for (std::vector<std::string>::const_iterator i = | 519 for (std::vector<std::string>::const_iterator i = |
519 hardware_login_input_methods.begin(); | 520 hardware_login_input_methods.begin(); |
520 i != hardware_login_input_methods.end(); | 521 i != hardware_login_input_methods.end(); |
521 ++i) { | 522 ++i) { |
522 const input_method::InputMethodDescriptor* ime = | 523 const input_method::InputMethodDescriptor* ime = |
523 util->GetInputMethodDescriptorFromId(*i); | 524 util->GetInputMethodDescriptorFromId(*i); |
524 // Do not crash in case of misconfiguration. | 525 // Do not crash in case of misconfiguration. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 // thread. | 578 // thread. |
578 std::string (*get_application_locale)(const std::string&, bool) = | 579 std::string (*get_application_locale)(const std::string&, bool) = |
579 &l10n_util::GetApplicationLocale; | 580 &l10n_util::GetApplicationLocale; |
580 base::PostTaskAndReplyWithResult( | 581 base::PostTaskAndReplyWithResult( |
581 background_task_runner.get(), | 582 background_task_runner.get(), |
582 FROM_HERE, | 583 FROM_HERE, |
583 base::Bind(get_application_locale, locale, false /* set_icu_locale */), | 584 base::Bind(get_application_locale, locale, false /* set_icu_locale */), |
584 base::Bind(&GetKeyboardLayoutsForResolvedLocale, callback)); | 585 base::Bind(&GetKeyboardLayoutsForResolvedLocale, callback)); |
585 } | 586 } |
586 | 587 |
587 scoped_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { | 588 std::unique_ptr<base::DictionaryValue> GetCurrentKeyboardLayout() { |
588 const input_method::InputMethodDescriptor current_input_method = | 589 const input_method::InputMethodDescriptor current_input_method = |
589 input_method::InputMethodManager::Get() | 590 input_method::InputMethodManager::Get() |
590 ->GetActiveIMEState() | 591 ->GetActiveIMEState() |
591 ->GetCurrentInputMethod(); | 592 ->GetCurrentInputMethod(); |
592 return CreateInputMethodsEntry(current_input_method, | 593 return CreateInputMethodsEntry(current_input_method, |
593 current_input_method.id()); | 594 current_input_method.id()); |
594 } | 595 } |
595 | 596 |
596 } // namespace chromeos | 597 } // namespace chromeos |
OLD | NEW |