OLD | NEW |
---|---|
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 Loading... | |
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()->InvalidateHardwareInputMethodIdsCache(); | |
Alexander Alekseev
2014/02/12 14:45:35
Wy do you need to invalidate cache here manually?
Seigo Nonaka
2014/02/12 16:49:51
Because InputMethodDelegate::GetHardwareLayouts ma
| |
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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1066 return; | 1072 return; |
1067 | 1073 |
1068 VLOG(1) << "Showing OOBE screen: " << first_screen_name; | 1074 VLOG(1) << "Showing OOBE screen: " << first_screen_name; |
1069 | 1075 |
1070 chromeos::input_method::InputMethodManager* manager = | 1076 chromeos::input_method::InputMethodManager* manager = |
1071 chromeos::input_method::InputMethodManager::Get(); | 1077 chromeos::input_method::InputMethodManager::Get(); |
1072 | 1078 |
1073 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty | 1079 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty |
1074 // and US dvorak keyboard layouts. | 1080 // and US dvorak keyboard layouts. |
1075 if (g_browser_process && g_browser_process->local_state()) { | 1081 if (g_browser_process && g_browser_process->local_state()) { |
1076 manager->SetInputMethodDefault(); | 1082 manager->SetInputMethodLoginDefault(); |
1077 | 1083 |
1078 PrefService* prefs = g_browser_process->local_state(); | 1084 PrefService* prefs = g_browser_process->local_state(); |
1079 // Apply owner preferences for tap-to-click and mouse buttons swap for | 1085 // Apply owner preferences for tap-to-click and mouse buttons swap for |
1080 // login screen. | 1086 // login screen. |
1081 system::mouse_settings::SetPrimaryButtonRight( | 1087 system::mouse_settings::SetPrimaryButtonRight( |
1082 prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight)); | 1088 prefs->GetBoolean(prefs::kOwnerPrimaryMouseButtonRight)); |
1083 system::touchpad_settings::SetTapToClick( | 1089 system::touchpad_settings::SetTapToClick( |
1084 prefs->GetBoolean(prefs::kOwnerTapToClickEnabled)); | 1090 prefs->GetBoolean(prefs::kOwnerTapToClickEnabled)); |
1085 } | 1091 } |
1086 | 1092 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1133 if (show_login_screen) { | 1139 if (show_login_screen) { |
1134 // R11 > R12 migration fix. See http://crosbug.com/p/4898. | 1140 // R11 > R12 migration fix. See http://crosbug.com/p/4898. |
1135 // If user has manually changed locale during R11 OOBE, locale will be set. | 1141 // If user has manually changed locale during R11 OOBE, locale will be set. |
1136 // On R12 > R12|R13 etc. this fix won't get activated since | 1142 // On R12 > R12|R13 etc. this fix won't get activated since |
1137 // OOBE process has set kApplicationLocale to non-default value. | 1143 // OOBE process has set kApplicationLocale to non-default value. |
1138 PrefService* prefs = g_browser_process->local_state(); | 1144 PrefService* prefs = g_browser_process->local_state(); |
1139 if (!prefs->HasPrefPath(prefs::kApplicationLocale)) { | 1145 if (!prefs->HasPrefPath(prefs::kApplicationLocale)) { |
1140 std::string locale = chromeos::StartupUtils::GetInitialLocale(); | 1146 std::string locale = chromeos::StartupUtils::GetInitialLocale(); |
1141 prefs->SetString(prefs::kApplicationLocale, locale); | 1147 prefs->SetString(prefs::kApplicationLocale, locale); |
1142 manager->EnableLoginLayouts( | 1148 manager->EnableLoginLayouts( |
1143 locale, manager->GetInputMethodUtil()->GetHardwareInputMethodId()); | 1149 locale, |
1150 manager->GetInputMethodUtil()->GetHardwareInputMethodIds()); | |
1144 base::ThreadRestrictions::ScopedAllowIO allow_io; | 1151 base::ThreadRestrictions::ScopedAllowIO allow_io; |
1145 const std::string loaded_locale = | 1152 const std::string loaded_locale = |
1146 ResourceBundle::GetSharedInstance().ReloadLocaleResources(locale); | 1153 ResourceBundle::GetSharedInstance().ReloadLocaleResources(locale); |
1147 g_browser_process->SetApplicationLocale(loaded_locale); | 1154 g_browser_process->SetApplicationLocale(loaded_locale); |
1148 } | 1155 } |
1149 display_host->StartSignInScreen(LoginScreenContext()); | 1156 display_host->StartSignInScreen(LoginScreenContext()); |
1150 return; | 1157 return; |
1151 } | 1158 } |
1152 | 1159 |
1153 // Load startup manifest. | 1160 // Load startup manifest. |
1154 const chromeos::StartupCustomizationDocument* startup_manifest = | 1161 const chromeos::StartupCustomizationDocument* startup_manifest = |
1155 chromeos::StartupCustomizationDocument::GetInstance(); | 1162 chromeos::StartupCustomizationDocument::GetInstance(); |
1156 | 1163 |
1157 // Switch to initial locale if specified by customization | 1164 // Switch to initial locale if specified by customization |
1158 // and has not been set yet. We cannot call | 1165 // and has not been set yet. We cannot call |
1159 // chromeos::LanguageSwitchMenu::SwitchLanguage here before | 1166 // chromeos::LanguageSwitchMenu::SwitchLanguage here before |
1160 // EmitLoginPromptReady. | 1167 // EmitLoginPromptReady. |
1161 PrefService* prefs = g_browser_process->local_state(); | 1168 PrefService* prefs = g_browser_process->local_state(); |
1162 const std::string current_locale = | 1169 const std::string current_locale = |
1163 prefs->GetString(prefs::kApplicationLocale); | 1170 prefs->GetString(prefs::kApplicationLocale); |
1164 VLOG(1) << "Current locale: " << current_locale; | 1171 VLOG(1) << "Current locale: " << current_locale; |
1165 std::string locale = startup_manifest->initial_locale_default(); | 1172 std::string locale = startup_manifest->initial_locale_default(); |
1166 | 1173 |
1174 std::string layout = startup_manifest->keyboard_layout(); | |
1175 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout; | |
1176 | |
1177 // Determine keyboard layout from OEM customization (if provided) or | |
1178 // initial locale and save it in preferences. | |
1179 DetermineAndSaveHardwareKeyboard(locale, layout); | |
1180 | |
1167 if (!current_locale.empty() || locale.empty()) { | 1181 if (!current_locale.empty() || locale.empty()) { |
1168 ShowLoginWizardFinish(first_screen_name, startup_manifest, display_host); | 1182 ShowLoginWizardFinish(first_screen_name, startup_manifest, display_host); |
1169 return; | 1183 return; |
1170 } | 1184 } |
1171 | 1185 |
1172 std::string layout = startup_manifest->keyboard_layout(); | |
1173 VLOG(1) << "Initial locale: " << locale << "keyboard layout " << layout; | |
1174 | |
1175 // Save initial locale from VPD/customization manifest as current | 1186 // Save initial locale from VPD/customization manifest as current |
1176 // Chrome locale. Otherwise it will be lost if Chrome restarts. | 1187 // Chrome locale. Otherwise it will be lost if Chrome restarts. |
1177 // Don't need to schedule pref save because setting initial local | 1188 // Don't need to schedule pref save because setting initial local |
1178 // will enforce preference saving. | 1189 // will enforce preference saving. |
1179 prefs->SetString(prefs::kApplicationLocale, locale); | 1190 prefs->SetString(prefs::kApplicationLocale, locale); |
1180 chromeos::StartupUtils::SetInitialLocale(locale); | 1191 chromeos::StartupUtils::SetInitialLocale(locale); |
1181 | 1192 |
1182 // Determine keyboard layout from OEM customization (if provided) or | |
1183 // initial locale and save it in preferences. | |
1184 DetermineAndSaveHardwareKeyboard(locale, layout); | |
1185 | |
1186 scoped_ptr<ShowLoginWizardSwitchLanguageCallbackData> data( | 1193 scoped_ptr<ShowLoginWizardSwitchLanguageCallbackData> data( |
1187 new ShowLoginWizardSwitchLanguageCallbackData( | 1194 new ShowLoginWizardSwitchLanguageCallbackData( |
1188 first_screen_name, startup_manifest, display_host)); | 1195 first_screen_name, startup_manifest, display_host)); |
1189 | 1196 |
1190 scoped_ptr<locale_util::SwitchLanguageCallback> callback( | 1197 scoped_ptr<locale_util::SwitchLanguageCallback> callback( |
1191 new locale_util::SwitchLanguageCallback( | 1198 new locale_util::SwitchLanguageCallback( |
1192 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); | 1199 base::Bind(&OnLanguageSwitchedCallback, base::Passed(data.Pass())))); |
1193 | 1200 |
1194 // Load locale keyboards here. Hardware layout would be automatically enabled. | 1201 // Load locale keyboards here. Hardware layout would be automatically enabled. |
1195 locale_util::SwitchLanguage( | 1202 locale_util::SwitchLanguage( |
1196 locale, true, true /* login_layouts_only */, callback.Pass()); | 1203 locale, true, true /* login_layouts_only */, callback.Pass()); |
1197 } | 1204 } |
1198 | 1205 |
1199 } // namespace chromeos | 1206 } // namespace chromeos |
OLD | NEW |