Chromium Code Reviews| Index: chrome/browser/chromeos/chrome_browser_main_chromeos.cc |
| diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc |
| index 453bf237a0162681e0280c33f9e75bdbabb499c0..3a4d05e5d3484f9f0ba4eeed8941d54657adc365 100644 |
| --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc |
| +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc |
| @@ -36,9 +36,11 @@ |
| #include "chrome/browser/chromeos/external_metrics.h" |
| #include "chrome/browser/chromeos/imageburner/burn_manager.h" |
| #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
| +#include "chrome/browser/chromeos/input_method/input_method_util.h" |
| #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_idle_logout.h" |
| #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h" |
| #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
| +#include "chrome/browser/chromeos/language_preferences.h" |
| #include "chrome/browser/chromeos/login/authenticator.h" |
| #include "chrome/browser/chromeos/login/login_utils.h" |
| #include "chrome/browser/chromeos/login/login_wizard.h" |
| @@ -547,6 +549,56 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() { |
| } |
| } |
| +class GuestLanguageSetCallbackData { |
| + public: |
| + explicit GuestLanguageSetCallbackData(Profile* profile) : profile(profile) { |
| + } |
| + |
| + // must match SwitchLanguageCallback type. |
| + static void Callback(const scoped_ptr<GuestLanguageSetCallbackData>& self, |
| + const std::string& locale, |
| + const std::string& loaded_locale, |
| + bool success); |
| + |
| + Profile* profile; |
| +}; |
| + |
| +// static |
| +void GuestLanguageSetCallbackData::Callback( |
| + const scoped_ptr<GuestLanguageSetCallbackData>& self, |
| + const std::string& locale, |
| + const std::string& loaded_locale, |
| + bool success) { |
| + input_method::InputMethodManager* const ime = |
|
Hiro Komatsu
2014/01/21 05:46:01
Please use 'imm' or 'ime_manager' instead of 'ime'
Alexander Alekseev
2014/01/21 14:05:27
Done.
|
| + input_method::InputMethodManager::Get(); |
| + // Implicitly enable owners choise. |
| + ime->EnableInputMethod(g_browser_process->local_state()->GetString( |
| + language_prefs::kPreferredKeyboardLayout)); |
| + // Active layout must be hardware "login layout". |
| + // The previous one must be "locale default layout". |
| + const std::string login_im = |
| + ime->GetInputMethodUtil()->GetHardwareLoginInputMethodId(); |
| + ime->ChangeInputMethod(login_im); |
| + |
| + const std::string locale_default_input_method = |
| + ime->GetInputMethodUtil()->GetLanguageDefaultInputMethodId(loaded_locale); |
| + if (!locale_default_input_method.empty()) { |
| + PrefService* user_prefs = self->profile->GetPrefs(); |
| + user_prefs->SetString(prefs::kLanguagePreviousInputMethod, |
| + locale_default_input_method); |
| + } |
| +} |
| + |
| +void SetGuestLocale(UserManager* const usermanager, Profile* const profile) { |
| + scoped_ptr<GuestLanguageSetCallbackData> data( |
| + new GuestLanguageSetCallbackData(profile)); |
| + scoped_ptr<locale_util::SwitchLanguageCallback> callback( |
| + new locale_util::SwitchLanguageCallback(base::Bind( |
| + &GuestLanguageSetCallbackData::Callback, base::Passed(data.Pass())))); |
| + User* const user = usermanager->GetUserByProfile(profile); |
| + usermanager->RespectLocalePreference(profile, user, callback.Pass()); |
| +} |
| + |
| void ChromeBrowserMainPartsChromeos::PostProfileInit() { |
| // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() |
| // -- just after CreateProfile(). |
| @@ -603,6 +655,13 @@ void ChromeBrowserMainPartsChromeos::PostProfileInit() { |
| OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); |
| } |
| + // Guest user profile is never initialized with locale settings, |
| + // so we need special handling for Guest session. |
| + UserManager* const usermanager = UserManager::Get(); |
| + if (usermanager->IsUserLoggedIn() && usermanager->IsLoggedInAsGuest()) { |
| + SetGuestLocale(usermanager, profile()); |
| + } |
| + |
| // These observers must be initialized after the profile because |
| // they use the profile to dispatch extension events. |
| extension_system_event_observer_.reset(new ExtensionSystemEventObserver()); |