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

Side by Side Diff: chrome/browser/chromeos/login/login_display_host_impl.cc

Issue 139803010: Support comma separated hardware keyboard layout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: /EnableInputMethods/ReplaceEnabeldInputMethods/ Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/login/login_display_host_impl.h" 5 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/audio/sounds.h" 9 #include "ash/audio/sounds.h"
10 #include "ash/desktop_background/desktop_background_controller.h" 10 #include "ash/desktop_background/desktop_background_controller.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // The output list |input_method_ids| is sorted by popularity, hence 140 // The output list |input_method_ids| is sorted by popularity, hence
141 // input_method_ids[0] now contains the most popular keyboard layout 141 // input_method_ids[0] now contains the most popular keyboard layout
142 // for the given locale. 142 // for the given locale.
143 layout = input_method_ids[0]; 143 layout = input_method_ids[0];
144 } 144 }
145 } 145 }
146 146
147 if (!layout.empty()) { 147 if (!layout.empty()) {
148 PrefService* prefs = g_browser_process->local_state(); 148 PrefService* prefs = g_browser_process->local_state();
149 prefs->SetString(prefs::kHardwareKeyboardLayout, layout); 149 prefs->SetString(prefs::kHardwareKeyboardLayout, layout);
150
150 // This asks the file thread to save the prefs (i.e. doesn't block). 151 // This asks the file thread to save the prefs (i.e. doesn't block).
151 // The latest values of Local State reside in memory so we can safely 152 // The latest values of Local State reside in memory so we can safely
152 // get the value of kHardwareKeyboardLayout even if the data is not 153 // get the value of kHardwareKeyboardLayout even if the data is not
153 // yet saved to disk. 154 // yet saved to disk.
154 prefs->CommitPendingWrite(); 155 prefs->CommitPendingWrite();
156
157 chromeos::input_method::InputMethodManager* manager =
158 chromeos::input_method::InputMethodManager::Get();
159 manager->GetInputMethodUtil()->UpdateHardwareLayoutCache();
160 manager->SetInputMethodLoginDefault();
155 } 161 }
156 } 162 }
157 163
158 // A class to observe an implicit animation and invokes the callback after the 164 // A class to observe an implicit animation and invokes the callback after the
159 // animation is completed. 165 // animation is completed.
160 class AnimationObserver : public ui::ImplicitAnimationObserver { 166 class AnimationObserver : public ui::ImplicitAnimationObserver {
161 public: 167 public:
162 explicit AnimationObserver(const base::Closure& callback) 168 explicit AnimationObserver(const base::Closure& callback)
163 : callback_(callback) {} 169 : callback_(callback) {}
164 virtual ~AnimationObserver() {} 170 virtual ~AnimationObserver() {}
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 return; 1077 return;
1072 1078
1073 VLOG(1) << "Showing OOBE screen: " << first_screen_name; 1079 VLOG(1) << "Showing OOBE screen: " << first_screen_name;
1074 1080
1075 chromeos::input_method::InputMethodManager* manager = 1081 chromeos::input_method::InputMethodManager* manager =
1076 chromeos::input_method::InputMethodManager::Get(); 1082 chromeos::input_method::InputMethodManager::Get();
1077 1083
1078 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty 1084 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty
1079 // and US dvorak keyboard layouts. 1085 // and US dvorak keyboard layouts.
1080 if (g_browser_process && g_browser_process->local_state()) { 1086 if (g_browser_process && g_browser_process->local_state()) {
1081 manager->SetInputMethodDefault(); 1087 manager->SetInputMethodLoginDefault();
1082 1088
1083 PrefService* prefs = g_browser_process->local_state(); 1089 PrefService* prefs = g_browser_process->local_state();
1084 // Apply owner preferences for tap-to-click and mouse buttons swap for 1090 // Apply owner preferences for tap-to-click and mouse buttons swap for
1085 // login screen. 1091 // login screen.
1086 system::InputDeviceSettings::Get()->SetPrimaryButtonRight( 1092 system::InputDeviceSettings::Get()->SetPrimaryButtonRight(
1087 prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight)); 1093 prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight));
1088 system::InputDeviceSettings::Get()->SetTapToClick( 1094 system::InputDeviceSettings::Get()->SetTapToClick(
1089 prefs->GetBoolean(prefs::kOwnerTapToClickEnabled)); 1095 prefs->GetBoolean(prefs::kOwnerTapToClickEnabled));
1090 } 1096 }
1091 1097
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 if (show_login_screen) { 1144 if (show_login_screen) {
1139 // R11 > R12 migration fix. See http://crosbug.com/p/4898. 1145 // R11 > R12 migration fix. See http://crosbug.com/p/4898.
1140 // If user has manually changed locale during R11 OOBE, locale will be set. 1146 // If user has manually changed locale during R11 OOBE, locale will be set.
1141 // On R12 > R12|R13 etc. this fix won't get activated since 1147 // On R12 > R12|R13 etc. this fix won't get activated since
1142 // OOBE process has set kApplicationLocale to non-default value. 1148 // OOBE process has set kApplicationLocale to non-default value.
1143 PrefService* prefs = g_browser_process->local_state(); 1149 PrefService* prefs = g_browser_process->local_state();
1144 if (!prefs->HasPrefPath(prefs::kApplicationLocale)) { 1150 if (!prefs->HasPrefPath(prefs::kApplicationLocale)) {
1145 std::string locale = chromeos::StartupUtils::GetInitialLocale(); 1151 std::string locale = chromeos::StartupUtils::GetInitialLocale();
1146 prefs->SetString(prefs::kApplicationLocale, locale); 1152 prefs->SetString(prefs::kApplicationLocale, locale);
1147 manager->EnableLoginLayouts( 1153 manager->EnableLoginLayouts(
1148 locale, manager->GetInputMethodUtil()->GetHardwareInputMethodId()); 1154 locale,
1155 manager->GetInputMethodUtil()->GetHardwareInputMethodIds());
1149 base::ThreadRestrictions::ScopedAllowIO allow_io; 1156 base::ThreadRestrictions::ScopedAllowIO allow_io;
1150 const std::string loaded_locale = 1157 const std::string loaded_locale =
1151 ResourceBundle::GetSharedInstance().ReloadLocaleResources(locale); 1158 ResourceBundle::GetSharedInstance().ReloadLocaleResources(locale);
1152 g_browser_process->SetApplicationLocale(loaded_locale); 1159 g_browser_process->SetApplicationLocale(loaded_locale);
1153 } 1160 }
1154 display_host->StartSignInScreen(LoginScreenContext()); 1161 display_host->StartSignInScreen(LoginScreenContext());
1155 return; 1162 return;
1156 } 1163 }
1157 1164
1158 // Load startup manifest. 1165 // Load startup manifest.
1159 const chromeos::StartupCustomizationDocument* startup_manifest = 1166 const chromeos::StartupCustomizationDocument* startup_manifest =
1160 chromeos::StartupCustomizationDocument::GetInstance(); 1167 chromeos::StartupCustomizationDocument::GetInstance();
1161 1168
1162 // Switch to initial locale if specified by customization 1169 // Switch to initial locale if specified by customization
1163 // and has not been set yet. We cannot call 1170 // and has not been set yet. We cannot call
1164 // chromeos::LanguageSwitchMenu::SwitchLanguage here before 1171 // chromeos::LanguageSwitchMenu::SwitchLanguage here before
1165 // EmitLoginPromptReady. 1172 // EmitLoginPromptReady.
1166 PrefService* prefs = g_browser_process->local_state(); 1173 PrefService* prefs = g_browser_process->local_state();
1167 const std::string current_locale = 1174 const std::string current_locale =
1168 prefs->GetString(prefs::kApplicationLocale); 1175 prefs->GetString(prefs::kApplicationLocale);
1169 VLOG(1) << "Current locale: " << current_locale; 1176 VLOG(1) << "Current locale: " << current_locale;
1170 std::string locale = startup_manifest->initial_locale_default(); 1177 std::string locale = startup_manifest->initial_locale_default();
1171 1178
1179 std::string layout = startup_manifest->keyboard_layout();
1180 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout;
1181
1182 // Determine keyboard layout from OEM customization (if provided) or
1183 // initial locale and save it in preferences.
1184 DetermineAndSaveHardwareKeyboard(locale, layout);
1185
1172 if (!current_locale.empty() || locale.empty()) { 1186 if (!current_locale.empty() || locale.empty()) {
1173 ShowLoginWizardFinish(first_screen_name, startup_manifest, display_host); 1187 ShowLoginWizardFinish(first_screen_name, startup_manifest, display_host);
1174 return; 1188 return;
1175 } 1189 }
1176 1190
1177 std::string layout = startup_manifest->keyboard_layout();
1178 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout;
1179
1180 // Save initial locale from VPD/customization manifest as current 1191 // Save initial locale from VPD/customization manifest as current
1181 // Chrome locale. Otherwise it will be lost if Chrome restarts. 1192 // Chrome locale. Otherwise it will be lost if Chrome restarts.
1182 // Don't need to schedule pref save because setting initial local 1193 // Don't need to schedule pref save because setting initial local
1183 // will enforce preference saving. 1194 // will enforce preference saving.
1184 prefs->SetString(prefs::kApplicationLocale, locale); 1195 prefs->SetString(prefs::kApplicationLocale, locale);
1185 chromeos::StartupUtils::SetInitialLocale(locale); 1196 chromeos::StartupUtils::SetInitialLocale(locale);
1186 1197
1187 // Determine keyboard layout from OEM customization (if provided) or
1188 // initial locale and save it in preferences.
1189 DetermineAndSaveHardwareKeyboard(locale, layout);
1190
1191 scoped_ptr<ShowLoginWizardSwitchLanguageCallbackData> data( 1198 scoped_ptr<ShowLoginWizardSwitchLanguageCallbackData> data(
1192 new ShowLoginWizardSwitchLanguageCallbackData( 1199 new ShowLoginWizardSwitchLanguageCallbackData(
1193 first_screen_name, startup_manifest, display_host)); 1200 first_screen_name, startup_manifest, display_host));
1194 1201
1195 scoped_ptr<locale_util::SwitchLanguageCallback> callback( 1202 scoped_ptr<locale_util::SwitchLanguageCallback> callback(
1196 new locale_util::SwitchLanguageCallback( 1203 new locale_util::SwitchLanguageCallback(
1197 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); 1204 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass()))));
1198 1205
1199 // Load locale keyboards here. Hardware layout would be automatically enabled. 1206 // Load locale keyboards here. Hardware layout would be automatically enabled.
1200 locale_util::SwitchLanguage( 1207 locale_util::SwitchLanguage(
1201 locale, true, true /* login_layouts_only */, callback.Pass()); 1208 locale, true, true /* login_layouts_only */, callback.Pass());
1202 } 1209 }
1203 1210
1204 } // namespace chromeos 1211 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/mode_indicator_browsertest.cc ('k') | chrome/browser/chromeos/preferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698