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/wm/user_activity_detector.h" | |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 12 #include "base/callback.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
16 #include "base/string_util.h" | 17 #include "base/string_util.h" |
17 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
18 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
(...skipping 117 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 const content::NotificationSource& source, | 230 const content::NotificationSource& source, |
222 const content::NotificationDetails& details) { | 231 const content::NotificationDetails& details) { |
223 if (type == chrome::NOTIFICATION_SESSION_STARTED) { | 232 if (type == chrome::NOTIFICATION_SESSION_STARTED) { |
224 // Stop listening to any notification once session has started. | 233 // Stop listening to any notification once session has started. |
225 // Sign in screen objects are marked for deletion with DeleteSoon so | 234 // Sign in screen objects are marked for deletion with DeleteSoon so |
226 // make sure no object would be used after session has started. | 235 // make sure no object would be used after session has started. |
227 // http://crbug.com/125276 | 236 // http://crbug.com/125276 |
228 registrar_.RemoveAll(); | 237 registrar_.RemoveAll(); |
229 return; | 238 return; |
230 } | 239 } |
240 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) { | |
241 std::string setting = *content::Details<const std::string>(details).ptr(); | |
242 if (setting == kAccountsPrefDeviceLocalAccountAutoLoginId || | |
243 setting == kAccountsPrefDeviceLocalAccountAutoLoginDelay) { | |
244 ConfigurePublicSessionAutoLogin(); | |
245 } | |
246 } | |
231 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || | 247 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED || |
232 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { | 248 type == chrome::NOTIFICATION_USER_LIST_CHANGED) { |
233 if (host_ != NULL) { | 249 if (host_ != NULL) { |
234 // Signed settings or user list changed. Notify views and update them. | 250 // Signed settings or user list changed. Notify views and update them. |
235 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); | 251 UpdateLoginDisplay(chromeos::UserManager::Get()->GetUsers()); |
236 return; | 252 return; |
237 } | 253 } |
238 } | 254 } |
239 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { | 255 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { |
240 // Possibly the user has authenticated against a proxy server and we might | 256 // Possibly the user has authenticated against a proxy server and we might |
(...skipping 29 matching lines...) Expand all Loading... | |
270 // ExistingUserController, private: | 286 // ExistingUserController, private: |
271 | 287 |
272 ExistingUserController::~ExistingUserController() { | 288 ExistingUserController::~ExistingUserController() { |
273 LoginUtils::Get()->DelegateDeleted(this); | 289 LoginUtils::Get()->DelegateDeleted(this); |
274 | 290 |
275 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, | 291 cros_settings_->RemoveSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, |
276 this); | 292 this); |
277 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); | 293 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowNewUser, this); |
278 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); | 294 cros_settings_->RemoveSettingsObserver(kAccountsPrefAllowGuest, this); |
279 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); | 295 cros_settings_->RemoveSettingsObserver(kAccountsPrefUsers, this); |
296 cros_settings_->RemoveSettingsObserver( | |
297 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
298 this); | |
299 cros_settings_->RemoveSettingsObserver( | |
300 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
301 this); | |
280 | 302 |
281 if (current_controller_ == this) { | 303 if (current_controller_ == this) { |
282 current_controller_ = NULL; | 304 current_controller_ = NULL; |
283 } else { | 305 } else { |
284 NOTREACHED() << "More than one controller are alive."; | 306 NOTREACHED() << "More than one controller are alive."; |
285 } | 307 } |
286 DCHECK(login_display_.get()); | 308 DCHECK(login_display_.get()); |
287 } | 309 } |
288 | 310 |
289 //////////////////////////////////////////////////////////////////////////////// | 311 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 // TODO(nkostylev): A11y message. | 346 // TODO(nkostylev): A11y message. |
325 } | 347 } |
326 | 348 |
327 void ExistingUserController::CompleteLogin(const std::string& username, | 349 void ExistingUserController::CompleteLogin(const std::string& username, |
328 const std::string& password) { | 350 const std::string& password) { |
329 if (!host_) { | 351 if (!host_) { |
330 // Complete login event was generated already from UI. Ignore notification. | 352 // Complete login event was generated already from UI. Ignore notification. |
331 return; | 353 return; |
332 } | 354 } |
333 | 355 |
356 // Stop the auto-login timer when attempting login. | |
357 StopPublicSessionAutoLoginTimer(); | |
358 | |
334 // Disable UI while loading user profile. | 359 // Disable UI while loading user profile. |
335 login_display_->SetUIEnabled(false); | 360 login_display_->SetUIEnabled(false); |
336 | 361 |
337 if (!time_init_.is_null()) { | 362 if (!time_init_.is_null()) { |
338 base::TimeDelta delta = base::Time::Now() - time_init_; | 363 base::TimeDelta delta = base::Time::Now() - time_init_; |
339 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); | 364 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); |
340 time_init_ = base::Time(); // Reset to null. | 365 time_init_ = base::Time(); // Reset to null. |
341 } | 366 } |
342 | 367 |
343 host_->OnCompleteLogin(); | 368 host_->OnCompleteLogin(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 } | 405 } |
381 | 406 |
382 string16 ExistingUserController::GetConnectedNetworkName() { | 407 string16 ExistingUserController::GetConnectedNetworkName() { |
383 return GetCurrentNetworkName(); | 408 return GetCurrentNetworkName(); |
384 } | 409 } |
385 | 410 |
386 void ExistingUserController::Login(const std::string& username, | 411 void ExistingUserController::Login(const std::string& username, |
387 const std::string& password) { | 412 const std::string& password) { |
388 if (username.empty() || password.empty()) | 413 if (username.empty() || password.empty()) |
389 return; | 414 return; |
415 | |
416 // Stop the auto-login timer when attempting login. | |
417 StopPublicSessionAutoLoginTimer(); | |
418 | |
390 // Disable clicking on other windows. | 419 // Disable clicking on other windows. |
391 login_display_->SetUIEnabled(false); | 420 login_display_->SetUIEnabled(false); |
392 | 421 |
393 BootTimesLoader::Get()->RecordLoginAttempted(); | 422 BootTimesLoader::Get()->RecordLoginAttempted(); |
394 | 423 |
395 if (last_login_attempt_username_ != username) { | 424 if (last_login_attempt_username_ != username) { |
396 last_login_attempt_username_ = username; | 425 last_login_attempt_username_ = username; |
397 num_login_attempts_ = 0; | 426 num_login_attempts_ = 0; |
398 // Also reset state variables, which are used to determine password change. | 427 // Also reset state variables, which are used to determine password change. |
399 offline_failed_ = false; | 428 offline_failed_ = false; |
(...skipping 27 matching lines...) Expand all Loading... | |
427 UserManager::kLocallyManagedUserDomain) { | 456 UserManager::kLocallyManagedUserDomain) { |
428 login_performer_->LoginAsLocallyManagedUser(username, password); | 457 login_performer_->LoginAsLocallyManagedUser(username, password); |
429 } else { | 458 } else { |
430 login_performer_->PerformLogin(username, password, auth_mode); | 459 login_performer_->PerformLogin(username, password, auth_mode); |
431 } | 460 } |
432 accessibility::MaybeSpeak( | 461 accessibility::MaybeSpeak( |
433 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); | 462 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); |
434 } | 463 } |
435 | 464 |
436 void ExistingUserController::LoginAsRetailModeUser() { | 465 void ExistingUserController::LoginAsRetailModeUser() { |
466 // Stop the auto-login timer when attempting login. | |
467 StopPublicSessionAutoLoginTimer(); | |
468 | |
437 // Disable clicking on other windows. | 469 // Disable clicking on other windows. |
438 login_display_->SetUIEnabled(false); | 470 login_display_->SetUIEnabled(false); |
439 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once | 471 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once |
440 // the enterprise policy wiring is done for retail mode. | 472 // the enterprise policy wiring is done for retail mode. |
441 | 473 |
442 // Only one instance of LoginPerformer should exist at a time. | 474 // Only one instance of LoginPerformer should exist at a time. |
443 login_performer_.reset(NULL); | 475 login_performer_.reset(NULL); |
444 login_performer_.reset(new LoginPerformer(this)); | 476 login_performer_.reset(new LoginPerformer(this)); |
445 is_login_in_progress_ = true; | 477 is_login_in_progress_ = true; |
446 login_performer_->LoginRetailMode(); | 478 login_performer_->LoginRetailMode(); |
447 accessibility::MaybeSpeak( | 479 accessibility::MaybeSpeak( |
448 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); | 480 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER)); |
449 } | 481 } |
450 | 482 |
451 void ExistingUserController::LoginAsGuest() { | 483 void ExistingUserController::LoginAsGuest() { |
484 // Stop the auto-login timer when attempting login. | |
485 StopPublicSessionAutoLoginTimer(); | |
486 | |
452 // Disable clicking on other windows. | 487 // Disable clicking on other windows. |
453 login_display_->SetUIEnabled(false); | 488 login_display_->SetUIEnabled(false); |
454 | 489 |
455 CrosSettingsProvider::TrustedStatus status = | 490 CrosSettingsProvider::TrustedStatus status = |
456 cros_settings_->PrepareTrustedValues( | 491 cros_settings_->PrepareTrustedValues( |
457 base::Bind(&ExistingUserController::LoginAsGuest, | 492 base::Bind(&ExistingUserController::LoginAsGuest, |
458 weak_factory_.GetWeakPtr())); | 493 weak_factory_.GetWeakPtr())); |
459 // Must not proceed without signature verification. | 494 // Must not proceed without signature verification. |
460 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { | 495 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { |
461 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, | 496 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, |
462 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 497 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
463 // Reenable clicking on other windows and status area. | 498 // Reenable clicking on other windows and status area. |
464 login_display_->SetUIEnabled(true); | 499 login_display_->SetUIEnabled(true); |
500 StartPublicSessionAutoLoginTimer(); | |
465 display_email_.clear(); | 501 display_email_.clear(); |
466 return; | 502 return; |
467 } else if (status != CrosSettingsProvider::TRUSTED) { | 503 } else if (status != CrosSettingsProvider::TRUSTED) { |
468 // Value of AllowNewUser setting is still not verified. | 504 // Value of AllowNewUser setting is still not verified. |
469 // Another attempt will be invoked after verification completion. | 505 // Another attempt will be invoked after verification completion. |
506 StartPublicSessionAutoLoginTimer(); | |
470 return; | 507 return; |
471 } | 508 } |
472 | 509 |
473 bool allow_guest; | 510 bool allow_guest; |
474 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 511 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
475 if (!allow_guest) { | 512 if (!allow_guest) { |
476 // Disallowed. The UI should normally not show the guest pod but if for some | 513 // 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 | 514 // reason this has been made available to the user here is the time to tell |
478 // this nicely. | 515 // this nicely. |
479 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, | 516 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1, |
480 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 517 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
481 // Reenable clicking on other windows and status area. | 518 // Reenable clicking on other windows and status area. |
482 login_display_->SetUIEnabled(true); | 519 login_display_->SetUIEnabled(true); |
520 StartPublicSessionAutoLoginTimer(); | |
483 display_email_.clear(); | 521 display_email_.clear(); |
484 return; | 522 return; |
485 } | 523 } |
486 | 524 |
487 // Only one instance of LoginPerformer should exist at a time. | 525 // Only one instance of LoginPerformer should exist at a time. |
488 login_performer_.reset(NULL); | 526 login_performer_.reset(NULL); |
489 login_performer_.reset(new LoginPerformer(this)); | 527 login_performer_.reset(new LoginPerformer(this)); |
490 is_login_in_progress_ = true; | 528 is_login_in_progress_ = true; |
491 login_performer_->LoginOffTheRecord(); | 529 login_performer_->LoginOffTheRecord(); |
492 accessibility::MaybeSpeak( | 530 accessibility::MaybeSpeak( |
493 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); | 531 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD)); |
494 } | 532 } |
495 | 533 |
496 void ExistingUserController::MigrateUserData(const std::string& old_password) { | 534 void ExistingUserController::MigrateUserData(const std::string& old_password) { |
497 RecoverEncryptedData(old_password); | 535 RecoverEncryptedData(old_password); |
498 } | 536 } |
499 | 537 |
500 void ExistingUserController::LoginAsPublicAccount( | 538 void ExistingUserController::LoginAsPublicAccount( |
501 const std::string& username) { | 539 const std::string& username) { |
540 // Stop the auto-login timer when attempting login. | |
541 StopPublicSessionAutoLoginTimer(); | |
542 | |
502 // Disable clicking on other windows. | 543 // Disable clicking on other windows. |
503 login_display_->SetUIEnabled(false); | 544 login_display_->SetUIEnabled(false); |
504 | 545 |
505 CrosSettingsProvider::TrustedStatus status = | 546 CrosSettingsProvider::TrustedStatus status = |
506 cros_settings_->PrepareTrustedValues( | 547 cros_settings_->PrepareTrustedValues( |
507 base::Bind(&ExistingUserController::LoginAsPublicAccount, | 548 base::Bind(&ExistingUserController::LoginAsPublicAccount, |
508 weak_factory_.GetWeakPtr(), | 549 weak_factory_.GetWeakPtr(), |
509 username)); | 550 username)); |
510 // If device policy is permanently unavailable, logging into public accounts | 551 // If device policy is permanently unavailable, logging into public accounts |
511 // is not possible. | 552 // is not possible. |
512 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { | 553 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { |
513 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, | 554 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1, |
514 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 555 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
515 // Re-enable clicking on other windows. | 556 // Re-enable clicking on other windows. |
516 login_display_->SetUIEnabled(true); | 557 login_display_->SetUIEnabled(true); |
517 return; | 558 return; |
518 } | 559 } |
519 | 560 |
520 // If device policy is not verified yet, this function will be called again | 561 // If device policy is not verified yet, this function will be called again |
521 // when verification finishes. | 562 // when verification finishes. |
522 if (status != CrosSettingsProvider::TRUSTED) | 563 if (status != CrosSettingsProvider::TRUSTED) { |
564 StartPublicSessionAutoLoginTimer(); | |
523 return; | 565 return; |
566 } | |
524 | 567 |
525 // If there is no public account with the given |username|, logging in is not | 568 // If there is no public account with the given |username|, logging in is not |
526 // possible. | 569 // possible. |
527 const User* user = UserManager::Get()->FindUser(username); | 570 const User* user = UserManager::Get()->FindUser(username); |
528 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { | 571 if (!user || user->GetType() != User::USER_TYPE_PUBLIC_ACCOUNT) { |
529 // Re-enable clicking on other windows. | 572 // Re-enable clicking on other windows. |
530 login_display_->SetUIEnabled(true); | 573 login_display_->SetUIEnabled(true); |
574 StartPublicSessionAutoLoginTimer(); | |
531 return; | 575 return; |
532 } | 576 } |
533 | 577 |
534 // Only one instance of LoginPerformer should exist at a time. | 578 // Only one instance of LoginPerformer should exist at a time. |
535 login_performer_.reset(NULL); | 579 login_performer_.reset(NULL); |
536 login_performer_.reset(new LoginPerformer(this)); | 580 login_performer_.reset(new LoginPerformer(this)); |
537 is_login_in_progress_ = true; | 581 is_login_in_progress_ = true; |
538 login_performer_->LoginAsPublicAccount(username); | 582 login_performer_->LoginAsPublicAccount(username); |
539 accessibility::MaybeSpeak( | 583 accessibility::MaybeSpeak( |
540 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); | 584 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_PUBLIC_ACCOUNT)); |
541 } | 585 } |
542 | 586 |
587 void ExistingUserController::OnSigninScreenReady() { | |
588 signin_screen_ready_ = true; | |
589 StartPublicSessionAutoLoginTimer(); | |
590 } | |
591 | |
543 void ExistingUserController::OnUserSelected(const std::string& username) { | 592 void ExistingUserController::OnUserSelected(const std::string& username) { |
544 login_performer_.reset(NULL); | 593 login_performer_.reset(NULL); |
545 num_login_attempts_ = 0; | 594 num_login_attempts_ = 0; |
546 } | 595 } |
547 | 596 |
548 void ExistingUserController::OnStartEnterpriseEnrollment() { | 597 void ExistingUserController::OnStartEnterpriseEnrollment() { |
549 DeviceSettingsService::Get()->GetOwnershipStatusAsync( | 598 DeviceSettingsService::Get()->GetOwnershipStatusAsync( |
550 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, | 599 base::Bind(&ExistingUserController::OnEnrollmentOwnershipCheckCompleted, |
551 weak_factory_.GetWeakPtr())); | 600 weak_factory_.GetWeakPtr())); |
552 } | 601 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 } | 722 } |
674 // Reenable clicking on other windows and status area. | 723 // Reenable clicking on other windows and status area. |
675 login_display_->SetUIEnabled(true); | 724 login_display_->SetUIEnabled(true); |
676 } | 725 } |
677 | 726 |
678 if (login_status_consumer_) | 727 if (login_status_consumer_) |
679 login_status_consumer_->OnLoginFailure(failure); | 728 login_status_consumer_->OnLoginFailure(failure); |
680 | 729 |
681 // Clear the recorded displayed email so it won't affect any future attempts. | 730 // Clear the recorded displayed email so it won't affect any future attempts. |
682 display_email_.clear(); | 731 display_email_.clear(); |
732 | |
733 StartPublicSessionAutoLoginTimer(); | |
683 } | 734 } |
684 | 735 |
685 void ExistingUserController::OnLoginSuccess( | 736 void ExistingUserController::OnLoginSuccess( |
686 const std::string& username, | 737 const std::string& username, |
687 const std::string& password, | 738 const std::string& password, |
688 bool pending_requests, | 739 bool pending_requests, |
689 bool using_oauth) { | 740 bool using_oauth) { |
690 is_login_in_progress_ = false; | 741 is_login_in_progress_ = false; |
691 offline_failed_ = false; | 742 offline_failed_ = false; |
692 | 743 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
827 display_email_.clear(); | 878 display_email_.clear(); |
828 } | 879 } |
829 | 880 |
830 void ExistingUserController::PolicyLoadFailed() { | 881 void ExistingUserController::PolicyLoadFailed() { |
831 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); | 882 ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, ""); |
832 | 883 |
833 // Reenable clicking on other windows and status area. | 884 // Reenable clicking on other windows and status area. |
834 login_display_->SetUIEnabled(true); | 885 login_display_->SetUIEnabled(true); |
835 | 886 |
836 display_email_.clear(); | 887 display_email_.clear(); |
888 | |
889 // Policy load failure stops login attempts---restart the timer. | |
890 StartPublicSessionAutoLoginTimer(); | |
837 } | 891 } |
838 | 892 |
839 void ExistingUserController::OnOnlineChecked(const std::string& username, | 893 void ExistingUserController::OnOnlineChecked(const std::string& username, |
840 bool success) { | 894 bool success) { |
841 if (success && last_login_attempt_username_ == username) { | 895 if (success && last_login_attempt_username_ == username) { |
842 online_succeeded_for_ = username; | 896 online_succeeded_for_ = username; |
843 // Wait for login attempt to end, if it hasn't yet. | 897 // Wait for login attempt to end, if it hasn't yet. |
844 if (offline_failed_ && !is_login_in_progress_) | 898 if (offline_failed_ && !is_login_in_progress_) |
845 ShowGaiaPasswordChanged(username); | 899 ShowGaiaPasswordChanged(username); |
846 } | 900 } |
(...skipping 21 matching lines...) Expand all Loading... | |
868 | 922 |
869 void ExistingUserController::ActivateWizard(const std::string& screen_name) { | 923 void ExistingUserController::ActivateWizard(const std::string& screen_name) { |
870 DictionaryValue* params = NULL; | 924 DictionaryValue* params = NULL; |
871 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { | 925 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) { |
872 params = new DictionaryValue; | 926 params = new DictionaryValue; |
873 params->SetString("start_url", guest_mode_url_.spec()); | 927 params->SetString("start_url", guest_mode_url_.spec()); |
874 } | 928 } |
875 host_->StartWizard(screen_name, params); | 929 host_->StartWizard(screen_name, params); |
876 } | 930 } |
877 | 931 |
932 void ExistingUserController::ConfigurePublicSessionAutoLogin() { | |
933 if (!cros_settings_->GetString( | |
934 kAccountsPrefDeviceLocalAccountAutoLoginId, | |
935 &public_session_auto_login_username_) || | |
936 public_session_auto_login_username_.empty()) { | |
937 public_session_auto_login_username_ = ""; | |
938 } | |
939 if (!cros_settings_->GetInteger( | |
940 kAccountsPrefDeviceLocalAccountAutoLoginDelay, | |
941 &public_session_auto_login_delay_)) { | |
942 public_session_auto_login_delay_ = 0; | |
943 } | |
944 | |
945 if (!public_session_auto_login_username_.empty()) { | |
946 if (!ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this)) | |
947 ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this); | |
Nikita (slow)
2013/02/11 17:30:29
Remove observer in dtor?
bartfab (slow)
2013/02/11 17:37:31
The observer could be unconditionally added and re
Nikita (slow)
2013/02/11 17:51:31
Ok then.
dconnelly
2013/02/21 10:42:21
Done.
| |
948 StartPublicSessionAutoLoginTimer(); | |
949 } else { | |
950 ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this); | |
Nikita (slow)
2013/02/11 17:30:29
On a normal boot path (i.e. no public accounts con
bartfab (slow)
2013/02/11 17:37:31
It's actually benign to remove an observer that do
Nikita (slow)
2013/02/11 17:51:31
I thought that previously it had a such check so i
dconnelly
2013/02/21 10:42:21
You're not confused--there was a check before. I
| |
951 StopPublicSessionAutoLoginTimer(); | |
952 } | |
953 } | |
954 | |
955 void ExistingUserController::OnUserActivity() { | |
956 if (auto_login_timer_.IsRunning()) { | |
957 StopPublicSessionAutoLoginTimer(); | |
958 StartPublicSessionAutoLoginTimer(); | |
Nikita (slow)
2013/02/11 17:30:29
What's the point of restarting timer?
bartfab (slow)
2013/02/11 17:37:31
The idea is that the timer performs an auto-login
Nikita (slow)
2013/02/11 17:57:17
Take into account that device will power off after
| |
959 } | |
960 } | |
961 | |
962 void ExistingUserController::StopPublicSessionAutoLoginTimer() { | |
963 auto_login_timer_.Stop(); | |
964 } | |
965 | |
966 void ExistingUserController::StartPublicSessionAutoLoginTimer() { | |
967 if (!signin_screen_ready_ || public_session_auto_login_username_.empty()) | |
968 return; | |
969 auto_login_timer_.Start(FROM_HERE, | |
970 base::TimeDelta::FromMilliseconds( | |
971 public_session_auto_login_delay_), | |
972 base::Bind( | |
973 &ExistingUserController::LoginAsPublicAccount, | |
974 weak_factory_.GetWeakPtr(), | |
975 public_session_auto_login_username_)); | |
976 } | |
977 | |
878 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { | 978 gfx::NativeWindow ExistingUserController::GetNativeWindow() const { |
879 return host_->GetNativeWindow(); | 979 return host_->GetNativeWindow(); |
880 } | 980 } |
881 | 981 |
882 void ExistingUserController::InitializeStartUrls() const { | 982 void ExistingUserController::InitializeStartUrls() const { |
883 std::vector<std::string> start_urls; | 983 std::vector<std::string> start_urls; |
884 | 984 |
885 PrefService* prefs = g_browser_process->local_state(); | 985 PrefService* prefs = g_browser_process->local_state(); |
886 const base::ListValue *urls; | 986 const base::ListValue *urls; |
887 bool show_getstarted_guide = false; | 987 bool show_getstarted_guide = false; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1013 // changed. | 1113 // changed. |
1014 UserManager::Get()->SaveUserOAuthStatus( | 1114 UserManager::Get()->SaveUserOAuthStatus( |
1015 username, | 1115 username, |
1016 User::OAUTH2_TOKEN_STATUS_INVALID); | 1116 User::OAUTH2_TOKEN_STATUS_INVALID); |
1017 | 1117 |
1018 login_display_->SetUIEnabled(true); | 1118 login_display_->SetUIEnabled(true); |
1019 login_display_->ShowGaiaPasswordChanged(username); | 1119 login_display_->ShowGaiaPasswordChanged(username); |
1020 } | 1120 } |
1021 | 1121 |
1022 } // namespace chromeos | 1122 } // namespace chromeos |
OLD | NEW |