| 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chromeos/cros/cros_library.h" | 11 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 12 #include "chrome/browser/chromeos/cros/input_method_library.h" | 12 #include "chrome/browser/chromeos/cros/input_method_library.h" |
| 13 #include "chrome/browser/chromeos/cros/login_library.h" | 13 #include "chrome/browser/chromeos/cros/login_library.h" |
| 14 #include "chrome/browser/chromeos/customization_document.h" |
| 14 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 15 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 15 #include "chrome/browser/chromeos/language_preferences.h" | 16 #include "chrome/browser/chromeos/language_preferences.h" |
| 16 #include "chrome/browser/chromeos/login/apply_services_customization.h" | |
| 17 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 17 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 18 #include "chrome/browser/chromeos/login/helper.h" | 18 #include "chrome/browser/chromeos/login/helper.h" |
| 19 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 19 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
| 20 #include "chrome/browser/chromeos/login/login_utils.h" | 20 #include "chrome/browser/chromeos/login/login_utils.h" |
| 21 #include "chrome/browser/chromeos/login/user_manager.h" | 21 #include "chrome/browser/chromeos/login/user_manager.h" |
| 22 #include "chrome/browser/chromeos/login/views_login_display_host.h" | 22 #include "chrome/browser/chromeos/login/views_login_display_host.h" |
| 23 #include "chrome/browser/chromeos/login/wizard_controller.h" | 23 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 24 #include "chrome/browser/chromeos/system_access.h" | 24 #include "chrome/browser/chromeos/system_access.h" |
| 25 #include "chrome/browser/chromeos/wm_ipc.h" | 25 #include "chrome/browser/chromeos/wm_ipc.h" |
| 26 #include "chrome/browser/prefs/pref_service.h" | 26 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 // LoginDisplayHost implementation --------------------------------------------- | 99 // LoginDisplayHost implementation --------------------------------------------- |
| 100 | 100 |
| 101 void BaseLoginDisplayHost::OnSessionStart() { | 101 void BaseLoginDisplayHost::OnSessionStart() { |
| 102 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 102 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void BaseLoginDisplayHost::StartWizard( | 105 void BaseLoginDisplayHost::StartWizard( |
| 106 const std::string& first_screen_name, | 106 const std::string& first_screen_name, |
| 107 const chromeos::StartupCustomizationDocument* manifest, | |
| 108 const GURL& start_url) { | 107 const GURL& start_url) { |
| 109 DVLOG(1) << "Starting wizard, first_screen_name: " << first_screen_name; | 108 DVLOG(1) << "Starting wizard, first_screen_name: " << first_screen_name; |
| 110 // Create and show the wizard. | 109 // Create and show the wizard. |
| 111 wizard_controller_.reset(); // Only one controller in a time. | 110 wizard_controller_.reset(); // Only one controller in a time. |
| 112 wizard_controller_.reset(new WizardController(this, background_bounds_)); | 111 wizard_controller_.reset(new WizardController(this, background_bounds_)); |
| 113 wizard_controller_->SetCustomization(manifest); | |
| 114 wizard_controller_->set_start_url(start_url); | 112 wizard_controller_->set_start_url(start_url); |
| 115 ShowBackground(); | 113 ShowBackground(); |
| 116 if (!WizardController::IsDeviceRegistered()) | 114 if (!WizardController::IsDeviceRegistered()) |
| 117 SetOobeProgressBarVisible(true); | 115 SetOobeProgressBarVisible(true); |
| 118 wizard_controller_->Init(first_screen_name); | 116 wizard_controller_->Init(first_screen_name); |
| 119 } | 117 } |
| 120 | 118 |
| 121 void BaseLoginDisplayHost::StartSignInScreen() { | 119 void BaseLoginDisplayHost::StartSignInScreen() { |
| 122 DVLOG(1) << "Starting sign in screen"; | 120 DVLOG(1) << "Starting sign in screen"; |
| 123 std::vector<chromeos::UserManager::User> users = | 121 std::vector<chromeos::UserManager::User> users = |
| 124 chromeos::UserManager::Get()->GetUsers(); | 122 chromeos::UserManager::Get()->GetUsers(); |
| 125 | 123 |
| 126 // Fix for users who updated device and thus never passed register screen. | 124 // Fix for users who updated device and thus never passed register screen. |
| 127 // If we already have users, we assume that it is not a second part of | 125 // If we already have users, we assume that it is not a second part of |
| 128 // OOBE. See http://crosbug.com/6289 | 126 // OOBE. See http://crosbug.com/6289 |
| 129 if (!WizardController::IsDeviceRegistered() && !users.empty()) { | 127 if (!WizardController::IsDeviceRegistered() && !users.empty()) { |
| 130 VLOG(1) << "Mark device registered because there are remembered users: " | 128 VLOG(1) << "Mark device registered because there are remembered users: " |
| 131 << users.size(); | 129 << users.size(); |
| 132 WizardController::MarkDeviceRegistered(); | 130 WizardController::MarkDeviceRegistered(); |
| 133 } | 131 } |
| 134 | 132 |
| 135 sign_in_controller_.reset(); // Only one controller in a time. | 133 sign_in_controller_.reset(); // Only one controller in a time. |
| 136 sign_in_controller_.reset(new chromeos::ExistingUserController(this)); | 134 sign_in_controller_.reset(new chromeos::ExistingUserController(this)); |
| 137 ShowBackground(); | 135 ShowBackground(); |
| 138 SetShutdownButtonEnabled(true); | 136 SetShutdownButtonEnabled(true); |
| 139 sign_in_controller_->Init(users); | 137 sign_in_controller_->Init(users); |
| 140 | 138 |
| 141 // Initiate services customization. | 139 // Initiate service customization manifest fetching. |
| 142 chromeos::ApplyServicesCustomization::StartIfNeeded(); | 140 if (!ServicesCustomizationDocument::WasApplied()) |
| 141 ServicesCustomizationDocument::GetInstance()->StartFetching(); |
| 143 } | 142 } |
| 144 | 143 |
| 145 // BaseLoginDisplayHost -------------------------------------------------------- | 144 // BaseLoginDisplayHost -------------------------------------------------------- |
| 146 | 145 |
| 147 void BaseLoginDisplayHost::Observe(NotificationType type, | 146 void BaseLoginDisplayHost::Observe(NotificationType type, |
| 148 const NotificationSource& source, | 147 const NotificationSource& source, |
| 149 const NotificationDetails& details) { | 148 const NotificationDetails& details) { |
| 150 CHECK(type == NotificationType::APP_TERMINATING); | 149 CHECK(type == NotificationType::APP_TERMINATING); |
| 151 | 150 |
| 152 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 151 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 chromeos::LoginDisplayHost* display_host = | 207 chromeos::LoginDisplayHost* display_host = |
| 209 new chromeos::ViewsLoginDisplayHost(screen_bounds); | 208 new chromeos::ViewsLoginDisplayHost(screen_bounds); |
| 210 #endif | 209 #endif |
| 211 if (show_login_screen && chromeos::CrosLibrary::Get()->EnsureLoaded()) { | 210 if (show_login_screen && chromeos::CrosLibrary::Get()->EnsureLoaded()) { |
| 212 display_host->StartSignInScreen(); | 211 display_host->StartSignInScreen(); |
| 213 return; | 212 return; |
| 214 } | 213 } |
| 215 | 214 |
| 216 // Load startup manifest. | 215 // Load startup manifest. |
| 217 const chromeos::StartupCustomizationDocument* startup_manifest = | 216 const chromeos::StartupCustomizationDocument* startup_manifest = |
| 218 chromeos::LoadStartupManifest(); | 217 chromeos::StartupCustomizationDocument::GetInstance(); |
| 219 | 218 |
| 220 std::string locale; | 219 std::string locale; |
| 221 if (startup_manifest) { | 220 if (startup_manifest->IsReady()) { |
| 222 // Switch to initial locale if specified by customization | 221 // Switch to initial locale if specified by customization |
| 223 // and has not been set yet. We cannot call | 222 // and has not been set yet. We cannot call |
| 224 // chromeos::LanguageSwitchMenu::SwitchLanguage here before | 223 // chromeos::LanguageSwitchMenu::SwitchLanguage here before |
| 225 // EmitLoginPromptReady. | 224 // EmitLoginPromptReady. |
| 226 PrefService* prefs = g_browser_process->local_state(); | 225 PrefService* prefs = g_browser_process->local_state(); |
| 227 const std::string current_locale = | 226 const std::string current_locale = |
| 228 prefs->GetString(prefs::kApplicationLocale); | 227 prefs->GetString(prefs::kApplicationLocale); |
| 229 VLOG(1) << "Current locale: " << current_locale; | 228 VLOG(1) << "Current locale: " << current_locale; |
| 230 if (current_locale.empty()) { | 229 if (current_locale.empty()) { |
| 231 locale = startup_manifest->initial_locale(); | 230 locale = startup_manifest->initial_locale(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 254 ResourceBundle::ReloadSharedInstance(locale); | 253 ResourceBundle::ReloadSharedInstance(locale); |
| 255 CHECK(!loaded_locale.empty()) << "Locale could not be found for " | 254 CHECK(!loaded_locale.empty()) << "Locale could not be found for " |
| 256 << locale; | 255 << locale; |
| 257 // Set the application locale here so that the language switch | 256 // Set the application locale here so that the language switch |
| 258 // menu works properly with the newly loaded locale. | 257 // menu works properly with the newly loaded locale. |
| 259 g_browser_process->SetApplicationLocale(loaded_locale); | 258 g_browser_process->SetApplicationLocale(loaded_locale); |
| 260 } | 259 } |
| 261 } | 260 } |
| 262 } | 261 } |
| 263 | 262 |
| 264 display_host->StartWizard(first_screen_name, startup_manifest, GURL()); | 263 display_host->StartWizard(first_screen_name, GURL()); |
| 265 | 264 |
| 266 chromeos::LoginUtils::Get()->PrewarmAuthentication(); | 265 chromeos::LoginUtils::Get()->PrewarmAuthentication(); |
| 267 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) | 266 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) |
| 268 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); | 267 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); |
| 269 | 268 |
| 270 if (startup_manifest) { | 269 if (startup_manifest->IsReady()) { |
| 271 // Set initial timezone if specified by customization. | 270 // Set initial timezone if specified by customization. |
| 272 const std::string timezone_name = startup_manifest->initial_timezone(); | 271 const std::string timezone_name = startup_manifest->initial_timezone(); |
| 273 VLOG(1) << "Initial time zone: " << timezone_name; | 272 VLOG(1) << "Initial time zone: " << timezone_name; |
| 274 // Apply locale customizations only once so preserve whatever locale | 273 // Apply locale customizations only once so preserve whatever locale |
| 275 // user has changed to during OOBE. | 274 // user has changed to during OOBE. |
| 276 if (!timezone_name.empty()) { | 275 if (!timezone_name.empty()) { |
| 277 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( | 276 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( |
| 278 icu::UnicodeString::fromUTF8(timezone_name)); | 277 icu::UnicodeString::fromUTF8(timezone_name)); |
| 279 CHECK(timezone) << "Timezone could not be set for " << timezone_name; | 278 CHECK(timezone) << "Timezone could not be set for " << timezone_name; |
| 280 chromeos::SystemAccess::GetInstance()->SetTimezone(*timezone); | 279 chromeos::SystemAccess::GetInstance()->SetTimezone(*timezone); |
| 281 } | 280 } |
| 282 } | 281 } |
| 283 } | 282 } |
| 284 | 283 |
| 285 } // namespace browser | 284 } // namespace browser |
| OLD | NEW |