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

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

Issue 696263003: Prevent login while cros settings are untrusted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f_2_425574_add_protos_for_device_disabling_in_steady_state
Patch Set: Fix multi-login. Fix style guide violation: no else after return. Created 6 years, 1 month 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
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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/browser_process_platform_part.h" 24 #include "chrome/browser/browser_process_platform_part.h"
25 #include "chrome/browser/chrome_notification_types.h" 25 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/chromeos/boot_times_loader.h" 26 #include "chrome/browser/chromeos/boot_times_loader.h"
27 #include "chrome/browser/chromeos/customization_document.h" 27 #include "chrome/browser/chromeos/customization_document.h"
28 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 28 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
29 #include "chrome/browser/chromeos/login/auth/chrome_login_performer.h" 29 #include "chrome/browser/chromeos/login/auth/chrome_login_performer.h"
30 #include "chrome/browser/chromeos/login/helper.h" 30 #include "chrome/browser/chromeos/login/helper.h"
31 #include "chrome/browser/chromeos/login/login_utils.h" 31 #include "chrome/browser/chromeos/login/login_utils.h"
32 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 32 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
33 #include "chrome/browser/chromeos/login/signin_specifics.h"
33 #include "chrome/browser/chromeos/login/startup_utils.h" 34 #include "chrome/browser/chromeos/login/startup_utils.h"
34 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 35 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
35 #include "chrome/browser/chromeos/login/user_flow.h" 36 #include "chrome/browser/chromeos/login/user_flow.h"
36 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 37 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
37 #include "chrome/browser/chromeos/login/wizard_controller.h" 38 #include "chrome/browser/chromeos/login/wizard_controller.h"
38 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 39 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
39 #include "chrome/browser/chromeos/policy/device_local_account.h" 40 #include "chrome/browser/chromeos/policy/device_local_account.h"
40 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" 41 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
41 #include "chrome/browser/chromeos/profiles/profile_helper.h" 42 #include "chrome/browser/chromeos/profiles/profile_helper.h"
42 #include "chrome/browser/chromeos/settings/cros_settings.h" 43 #include "chrome/browser/chromeos/settings/cros_settings.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 338
338 void ExistingUserController::CancelPasswordChangedFlow() { 339 void ExistingUserController::CancelPasswordChangedFlow() {
339 login_performer_.reset(NULL); 340 login_performer_.reset(NULL);
340 PerformLoginFinishedActions(true /* start public session timer */); 341 PerformLoginFinishedActions(true /* start public session timer */);
341 } 342 }
342 343
343 void ExistingUserController::CreateAccount() { 344 void ExistingUserController::CreateAccount() {
344 content::RecordAction(base::UserMetricsAction("Login.CreateAccount")); 345 content::RecordAction(base::UserMetricsAction("Login.CreateAccount"));
345 guest_mode_url_ = google_util::AppendGoogleLocaleParam( 346 guest_mode_url_ = google_util::AppendGoogleLocaleParam(
346 GURL(kCreateAccountURL), g_browser_process->GetApplicationLocale()); 347 GURL(kCreateAccountURL), g_browser_process->GetApplicationLocale());
347 LoginAsGuest(); 348 Login(UserContext(user_manager::USER_TYPE_GUEST, std::string()),
349 SigninSpecifics());
348 } 350 }
349 351
350 void ExistingUserController::CompleteLogin(const UserContext& user_context) { 352 void ExistingUserController::CompleteLogin(const UserContext& user_context) {
351 login_display_->set_signin_completed(true); 353 login_display_->set_signin_completed(true);
352 if (!host_) { 354 if (!host_) {
353 // Complete login event was generated already from UI. Ignore notification. 355 // Complete login event was generated already from UI. Ignore notification.
354 return; 356 return;
355 } 357 }
356 358
357 PerformPreLoginActions(user_context); 359 PerformPreLoginActions(user_context);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 base::string16 ExistingUserController::GetConnectedNetworkName() { 404 base::string16 ExistingUserController::GetConnectedNetworkName() {
403 return network_state_helper_->GetCurrentNetworkName(); 405 return network_state_helper_->GetCurrentNetworkName();
404 } 406 }
405 407
406 bool ExistingUserController::IsSigninInProgress() const { 408 bool ExistingUserController::IsSigninInProgress() const {
407 return is_login_in_progress_; 409 return is_login_in_progress_;
408 } 410 }
409 411
410 void ExistingUserController::Login(const UserContext& user_context, 412 void ExistingUserController::Login(const UserContext& user_context,
411 const SigninSpecifics& specifics) { 413 const SigninSpecifics& specifics) {
414 // Disable clicking on other windows and status tray.
415 login_display_->SetUIEnabled(false);
416
417 // Stop the auto-login timer.
418 StopPublicSessionAutoLoginTimer();
419
420 // Wait for the |cros_settings_| to become either trusted or permanently
421 // untrusted.
422 const CrosSettingsProvider::TrustedStatus status =
423 cros_settings_->PrepareTrustedValues(base::Bind(
424 &ExistingUserController::Login,
425 weak_factory_.GetWeakPtr(),
426 user_context,
427 specifics));
428 if (status == CrosSettingsProvider::TEMPORARILY_UNTRUSTED)
429 return;
430
431 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
432 // If the |cros_settings_| are permanently untrusted, show an error message
433 // and refuse to log in.
434 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST,
435 1,
436 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
437
438 // Reenable clicking on other windows and the status area. Do not start the
439 // auto-login timer though. Without trusted |cros_settings_|, no auto-login
440 // can succeed.
441 login_display_->SetUIEnabled(true);
442 return;
443 }
444
445 if (is_login_in_progress_) {
446 // If there is another login in progress, bail out. Do not re-enable
447 // clicking on other windows and the status area. Do not start the
448 // auto-login timer.
449 return;
450 }
451
452 if (user_context.GetUserType() != user_manager::USER_TYPE_REGULAR &&
453 user_manager::UserManager::Get()->IsUserLoggedIn()) {
454 // Multi-login is only allowed for regular users. If we are attempting to
455 // do multi-login as another type of user somehow, bail out. Do not
456 // re-enable clicking on other windows and the status area. Do not start the
457 // auto-login timer.
458 return;
459 }
460
412 if (user_context.GetUserType() == user_manager::USER_TYPE_GUEST) { 461 if (user_context.GetUserType() == user_manager::USER_TYPE_GUEST) {
413 if (!specifics.guest_mode_url.empty()) { 462 if (!specifics.guest_mode_url.empty()) {
414 guest_mode_url_ = GURL(specifics.guest_mode_url); 463 guest_mode_url_ = GURL(specifics.guest_mode_url);
415 if (specifics.guest_mode_url_append_locale) 464 if (specifics.guest_mode_url_append_locale)
416 guest_mode_url_ = google_util::AppendGoogleLocaleParam( 465 guest_mode_url_ = google_util::AppendGoogleLocaleParam(
417 guest_mode_url_, g_browser_process->GetApplicationLocale()); 466 guest_mode_url_, g_browser_process->GetApplicationLocale());
418 } 467 }
419 LoginAsGuest(); 468 LoginAsGuest();
420 return; 469 return;
421 } else if (user_context.GetUserType() == 470 }
422 user_manager::USER_TYPE_PUBLIC_ACCOUNT) { 471
472 if (user_context.GetUserType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT) {
423 LoginAsPublicSession(user_context); 473 LoginAsPublicSession(user_context);
424 return; 474 return;
425 } else if (user_context.GetUserType() == 475 }
426 user_manager::USER_TYPE_RETAIL_MODE) { 476
477 if (user_context.GetUserType() == user_manager::USER_TYPE_RETAIL_MODE) {
427 LoginAsRetailModeUser(); 478 LoginAsRetailModeUser();
428 return; 479 return;
429 } else if (user_context.GetUserType() == user_manager::USER_TYPE_KIOSK_APP) { 480 }
481
482 if (user_context.GetUserType() == user_manager::USER_TYPE_KIOSK_APP) {
430 LoginAsKioskApp(user_context.GetUserID(), specifics.kiosk_diagnostic_mode); 483 LoginAsKioskApp(user_context.GetUserID(), specifics.kiosk_diagnostic_mode);
431 return; 484 return;
432 } 485 }
433 486
487 // Regular user or supervised user login.
488
434 if (!user_context.HasCredentials()) { 489 if (!user_context.HasCredentials()) {
435 // For easy unlock auth, login UI gets disabled prior to attempting login. 490 // If credentials are missing, refuse to log in.
436 if (user_context.GetAuthFlow() == UserContext::AUTH_FLOW_EASY_UNLOCK) 491
437 login_display_->SetUIEnabled(true); 492 // Reenable clicking on other windows and status area.
438 return; 493 login_display_->SetUIEnabled(true);
494 // Restart the auto-login timer.
495 StartPublicSessionAutoLoginTimer();
439 } 496 }
440 497
441 PerformPreLoginActions(user_context); 498 PerformPreLoginActions(user_context);
442 PerformLogin(user_context, LoginPerformer::AUTH_MODE_INTERNAL); 499 PerformLogin(user_context, LoginPerformer::AUTH_MODE_INTERNAL);
443 } 500 }
444 501
445 void ExistingUserController::PerformLogin( 502 void ExistingUserController::PerformLogin(
446 const UserContext& user_context, 503 const UserContext& user_context,
447 LoginPerformer::AuthorizationMode auth_mode) { 504 LoginPerformer::AuthorizationMode auth_mode) {
448 // TODO(antrim): remove this output once crash reason is found. 505 // TODO(antrim): remove this output once crash reason is found.
(...skipping 18 matching lines...) Expand all
467 chromeos::login::kSupervisedUserDomain) { 524 chromeos::login::kSupervisedUserDomain) {
468 login_performer_->LoginAsSupervisedUser(user_context); 525 login_performer_->LoginAsSupervisedUser(user_context);
469 } else { 526 } else {
470 login_performer_->PerformLogin(user_context, auth_mode); 527 login_performer_->PerformLogin(user_context, auth_mode);
471 RecordPasswordLoginEvent(user_context); 528 RecordPasswordLoginEvent(user_context);
472 } 529 }
473 SendAccessibilityAlert( 530 SendAccessibilityAlert(
474 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN)); 531 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNING_IN));
475 } 532 }
476 533
477 void ExistingUserController::LoginAsRetailModeUser() {
478 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_RETAIL_MODE,
479 chromeos::login::kRetailModeUserName));
480
481 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once
482 // the enterprise policy wiring is done for retail mode.
483
484 // Only one instance of LoginPerformer should exist at a time.
485 login_performer_.reset(NULL);
486 login_performer_.reset(new ChromeLoginPerformer(this));
487 login_performer_->LoginRetailMode();
488 SendAccessibilityAlert(
489 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER));
490 }
491
492 void ExistingUserController::LoginAsGuest() {
493 if (is_login_in_progress_ ||
494 user_manager::UserManager::Get()->IsUserLoggedIn()) {
495 return;
496 }
497
498 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_GUEST,
499 chromeos::login::kGuestUserName));
500
501 CrosSettingsProvider::TrustedStatus status =
502 cros_settings_->PrepareTrustedValues(
503 base::Bind(&ExistingUserController::LoginAsGuest,
504 weak_factory_.GetWeakPtr()));
505 // Must not proceed without signature verification.
506 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
507 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1,
508 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
509 PerformLoginFinishedActions(false /* don't start public session timer */);
510 display_email_.clear();
511 return;
512 } else if (status != CrosSettingsProvider::TRUSTED) {
513 // Value of AllowNewUser setting is still not verified.
514 // Another attempt will be invoked after verification completion.
515 return;
516 }
517
518 bool allow_guest;
519 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
520 if (!allow_guest) {
521 // Disallowed. The UI should normally not show the guest pod but if for some
522 // reason this has been made available to the user here is the time to tell
523 // this nicely.
524 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1,
525 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
526 PerformLoginFinishedActions(true /* start public session timer */);
527 display_email_.clear();
528 return;
529 }
530
531 // Only one instance of LoginPerformer should exist at a time.
532 login_performer_.reset(NULL);
533 login_performer_.reset(new ChromeLoginPerformer(this));
534 login_performer_->LoginOffTheRecord();
535 SendAccessibilityAlert(
536 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD));
537 }
538
539 void ExistingUserController::MigrateUserData(const std::string& old_password) { 534 void ExistingUserController::MigrateUserData(const std::string& old_password) {
540 // LoginPerformer instance has state of the user so it should exist. 535 // LoginPerformer instance has state of the user so it should exist.
541 if (login_performer_.get()) 536 if (login_performer_.get())
542 login_performer_->RecoverEncryptedData(old_password); 537 login_performer_->RecoverEncryptedData(old_password);
543 } 538 }
544 539
545 void ExistingUserController::LoginAsPublicSession(
546 const UserContext& user_context) {
547 if (is_login_in_progress_ ||
548 user_manager::UserManager::Get()->IsUserLoggedIn()) {
549 return;
550 }
551
552 PerformPreLoginActions(user_context);
553
554 CrosSettingsProvider::TrustedStatus status =
555 cros_settings_->PrepareTrustedValues(
556 base::Bind(&ExistingUserController::LoginAsPublicSession,
557 weak_factory_.GetWeakPtr(),
558 user_context));
559 // If device policy is permanently unavailable, logging into public accounts
560 // is not possible.
561 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
562 login_display_->ShowError(IDS_LOGIN_ERROR_OWNER_KEY_LOST, 1,
563 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
564 PerformLoginFinishedActions(false /* don't start public session timer */);
565 return;
566 }
567
568 // If device policy is not verified yet, this function will be called again
569 // when verification finishes.
570 if (status != CrosSettingsProvider::TRUSTED)
571 return;
572
573 // If there is no public account with the given user ID, logging in is not
574 // possible.
575 const user_manager::User* user =
576 user_manager::UserManager::Get()->FindUser(user_context.GetUserID());
577 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) {
578 PerformLoginFinishedActions(true /* start public session timer */);
579 return;
580 }
581
582 UserContext new_user_context = user_context;
583 std::string locale = user_context.GetPublicSessionLocale();
584 if (locale.empty()) {
585 // When performing auto-login, no locale is chosen by the user. Check
586 // whether a list of recommended locales was set by policy. If so, use its
587 // first entry. Otherwise, |locale| will remain blank, indicating that the
588 // public session should use the current UI locale.
589 const policy::PolicyMap::Entry* entry = g_browser_process->platform_part()->
590 browser_policy_connector_chromeos()->
591 GetDeviceLocalAccountPolicyService()->
592 GetBrokerForUser(user_context.GetUserID())->core()->store()->
593 policy_map().Get(policy::key::kSessionLocales);
594 base::ListValue const* list = NULL;
595 if (entry &&
596 entry->level == policy::POLICY_LEVEL_RECOMMENDED &&
597 entry->value &&
598 entry->value->GetAsList(&list)) {
599 if (list->GetString(0, &locale))
600 new_user_context.SetPublicSessionLocale(locale);
601 }
602 }
603
604 if (!locale.empty() &&
605 new_user_context.GetPublicSessionInputMethod().empty()) {
606 // When |locale| is set, a suitable keyboard layout should be chosen. In
607 // most cases, this will already be the case because the UI shows a list of
608 // keyboard layouts suitable for the |locale| and ensures that one of them
609 // us selected. However, it is still possible that |locale| is set but no
610 // keyboard layout was chosen:
611 // * The list of keyboard layouts is updated asynchronously. If the user
612 // enters the public session before the list of keyboard layouts for the
613 // |locale| has been retrieved, the UI will indicate that no keyboard
614 // layout was chosen.
615 // * During auto-login, the |locale| is set in this method and a suitable
616 // keyboard layout must be chosen next.
617 //
618 // The list of suitable keyboard layouts is constructed asynchronously. Once
619 // it has been retrieved, |SetPublicSessionKeyboardLayoutAndLogin| will
620 // select the first layout from the list and continue login.
621 GetKeyboardLayoutsForLocale(
622 base::Bind(
623 &ExistingUserController::SetPublicSessionKeyboardLayoutAndLogin,
624 weak_factory_.GetWeakPtr(),
625 new_user_context),
626 locale);
627 return;
628 }
629
630 // The user chose a locale and a suitable keyboard layout or left both unset.
631 // Login can continue immediately.
632 LoginAsPublicSessionInternal(new_user_context);
633 }
634
635 void ExistingUserController::LoginAsKioskApp(const std::string& app_id,
636 bool diagnostic_mode) {
637 host_->StartAppLaunch(app_id, diagnostic_mode);
638 }
639 540
640 void ExistingUserController::OnSigninScreenReady() { 541 void ExistingUserController::OnSigninScreenReady() {
641 signin_screen_ready_ = true; 542 signin_screen_ready_ = true;
642 StartPublicSessionAutoLoginTimer(); 543 StartPublicSessionAutoLoginTimer();
643 } 544 }
644 545
645 void ExistingUserController::OnStartEnterpriseEnrollment() { 546 void ExistingUserController::OnStartEnterpriseEnrollment() {
646 if (KioskAppManager::Get()->IsConsumerKioskDeviceWithAutoLaunch()) { 547 if (KioskAppManager::Get()->IsConsumerKioskDeviceWithAutoLaunch()) {
647 LOG(WARNING) << "Enterprise enrollment is not available after kiosk auto " 548 LOG(WARNING) << "Enterprise enrollment is not available after kiosk auto "
648 "launch is set."; 549 "launch is set.";
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 return auth_mode_; 885 return auth_mode_;
985 } 886 }
986 887
987 bool ExistingUserController::password_changed() const { 888 bool ExistingUserController::password_changed() const {
988 if (login_performer_) 889 if (login_performer_)
989 return login_performer_->password_changed(); 890 return login_performer_->password_changed();
990 891
991 return password_changed_; 892 return password_changed_;
992 } 893 }
993 894
895 void ExistingUserController::LoginAsRetailModeUser() {
896 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_RETAIL_MODE,
897 chromeos::login::kRetailModeUserName));
898
899 // TODO(rkc): Add a CHECK to make sure retail mode logins are allowed once
900 // the enterprise policy wiring is done for retail mode.
901
902 // Only one instance of LoginPerformer should exist at a time.
903 login_performer_.reset(NULL);
904 login_performer_.reset(new ChromeLoginPerformer(this));
905 login_performer_->LoginRetailMode();
906 SendAccessibilityAlert(
907 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_DEMOUSER));
908 }
909
910 void ExistingUserController::LoginAsGuest() {
911 PerformPreLoginActions(UserContext(user_manager::USER_TYPE_GUEST,
912 chromeos::login::kGuestUserName));
913
914 bool allow_guest;
915 cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &allow_guest);
916 if (!allow_guest) {
917 // Disallowed. The UI should normally not show the guest pod but if for some
918 // reason this has been made available to the user here is the time to tell
919 // this nicely.
920 login_display_->ShowError(IDS_LOGIN_ERROR_WHITELIST, 1,
921 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT);
922 PerformLoginFinishedActions(true /* start public session timer */);
923 display_email_.clear();
924 return;
925 }
926
927 // Only one instance of LoginPerformer should exist at a time.
928 login_performer_.reset(NULL);
929 login_performer_.reset(new ChromeLoginPerformer(this));
930 login_performer_->LoginOffTheRecord();
931 SendAccessibilityAlert(
932 l10n_util::GetStringUTF8(IDS_CHROMEOS_ACC_LOGIN_SIGNIN_OFFRECORD));
933 }
934
935 void ExistingUserController::LoginAsPublicSession(
936 const UserContext& user_context) {
937 PerformPreLoginActions(user_context);
938
939 // If there is no public account with the given user ID, logging in is not
940 // possible.
941 const user_manager::User* user =
942 user_manager::UserManager::Get()->FindUser(user_context.GetUserID());
943 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) {
944 PerformLoginFinishedActions(true /* start public session timer */);
945 return;
946 }
947
948 UserContext new_user_context = user_context;
949 std::string locale = user_context.GetPublicSessionLocale();
950 if (locale.empty()) {
951 // When performing auto-login, no locale is chosen by the user. Check
952 // whether a list of recommended locales was set by policy. If so, use its
953 // first entry. Otherwise, |locale| will remain blank, indicating that the
954 // public session should use the current UI locale.
955 const policy::PolicyMap::Entry* entry = g_browser_process->platform_part()->
956 browser_policy_connector_chromeos()->
957 GetDeviceLocalAccountPolicyService()->
958 GetBrokerForUser(user_context.GetUserID())->core()->store()->
959 policy_map().Get(policy::key::kSessionLocales);
960 base::ListValue const* list = NULL;
961 if (entry &&
962 entry->level == policy::POLICY_LEVEL_RECOMMENDED &&
963 entry->value &&
964 entry->value->GetAsList(&list)) {
965 if (list->GetString(0, &locale))
966 new_user_context.SetPublicSessionLocale(locale);
967 }
968 }
969
970 if (!locale.empty() &&
971 new_user_context.GetPublicSessionInputMethod().empty()) {
972 // When |locale| is set, a suitable keyboard layout should be chosen. In
973 // most cases, this will already be the case because the UI shows a list of
974 // keyboard layouts suitable for the |locale| and ensures that one of them
975 // us selected. However, it is still possible that |locale| is set but no
976 // keyboard layout was chosen:
977 // * The list of keyboard layouts is updated asynchronously. If the user
978 // enters the public session before the list of keyboard layouts for the
979 // |locale| has been retrieved, the UI will indicate that no keyboard
980 // layout was chosen.
981 // * During auto-login, the |locale| is set in this method and a suitable
982 // keyboard layout must be chosen next.
983 //
984 // The list of suitable keyboard layouts is constructed asynchronously. Once
985 // it has been retrieved, |SetPublicSessionKeyboardLayoutAndLogin| will
986 // select the first layout from the list and continue login.
987 GetKeyboardLayoutsForLocale(
988 base::Bind(
989 &ExistingUserController::SetPublicSessionKeyboardLayoutAndLogin,
990 weak_factory_.GetWeakPtr(),
991 new_user_context),
992 locale);
993 return;
994 }
995
996 // The user chose a locale and a suitable keyboard layout or left both unset.
997 // Login can continue immediately.
998 LoginAsPublicSessionInternal(new_user_context);
999 }
1000
1001 void ExistingUserController::LoginAsKioskApp(const std::string& app_id,
1002 bool diagnostic_mode) {
1003 host_->StartAppLaunch(app_id, diagnostic_mode);
1004 }
1005
994 void ExistingUserController::ConfigurePublicSessionAutoLogin() { 1006 void ExistingUserController::ConfigurePublicSessionAutoLogin() {
995 std::string auto_login_account_id; 1007 std::string auto_login_account_id;
996 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, 1008 cros_settings_->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId,
997 &auto_login_account_id); 1009 &auto_login_account_id);
998 const std::vector<policy::DeviceLocalAccount> device_local_accounts = 1010 const std::vector<policy::DeviceLocalAccount> device_local_accounts =
999 policy::GetDeviceLocalAccounts(cros_settings_); 1011 policy::GetDeviceLocalAccounts(cros_settings_);
1000 1012
1001 public_session_auto_login_username_.clear(); 1013 public_session_auto_login_username_.clear();
1002 for (std::vector<policy::DeviceLocalAccount>::const_iterator 1014 for (std::vector<policy::DeviceLocalAccount>::const_iterator
1003 it = device_local_accounts.begin(); 1015 it = device_local_accounts.begin();
(...skipping 23 matching lines...) Expand all
1027 1039
1028 void ExistingUserController::ResetPublicSessionAutoLoginTimer() { 1040 void ExistingUserController::ResetPublicSessionAutoLoginTimer() {
1029 // Only restart the auto-login timer if it's already running. 1041 // Only restart the auto-login timer if it's already running.
1030 if (auto_login_timer_ && auto_login_timer_->IsRunning()) { 1042 if (auto_login_timer_ && auto_login_timer_->IsRunning()) {
1031 StopPublicSessionAutoLoginTimer(); 1043 StopPublicSessionAutoLoginTimer();
1032 StartPublicSessionAutoLoginTimer(); 1044 StartPublicSessionAutoLoginTimer();
1033 } 1045 }
1034 } 1046 }
1035 1047
1036 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() { 1048 void ExistingUserController::OnPublicSessionAutoLoginTimerFire() {
1037 CHECK(signin_screen_ready_ && 1049 CHECK(signin_screen_ready_ && !public_session_auto_login_username_.empty());
1038 !is_login_in_progress_ && 1050 Login(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT,
1039 !public_session_auto_login_username_.empty()); 1051 public_session_auto_login_username_),
1040 // TODO(bartfab): Set the UI language and initial locale. 1052 SigninSpecifics());
1041 LoginAsPublicSession(UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT,
1042 public_session_auto_login_username_));
1043 } 1053 }
1044 1054
1045 void ExistingUserController::StopPublicSessionAutoLoginTimer() { 1055 void ExistingUserController::StopPublicSessionAutoLoginTimer() {
1046 if (auto_login_timer_) 1056 if (auto_login_timer_)
1047 auto_login_timer_->Stop(); 1057 auto_login_timer_->Stop();
1048 } 1058 }
1049 1059
1050 void ExistingUserController::StartPublicSessionAutoLoginTimer() { 1060 void ExistingUserController::StartPublicSessionAutoLoginTimer() {
1051 if (!signin_screen_ready_ || 1061 if (!signin_screen_ready_ ||
1052 is_login_in_progress_ || 1062 is_login_in_progress_ ||
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 is_login_in_progress_ = false; 1200 is_login_in_progress_ = false;
1191 1201
1192 // Reenable clicking on other windows and status area. 1202 // Reenable clicking on other windows and status area.
1193 login_display_->SetUIEnabled(true); 1203 login_display_->SetUIEnabled(true);
1194 1204
1195 if (start_public_session_timer) 1205 if (start_public_session_timer)
1196 StartPublicSessionAutoLoginTimer(); 1206 StartPublicSessionAutoLoginTimer();
1197 } 1207 }
1198 1208
1199 } // namespace chromeos 1209 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698