Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base_login_display_host.h" | 5 #include "chrome/browser/chromeos/login/base_login_display_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 } // namespace chromeos | 207 } // namespace chromeos |
| 208 | 208 |
| 209 // browser::ShowLoginWizard implementation ------------------------------------- | 209 // browser::ShowLoginWizard implementation ------------------------------------- |
| 210 | 210 |
| 211 namespace browser { | 211 namespace browser { |
| 212 | 212 |
| 213 // Declared in browser_dialogs.h so that others don't need to depend on our .h. | 213 // Declared in browser_dialogs.h so that others don't need to depend on our .h. |
| 214 // TODO(nkostylev): Split this into a smaller functions. | 214 // TODO(nkostylev): Split this into a smaller functions. |
| 215 void ShowLoginWizard(const std::string& first_screen_name, | 215 void ShowLoginWizard(const std::string& first_screen_name, |
| 216 const gfx::Size& size) { | 216 const gfx::Size& size) { |
| 217 VLOG(1) << "Showing login screen: " << first_screen_name; | 217 VLOG(1) << "Showing wizard screen: " << first_screen_name; |
|
whywhat
2011/08/16 08:01:24
nit: wizard -> OOBE?
Dmitry Polukhin
2011/08/16 08:29:51
Done.
| |
| 218 | 218 |
| 219 // The login screen will enable alternate keyboard layouts, but we don't want | 219 // The login screen will enable alternate keyboard layouts, but we don't want |
| 220 // to start the IME process unless one is selected. | 220 // to start the IME process unless one is selected. |
| 221 chromeos::input_method::InputMethodManager::GetInstance()-> | 221 chromeos::input_method::InputMethodManager::GetInstance()-> |
| 222 SetDeferImeStartup(true); | 222 SetDeferImeStartup(true); |
| 223 // Tell the window manager that the user isn't logged in. | 223 // Tell the window manager that the user isn't logged in. |
| 224 chromeos::WmIpc::instance()->SetLoggedInProperty(false); | 224 chromeos::WmIpc::instance()->SetLoggedInProperty(false); |
| 225 | 225 |
| 226 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty | 226 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty |
| 227 // and US dvorak keyboard layouts. | 227 // and US dvorak keyboard layouts. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 g_browser_process->SetApplicationLocale(loaded_locale); | 275 g_browser_process->SetApplicationLocale(loaded_locale); |
| 276 } | 276 } |
| 277 display_host->StartSignInScreen(); | 277 display_host->StartSignInScreen(); |
| 278 return; | 278 return; |
| 279 } | 279 } |
| 280 | 280 |
| 281 // Load startup manifest. | 281 // Load startup manifest. |
| 282 const chromeos::StartupCustomizationDocument* startup_manifest = | 282 const chromeos::StartupCustomizationDocument* startup_manifest = |
| 283 chromeos::StartupCustomizationDocument::GetInstance(); | 283 chromeos::StartupCustomizationDocument::GetInstance(); |
| 284 | 284 |
| 285 // Switch to initial locale if specified by customization | |
| 286 // and has not been set yet. We cannot call | |
| 287 // chromeos::LanguageSwitchMenu::SwitchLanguage here before | |
| 288 // EmitLoginPromptReady. | |
| 289 PrefService* prefs = g_browser_process->local_state(); | |
| 290 const std::string current_locale = | |
| 291 prefs->GetString(prefs::kApplicationLocale); | |
| 292 VLOG(1) << "Current locale: " << current_locale; | |
| 285 std::string locale; | 293 std::string locale; |
| 286 if (startup_manifest->IsReady()) { | 294 if (current_locale.empty()) { |
| 287 // Switch to initial locale if specified by customization | 295 locale = startup_manifest->initial_locale(); |
| 288 // and has not been set yet. We cannot call | 296 std::string layout = startup_manifest->keyboard_layout(); |
| 289 // chromeos::LanguageSwitchMenu::SwitchLanguage here before | 297 VLOG(1) << "Initial locale: " << locale |
| 290 // EmitLoginPromptReady. | 298 << "keyboard layout " << layout; |
| 291 PrefService* prefs = g_browser_process->local_state(); | 299 if (!locale.empty()) { |
| 292 const std::string current_locale = | 300 // Save initial locale from VPD/customization manifest as current |
| 293 prefs->GetString(prefs::kApplicationLocale); | 301 // Chrome locale. Otherwise it will be lost if Chrome restarts. |
| 294 VLOG(1) << "Current locale: " << current_locale; | 302 // Don't need to schedule pref save because setting initial local |
| 295 if (current_locale.empty()) { | 303 // will enforce preference saving. |
| 296 locale = startup_manifest->initial_locale(); | 304 prefs->SetString(prefs::kApplicationLocale, locale); |
| 297 std::string layout = startup_manifest->keyboard_layout(); | 305 chromeos::WizardController::SetInitialLocale(locale); |
| 298 VLOG(1) << "Initial locale: " << locale | 306 // Determine keyboard layout from OEM customization (if provided) or |
| 299 << "keyboard layout " << layout; | 307 // initial locale and save it in preferences. |
| 300 if (!locale.empty()) { | 308 DetermineAndSaveHardwareKeyboard(locale, layout); |
| 301 // Save initial locale from VPD/customization manifest as current | 309 // Then, enable the hardware keyboard. |
| 302 // Chrome locale. Otherwise it will be lost if Chrome restarts. | 310 chromeos::input_method::EnableInputMethods( |
| 303 // Don't need to schedule pref save because setting initial local | 311 locale, |
| 304 // will enforce preference saving. | 312 chromeos::input_method::kKeyboardLayoutsOnly, |
| 305 prefs->SetString(prefs::kApplicationLocale, locale); | 313 chromeos::input_method::GetHardwareInputMethodId()); |
| 306 chromeos::WizardController::SetInitialLocale(locale); | 314 // Reloading resource bundle causes us to do blocking IO on UI thread. |
| 307 // Determine keyboard layout from OEM customization (if provided) or | 315 // Temporarily allow it until we fix http://crosbug.com/11102 |
| 308 // initial locale and save it in preferences. | 316 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 309 DetermineAndSaveHardwareKeyboard(locale, layout); | 317 const std::string loaded_locale = |
| 310 // Then, enable the hardware keyboard. | 318 ResourceBundle::ReloadSharedInstance(locale); |
| 311 chromeos::input_method::EnableInputMethods( | 319 CHECK(!loaded_locale.empty()) << "Locale could not be found for " |
| 312 locale, | 320 << locale; |
| 313 chromeos::input_method::kKeyboardLayoutsOnly, | 321 // Set the application locale here so that the language switch |
| 314 chromeos::input_method::GetHardwareInputMethodId()); | 322 // menu works properly with the newly loaded locale. |
| 315 // Reloading resource bundle causes us to do blocking IO on UI thread. | 323 g_browser_process->SetApplicationLocale(loaded_locale); |
| 316 // Temporarily allow it until we fix http://crosbug.com/11102 | |
| 317 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
| 318 const std::string loaded_locale = | |
| 319 ResourceBundle::ReloadSharedInstance(locale); | |
| 320 CHECK(!loaded_locale.empty()) << "Locale could not be found for " | |
| 321 << locale; | |
| 322 // Set the application locale here so that the language switch | |
| 323 // menu works properly with the newly loaded locale. | |
| 324 g_browser_process->SetApplicationLocale(loaded_locale); | |
| 325 } | |
| 326 } | 324 } |
| 327 } | 325 } |
| 328 | 326 |
| 329 display_host->StartWizard(first_screen_name, GURL()); | 327 display_host->StartWizard(first_screen_name, GURL()); |
| 330 | 328 |
| 331 chromeos::LoginUtils::Get()->PrewarmAuthentication(); | 329 chromeos::LoginUtils::Get()->PrewarmAuthentication(); |
| 332 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) | 330 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) |
| 333 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); | 331 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); |
| 334 | 332 |
| 335 if (startup_manifest->IsReady()) { | 333 // Set initial timezone if specified by customization. |
| 336 // Set initial timezone if specified by customization. | 334 const std::string timezone_name = startup_manifest->initial_timezone(); |
| 337 const std::string timezone_name = startup_manifest->initial_timezone(); | 335 VLOG(1) << "Initial time zone: " << timezone_name; |
| 338 VLOG(1) << "Initial time zone: " << timezone_name; | 336 // Apply locale customizations only once so preserve whatever locale |
|
whywhat
2011/08/16 08:01:24
nit: so -> to
Dmitry Polukhin
2011/08/16 08:29:51
Done.
| |
| 339 // Apply locale customizations only once so preserve whatever locale | 337 // user has changed to during OOBE. |
| 340 // user has changed to during OOBE. | 338 if (!timezone_name.empty()) { |
| 341 if (!timezone_name.empty()) { | 339 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( |
| 342 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( | 340 icu::UnicodeString::fromUTF8(timezone_name)); |
| 343 icu::UnicodeString::fromUTF8(timezone_name)); | 341 CHECK(timezone) << "Timezone could not be set for " << timezone_name; |
| 344 CHECK(timezone) << "Timezone could not be set for " << timezone_name; | 342 chromeos::system::TimezoneSettings::GetInstance()->SetTimezone(*timezone); |
| 345 chromeos::system::TimezoneSettings::GetInstance()->SetTimezone(*timezone); | |
| 346 } | |
| 347 } | 343 } |
| 348 } | 344 } |
| 349 | 345 |
| 350 } // namespace browser | 346 } // namespace browser |
| OLD | NEW |