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