Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: chrome/browser/chromeos/chrome_browser_main_chromeos.cc

Issue 133273032: Guest Mode: input method should default to the underlying latin keyboard layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Use EnableInputMethod instead of EnableInputMethods. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b995ba00c5930dae5eedfa05b0aed5fe532867b1..c1744ff91e97dd4659443b0b874f8dd733b65ee6 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"
@@ -553,6 +555,54 @@ 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_manager =
+ input_method::InputMethodManager::Get();
+ // Active layout must be hardware "login layout".
+ // The previous one must be "locale default layout".
+ const std::string login_input_method =
+ ime_manager->GetInputMethodUtil()->GetHardwareLoginInputMethodId();
+ ime_manager->ChangeInputMethod(login_input_method);
+
+ const std::string locale_default_input_method =
+ ime_manager->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().
@@ -609,6 +659,12 @@ 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->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());
« no previous file with comments | « chrome/browser/chromeos/base/locale_util.cc ('k') | chrome/browser/chromeos/extensions/input_method_apitest_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698