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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 452 |
453 Profile* profile; | 453 Profile* profile; |
454 }; | 454 }; |
455 | 455 |
456 // static | 456 // static |
457 void GuestLanguageSetCallbackData::Callback( | 457 void GuestLanguageSetCallbackData::Callback( |
458 const scoped_ptr<GuestLanguageSetCallbackData>& self, | 458 const scoped_ptr<GuestLanguageSetCallbackData>& self, |
459 const std::string& locale, | 459 const std::string& locale, |
460 const std::string& loaded_locale, | 460 const std::string& loaded_locale, |
461 bool success) { | 461 bool success) { |
462 input_method::InputMethodManager* const ime_manager = | 462 input_method::InputMethodManager* manager = |
463 input_method::InputMethodManager::Get(); | 463 input_method::InputMethodManager::Get(); |
| 464 scoped_refptr<input_method::InputMethodManager::State> ime_state = |
| 465 manager->GetActiveIMEState(); |
464 // Active layout must be hardware "login layout". | 466 // Active layout must be hardware "login layout". |
465 // The previous one must be "locale default layout". | 467 // The previous one must be "locale default layout". |
466 // First, enable all hardware input methods. | 468 // First, enable all hardware input methods. |
467 const std::vector<std::string>& input_methods = | 469 const std::vector<std::string>& input_methods = |
468 ime_manager->GetInputMethodUtil()->GetHardwareInputMethodIds(); | 470 manager->GetInputMethodUtil()->GetHardwareInputMethodIds(); |
469 for (size_t i = 0; i < input_methods.size(); ++i) | 471 for (size_t i = 0; i < input_methods.size(); ++i) |
470 ime_manager->EnableInputMethod(input_methods[i]); | 472 ime_state->EnableInputMethod(input_methods[i]); |
471 | 473 |
472 // Second, enable locale based input methods. | 474 // Second, enable locale based input methods. |
473 const std::string locale_default_input_method = | 475 const std::string locale_default_input_method = |
474 ime_manager->GetInputMethodUtil()-> | 476 manager->GetInputMethodUtil()->GetLanguageDefaultInputMethodId( |
475 GetLanguageDefaultInputMethodId(loaded_locale); | 477 loaded_locale); |
476 if (!locale_default_input_method.empty()) { | 478 if (!locale_default_input_method.empty()) { |
477 PrefService* user_prefs = self->profile->GetPrefs(); | 479 PrefService* user_prefs = self->profile->GetPrefs(); |
478 user_prefs->SetString(prefs::kLanguagePreviousInputMethod, | 480 user_prefs->SetString(prefs::kLanguagePreviousInputMethod, |
479 locale_default_input_method); | 481 locale_default_input_method); |
480 ime_manager->EnableInputMethod(locale_default_input_method); | 482 ime_state->EnableInputMethod(locale_default_input_method); |
481 } | 483 } |
482 | 484 |
483 // Finally, activate the first login input method. | 485 // Finally, activate the first login input method. |
484 const std::vector<std::string>& login_input_methods = | 486 const std::vector<std::string>& login_input_methods = |
485 ime_manager->GetInputMethodUtil()->GetHardwareLoginInputMethodIds(); | 487 manager->GetInputMethodUtil()->GetHardwareLoginInputMethodIds(); |
486 ime_manager->ChangeInputMethod(login_input_methods[0]); | 488 ime_state->ChangeInputMethod(login_input_methods[0], |
| 489 false /* show_message */); |
487 } | 490 } |
488 | 491 |
489 void SetGuestLocale(Profile* const profile) { | 492 void SetGuestLocale(Profile* const profile) { |
490 scoped_ptr<GuestLanguageSetCallbackData> data( | 493 scoped_ptr<GuestLanguageSetCallbackData> data( |
491 new GuestLanguageSetCallbackData(profile)); | 494 new GuestLanguageSetCallbackData(profile)); |
492 scoped_ptr<locale_util::SwitchLanguageCallback> callback( | 495 scoped_ptr<locale_util::SwitchLanguageCallback> callback( |
493 new locale_util::SwitchLanguageCallback(base::Bind( | 496 new locale_util::SwitchLanguageCallback(base::Bind( |
494 &GuestLanguageSetCallbackData::Callback, base::Passed(data.Pass())))); | 497 &GuestLanguageSetCallbackData::Callback, base::Passed(data.Pass())))); |
495 user_manager::User* const user = | 498 user_manager::User* const user = |
496 ProfileHelper::Get()->GetUserByProfile(profile); | 499 ProfileHelper::Get()->GetUserByProfile(profile); |
(...skipping 20 matching lines...) Expand all Loading... |
517 bool is_official_build = true; | 520 bool is_official_build = true; |
518 #else | 521 #else |
519 bool is_official_build = false; | 522 bool is_official_build = false; |
520 #endif | 523 #endif |
521 // Enable portal detector if EULA was previously accepted or if | 524 // Enable portal detector if EULA was previously accepted or if |
522 // this is an unofficial build. | 525 // this is an unofficial build. |
523 if (!is_official_build || StartupUtils::IsEulaAccepted()) | 526 if (!is_official_build || StartupUtils::IsEulaAccepted()) |
524 detector->Enable(true); | 527 detector->Enable(true); |
525 } | 528 } |
526 | 529 |
| 530 // Initialize input methods. |
| 531 input_method::InputMethodManager* manager = |
| 532 input_method::InputMethodManager::Get(); |
| 533 UserSessionManager* session_manager = UserSessionManager::GetInstance(); |
| 534 DCHECK(manager); |
| 535 DCHECK(session_manager); |
| 536 |
| 537 manager->SetState(session_manager->GetDefaultIMEState(profile())); |
| 538 |
527 bool is_running_test = parameters().ui_task != NULL; | 539 bool is_running_test = parameters().ui_task != NULL; |
528 g_browser_process->platform_part()->InitializeSessionManager( | 540 g_browser_process->platform_part()->InitializeSessionManager( |
529 parsed_command_line(), profile(), is_running_test); | 541 parsed_command_line(), profile(), is_running_test); |
530 g_browser_process->platform_part()->SessionManager()->Start(); | 542 g_browser_process->platform_part()->SessionManager()->Start(); |
531 | 543 |
532 // Guest user profile is never initialized with locale settings, | 544 // Guest user profile is never initialized with locale settings, |
533 // so we need special handling for Guest session. | 545 // so we need special handling for Guest session. |
534 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) | 546 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) |
535 SetGuestLocale(profile()); | 547 SetGuestLocale(profile()); |
536 | 548 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 // Destroy DBus services immediately after threads are stopped. | 746 // Destroy DBus services immediately after threads are stopped. |
735 dbus_services_.reset(); | 747 dbus_services_.reset(); |
736 | 748 |
737 ChromeBrowserMainPartsLinux::PostDestroyThreads(); | 749 ChromeBrowserMainPartsLinux::PostDestroyThreads(); |
738 | 750 |
739 // Destroy DeviceSettingsService after g_browser_process. | 751 // Destroy DeviceSettingsService after g_browser_process. |
740 DeviceSettingsService::Shutdown(); | 752 DeviceSettingsService::Shutdown(); |
741 } | 753 } |
742 | 754 |
743 } // namespace chromeos | 755 } // namespace chromeos |
OLD | NEW |