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

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: Style. 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 453bf237a0162681e0280c33f9e75bdbabb499c0..a6b13548aaaee1673c9b685b80a08834021d30f0 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,54 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() {
}
}
+class GuestLanguageSetCallbackData {
+ public:
+ explicit GuestLanguageSetCallbackData(Profile* profile) : profile(profile) {
+ }
+
+ // must match SwitchLanguageCallback type.
Nikita (slow) 2014/01/27 19:31:21 nit: // SwitchLanguageCallback Or at least capit
Alexander Alekseev 2014/01/29 13:37:01 Done.
+ 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_im =
Nikita (slow) 2014/01/27 19:31:21 nit: login_input_method
Alexander Alekseev 2014/01/29 13:37:01 Done.
+ ime_manager->GetInputMethodUtil()->GetHardwareLoginInputMethodId();
+ ime_manager->ChangeInputMethod(login_im);
+
+ const std::string locale_default_input_method =
+ ime_manager->GetInputMethodUtil()->GetLanguageDefaultInputMethodId(
Nikita (slow) 2014/01/27 19:31:21 nit: Place GetLanguageDefaultInputMethodId on next
Alexander Alekseev 2014/01/29 13:37:01 Done.
+ 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) {
Nikita (slow) 2014/01/27 19:31:21 nit: const UserManager* user_manager, const Profil
+ 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 +653,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()) {
Nikita (slow) 2014/01/27 19:31:21 just if (UserManager::Get()->IsLoggedInAsGuest()
Alexander Alekseev 2014/01/29 13:37:01 Done.
+ SetGuestLocale(usermanager, profile());
+ }
Nikita (slow) 2014/01/27 19:31:21 nit: drop {}
Alexander Alekseev 2014/01/29 13:37:01 Done.
+
// These observers must be initialized after the profile because
// they use the profile to dispatch extension events.
extension_system_event_observer_.reset(new ExtensionSystemEventObserver());

Powered by Google App Engine
This is Rietveld 408576698