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