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