Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/session/user_session_manager.h" | 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 // This makes sure that Chrome restarts with no per-session flags. The guest | 367 // This makes sure that Chrome restarts with no per-session flags. The guest |
| 368 // profile will always have empty set of per-session flags. If this is not | 368 // profile will always have empty set of per-session flags. If this is not |
| 369 // done and device owner has some per-session flags, when Chrome is relaunched | 369 // done and device owner has some per-session flags, when Chrome is relaunched |
| 370 // the guest profile session flags will not match the current command line and | 370 // the guest profile session flags will not match the current command line and |
| 371 // another restart will be attempted in order to reset the user flags for the | 371 // another restart will be attempted in order to reset the user flags for the |
| 372 // guest user. | 372 // guest user. |
| 373 const base::CommandLine user_flags(base::CommandLine::NO_PROGRAM); | 373 const base::CommandLine user_flags(base::CommandLine::NO_PROGRAM); |
| 374 if (!about_flags::AreSwitchesIdenticalToCurrentCommandLine( | 374 if (!about_flags::AreSwitchesIdenticalToCurrentCommandLine( |
| 375 user_flags, *base::CommandLine::ForCurrentProcess(), NULL)) { | 375 user_flags, *base::CommandLine::ForCurrentProcess(), NULL)) { |
| 376 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( | 376 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( |
| 377 chromeos::login::kGuestUserName, base::CommandLine::StringVector()); | 377 chromeos::login::GetGuestUserID(), base::CommandLine::StringVector()); |
| 378 } | 378 } |
| 379 | 379 |
| 380 RestartChrome(cmd_line_str); | 380 RestartChrome(cmd_line_str); |
| 381 } | 381 } |
| 382 | 382 |
| 383 scoped_refptr<Authenticator> UserSessionManager::CreateAuthenticator( | 383 scoped_refptr<Authenticator> UserSessionManager::CreateAuthenticator( |
| 384 AuthStatusConsumer* consumer) { | 384 AuthStatusConsumer* consumer) { |
| 385 // Screen locker needs new Authenticator instance each time. | 385 // Screen locker needs new Authenticator instance each time. |
| 386 if (ScreenLocker::default_screen_locker()) { | 386 if (ScreenLocker::default_screen_locker()) { |
| 387 if (authenticator_.get()) | 387 if (authenticator_.get()) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 405 | 405 |
| 406 void UserSessionManager::StartSession( | 406 void UserSessionManager::StartSession( |
| 407 const UserContext& user_context, | 407 const UserContext& user_context, |
| 408 StartSessionType start_session_type, | 408 StartSessionType start_session_type, |
| 409 bool has_auth_cookies, | 409 bool has_auth_cookies, |
| 410 bool has_active_session, | 410 bool has_active_session, |
| 411 UserSessionManagerDelegate* delegate) { | 411 UserSessionManagerDelegate* delegate) { |
| 412 delegate_ = delegate; | 412 delegate_ = delegate; |
| 413 start_session_type_ = start_session_type; | 413 start_session_type_ = start_session_type; |
| 414 | 414 |
| 415 VLOG(1) << "Starting session for " << user_context.GetUserID(); | 415 VLOG(1) << "Starting session for " << user_context.GetUserID().GetUserEmail(); |
| 416 | 416 |
| 417 PreStartSession(); | 417 PreStartSession(); |
| 418 CreateUserSession(user_context, has_auth_cookies); | 418 CreateUserSession(user_context, has_auth_cookies); |
| 419 | 419 |
| 420 if (!has_active_session) | 420 if (!has_active_session) |
| 421 StartCrosSession(); | 421 StartCrosSession(); |
| 422 | 422 |
| 423 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually | 423 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually |
| 424 // ready to be used (http://crbug.com/361528). | 424 // ready to be used (http://crbug.com/361528). |
| 425 NotifyUserLoggedIn(); | 425 NotifyUserLoggedIn(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 if (!user_manager->IsUserLoggedIn() || | 458 if (!user_manager->IsUserLoggedIn() || |
| 459 !user_manager->IsLoggedInAsUserWithGaiaAccount() || | 459 !user_manager->IsLoggedInAsUserWithGaiaAccount() || |
| 460 user_manager->IsLoggedInAsStub()) { | 460 user_manager->IsLoggedInAsStub()) { |
| 461 return; | 461 return; |
| 462 } | 462 } |
| 463 | 463 |
| 464 const user_manager::User* user = | 464 const user_manager::User* user = |
| 465 ProfileHelper::Get()->GetUserByProfile(user_profile); | 465 ProfileHelper::Get()->GetUserByProfile(user_profile); |
| 466 DCHECK(user); | 466 DCHECK(user); |
| 467 if (!net::NetworkChangeNotifier::IsOffline()) { | 467 if (!net::NetworkChangeNotifier::IsOffline()) { |
| 468 pending_signin_restore_sessions_.erase(user->email()); | 468 pending_signin_restore_sessions_.erase(user->GetUserID()); |
| 469 RestoreAuthSessionImpl(user_profile, false /* has_auth_cookies */); | 469 RestoreAuthSessionImpl(user_profile, false /* has_auth_cookies */); |
| 470 } else { | 470 } else { |
| 471 // Even if we're online we should wait till initial | 471 // Even if we're online we should wait till initial |
| 472 // OnConnectionTypeChanged() call. Otherwise starting fetchers too early may | 472 // OnConnectionTypeChanged() call. Otherwise starting fetchers too early may |
| 473 // end up canceling all request when initial network connection type is | 473 // end up canceling all request when initial network connection type is |
| 474 // processed. See http://crbug.com/121643. | 474 // processed. See http://crbug.com/121643. |
| 475 pending_signin_restore_sessions_.insert(user->email()); | 475 pending_signin_restore_sessions_.insert(user->GetUserID()); |
| 476 } | 476 } |
| 477 } | 477 } |
| 478 | 478 |
| 479 void UserSessionManager::RestoreActiveSessions() { | 479 void UserSessionManager::RestoreActiveSessions() { |
| 480 user_sessions_restore_in_progress_ = true; | 480 user_sessions_restore_in_progress_ = true; |
| 481 DBusThreadManager::Get()->GetSessionManagerClient()->RetrieveActiveSessions( | 481 DBusThreadManager::Get()->GetSessionManagerClient()->RetrieveActiveSessions( |
| 482 base::Bind(&UserSessionManager::OnRestoreActiveSessions, AsWeakPtr())); | 482 base::Bind(&UserSessionManager::OnRestoreActiveSessions, AsWeakPtr())); |
| 483 } | 483 } |
| 484 | 484 |
| 485 bool UserSessionManager::UserSessionsRestored() const { | 485 bool UserSessionManager::UserSessionsRestored() const { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 | 649 |
| 650 LogCustomSwitches(command_line_difference); | 650 LogCustomSwitches(command_line_difference); |
| 651 | 651 |
| 652 about_flags::ReportCustomFlags("Login.CustomFlags", command_line_difference); | 652 about_flags::ReportCustomFlags("Login.CustomFlags", command_line_difference); |
| 653 | 653 |
| 654 base::CommandLine::StringVector flags; | 654 base::CommandLine::StringVector flags; |
| 655 // argv[0] is the program name |base::CommandLine::NO_PROGRAM|. | 655 // argv[0] is the program name |base::CommandLine::NO_PROGRAM|. |
| 656 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); | 656 flags.assign(user_flags.argv().begin() + 1, user_flags.argv().end()); |
| 657 LOG(WARNING) << "Restarting to apply per-session flags..."; | 657 LOG(WARNING) << "Restarting to apply per-session flags..."; |
| 658 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( | 658 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( |
| 659 user_manager::UserManager::Get()->GetActiveUser()->email(), flags); | 659 user_manager::UserManager::Get()->GetActiveUser()->GetUserID(), flags); |
| 660 AttemptRestart(profile); | 660 AttemptRestart(profile); |
| 661 return true; | 661 return true; |
| 662 } | 662 } |
| 663 | 663 |
| 664 bool UserSessionManager::NeedsToUpdateEasyUnlockKeys() const { | 664 bool UserSessionManager::NeedsToUpdateEasyUnlockKeys() const { |
| 665 return EasyUnlockService::IsSignInEnabled() && | 665 return EasyUnlockService::IsSignInEnabled() && |
| 666 !user_context_.GetUserID().empty() && | 666 !user_context_.GetUserID().empty() && |
| 667 user_manager::User::TypeHasGaiaAccount(user_context_.GetUserType()) && | 667 user_manager::User::TypeHasGaiaAccount(user_context_.GetUserType()) && |
| 668 user_context_.GetKey() && !user_context_.GetKey()->GetSecret().empty(); | 668 user_context_.GetKey() && !user_context_.GetKey()->GetSecret().empty(); |
| 669 } | 669 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 714 case OAuth2LoginManager::SESSION_RESTORE_PREPARING: | 714 case OAuth2LoginManager::SESSION_RESTORE_PREPARING: |
| 715 case OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: | 715 case OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS: |
| 716 return; | 716 return; |
| 717 } | 717 } |
| 718 | 718 |
| 719 // We should not be clearing existing token state if that was a connection | 719 // We should not be clearing existing token state if that was a connection |
| 720 // error. http://crbug.com/295245 | 720 // error. http://crbug.com/295245 |
| 721 if (!connection_error) { | 721 if (!connection_error) { |
| 722 // We are in one of "done" states here. | 722 // We are in one of "done" states here. |
| 723 user_manager::UserManager::Get()->SaveUserOAuthStatus( | 723 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
| 724 user_manager::UserManager::Get()->GetLoggedInUser()->email(), | 724 user_manager::UserManager::Get()->GetLoggedInUser()->GetUserID(), |
| 725 user_status); | 725 user_status); |
| 726 } | 726 } |
| 727 | 727 |
| 728 login_manager->RemoveObserver(this); | 728 login_manager->RemoveObserver(this); |
| 729 | 729 |
| 730 if (exit_after_session_restore_ && | 730 if (exit_after_session_restore_ && |
| 731 (state == OAuth2LoginManager::SESSION_RESTORE_DONE || | 731 (state == OAuth2LoginManager::SESSION_RESTORE_DONE || |
| 732 state == OAuth2LoginManager::SESSION_RESTORE_FAILED || | 732 state == OAuth2LoginManager::SESSION_RESTORE_FAILED || |
| 733 state == OAuth2LoginManager::SESSION_RESTORE_CONNECTION_FAILED)) { | 733 state == OAuth2LoginManager::SESSION_RESTORE_CONNECTION_FAILED)) { |
| 734 LOG(WARNING) << "Restarting Chrome after session restore finishes, " | 734 LOG(WARNING) << "Restarting Chrome after session restore finishes, " |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 757 // Need to iterate over all users and their OAuth2 session state. | 757 // Need to iterate over all users and their OAuth2 session state. |
| 758 const user_manager::UserList& users = user_manager->GetLoggedInUsers(); | 758 const user_manager::UserList& users = user_manager->GetLoggedInUsers(); |
| 759 for (user_manager::UserList::const_iterator it = users.begin(); | 759 for (user_manager::UserList::const_iterator it = users.begin(); |
| 760 it != users.end(); | 760 it != users.end(); |
| 761 ++it) { | 761 ++it) { |
| 762 if (!(*it)->is_profile_created()) | 762 if (!(*it)->is_profile_created()) |
| 763 continue; | 763 continue; |
| 764 | 764 |
| 765 Profile* user_profile = ProfileHelper::Get()->GetProfileByUserUnsafe(*it); | 765 Profile* user_profile = ProfileHelper::Get()->GetProfileByUserUnsafe(*it); |
| 766 bool should_restore_session = | 766 bool should_restore_session = |
| 767 pending_signin_restore_sessions_.find((*it)->email()) != | 767 pending_signin_restore_sessions_.find((*it)->GetUserID()) != |
| 768 pending_signin_restore_sessions_.end(); | 768 pending_signin_restore_sessions_.end(); |
| 769 OAuth2LoginManager* login_manager = | 769 OAuth2LoginManager* login_manager = |
| 770 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile); | 770 OAuth2LoginManagerFactory::GetInstance()->GetForProfile(user_profile); |
| 771 if (login_manager->SessionRestoreIsRunning()) { | 771 if (login_manager->SessionRestoreIsRunning()) { |
| 772 // If we come online for the first time after successful offline login, | 772 // If we come online for the first time after successful offline login, |
| 773 // we need to kick off OAuth token verification process again. | 773 // we need to kick off OAuth token verification process again. |
| 774 login_manager->ContinueSessionRestore(); | 774 login_manager->ContinueSessionRestore(); |
| 775 } else if (should_restore_session) { | 775 } else if (should_restore_session) { |
| 776 pending_signin_restore_sessions_.erase((*it)->email()); | 776 pending_signin_restore_sessions_.erase((*it)->GetUserID()); |
| 777 RestoreAuthSessionImpl(user_profile, false /* has_auth_cookies */); | 777 RestoreAuthSessionImpl(user_profile, false /* has_auth_cookies */); |
| 778 } | 778 } |
| 779 } | 779 } |
| 780 } | 780 } |
| 781 | 781 |
| 782 void UserSessionManager::OnProfilePrepared(Profile* profile, | 782 void UserSessionManager::OnProfilePrepared(Profile* profile, |
| 783 bool browser_launched) { | 783 bool browser_launched) { |
| 784 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 784 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 785 ::switches::kTestName)) { | 785 ::switches::kTestName)) { |
| 786 // Did not log in (we crashed or are debugging), need to restore Sync. | 786 // Did not log in (we crashed or are debugging), need to restore Sync. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 816 } | 816 } |
| 817 | 817 |
| 818 void UserSessionManager::PreStartSession() { | 818 void UserSessionManager::PreStartSession() { |
| 819 // Switch log file as soon as possible. | 819 // Switch log file as soon as possible. |
| 820 if (base::SysInfo::IsRunningOnChromeOS()) | 820 if (base::SysInfo::IsRunningOnChromeOS()) |
| 821 logging::RedirectChromeLogging(*(base::CommandLine::ForCurrentProcess())); | 821 logging::RedirectChromeLogging(*(base::CommandLine::ForCurrentProcess())); |
| 822 } | 822 } |
| 823 | 823 |
| 824 void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() { | 824 void UserSessionManager::StoreUserContextDataBeforeProfileIsCreated() { |
| 825 // Store obfuscated GAIA ID. | 825 // Store obfuscated GAIA ID. |
| 826 if (!user_context_.GetGaiaID().empty()) { | 826 if (!user_context_.GetUserID().GetGaiaId().empty()) { |
| 827 user_manager::UserManager::Get()->UpdateGaiaID(user_context_.GetUserID(), | 827 user_manager::UserManager::Get()->UpdateGaiaID(user_context_.GetUserID(), |
| 828 user_context_.GetGaiaID()); | 828 user_context_.GetUserID().Get GaiaId()); |
| 829 } | 829 } |
| 830 } | 830 } |
| 831 | 831 |
| 832 void UserSessionManager::StartCrosSession() { | 832 void UserSessionManager::StartCrosSession() { |
| 833 BootTimesRecorder* btl = BootTimesRecorder::Get(); | 833 BootTimesRecorder* btl = BootTimesRecorder::Get(); |
| 834 btl->AddLoginTimeMarker("StartSession-Start", false); | 834 btl->AddLoginTimeMarker("StartSession-Start", false); |
| 835 DBusThreadManager::Get()->GetSessionManagerClient()-> | 835 DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 836 StartSession(user_context_.GetUserID()); | 836 StartSession(user_context_.GetUserID()); |
| 837 btl->AddLoginTimeMarker("StartSession-End", false); | 837 btl->AddLoginTimeMarker("StartSession-End", false); |
| 838 } | 838 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 854 // TODO(nkostylev): Figure out whether demo session is using the right profile | 854 // TODO(nkostylev): Figure out whether demo session is using the right profile |
| 855 // path or not. See https://codereview.chromium.org/171423009 | 855 // path or not. See https://codereview.chromium.org/171423009 |
| 856 g_browser_process->profile_manager()->CreateProfileAsync( | 856 g_browser_process->profile_manager()->CreateProfileAsync( |
| 857 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), | 857 ProfileHelper::GetProfilePathByUserIdHash(user_context_.GetUserIDHash()), |
| 858 base::Bind(&UserSessionManager::OnProfileCreated, | 858 base::Bind(&UserSessionManager::OnProfileCreated, |
| 859 AsWeakPtr(), | 859 AsWeakPtr(), |
| 860 user_context_, | 860 user_context_, |
| 861 is_demo_session), | 861 is_demo_session), |
| 862 base::string16(), | 862 base::string16(), |
| 863 base::string16(), | 863 base::string16(), |
| 864 std::string()); | 864 user_manager::UserID(std::string(), std::string())); |
|
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
EmptyGaiaID() ?
| |
| 865 } | 865 } |
| 866 | 866 |
| 867 void UserSessionManager::OnProfileCreated(const UserContext& user_context, | 867 void UserSessionManager::OnProfileCreated(const UserContext& user_context, |
| 868 bool is_incognito_profile, | 868 bool is_incognito_profile, |
| 869 Profile* profile, | 869 Profile* profile, |
| 870 Profile::CreateStatus status) { | 870 Profile::CreateStatus status) { |
| 871 CHECK(profile); | 871 CHECK(profile); |
| 872 | 872 |
| 873 switch (status) { | 873 switch (status) { |
| 874 case Profile::CREATE_STATUS_CREATED: | 874 case Profile::CREATE_STATUS_CREATED: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 SetFirstLoginPrefs(profile, | 911 SetFirstLoginPrefs(profile, |
| 912 user_context.GetPublicSessionLocale(), | 912 user_context.GetPublicSessionLocale(), |
| 913 user_context.GetPublicSessionInputMethod()); | 913 user_context.GetPublicSessionInputMethod()); |
| 914 } | 914 } |
| 915 | 915 |
| 916 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { | 916 if (user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { |
| 917 user_manager::User* active_user = | 917 user_manager::User* active_user = |
| 918 user_manager::UserManager::Get()->GetActiveUser(); | 918 user_manager::UserManager::Get()->GetActiveUser(); |
| 919 std::string supervised_user_sync_id = | 919 std::string supervised_user_sync_id = |
| 920 ChromeUserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( | 920 ChromeUserManager::Get()->GetSupervisedUserManager()->GetUserSyncId( |
| 921 active_user->email()); | 921 active_user->GetUserID()); |
| 922 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, | 922 profile->GetPrefs()->SetString(prefs::kSupervisedUserId, |
| 923 supervised_user_sync_id); | 923 supervised_user_sync_id); |
| 924 } else if (user_manager::UserManager::Get()-> | 924 } else if (user_manager::UserManager::Get()-> |
| 925 IsLoggedInAsUserWithGaiaAccount()) { | 925 IsLoggedInAsUserWithGaiaAccount()) { |
| 926 // Get the Gaia ID from the user context. If it's not available, this may | 926 user_manager::UserID user_id(user->GetUserID()); |
| 927 // not be available when unlocking a previously opened profile, or when | 927 |
| 928 // creating a supervised users. However, in these cases the gaia_id should | 928 { |
| 929 // be already available in the account tracker. | 929 // Get the Gaia ID from the user context. If it's not available, this may |
| 930 std::string gaia_id = user_context.GetGaiaID(); | 930 // not be available when unlocking a previously opened profile, or when |
| 931 if (gaia_id.empty()) { | 931 // creating a supervised users. However, in these cases the gaia_id shoul d |
| 932 AccountTrackerService* account_tracker = | 932 // be already available in the account tracker. |
| 933 AccountTrackerServiceFactory::GetForProfile(profile); | 933 std::string gaia_id = user_context.GetUserID().GetGaiaId(); |
| 934 AccountTrackerService::AccountInfo info = | 934 if (gaia_id.empty()) { |
| 935 account_tracker->FindAccountInfoByEmail(user_context.GetUserID()); | 935 AccountTrackerService* account_tracker = |
| 936 gaia_id = info.gaia; | 936 AccountTrackerServiceFactory::GetForProfile(profile); |
| 937 DCHECK(!gaia_id.empty()); | 937 AccountTrackerService::AccountInfo info = |
| 938 account_tracker->FindAccountInfoByEmail(user_context.GetUserID().Get UserEmail()); | |
| 939 gaia_id = info.gaia; | |
| 940 DCHECK(!gaia_id.empty()); | |
| 941 } | |
| 942 user_id.SetGaiaId(gaia_id); | |
| 938 } | 943 } |
| 939 | 944 |
| 940 // Make sure that the google service username is properly set (we do this | 945 // Make sure that the google service username is properly set (we do this |
| 941 // on every sign in, not just the first login, to deal with existing | 946 // on every sign in, not just the first login, to deal with existing |
| 942 // profiles that might not have it set yet). | 947 // profiles that might not have it set yet). |
| 943 SigninManagerBase* signin_manager = | 948 SigninManagerBase* signin_manager = |
| 944 SigninManagerFactory::GetForProfile(profile); | 949 SigninManagerFactory::GetForProfile(profile); |
| 945 signin_manager->SetAuthenticatedAccountInfo(gaia_id, | 950 signin_manager->SetAuthenticatedAccountInfo(user_id.GetGaiaId(), |
| 946 user_context.GetUserID()); | 951 user_id.GetUserEmail()); |
| 947 | 952 |
| 948 // Backfill GAIA ID in user prefs stored in Local State. | 953 // Backfill GAIA ID in user prefs stored in Local State. |
| 949 std::string tmp_gaia_id; | 954 std::string tmp_gaia_id; |
| 950 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 955 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 951 if (!user_manager->FindGaiaID(user_context.GetUserID(), &tmp_gaia_id) && | 956 if (!user_manager->FindGaiaID(user_context.GetUserID(), &tmp_gaia_id) && |
| 952 !gaia_id.empty()) { | 957 !user_id.GetGaiaId().empty()) { |
| 953 user_manager->UpdateGaiaID(user_context.GetUserID(), gaia_id); | 958 user_manager->UpdateGaiaID(user_context.GetUserID(), user_id.GetGaiaId()); |
| 954 } | 959 } |
| 955 } | 960 } |
| 956 } | 961 } |
| 957 | 962 |
| 958 void UserSessionManager::UserProfileInitialized(Profile* profile, | 963 void UserSessionManager::UserProfileInitialized(Profile* profile, |
| 959 bool is_incognito_profile, | 964 bool is_incognito_profile, |
| 960 const std::string& user_id) { | 965 const user_manager::UserID& user _id) { |
| 961 // Demo user signed in. | 966 // Demo user signed in. |
| 962 if (is_incognito_profile) { | 967 if (is_incognito_profile) { |
| 963 profile->OnLogin(); | 968 profile->OnLogin(); |
| 964 | 969 |
| 965 // Send the notification before creating the browser so additional objects | 970 // Send the notification before creating the browser so additional objects |
| 966 // that need the profile (e.g. the launcher) can be created first. | 971 // that need the profile (e.g. the launcher) can be created first. |
| 967 content::NotificationService::current()->Notify( | 972 content::NotificationService::current()->Notify( |
| 968 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 973 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 969 content::NotificationService::AllSources(), | 974 content::NotificationService::AllSources(), |
| 970 content::Details<Profile>(profile)); | 975 content::Details<Profile>(profile)); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1335 // If we could not get list of active user sessions it is safer to just | 1340 // If we could not get list of active user sessions it is safer to just |
| 1336 // sign out so that we don't get in the inconsistent state. | 1341 // sign out so that we don't get in the inconsistent state. |
| 1337 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); | 1342 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); |
| 1338 return; | 1343 return; |
| 1339 } | 1344 } |
| 1340 | 1345 |
| 1341 // One profile has been already loaded on browser start. | 1346 // One profile has been already loaded on browser start. |
| 1342 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 1347 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 1343 DCHECK(user_manager->GetLoggedInUsers().size() == 1); | 1348 DCHECK(user_manager->GetLoggedInUsers().size() == 1); |
| 1344 DCHECK(user_manager->GetActiveUser()); | 1349 DCHECK(user_manager->GetActiveUser()); |
| 1345 std::string active_user_id = user_manager->GetActiveUser()->email(); | 1350 const user_manager::UserID& active_user_id = user_manager->GetActiveUser()->Ge tUserID(); |
|
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:46
auto
| |
| 1346 | 1351 |
| 1347 SessionManagerClient::ActiveSessionsMap::const_iterator it; | 1352 SessionManagerClient::ActiveSessionsMap::const_iterator it; |
| 1348 for (it = sessions.begin(); it != sessions.end(); ++it) { | 1353 for (it = sessions.begin(); it != sessions.end(); ++it) { |
| 1349 if (active_user_id == it->first) | 1354 if (active_user_id == it->first) |
| 1350 continue; | 1355 continue; |
| 1351 pending_user_sessions_[it->first] = it->second; | 1356 pending_user_sessions_[it->first] = it->second; |
| 1352 } | 1357 } |
| 1353 RestorePendingUserSessions(); | 1358 RestorePendingUserSessions(); |
| 1354 } | 1359 } |
| 1355 | 1360 |
| 1356 void UserSessionManager::RestorePendingUserSessions() { | 1361 void UserSessionManager::RestorePendingUserSessions() { |
| 1357 if (pending_user_sessions_.empty()) { | 1362 if (pending_user_sessions_.empty()) { |
| 1358 user_manager::UserManager::Get()->SwitchToLastActiveUser(); | 1363 user_manager::UserManager::Get()->SwitchToLastActiveUser(); |
| 1359 NotifyPendingUserSessionsRestoreFinished(); | 1364 NotifyPendingUserSessionsRestoreFinished(); |
| 1360 return; | 1365 return; |
| 1361 } | 1366 } |
| 1362 | 1367 |
| 1363 // Get next user to restore sessions and delete it from list. | 1368 // Get next user to restore sessions and delete it from list. |
| 1364 SessionManagerClient::ActiveSessionsMap::const_iterator it = | 1369 SessionManagerClient::ActiveSessionsMap::const_iterator it = |
| 1365 pending_user_sessions_.begin(); | 1370 pending_user_sessions_.begin(); |
| 1366 std::string user_id = it->first; | 1371 user_manager::UserID user_id = it->first; |
| 1367 std::string user_id_hash = it->second; | 1372 std::string user_id_hash = it->second; |
| 1368 DCHECK(!user_id.empty()); | 1373 DCHECK(!user_id.empty()); |
| 1369 DCHECK(!user_id_hash.empty()); | 1374 DCHECK(!user_id_hash.empty()); |
| 1370 pending_user_sessions_.erase(user_id); | 1375 pending_user_sessions_.erase(user_id); |
| 1371 | 1376 |
| 1372 // Check that this user is not logged in yet. | 1377 // Check that this user is not logged in yet. |
| 1373 user_manager::UserList logged_in_users = | 1378 user_manager::UserList logged_in_users = |
| 1374 user_manager::UserManager::Get()->GetLoggedInUsers(); | 1379 user_manager::UserManager::Get()->GetLoggedInUsers(); |
| 1375 bool user_already_logged_in = false; | 1380 bool user_already_logged_in = false; |
| 1376 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); | 1381 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); |
| 1377 it != logged_in_users.end(); | 1382 it != logged_in_users.end(); |
| 1378 ++it) { | 1383 ++it) { |
| 1379 const user_manager::User* user = (*it); | 1384 const user_manager::User* user = (*it); |
| 1380 if (user->email() == user_id) { | 1385 if (user->GetUserID() == user_id) { |
| 1381 user_already_logged_in = true; | 1386 user_already_logged_in = true; |
| 1382 break; | 1387 break; |
| 1383 } | 1388 } |
| 1384 } | 1389 } |
| 1385 DCHECK(!user_already_logged_in); | 1390 DCHECK(!user_already_logged_in); |
| 1386 | 1391 |
| 1387 if (!user_already_logged_in) { | 1392 if (!user_already_logged_in) { |
| 1388 UserContext user_context(user_id); | 1393 UserContext user_context(user_id); |
| 1389 user_context.SetUserIDHash(user_id_hash); | 1394 user_context.SetUserIDHash(user_id_hash); |
| 1390 user_context.SetIsUsingOAuth(false); | 1395 user_context.SetIsUsingOAuth(false); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1490 OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS) { | 1495 OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS) { |
| 1491 chrome::AttemptRestart(); | 1496 chrome::AttemptRestart(); |
| 1492 return; | 1497 return; |
| 1493 } | 1498 } |
| 1494 | 1499 |
| 1495 LOG(WARNING) << "Attempting browser restart during session restore."; | 1500 LOG(WARNING) << "Attempting browser restart during session restore."; |
| 1496 exit_after_session_restore_ = true; | 1501 exit_after_session_restore_ = true; |
| 1497 } | 1502 } |
| 1498 | 1503 |
| 1499 void UserSessionManager::OnEasyUnlockKeyOpsFinished( | 1504 void UserSessionManager::OnEasyUnlockKeyOpsFinished( |
| 1500 const std::string& user_id, | 1505 const user_manager::UserID& user_id, |
| 1501 bool success) { | 1506 bool success) { |
| 1502 running_easy_unlock_key_ops_ = false; | 1507 running_easy_unlock_key_ops_ = false; |
| 1503 if (!easy_unlock_key_ops_finished_callback_.is_null()) | 1508 if (!easy_unlock_key_ops_finished_callback_.is_null()) |
| 1504 easy_unlock_key_ops_finished_callback_.Run(); | 1509 easy_unlock_key_ops_finished_callback_.Run(); |
| 1505 | 1510 |
| 1506 const user_manager::User* user = | 1511 const user_manager::User* user = |
| 1507 user_manager::UserManager::Get()->FindUser(user_id); | 1512 user_manager::UserManager::Get()->FindUser(user_id); |
| 1508 EasyUnlockService* easy_unlock_service = | 1513 EasyUnlockService* easy_unlock_service = |
| 1509 EasyUnlockService::GetForUser(*user); | 1514 EasyUnlockService::GetForUser(*user); |
| 1510 easy_unlock_service->CheckCryptohomeKeysAndMaybeHardlock(); | 1515 easy_unlock_service->CheckCryptohomeKeysAndMaybeHardlock(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1695 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, | 1700 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
| 1696 &show_names_on_signin); | 1701 &show_names_on_signin); |
| 1697 return show_names_on_signin && !ephemeral_users_enabled; | 1702 return show_names_on_signin && !ephemeral_users_enabled; |
| 1698 } | 1703 } |
| 1699 | 1704 |
| 1700 void UserSessionManager::Shutdown() { | 1705 void UserSessionManager::Shutdown() { |
| 1701 token_handle_util_.reset(); | 1706 token_handle_util_.reset(); |
| 1702 } | 1707 } |
| 1703 | 1708 |
| 1704 } // namespace chromeos | 1709 } // namespace chromeos |
| OLD | NEW |