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/existing_user_controller.h" | 5 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 #include "chrome/browser/chromeos/cros/cros_library.h" | 25 #include "chrome/browser/chromeos/cros/cros_library.h" |
26 #include "chrome/browser/chromeos/customization_document.h" | 26 #include "chrome/browser/chromeos/customization_document.h" |
27 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 27 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
28 #include "chrome/browser/chromeos/login/helper.h" | 28 #include "chrome/browser/chromeos/login/helper.h" |
29 #include "chrome/browser/chromeos/login/login_display_host.h" | 29 #include "chrome/browser/chromeos/login/login_display_host.h" |
30 #include "chrome/browser/chromeos/login/login_utils.h" | 30 #include "chrome/browser/chromeos/login/login_utils.h" |
31 #include "chrome/browser/chromeos/login/user_manager.h" | 31 #include "chrome/browser/chromeos/login/user_manager.h" |
32 #include "chrome/browser/chromeos/login/wizard_controller.h" | 32 #include "chrome/browser/chromeos/login/wizard_controller.h" |
33 #include "chrome/browser/chromeos/net/connectivity_state_helper.h" | 33 #include "chrome/browser/chromeos/net/connectivity_state_helper.h" |
34 #include "chrome/browser/chromeos/settings/cros_settings.h" | 34 #include "chrome/browser/chromeos/settings/cros_settings.h" |
35 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | |
35 #include "chrome/browser/chromeos/system/statistics_provider.h" | 36 #include "chrome/browser/chromeos/system/statistics_provider.h" |
36 #include "chrome/browser/google/google_util.h" | 37 #include "chrome/browser/google/google_util.h" |
37 #include "chrome/browser/policy/policy_service.h" | 38 #include "chrome/browser/policy/policy_service.h" |
38 #include "chrome/browser/prefs/session_startup_pref.h" | 39 #include "chrome/browser/prefs/session_startup_pref.h" |
39 #include "chrome/browser/profiles/profile_manager.h" | 40 #include "chrome/browser/profiles/profile_manager.h" |
40 #include "chrome/common/chrome_notification_types.h" | 41 #include "chrome/common/chrome_notification_types.h" |
41 #include "chrome/common/chrome_switches.h" | 42 #include "chrome/common/chrome_switches.h" |
42 #include "chrome/common/chrome_version_info.h" | 43 #include "chrome/common/chrome_version_info.h" |
43 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
44 #include "chrome/common/url_constants.h" | 45 #include "chrome/common/url_constants.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 ExistingUserController::ExistingUserController(LoginDisplayHost* host) | 137 ExistingUserController::ExistingUserController(LoginDisplayHost* host) |
137 : login_status_consumer_(NULL), | 138 : login_status_consumer_(NULL), |
138 host_(host), | 139 host_(host), |
139 login_display_(host_->CreateLoginDisplay(this)), | 140 login_display_(host_->CreateLoginDisplay(this)), |
140 num_login_attempts_(0), | 141 num_login_attempts_(0), |
141 cros_settings_(CrosSettings::Get()), | 142 cros_settings_(CrosSettings::Get()), |
142 weak_factory_(this), | 143 weak_factory_(this), |
143 offline_failed_(false), | 144 offline_failed_(false), |
144 is_login_in_progress_(false), | 145 is_login_in_progress_(false), |
145 password_changed_(false), | 146 password_changed_(false), |
146 do_auto_enrollment_(false) { | 147 do_auto_enrollment_(false), |
148 signin_screen_ready_(false) { | |
147 DCHECK(current_controller_ == NULL); | 149 DCHECK(current_controller_ == NULL); |
148 current_controller_ = this; | 150 current_controller_ = this; |
149 | 151 |
150 registrar_.Add(this, | 152 registrar_.Add(this, |
151 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 153 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
152 content::NotificationService::AllSources()); | 154 content::NotificationService::AllSources()); |
153 registrar_.Add(this, | 155 registrar_.Add(this, |
154 chrome::NOTIFICATION_USER_LIST_CHANGED, | 156 chrome::NOTIFICATION_USER_LIST_CHANGED, |
155 content::NotificationService::AllSources()); | 157 content::NotificationService::AllSources()); |
156 registrar_.Add(this, | 158 registrar_.Add(this, |
157 chrome::NOTIFICATION_AUTH_SUPPLIED, | 159 chrome::NOTIFICATION_AUTH_SUPPLIED, |
158 content::NotificationService::AllSources()); | 160 content::NotificationService::AllSources()); |
159 registrar_.Add(this, | 161 registrar_.Add(this, |
160 chrome::NOTIFICATION_SESSION_STARTED, | 162 chrome::NOTIFICATION_SESSION_STARTED, |
161 content::NotificationService::AllSources()); | 163 content::NotificationService::AllSources()); |
162 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); | 164 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); |
163 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); | 165 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); |
164 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); | 166 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); |
165 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); | 167 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); |
168 cros_settings_->AddSettingsObserver( | |
169 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
170 this); | |
171 cros_settings_->AddSettingsObserver( | |
172 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
173 this); | |
166 } | 174 } |
167 | 175 |
168 void ExistingUserController::Init(const UserList& users) { | 176 void ExistingUserController::Init(const UserList& users) { |
169 time_init_ = base::Time::Now(); | 177 time_init_ = base::Time::Now(); |
170 UpdateLoginDisplay(users); | 178 UpdateLoginDisplay(users); |
179 ConfigurePublicSessionAutoLogin(); | |
171 | 180 |
172 LoginUtils::Get()->PrewarmAuthentication(); | 181 LoginUtils::Get()->PrewarmAuthentication(); |
173 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); | 182 DBusThreadManager::Get()->GetSessionManagerClient()->EmitLoginPromptReady(); |
174 } | 183 } |
175 | 184 |
176 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { | 185 void ExistingUserController::UpdateLoginDisplay(const UserList& users) { |
177 bool show_users_on_signin; | 186 bool show_users_on_signin; |
178 UserList filtered_users; | 187 UserList filtered_users; |
179 | 188 |
180 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, | 189 cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 const content::NotificationSource& source, | 239 const content::NotificationSource& source, |
231 const content::NotificationDetails& details) { | 240 const content::NotificationDetails& details) { |
232 if (type == chrome::NOTIFICATION_SESSION_STARTED) { | 241 if (type == chrome::NOTIFICATION_SESSION_STARTED) { |
233 // Stop listening to any notification once session has started. | 242 // Stop listening to any notification once session has started. |
234 // Sign in screen objects are marked for deletion with DeleteSoon so | 243 // Sign in screen objects are marked for deletion with DeleteSoon so |
235 // make sure no object would be used after session has started. | 244 // make sure no object would be used after session has started. |
236 // http://crbug.com/125276 | 245 // http://crbug.com/125276 |
237 registrar_.RemoveAll(); | 246 registrar_.RemoveAll(); |
238 return; | 247 return; |
239 } | 248 } |
249 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) { | |
250 const std::string setting = *content::Details<const std::string>( | |
251 details).ptr(); | |
252 if (setting == kAccountsPrefDeviceLocalAccountAutoLoginId || | |
253 setting == kAccountsPrefDeviceLocalAccountAutoLoginDelay) { | |
254 ConfigurePublicSessionAutoLogin(); | |
255 } | |
256 } | |
240 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || | 257 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || |
241 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { | 258 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { |
242 if (host_ != NULL) { | 259 if (host_ != NULL) { |
243 // Signed settings or user list changed. Notify views and update them. | 260 // Signed settings or user list changed. Notify views and update them. |
244 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); | 261 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); |
245 return; | 262 return; |
246 } | 263 } |
247 } | 264 } |
248 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { | 265 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { |
249 // Possibly the user has authenticated against a proxy server and we might | 266 // Possibly the user has authenticated against a proxy server and we might |
(...skipping 29 matching lines...) Expand all Loading... | |
279 // ExistingUserController, private: | 296 // ExistingUserController, private: |
280 | 297 |
281 ExistingUserController::~ExistingUserController() { | 298 ExistingUserController::~ExistingUserController() { |
282 LoginUtils::Get()->DelegateDeleted(this); | 299 LoginUtils::Get()->DelegateDeleted(this); |
283 | 300 |
284 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, | 301 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, |
285 this); | 302 this); |
286 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); | 303 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); |
287 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); | 304 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); |
288 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); | 305 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); |
306 cros_settings_->RemoveSettingsObserver( | |
307 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
308 this); | |
309 cros_settings_->RemoveSettingsObserver( | |
310 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
311 this); | |
289 | 312 |
290 if (current_controller_ == this) { | 313 if (current_controller_ == this) { |
291 current_controller_ = NULL; | 314 current_controller_ = NULL; |
292 } else { | 315 } else { |
293 NOTREACHED() << "More than one controller are alive."; | 316 NOTREACHED() << "More than one controller are alive."; |
294 } | 317 } |
295 DCHECK(login_display_.get()); | 318 DCHECK(login_display_.get()); |
296 } | 319 } |
297 | 320 |
298 //////////////////////////////////////////////////////////////////////////////// | 321 //////////////////////////////////////////////////////////////////////////////// |
299 // ExistingUserController, LoginDisplay::Delegate implementation: | 322 // ExistingUserController, LoginDisplay::Delegate implementation: |
300 // | 323 // |
301 | 324 |
302 void ExistingUserController::CancelPasswordChangedFlow() { | 325 void ExistingUserController::CancelPasswordChangedFlow() { |
303 login_performer_.reset(NULL); | 326 login_performer_.reset(NULL); |
304 login_display_->SetUIEnabled(true); | 327 login_display_->SetUIEnabled(true); |
328 StartPublicSessionAutoLoginTimer(); | |
305 } | 329 } |
306 | 330 |
307 void ExistingUserController::CreateAccount() { | 331 void ExistingUserController::CreateAccount() { |
308 content::RecordAction(content::UserMetricsAction("Login.CreateAccount")); | 332 content::RecordAction(content::UserMetricsAction("Login.CreateAccount")); |
309 guest_mode_url_ = | 333 guest_mode_url_ = |
310 google_util::AppendGoogleLocaleParam(GURL(kCreateAccountURL)); | 334 google_util::AppendGoogleLocaleParam(GURL(kCreateAccountURL)); |
311 LoginAsGuest(); | 335 LoginAsGuest(); |
312 } | 336 } |
313 | 337 |
314 void ExistingUserController::CreateLocallyManagedUser( | 338 void ExistingUserController::CreateLocallyManagedUser( |
315 const string16& display_name, | 339 const string16& display_name, |
316 const std::string& password) { | 340 const std::string& password) { |
317 // TODO(nkostylev): Check that policy allows creation of such account type. | 341 // TODO(nkostylev): Check that policy allows creation of such account type. |
318 if (display_name.empty()) | 342 if (display_name.empty()) |
319 return; | 343 return; |
320 | 344 |
321 // Disable clicking on other windows. | 345 // Disable clicking on other windows. |
346 StopPublicSessionAutoLoginTimer(); | |
322 login_display_->SetUIEnabled(false); | 347 login_display_->SetUIEnabled(false); |
323 | 348 |
324 LoginPerformer::Delegate* delegate = this; | 349 LoginPerformer::Delegate* delegate = this; |
325 if (login_performer_delegate_.get()) | 350 if (login_performer_delegate_.get()) |
326 delegate = login_performer_delegate_.get(); | 351 delegate = login_performer_delegate_.get(); |
327 // Only one instance of LoginPerformer should exist at a time. | 352 // Only one instance of LoginPerformer should exist at a time. |
328 login_performer_.reset(NULL); | 353 login_performer_.reset(NULL); |
329 login_performer_.reset(new LoginPerformer(delegate)); | 354 login_performer_.reset(new LoginPerformer(delegate)); |
330 is_login_in_progress_ = true; | 355 is_login_in_progress_ = true; |
331 login_performer_-> | 356 login_performer_-> |
332 CreateLocallyManagedUser(display_name, password); | 357 CreateLocallyManagedUser(display_name, password); |
333 // TODO(nkostylev): A11y message. | 358 // TODO(nkostylev): A11y message. |
334 } | 359 } |
335 | 360 |
336 void ExistingUserController::CompleteLogin(const std::string& username, | 361 void ExistingUserController::CompleteLogin(const std::string& username, |
337 const std::string& password) { | 362 const std::string& password) { |
338 if (!host_) { | 363 if (!host_) { |
339 // Complete login event was generated already from UI. Ignore notification. | 364 // Complete login event was generated already from UI. Ignore notification. |
340 return; | 365 return; |
341 } | 366 } |
342 | 367 |
368 // Stop the auto-login timer when attempting login. | |
369 StopPublicSessionAutoLoginTimer(); | |
370 | |
343 // Disable UI while loading user profile. | 371 // Disable UI while loading user profile. |
344 login_display_->SetUIEnabled(false); | 372 login_display_->SetUIEnabled(false); |
345 | 373 |
346 if (!time_init_.is_null()) { | 374 if (!time_init_.is_null()) { |
347 base::TimeDelta delta = base::Time::Now() - time_init_; | 375 base::TimeDelta delta = base::Time::Now() - time_init_; |
348 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); | 376 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); |
349 time_init_ = base::Time(); // Reset to null. | 377 time_init_ = base::Time(); // Reset to null. |
350 } | 378 } |
351 | 379 |
352 host_->OnCompleteLogin(); | 380 host_->OnCompleteLogin(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 } | 417 } |
390 | 418 |
391 string16 ExistingUserController::GetConnectedNetworkName() { | 419 string16 ExistingUserController::GetConnectedNetworkName() { |
392 return GetCurrentNetworkName(); | 420 return GetCurrentNetworkName(); |
393 } | 421 } |
394 | 422 |
395 void ExistingUserController::Login(const std::string& username, | 423 void ExistingUserController::Login(const std::string& username, |
396 const std::string& password) { | 424 const std::string& password) { |
397 if (username.empty() || password.empty()) | 425 if (username.empty() || password.empty()) |
398 return; | 426 return; |
427 | |
428 // Stop the auto-login timer when attempting login. | |
429 StopPublicSessionAutoLoginTimer(); | |
430 | |
399 // Disable clicking on other windows. | 431 // Disable clicking on other windows. |
400 login_display_->SetUIEnabled(false); | 432 login_display_->SetUIEnabled(false); |
401 | 433 |
402 BootTimesLoader::Get()->RecordLoginAttempted(); | 434 BootTimesLoader::Get()->RecordLoginAttempted(); |
403 | 435 |
404 if (last_login_attempt_username_ != username) { | 436 if (last_login_attempt_username_ != username) { |
405 last_login_attempt_username_ = username; | 437 last_login_attempt_username_ = username; |
406 num_login_attempts_ = 0; | 438 num_login_attempts_ = 0; |
407 // Also reset state variables, which are used to determine password change. | 439 // Also reset state variables, which are used to determine password change. |
408 offline_failed_ = false; | 440 offline_failed_ = false; |
(...skipping 27 matching lines...) Expand all Loading... | |
436 UserManager::kLocallyManagedUserDomain) { | 468 UserManager::kLocallyManagedUserDomain) { |
437 login_performer_->LoginAsLocallyManagedUser(username, password); | 469 login_performer_->LoginAsLocallyManagedUser(username, password); |
438 } else { | 470 } else { |
439 login_performer_->PerformLogin(username, password, auth_mode); | 471 login_performer_->PerformLogin(username, password, auth_mode); |
440 } | 472 } |
441 accessibility::MaybeSpeak( | 473 accessibility::MaybeSpeak( |
442 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 474 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
443 } | 475 } |
444 | 476 |
445 void ExistingUserController::LoginAsRetailModeUser() { | 477 void ExistingUserController::LoginAsRetailModeUser() { |
478 // Stop the auto-login timer when attempting login. | |
479 StopPublicSessionAutoLoginTimer(); | |
480 | |
446 // Disable clicking on other windows. | 481 // Disable clicking on other windows. |
447 login_display_->SetUIEnabled(false); | 482 login_display_->SetUIEnabled(false); |
448 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once | 483 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once |
449 // the enterprise policy wiring is done for retail mode. | 484 // the enterprise policy wiring is done for retail mode. |
450 | 485 |
451 // Only one instance of LoginPerformer should exist at a time. | 486 // Only one instance of LoginPerformer should exist at a time. |
452 login_performer_.reset(NULL); | 487 login_performer_.reset(NULL); |
453 login_performer_.reset(new LoginPerformer(this)); | 488 login_performer_.reset(new LoginPerformer(this)); |
454 is_login_in_progress_ = true; | 489 is_login_in_progress_ = true; |
455 login_performer_->LoginRetailMode(); | 490 login_performer_->LoginRetailMode(); |
456 accessibility::MaybeSpeak( | 491 accessibility::MaybeSpeak( |
457 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); | 492 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); |
458 } | 493 } |
459 | 494 |
460 void ExistingUserController::LoginAsGuest() { | 495 void ExistingUserController::LoginAsGuest() { |
496 // Stop the auto-login timer when attempting login. | |
497 StopPublicSessionAutoLoginTimer(); | |
498 | |
461 // Disable clicking on other windows. | 499 // Disable clicking on other windows. |
462 login_display_->SetUIEnabled(false); | 500 login_display_->SetUIEnabled(false); |
463 | 501 |
464 CrosSettingsProvider::TrustedStatus status = | 502 CrosSettingsProvider::TrustedStatus status = |
465 cros_settings_->PrepareTrustedValues( | 503 cros_settings_->PrepareTrustedValues( |
466 base::Bind(&ExistingUserController::LoginAsGuest, | 504 base::Bind(&ExistingUserController::LoginAsGuest, |
467 weak_factory_.GetWeakPtr())); | 505 weak_factory_.GetWeakPtr())); |
468 // Must not proceed without signature verification. | 506 // Must not proceed without signature verification. |
469 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { | 507 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { |
470 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, | 508 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, |
471 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 509 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
472 // Reenable clicking on other windows and status area. | 510 // Reenable clicking on other windows and status area. |
473 login_display_->SetUIEnabled(true); | 511 login_display_->SetUIEnabled(true); |
512 StartPublicSessionAutoLoginTimer(); | |
474 display_email_.clear(); | 513 display_email_.clear(); |
475 return; | 514 return; |
476 } else if (status != CrosSettingsProvider::TRUSTED) { | 515 } else if (status != CrosSettingsProvider::TRUSTED) { |
477 // Value of AllowNewUser setting is still not verified. | 516 // Value of AllowNewUser setting is still not verified. |
478 // Another attempt will be invoked after verification completion. | 517 // Another attempt will be invoked after verification completion. |
479 return; | 518 return; |
480 } | 519 } |
481 | 520 |
482 bool allow_guest; | 521 bool allow_guest; |
483 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 522 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
484 if (!allow_guest) { | 523 if (!allow_guest) { |
485 // Disallowed. The UI should normally not show the guest pod but if for some | 524 // Disallowed. The UI should normally not show the guest pod but if for some |
486 // reason this has been made available to the user here is the time to tell | 525 // reason this has been made available to the user here is the time to tell |
487 // this nicely. | 526 // this nicely. |
488 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, | 527 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, |
489 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 528 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
490 // Reenable clicking on other windows and status area. | 529 // Reenable clicking on other windows and status area. |
491 login_display_->SetUIEnabled(true); | 530 login_display_->SetUIEnabled(true); |
531 StartPublicSessionAutoLoginTimer(); | |
492 display_email_.clear(); | 532 display_email_.clear(); |
493 return; | 533 return; |
494 } | 534 } |
495 | 535 |
496 // Only one instance of LoginPerformer should exist at a time. | 536 // Only one instance of LoginPerformer should exist at a time. |
497 login_performer_.reset(NULL); | 537 login_performer_.reset(NULL); |
498 login_performer_.reset(new LoginPerformer(this)); | 538 login_performer_.reset(new LoginPerformer(this)); |
499 is_login_in_progress_ = true; | 539 is_login_in_progress_ = true; |
500 login_performer_->LoginOffTheRecord(); | 540 login_performer_->LoginOffTheRecord(); |
501 accessibility::MaybeSpeak( | 541 accessibility::MaybeSpeak( |
502 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); | 542 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); |
503 } | 543 } |
504 | 544 |
505 void ExistingUserController::MigrateUserData(const std::string& old_password) { | 545 void ExistingUserController::MigrateUserData(const std::string& old_password) { |
506 // LoginPerformer instance has state of the user so it should exist. | 546 // LoginPerformer instance has state of the user so it should exist. |
507 if (login_performer_.get()) | 547 if (login_performer_.get()) |
508 login_performer_->RecoverEncryptedData(old_password); | 548 login_performer_->RecoverEncryptedData(old_password); |
509 } | 549 } |
510 | 550 |
511 void ExistingUserController::LoginAsPublicAccount( | 551 void ExistingUserController::LoginAsPublicAccount( |
512 const std::string& username) { | 552 const std::string& username) { |
553 // Stop the auto-login timer when attempting login. | |
554 StopPublicSessionAutoLoginTimer(); | |
555 | |
513 // Disable clicking on other windows. | 556 // Disable clicking on other windows. |
514 login_display_->SetUIEnabled(false); | 557 login_display_->SetUIEnabled(false); |
515 | 558 |
516 CrosSettingsProvider::TrustedStatus status = | 559 CrosSettingsProvider::TrustedStatus status = |
517 cros_settings_->PrepareTrustedValues( | 560 cros_settings_->PrepareTrustedValues( |
518 base::Bind(&ExistingUserController::LoginAsPublicAccount, | 561 base::Bind(&ExistingUserController::LoginAsPublicAccount, |
519 weak_factory_.GetWeakPtr(), | 562 weak_factory_.GetWeakPtr(), |
520 username)); | 563 username)); |
521 // If device policy is permanently unavailable, logging into public accounts | 564 // If device policy is permanently unavailable, logging into public accounts |
522 // is not possible. | 565 // is not possible. |
523 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { | 566 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { |
524 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, | 567 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, |
525 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 568 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
526 // Re-enable clicking on other windows. | 569 // Re-enable clicking on other windows. |
527 login_display_->SetUIEnabled(true); | 570 login_display_->SetUIEnabled(true); |
528 return; | 571 return; |
529 } | 572 } |
530 | 573 |
531 // If device policy is not verified yet, this function will be called again | 574 // If device policy is not verified yet, this function will be called again |
532 // when verification finishes. | 575 // when verification finishes. |
533 if (status != CrosSettingsProvider::TRUSTED) | 576 if (status != CrosSettingsProvider::TRUSTED) |
534 return; | 577 return; |
535 | 578 |
536 // If there is no public account with the given |username|, logging in is not | 579 // If there is no public account with the given |username|, logging in is not |
537 // possible. | 580 // possible. |
538 const User* user = UserManager::Get()->FindUser(username); | 581 const User* user = UserManager::Get()->FindUser(username); |
539 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { | 582 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { |
540 // Re-enable clicking on other windows. | 583 // Re-enable clicking on other windows. |
541 login_display_->SetUIEnabled(true); | 584 login_display_->SetUIEnabled(true); |
585 StartPublicSessionAutoLoginTimer(); | |
542 return; | 586 return; |
543 } | 587 } |
544 | 588 |
545 // Only one instance of LoginPerformer should exist at a time. | 589 // Only one instance of LoginPerformer should exist at a time. |
546 login_performer_.reset(NULL); | 590 login_performer_.reset(NULL); |
547 login_performer_.reset(new LoginPerformer(this)); | 591 login_performer_.reset(new LoginPerformer(this)); |
548 is_login_in_progress_ = true; | 592 is_login_in_progress_ = true; |
549 login_performer_->LoginAsPublicAccount(username); | 593 login_performer_->LoginAsPublicAccount(username); |
550 accessibility::MaybeSpeak( | 594 accessibility::MaybeSpeak( |
551 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); | 595 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
552 } | 596 } |
553 | 597 |
598 void ExistingUserController::OnSigninScreenReady() { | |
599 signin_screen_ready_ = true; | |
600 StartPublicSessionAutoLoginTimer(); | |
601 } | |
602 | |
554 void ExistingUserController::OnUserSelected(const std::string& username) { | 603 void ExistingUserController::OnUserSelected(const std::string& username) { |
555 login_performer_.reset(NULL); | 604 login_performer_.reset(NULL); |
556 num_login_attempts_ = 0; | 605 num_login_attempts_ = 0; |
557 } | 606 } |
558 | 607 |
559 void ExistingUserController::OnStartEnterpriseEnrollment() { | 608 void ExistingUserController::OnStartEnterpriseEnrollment() { |
560 DeviceSettingsService::Get()->GetOwnershipStatusAsync( | 609 DeviceSettingsService::Get()->GetOwnershipStatusAsync( |
561 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, | 610 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, |
562 weak_factory_.GetWeakPtr())); | 611 weak_factory_.GetWeakPtr())); |
563 } | 612 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); | 728 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); |
680 } else { | 729 } else { |
681 if (!is_known_user) | 730 if (!is_known_user) |
682 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); | 731 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); |
683 else | 732 else |
684 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); | 733 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); |
685 } | 734 } |
686 } | 735 } |
687 // Reenable clicking on other windows and status area. | 736 // Reenable clicking on other windows and status area. |
688 login_display_->SetUIEnabled(true); | 737 login_display_->SetUIEnabled(true); |
738 StartPublicSessionAutoLoginTimer(); | |
689 } | 739 } |
690 | 740 |
691 // Reset user flow to default, so that special flow will not affect next | 741 // Reset user flow to default, so that special flow will not affect next |
692 // attempt. | 742 // attempt. |
693 UserManager::Get()->ResetUserFlow(last_login_attempt_username_); | 743 UserManager::Get()->ResetUserFlow(last_login_attempt_username_); |
694 | 744 |
695 if (login_status_consumer_) | 745 if (login_status_consumer_) |
696 login_status_consumer_->OnLoginFailure(failure); | 746 login_status_consumer_->OnLoginFailure(failure); |
697 | 747 |
698 // Clear the recorded displayed email so it won't affect any future attempts. | 748 // Clear the recorded displayed email so it won't affect any future attempts. |
699 display_email_.clear(); | 749 display_email_.clear(); |
700 } | 750 } |
701 | 751 |
702 void ExistingUserController::OnLoginSuccess( | 752 void ExistingUserController::OnLoginSuccess( |
703 const std::string& username, | 753 const std::string& username, |
704 const std::string& password, | 754 const std::string& password, |
705 bool pending_requests, | 755 bool pending_requests, |
706 bool using_oauth) { | 756 bool using_oauth) { |
707 is_login_in_progress_ = false; | 757 is_login_in_progress_ = false; |
708 offline_failed_ = false; | 758 offline_failed_ = false; |
709 | 759 |
760 StopPublicSessionAutoLoginTimer(); | |
761 | |
710 bool has_cookies = | 762 bool has_cookies = |
711 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION; | 763 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION; |
712 | 764 |
713 // Login performer will be gone so cache this value to use | 765 // Login performer will be gone so cache this value to use |
714 // once profile is loaded. | 766 // once profile is loaded. |
715 password_changed_ = login_performer_->password_changed(); | 767 password_changed_ = login_performer_->password_changed(); |
716 | 768 |
717 // LoginPerformer instance will delete itself once online auth result is OK. | 769 // LoginPerformer instance will delete itself once online auth result is OK. |
718 // In case of failure it'll bring up ScreenLock and ask for | 770 // In case of failure it'll bring up ScreenLock and ask for |
719 // correct password/display error message. | 771 // correct password/display error message. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
825 // Reenable clicking on other windows and status area. | 877 // Reenable clicking on other windows and status area. |
826 login_display_->SetUIEnabled(true); | 878 login_display_->SetUIEnabled(true); |
827 login_display_->ShowSigninUI(email); | 879 login_display_->ShowSigninUI(email); |
828 | 880 |
829 if (login_status_consumer_) { | 881 if (login_status_consumer_) { |
830 login_status_consumer_->OnLoginFailure(LoginFailure( | 882 login_status_consumer_->OnLoginFailure(LoginFailure( |
831 LoginFailure::WHITELIST_CHECK_FAILED)); | 883 LoginFailure::WHITELIST_CHECK_FAILED)); |
832 } | 884 } |
833 | 885 |
834 display_email_.clear(); | 886 display_email_.clear(); |
887 | |
888 StartPublicSessionAutoLoginTimer(); | |
835 } | 889 } |
836 | 890 |
837 void ExistingUserController::PolicyLoadFailed() { | 891 void ExistingUserController::PolicyLoadFailed() { |
838 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); | 892 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); |
839 | 893 |
840 // Reenable clicking on other windows and status area. | 894 // Reenable clicking on other windows and status area. |
841 login_display_->SetUIEnabled(true); | 895 login_display_->SetUIEnabled(true); |
842 | 896 |
843 display_email_.clear(); | 897 display_email_.clear(); |
898 | |
899 // Policy load failure stops login attempts -- restart the timer. | |
900 StartPublicSessionAutoLoginTimer(); | |
844 } | 901 } |
845 | 902 |
846 void ExistingUserController::OnOnlineChecked(const std::string& username, | 903 void ExistingUserController::OnOnlineChecked(const std::string& username, |
847 bool success) { | 904 bool success) { |
848 if (success && last_login_attempt_username_ == username) { | 905 if (success && last_login_attempt_username_ == username) { |
849 online_succeeded_for_ = username; | 906 online_succeeded_for_ = username; |
850 // Wait for login attempt to end, if it hasn't yet. | 907 // Wait for login attempt to end, if it hasn't yet. |
851 if (offline_failed_ && !is_login_in_progress_) | 908 if (offline_failed_ && !is_login_in_progress_) |
852 ShowGaiaPasswordChanged(username); | 909 ShowGaiaPasswordChanged(username); |
853 } | 910 } |
854 } | 911 } |
855 | 912 |
856 //////////////////////////////////////////////////////////////////////////////// | 913 //////////////////////////////////////////////////////////////////////////////// |
857 // ExistingUserController, private: | 914 // ExistingUserController, private: |
858 | 915 |
859 void ExistingUserController::ActivateWizard(const std::string& screen_name) { | 916 void ExistingUserController::ActivateWizard(const std::string& screen_name) { |
860 DictionaryValue* params = NULL; | 917 DictionaryValue* params = NULL; |
861 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { | 918 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { |
862 params = new DictionaryValue; | 919 params = new DictionaryValue; |
863 params->SetString("start_url", guest_mode_url_.spec()); | 920 params->SetString("start_url", guest_mode_url_.spec()); |
864 } | 921 } |
865 host_->StartWizard(screen_name, params); | 922 host_->StartWizard(screen_name, params); |
866 } | 923 } |
867 | 924 |
925 void ExistingUserController::ConfigurePublicSessionAutoLogin() { | |
926 if (!cros_settings_->GetString( | |
927 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
928 &public_session_auto_login_username_)) { | |
929 public_session_auto_login_username_ = ""; | |
Mattias Nissler (ping if slow)
2013/03/11 16:26:59
nit: could also do public_session_auto_login_usern
dconnelly
2013/03/11 17:34:32
Done.
| |
930 } | |
931 if (!cros_settings_->GetInteger( | |
932 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
933 &public_session_auto_login_delay_)) { | |
934 public_session_auto_login_delay_ = 0; | |
935 } | |
936 | |
937 if (!public_session_auto_login_username_.empty()) | |
938 StartPublicSessionAutoLoginTimer(); | |
939 else | |
940 StopPublicSessionAutoLoginTimer(); | |
941 } | |
942 | |
943 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { | |
944 // Only restart the auto-login timer if it's already running. | |
945 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { | |
946 StopPublicSessionAutoLoginTimer(); | |
947 StartPublicSessionAutoLoginTimer(); | |
948 } | |
949 } | |
950 | |
951 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { | |
952 CHECK(signin_screen_ready_ && | |
953 !is_login_in_progress_ && | |
954 !public_session_auto_login_username_.empty()); | |
955 LoginAsPublicAccount(public_session_auto_login_username_); | |
956 } | |
957 | |
958 void ExistingUserController::StopPublicSessionAutoLoginTimer() { | |
959 if (auto_login_timer_) | |
960 auto_login_timer_->Stop(); | |
961 } | |
962 | |
963 void ExistingUserController::StartPublicSessionAutoLoginTimer() { | |
964 if (!signin_screen_ready_ || | |
965 is_login_in_progress_ || | |
966 public_session_auto_login_username_.empty()) { | |
967 return; | |
968 } | |
969 | |
970 // Start the auto-login timer. | |
971 if (!auto_login_timer_) | |
972 auto_login_timer_.reset(new base::OneShotTimer<ExistingUserController>); | |
973 | |
974 auto_login_timer_->Start( | |
975 FROM_HERE, | |
976 base::TimeDelta::FromMilliseconds( | |
977 public_session_auto_login_delay_), | |
978 base::Bind( | |
979 &ExistingUserController::OnPublicSessionAutoLoginTimerFire, | |
980 weak_factory_.GetWeakPtr())); | |
981 } | |
982 | |
868 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { | 983 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
869 return host_->GetNativeWindow(); | 984 return host_->GetNativeWindow(); |
870 } | 985 } |
871 | 986 |
872 void ExistingUserController::InitializeStartUrls() const { | 987 void ExistingUserController::InitializeStartUrls() const { |
873 std::vector<std::string> start_urls; | 988 std::vector<std::string> start_urls; |
874 | 989 |
875 PrefService* prefs = g_browser_process->local_state(); | 990 PrefService* prefs = g_browser_process->local_state(); |
876 const base::ListValue *urls; | 991 const base::ListValue *urls; |
877 bool show_getstarted_guide = false; | 992 bool show_getstarted_guide = false; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1004 // changed. | 1119 // changed. |
1005 UserManager::Get()->SaveUserOAuthStatus( | 1120 UserManager::Get()->SaveUserOAuthStatus( |
1006 username, | 1121 username, |
1007 User::OAUTH2_TOKEN_STATUS_INVALID); | 1122 User::OAUTH2_TOKEN_STATUS_INVALID); |
1008 | 1123 |
1009 login_display_->SetUIEnabled(true); | 1124 login_display_->SetUIEnabled(true); |
1010 login_display_->ShowGaiaPasswordChanged(username); | 1125 login_display_->ShowGaiaPasswordChanged(username); |
1011 } | 1126 } |
1012 | 1127 |
1013 } // namespace chromeos | 1128 } // namespace chromeos |
OLD | NEW |