OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/chrome_browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 } | 445 } |
446 } | 446 } |
447 | 447 |
448 class GuestLanguageSetCallbackData { | 448 class GuestLanguageSetCallbackData { |
449 public: | 449 public: |
450 explicit GuestLanguageSetCallbackData(Profile* profile) : profile(profile) { | 450 explicit GuestLanguageSetCallbackData(Profile* profile) : profile(profile) { |
451 } | 451 } |
452 | 452 |
453 // Must match SwitchLanguageCallback type. | 453 // Must match SwitchLanguageCallback type. |
454 static void Callback(const scoped_ptr<GuestLanguageSetCallbackData>& self, | 454 static void Callback(const scoped_ptr<GuestLanguageSetCallbackData>& self, |
455 const locale_util::LanguageSwitchResult& result); | 455 const std::string& locale, |
| 456 const std::string& loaded_locale, |
| 457 bool success); |
456 | 458 |
457 Profile* profile; | 459 Profile* profile; |
458 }; | 460 }; |
459 | 461 |
460 // static | 462 // static |
461 void GuestLanguageSetCallbackData::Callback( | 463 void GuestLanguageSetCallbackData::Callback( |
462 const scoped_ptr<GuestLanguageSetCallbackData>& self, | 464 const scoped_ptr<GuestLanguageSetCallbackData>& self, |
463 const locale_util::LanguageSwitchResult& result) { | 465 const std::string& locale, |
| 466 const std::string& loaded_locale, |
| 467 bool success) { |
464 input_method::InputMethodManager* manager = | 468 input_method::InputMethodManager* manager = |
465 input_method::InputMethodManager::Get(); | 469 input_method::InputMethodManager::Get(); |
466 scoped_refptr<input_method::InputMethodManager::State> ime_state = | 470 scoped_refptr<input_method::InputMethodManager::State> ime_state = |
467 manager->GetActiveIMEState(); | 471 manager->GetActiveIMEState(); |
468 // Active layout must be hardware "login layout". | 472 // Active layout must be hardware "login layout". |
469 // The previous one must be "locale default layout". | 473 // The previous one must be "locale default layout". |
470 // First, enable all hardware input methods. | 474 // First, enable all hardware input methods. |
471 const std::vector<std::string>& input_methods = | 475 const std::vector<std::string>& input_methods = |
472 manager->GetInputMethodUtil()->GetHardwareInputMethodIds(); | 476 manager->GetInputMethodUtil()->GetHardwareInputMethodIds(); |
473 for (size_t i = 0; i < input_methods.size(); ++i) | 477 for (size_t i = 0; i < input_methods.size(); ++i) |
474 ime_state->EnableInputMethod(input_methods[i]); | 478 ime_state->EnableInputMethod(input_methods[i]); |
475 | 479 |
476 // Second, enable locale based input methods. | 480 // Second, enable locale based input methods. |
477 const std::string locale_default_input_method = | 481 const std::string locale_default_input_method = |
478 manager->GetInputMethodUtil()->GetLanguageDefaultInputMethodId( | 482 manager->GetInputMethodUtil()->GetLanguageDefaultInputMethodId( |
479 result.loaded_locale); | 483 loaded_locale); |
480 if (!locale_default_input_method.empty()) { | 484 if (!locale_default_input_method.empty()) { |
481 PrefService* user_prefs = self->profile->GetPrefs(); | 485 PrefService* user_prefs = self->profile->GetPrefs(); |
482 user_prefs->SetString(prefs::kLanguagePreviousInputMethod, | 486 user_prefs->SetString(prefs::kLanguagePreviousInputMethod, |
483 locale_default_input_method); | 487 locale_default_input_method); |
484 ime_state->EnableInputMethod(locale_default_input_method); | 488 ime_state->EnableInputMethod(locale_default_input_method); |
485 } | 489 } |
486 | 490 |
487 // Finally, activate the first login input method. | 491 // Finally, activate the first login input method. |
488 const std::vector<std::string>& login_input_methods = | 492 const std::vector<std::string>& login_input_methods = |
489 manager->GetInputMethodUtil()->GetHardwareLoginInputMethodIds(); | 493 manager->GetInputMethodUtil()->GetHardwareLoginInputMethodIds(); |
490 ime_state->ChangeInputMethod(login_input_methods[0], | 494 ime_state->ChangeInputMethod(login_input_methods[0], |
491 false /* show_message */); | 495 false /* show_message */); |
492 } | 496 } |
493 | 497 |
494 void SetGuestLocale(Profile* const profile) { | 498 void SetGuestLocale(Profile* const profile) { |
495 scoped_ptr<GuestLanguageSetCallbackData> data( | 499 scoped_ptr<GuestLanguageSetCallbackData> data( |
496 new GuestLanguageSetCallbackData(profile)); | 500 new GuestLanguageSetCallbackData(profile)); |
497 locale_util::SwitchLanguageCallback callback(base::Bind( | 501 scoped_ptr<locale_util::SwitchLanguageCallback> callback( |
498 &GuestLanguageSetCallbackData::Callback, base::Passed(data.Pass()))); | 502 new locale_util::SwitchLanguageCallback(base::Bind( |
| 503 &GuestLanguageSetCallbackData::Callback, base::Passed(data.Pass())))); |
499 user_manager::User* const user = | 504 user_manager::User* const user = |
500 ProfileHelper::Get()->GetUserByProfile(profile); | 505 ProfileHelper::Get()->GetUserByProfile(profile); |
501 UserSessionManager::GetInstance()->RespectLocalePreference( | 506 UserSessionManager::GetInstance()->RespectLocalePreference( |
502 profile, user, callback); | 507 profile, user, callback.Pass()); |
503 } | 508 } |
504 | 509 |
505 void ChromeBrowserMainPartsChromeos::PostProfileInit() { | 510 void ChromeBrowserMainPartsChromeos::PostProfileInit() { |
506 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() | 511 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() |
507 // -- just after CreateProfile(). | 512 // -- just after CreateProfile(). |
508 | 513 |
509 BootTimesLoader::Get()->OnChromeProcessStart(); | 514 BootTimesLoader::Get()->OnChromeProcessStart(); |
510 | 515 |
511 // Initialize the network portal detector for Chrome OS. The network | 516 // Initialize the network portal detector for Chrome OS. The network |
512 // portal detector starts to listen for notifications from | 517 // portal detector starts to listen for notifications from |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 // Destroy DBus services immediately after threads are stopped. | 766 // Destroy DBus services immediately after threads are stopped. |
762 dbus_services_.reset(); | 767 dbus_services_.reset(); |
763 | 768 |
764 ChromeBrowserMainPartsLinux::PostDestroyThreads(); | 769 ChromeBrowserMainPartsLinux::PostDestroyThreads(); |
765 | 770 |
766 // Destroy DeviceSettingsService after g_browser_process. | 771 // Destroy DeviceSettingsService after g_browser_process. |
767 DeviceSettingsService::Shutdown(); | 772 DeviceSettingsService::Shutdown(); |
768 } | 773 } |
769 | 774 |
770 } // namespace chromeos | 775 } // namespace chromeos |
OLD | NEW |