Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 12218078: Implement a policy to autologin a public account. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: split out FakeSessionManagerClient Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 std::string setting = *content::Details<const std::string>(details).ptr();
bartfab (slow) 2013/02/25 16:51:23 Nit: I would make this a "const std::string"
dconnelly 2013/02/26 18:04:15 Done.
243 if (setting == kAccountsPrefDeviceLocalAccountAutoLoginId ||
244 setting == kAccountsPrefDeviceLocalAccountAutoLoginDelay) {
245 ConfigurePublicSessionAutoLogin();
246 }
247 }
231 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || 248 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED ||
232 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { 249 type == chrome::NOTIFICATION_USER_LIST_CHANGED) {
233 if (host_ != NULL) { 250 if (host_ != NULL) {
234 // Signed settings or user list changed. Notify views and update them. 251 // Signed settings or user list changed. Notify views and update them.
235 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); 252 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers());
236 return; 253 return;
237 } 254 }
238 } 255 }
239 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { 256 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) {
240 // Possibly the user has authenticated against a proxy server and we might 257 // Possibly the user has authenticated against a proxy server and we might
(...skipping 29 matching lines...) Expand all
270 // ExistingUserController, private: 287 // ExistingUserController, private:
271 288
272 ExistingUserController::~ExistingUserController() { 289 ExistingUserController::~ExistingUserController() {
273 LoginUtils::Get()->DelegateDeleted(this); 290 LoginUtils::Get()->DelegateDeleted(this);
274 291
275 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, 292 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn,
276 this); 293 this);
277 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); 294 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this);
278 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); 295 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this);
279 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); 296 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this);
297 cros_settings_->RemoveSettingsObserver(
298 kAccountsPrefDeviceLocalAccountAutoLoginId,
299 this);
300 cros_settings_->RemoveSettingsObserver(
301 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
302 this);
303
304 if (ash::Shell::HasInstance())
305 ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this);
280 306
281 if (current_controller_ == this) { 307 if (current_controller_ == this) {
282 current_controller_ = NULL; 308 current_controller_ = NULL;
283 } else { 309 } else {
284 NOTREACHED() << "More than one controller are alive."; 310 NOTREACHED() << "More than one controller are alive.";
285 } 311 }
286 DCHECK(login_display_.get()); 312 DCHECK(login_display_.get());
287 } 313 }
288 314
289 //////////////////////////////////////////////////////////////////////////////// 315 ////////////////////////////////////////////////////////////////////////////////
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // TODO(nkostylev): A11y message. 350 // TODO(nkostylev): A11y message.
325 } 351 }
326 352
327 void ExistingUserController::CompleteLogin(const std::string& username, 353 void ExistingUserController::CompleteLogin(const std::string& username,
328 const std::string& password) { 354 const std::string& password) {
329 if (!host_) { 355 if (!host_) {
330 // Complete login event was generated already from UI. Ignore notification. 356 // Complete login event was generated already from UI. Ignore notification.
331 return; 357 return;
332 } 358 }
333 359
360 // Stop the auto-login timer when attempting login.
361 StopPublicSessionAutoLoginTimer();
362
334 // Disable UI while loading user profile. 363 // Disable UI while loading user profile.
335 login_display_->SetUIEnabled(false); 364 login_display_->SetUIEnabled(false);
336 365
337 if (!time_init_.is_null()) { 366 if (!time_init_.is_null()) {
338 base::TimeDelta delta = base::Time::Now() - time_init_; 367 base::TimeDelta delta = base::Time::Now() - time_init_;
339 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); 368 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta);
340 time_init_ = base::Time(); // Reset to null. 369 time_init_ = base::Time(); // Reset to null.
341 } 370 }
342 371
343 host_->OnCompleteLogin(); 372 host_->OnCompleteLogin();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 409 }
381 410
382 string16 ExistingUserController::GetConnectedNetworkName() { 411 string16 ExistingUserController::GetConnectedNetworkName() {
383 return GetCurrentNetworkName(); 412 return GetCurrentNetworkName();
384 } 413 }
385 414
386 void ExistingUserController::Login(const std::string& username, 415 void ExistingUserController::Login(const std::string& username,
387 const std::string& password) { 416 const std::string& password) {
388 if (username.empty() || password.empty()) 417 if (username.empty() || password.empty())
389 return; 418 return;
419
420 // Stop the auto-login timer when attempting login.
421 StopPublicSessionAutoLoginTimer();
422
390 // Disable clicking on other windows. 423 // Disable clicking on other windows.
391 login_display_->SetUIEnabled(false); 424 login_display_->SetUIEnabled(false);
392 425
393 BootTimesLoader::Get()->RecordLoginAttempted(); 426 BootTimesLoader::Get()->RecordLoginAttempted();
394 427
395 if (last_login_attempt_username_ != username) { 428 if (last_login_attempt_username_ != username) {
396 last_login_attempt_username_ = username; 429 last_login_attempt_username_ = username;
397 num_login_attempts_ = 0; 430 num_login_attempts_ = 0;
398 // Also reset state variables, which are used to determine password change. 431 // Also reset state variables, which are used to determine password change.
399 offline_failed_ = false; 432 offline_failed_ = false;
(...skipping 27 matching lines...) Expand all
427 UserManager::kLocallyManagedUserDomain) { 460 UserManager::kLocallyManagedUserDomain) {
428 login_performer_->LoginAsLocallyManagedUser(username, password); 461 login_performer_->LoginAsLocallyManagedUser(username, password);
429 } else { 462 } else {
430 login_performer_->PerformLogin(username, password, auth_mode); 463 login_performer_->PerformLogin(username, password, auth_mode);
431 } 464 }
432 accessibility::MaybeSpeak( 465 accessibility::MaybeSpeak(
433 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); 466 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN));
434 } 467 }
435 468
436 void ExistingUserController::LoginAsRetailModeUser() { 469 void ExistingUserController::LoginAsRetailModeUser() {
470 // Stop the auto-login timer when attempting login.
471 StopPublicSessionAutoLoginTimer();
472
437 // Disable clicking on other windows. 473 // Disable clicking on other windows.
438 login_display_->SetUIEnabled(false); 474 login_display_->SetUIEnabled(false);
439 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once 475 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once
440 // the enterprise policy wiring is done for retail mode. 476 // the enterprise policy wiring is done for retail mode.
441 477
442 // Only one instance of LoginPerformer should exist at a time. 478 // Only one instance of LoginPerformer should exist at a time.
443 login_performer_.reset(NULL); 479 login_performer_.reset(NULL);
444 login_performer_.reset(new LoginPerformer(this)); 480 login_performer_.reset(new LoginPerformer(this));
445 is_login_in_progress_ = true; 481 is_login_in_progress_ = true;
446 login_performer_->LoginRetailMode(); 482 login_performer_->LoginRetailMode();
447 accessibility::MaybeSpeak( 483 accessibility::MaybeSpeak(
448 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); 484 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER));
449 } 485 }
450 486
451 void ExistingUserController::LoginAsGuest() { 487 void ExistingUserController::LoginAsGuest() {
488 // Stop the auto-login timer when attempting login.
489 StopPublicSessionAutoLoginTimer();
490
452 // Disable clicking on other windows. 491 // Disable clicking on other windows.
453 login_display_->SetUIEnabled(false); 492 login_display_->SetUIEnabled(false);
454 493
455 CrosSettingsProvider::TrustedStatus status = 494 CrosSettingsProvider::TrustedStatus status =
456 cros_settings_->PrepareTrustedValues( 495 cros_settings_->PrepareTrustedValues(
457 base::Bind(&ExistingUserController::LoginAsGuest, 496 base::Bind(&ExistingUserController::LoginAsGuest,
458 weak_factory_.GetWeakPtr())); 497 weak_factory_.GetWeakPtr()));
459 // Must not proceed without signature verification. 498 // Must not proceed without signature verification.
460 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { 499 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
461 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, 500 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1,
462 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); 501 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
463 // Reenable clicking on other windows and status area. 502 // Reenable clicking on other windows and status area.
464 login_display_->SetUIEnabled(true); 503 login_display_->SetUIEnabled(true);
504 StartPublicSessionAutoLoginTimer();
465 display_email_.clear(); 505 display_email_.clear();
466 return; 506 return;
467 } else if (status != CrosSettingsProvider::TRUSTED) { 507 } else if (status != CrosSettingsProvider::TRUSTED) {
468 // Value of AllowNewUser setting is still not verified. 508 // Value of AllowNewUser setting is still not verified.
469 // Another attempt will be invoked after verification completion. 509 // Another attempt will be invoked after verification completion.
510 StartPublicSessionAutoLoginTimer();
bartfab (slow) 2013/02/25 16:51:23 Notice that we end up here if the policy subsystem
dconnelly 2013/02/26 18:04:15 Done.
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) {
570 StartPublicSessionAutoLoginTimer();
bartfab (slow) 2013/02/25 16:51:23 Notice that we end up here if the policy subsystem
dconnelly 2013/02/26 18:04:15 Done.
525 return; 571 return;
572 }
526 573
527 // If there is no public account with the given |username|, logging in is not 574 // If there is no public account with the given |username|, logging in is not
528 // possible. 575 // possible.
529 const User* user = UserManager::Get()->FindUser(username); 576 const User* user = UserManager::Get()->FindUser(username);
530 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { 577 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) {
531 // Re-enable clicking on other windows. 578 // Re-enable clicking on other windows.
532 login_display_->SetUIEnabled(true); 579 login_display_->SetUIEnabled(true);
580 StartPublicSessionAutoLoginTimer();
533 return; 581 return;
534 } 582 }
535 583
536 // Only one instance of LoginPerformer should exist at a time. 584 // Only one instance of LoginPerformer should exist at a time.
537 login_performer_.reset(NULL); 585 login_performer_.reset(NULL);
538 login_performer_.reset(new LoginPerformer(this)); 586 login_performer_.reset(new LoginPerformer(this));
539 is_login_in_progress_ = true; 587 is_login_in_progress_ = true;
540 login_performer_->LoginAsPublicAccount(username); 588 login_performer_->LoginAsPublicAccount(username);
541 accessibility::MaybeSpeak( 589 accessibility::MaybeSpeak(
542 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); 590 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT));
543 } 591 }
544 592
593 void ExistingUserController::OnSigninScreenReady() {
594 signin_screen_ready_ = true;
595 StartPublicSessionAutoLoginTimer();
596 }
597
545 void ExistingUserController::OnUserSelected(const std::string& username) { 598 void ExistingUserController::OnUserSelected(const std::string& username) {
546 login_performer_.reset(NULL); 599 login_performer_.reset(NULL);
547 num_login_attempts_ = 0; 600 num_login_attempts_ = 0;
548 } 601 }
549 602
550 void ExistingUserController::OnStartEnterpriseEnrollment() { 603 void ExistingUserController::OnStartEnterpriseEnrollment() {
551 DeviceSettingsService::Get()->GetOwnershipStatusAsync( 604 DeviceSettingsService::Get()->GetOwnershipStatusAsync(
552 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, 605 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted,
553 weak_factory_.GetWeakPtr())); 606 weak_factory_.GetWeakPtr()));
554 } 607 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error); 726 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_HOSTED, error);
674 } else { 727 } else {
675 if (!is_known_user) 728 if (!is_known_user)
676 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error); 729 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING_NEW, error);
677 else 730 else
678 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error); 731 ShowError(IDS_LOGIN_ERROR_AUTHENTICATING, error);
679 } 732 }
680 } 733 }
681 // Reenable clicking on other windows and status area. 734 // Reenable clicking on other windows and status area.
682 login_display_->SetUIEnabled(true); 735 login_display_->SetUIEnabled(true);
736 StartPublicSessionAutoLoginTimer();
683 } 737 }
684 738
685 // Reset user flow to default, so that special flow will not affect next 739 // Reset user flow to default, so that special flow will not affect next
686 // attempt. 740 // attempt.
687 UserManager::Get()->ResetUserFlow(last_login_attempt_username_); 741 UserManager::Get()->ResetUserFlow(last_login_attempt_username_);
688 742
689 if (login_status_consumer_) 743 if (login_status_consumer_)
690 login_status_consumer_->OnLoginFailure(failure); 744 login_status_consumer_->OnLoginFailure(failure);
691 745
692 // Clear the recorded displayed email so it won't affect any future attempts. 746 // Clear the recorded displayed email so it won't affect any future attempts.
693 display_email_.clear(); 747 display_email_.clear();
694 } 748 }
695 749
696 void ExistingUserController::OnLoginSuccess( 750 void ExistingUserController::OnLoginSuccess(
697 const std::string& username, 751 const std::string& username,
698 const std::string& password, 752 const std::string& password,
699 bool pending_requests, 753 bool pending_requests,
700 bool using_oauth) { 754 bool using_oauth) {
701 is_login_in_progress_ = false; 755 is_login_in_progress_ = false;
702 offline_failed_ = false; 756 offline_failed_ = false;
703 757
758 StopPublicSessionAutoLoginTimer();
759
704 bool has_cookies = 760 bool has_cookies =
705 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION; 761 login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION;
706 762
707 // Login performer will be gone so cache this value to use 763 // Login performer will be gone so cache this value to use
708 // once profile is loaded. 764 // once profile is loaded.
709 password_changed_ = login_performer_->password_changed(); 765 password_changed_ = login_performer_->password_changed();
710 766
711 // LoginPerformer instance will delete itself once online auth result is OK. 767 // LoginPerformer instance will delete itself once online auth result is OK.
712 // In case of failure it'll bring up ScreenLock and ask for 768 // In case of failure it'll bring up ScreenLock and ask for
713 // correct password/display error message. 769 // correct password/display error message.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 874
819 // Reenable clicking on other windows and status area. 875 // Reenable clicking on other windows and status area.
820 login_display_->SetUIEnabled(true); 876 login_display_->SetUIEnabled(true);
821 877
822 if (login_status_consumer_) { 878 if (login_status_consumer_) {
823 login_status_consumer_->OnLoginFailure(LoginFailure( 879 login_status_consumer_->OnLoginFailure(LoginFailure(
824 LoginFailure::WHITELIST_CHECK_FAILED)); 880 LoginFailure::WHITELIST_CHECK_FAILED));
825 } 881 }
826 882
827 display_email_.clear(); 883 display_email_.clear();
884
885 StartPublicSessionAutoLoginTimer();
828 } 886 }
829 887
830 void ExistingUserController::PolicyLoadFailed() { 888 void ExistingUserController::PolicyLoadFailed() {
831 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); 889 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, "");
832 890
833 // Reenable clicking on other windows and status area. 891 // Reenable clicking on other windows and status area.
834 login_display_->SetUIEnabled(true); 892 login_display_->SetUIEnabled(true);
835 893
836 display_email_.clear(); 894 display_email_.clear();
895
896 // Policy load failure stops login attempts---restart the timer.
bartfab (slow) 2013/02/25 16:51:23 Nit: I am still bothered by these triple dashes an
dconnelly 2013/02/26 18:04:15 Done. But I'm going to make sure that every email
897 StartPublicSessionAutoLoginTimer();
837 } 898 }
838 899
839 void ExistingUserController::OnOnlineChecked(const std::string& username, 900 void ExistingUserController::OnOnlineChecked(const std::string& username,
840 bool success) { 901 bool success) {
841 if (success && last_login_attempt_username_ == username) { 902 if (success && last_login_attempt_username_ == username) {
842 online_succeeded_for_ = username; 903 online_succeeded_for_ = username;
843 // Wait for login attempt to end, if it hasn't yet. 904 // Wait for login attempt to end, if it hasn't yet.
844 if (offline_failed_ && !is_login_in_progress_) 905 if (offline_failed_ && !is_login_in_progress_)
845 ShowGaiaPasswordChanged(username); 906 ShowGaiaPasswordChanged(username);
846 } 907 }
847 } 908 }
848 909
849 //////////////////////////////////////////////////////////////////////////////// 910 ////////////////////////////////////////////////////////////////////////////////
850 // ExistingUserController, private: 911 // ExistingUserController, private:
851 912
852 void ExistingUserController::ActivateWizard(const std::string& screen_name) { 913 void ExistingUserController::ActivateWizard(const std::string& screen_name) {
853 DictionaryValue* params = NULL; 914 DictionaryValue* params = NULL;
854 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { 915 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) {
855 params = new DictionaryValue; 916 params = new DictionaryValue;
856 params->SetString("start_url", guest_mode_url_.spec()); 917 params->SetString("start_url", guest_mode_url_.spec());
857 } 918 }
858 host_->StartWizard(screen_name, params); 919 host_->StartWizard(screen_name, params);
859 } 920 }
860 921
922 void ExistingUserController::ConfigurePublicSessionAutoLogin() {
923 if (!cros_settings_->GetString(
924 kAccountsPrefDeviceLocalAccountAutoLoginId,
925 &public_session_auto_login_username_) ||
926 public_session_auto_login_username_.empty()) {
927 public_session_auto_login_username_ = "";
bartfab (slow) 2013/02/25 16:51:23 You can simplify this to: if (!cros_settings_->Ge
dconnelly 2013/02/26 18:04:15 Done.
928 }
929 if (!cros_settings_->GetInteger(
930 kAccountsPrefDeviceLocalAccountAutoLoginDelay,
931 &public_session_auto_login_delay_)) {
932 public_session_auto_login_delay_ = 0;
933 }
934
935 ash::UserActivityDetector* detector = ash::Shell::HasInstance()
936 ? ash::Shell::GetInstance()->user_activity_detector() : NULL;
bartfab (slow) 2013/02/25 16:51:23 I think it is allowed to put the |?| at the start
dconnelly 2013/02/26 18:04:15 Done.
937 if (!public_session_auto_login_username_.empty()) {
938 StartPublicSessionAutoLoginTimer();
939 if (detector && !detector->HasObserver(this))
940 detector->AddObserver(this);
941 } else {
942 if (detector)
943 detector->RemoveObserver(this);
944 StopPublicSessionAutoLoginTimer();
945 }
946 }
947
948 void ExistingUserController::OnUserActivity() {
949 if (auto_login_timer_.IsRunning()) {
bartfab (slow) 2013/02/25 16:51:23 It is pretty obvious what this function is doing b
dconnelly 2013/02/26 18:04:15 Done.
950 StopPublicSessionAutoLoginTimer();
951 StartPublicSessionAutoLoginTimer();
952 }
953 }
954
955 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() {
956 DCHECK(signin_screen_ready_ &&
957 !is_login_in_progress_ &&
958 !public_session_auto_login_username_.empty());
959 LoginAsPublicAccount(public_session_auto_login_username_);
960 }
961
962 void ExistingUserController::StopPublicSessionAutoLoginTimer() {
963 auto_login_timer_.Stop();
964 }
965
966 void ExistingUserController::StartPublicSessionAutoLoginTimer() {
967 if (!signin_screen_ready_ ||
968 public_session_auto_login_username_.empty() ||
969 is_login_in_progress_) {
bartfab (slow) 2013/02/25 16:51:23 Nit: The conditions in lines 956-958 and 967-969 a
dconnelly 2013/02/26 18:04:15 Done.
970 return;
971 }
972
973 // Start the auto-login timer.
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
861 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { 983 gfx::NativeWindow ExistingUserController::GetNativeWindow() const {
862 return host_->GetNativeWindow(); 984 return host_->GetNativeWindow();
863 } 985 }
864 986
865 void ExistingUserController::InitializeStartUrls() const { 987 void ExistingUserController::InitializeStartUrls() const {
866 std::vector<std::string> start_urls; 988 std::vector<std::string> start_urls;
867 989
868 PrefService* prefs = g_browser_process->local_state(); 990 PrefService* prefs = g_browser_process->local_state();
869 const base::ListValue *urls; 991 const base::ListValue *urls;
870 bool show_getstarted_guide = false; 992 bool show_getstarted_guide = false;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 // changed. 1120 // changed.
999 UserManager::Get()->SaveUserOAuthStatus( 1121 UserManager::Get()->SaveUserOAuthStatus(
1000 username, 1122 username,
1001 User::OAUTH2_TOKEN_STATUS_INVALID); 1123 User::OAUTH2_TOKEN_STATUS_INVALID);
1002 1124
1003 login_display_->SetUIEnabled(true); 1125 login_display_->SetUIEnabled(true);
1004 login_display_->ShowGaiaPasswordChanged(username); 1126 login_display_->ShowGaiaPasswordChanged(username);
1005 } 1127 }
1006 1128
1007 } // namespace chromeos 1129 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698