| 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/users/chrome_user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "ash/multi_profile_uma.h" | 10 #include "ash/multi_profile_uma.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 } | 431 } |
| 432 break; | 432 break; |
| 433 } | 433 } |
| 434 default: | 434 default: |
| 435 NOTREACHED(); | 435 NOTREACHED(); |
| 436 } | 436 } |
| 437 } | 437 } |
| 438 | 438 |
| 439 void ChromeUserManagerImpl::OnExternalDataSet(const std::string& policy, | 439 void ChromeUserManagerImpl::OnExternalDataSet(const std::string& policy, |
| 440 const std::string& user_id) { | 440 const std::string& user_id) { |
| 441 const AccountId account_id = |
| 442 user_manager::UserManager::Get()->GetKnownUserAccountId(user_id, |
| 443 std::string()); |
| 441 if (policy == policy::key::kUserAvatarImage) | 444 if (policy == policy::key::kUserAvatarImage) |
| 442 GetUserImageManager(AccountId::FromUserEmail(user_id)) | 445 GetUserImageManager(account_id)->OnExternalDataSet(policy); |
| 443 ->OnExternalDataSet(policy); | |
| 444 else if (policy == policy::key::kWallpaperImage) | 446 else if (policy == policy::key::kWallpaperImage) |
| 445 WallpaperManager::Get()->OnPolicySet(policy, user_id); | 447 WallpaperManager::Get()->OnPolicySet(policy, account_id); |
| 446 else | 448 else |
| 447 NOTREACHED(); | 449 NOTREACHED(); |
| 448 } | 450 } |
| 449 | 451 |
| 450 void ChromeUserManagerImpl::OnExternalDataCleared(const std::string& policy, | 452 void ChromeUserManagerImpl::OnExternalDataCleared(const std::string& policy, |
| 451 const std::string& user_id) { | 453 const std::string& user_id) { |
| 454 const AccountId account_id = |
| 455 user_manager::UserManager::Get()->GetKnownUserAccountId(user_id, |
| 456 std::string()); |
| 452 if (policy == policy::key::kUserAvatarImage) | 457 if (policy == policy::key::kUserAvatarImage) |
| 453 GetUserImageManager(AccountId::FromUserEmail(user_id)) | 458 GetUserImageManager(account_id)->OnExternalDataCleared(policy); |
| 454 ->OnExternalDataCleared(policy); | |
| 455 else if (policy == policy::key::kWallpaperImage) | 459 else if (policy == policy::key::kWallpaperImage) |
| 456 WallpaperManager::Get()->OnPolicyCleared(policy, user_id); | 460 WallpaperManager::Get()->OnPolicyCleared(policy, account_id); |
| 457 else | 461 else |
| 458 NOTREACHED(); | 462 NOTREACHED(); |
| 459 } | 463 } |
| 460 | 464 |
| 461 void ChromeUserManagerImpl::OnExternalDataFetched( | 465 void ChromeUserManagerImpl::OnExternalDataFetched( |
| 462 const std::string& policy, | 466 const std::string& policy, |
| 463 const std::string& user_id, | 467 const std::string& user_id, |
| 464 scoped_ptr<std::string> data) { | 468 scoped_ptr<std::string> data) { |
| 469 const AccountId account_id = |
| 470 user_manager::UserManager::Get()->GetKnownUserAccountId(user_id, |
| 471 std::string()); |
| 465 if (policy == policy::key::kUserAvatarImage) | 472 if (policy == policy::key::kUserAvatarImage) |
| 466 GetUserImageManager(AccountId::FromUserEmail(user_id)) | 473 GetUserImageManager(account_id)->OnExternalDataFetched(policy, data.Pass()); |
| 467 ->OnExternalDataFetched(policy, data.Pass()); | |
| 468 else if (policy == policy::key::kWallpaperImage) | 474 else if (policy == policy::key::kWallpaperImage) |
| 469 WallpaperManager::Get()->OnPolicyFetched(policy, user_id, data.Pass()); | 475 WallpaperManager::Get()->OnPolicyFetched(policy, account_id, data.Pass()); |
| 470 else | 476 else |
| 471 NOTREACHED(); | 477 NOTREACHED(); |
| 472 } | 478 } |
| 473 | 479 |
| 474 void ChromeUserManagerImpl::OnPolicyUpdated(const std::string& user_id) { | 480 void ChromeUserManagerImpl::OnPolicyUpdated(const std::string& user_id) { |
| 475 const user_manager::User* user = FindUser(AccountId::FromUserEmail(user_id)); | 481 const AccountId account_id = |
| 482 user_manager::UserManager::Get()->GetKnownUserAccountId(user_id, |
| 483 std::string()); |
| 484 const user_manager::User* user = FindUser(account_id); |
| 476 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 485 if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
| 477 return; | 486 return; |
| 478 UpdatePublicAccountDisplayName(user_id); | 487 UpdatePublicAccountDisplayName(user_id); |
| 479 } | 488 } |
| 480 | 489 |
| 481 void ChromeUserManagerImpl::OnDeviceLocalAccountsChanged() { | 490 void ChromeUserManagerImpl::OnDeviceLocalAccountsChanged() { |
| 482 // No action needed here, changes to the list of device-local accounts get | 491 // No action needed here, changes to the list of device-local accounts get |
| 483 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. | 492 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. |
| 484 } | 493 } |
| 485 | 494 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 // mount point. Legacy (--login-profile) value will be used for now. | 660 // mount point. Legacy (--login-profile) value will be used for now. |
| 652 // http://crosbug.com/230859 | 661 // http://crosbug.com/230859 |
| 653 active_user_->SetStubImage( | 662 active_user_->SetStubImage( |
| 654 user_manager::UserImage( | 663 user_manager::UserImage( |
| 655 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 664 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 656 IDR_PROFILE_PICTURE_LOADING)), | 665 IDR_PROFILE_PICTURE_LOADING)), |
| 657 user_manager::User::USER_IMAGE_INVALID, | 666 user_manager::User::USER_IMAGE_INVALID, |
| 658 false); | 667 false); |
| 659 | 668 |
| 660 // Initializes wallpaper after active_user_ is set. | 669 // Initializes wallpaper after active_user_ is set. |
| 661 WallpaperManager::Get()->SetUserWallpaperNow( | 670 WallpaperManager::Get()->SetUserWallpaperNow(login::GuestAccountId()); |
| 662 login::GuestAccountId().GetUserEmail()); | |
| 663 } | 671 } |
| 664 | 672 |
| 665 void ChromeUserManagerImpl::RegularUserLoggedIn(const AccountId& account_id) { | 673 void ChromeUserManagerImpl::RegularUserLoggedIn(const AccountId& account_id) { |
| 666 ChromeUserManager::RegularUserLoggedIn(account_id); | 674 ChromeUserManager::RegularUserLoggedIn(account_id); |
| 667 | 675 |
| 668 if (FakeOwnership()) { | 676 if (FakeOwnership()) { |
| 669 const AccountId owner_account_id = GetActiveUser()->GetAccountId(); | 677 const AccountId owner_account_id = GetActiveUser()->GetAccountId(); |
| 670 VLOG(1) << "Set device owner to: " << owner_account_id.GetUserEmail(); | 678 VLOG(1) << "Set device owner to: " << owner_account_id.GetUserEmail(); |
| 671 CrosSettings::Get()->SetString(kDeviceOwner, | 679 CrosSettings::Get()->SetString(kDeviceOwner, |
| 672 owner_account_id.GetUserEmail()); | 680 owner_account_id.GetUserEmail()); |
| 673 SetOwnerId(owner_account_id); | 681 SetOwnerId(owner_account_id); |
| 674 } | 682 } |
| 675 | 683 |
| 676 if (IsCurrentUserNew()) | 684 if (IsCurrentUserNew()) |
| 677 WallpaperManager::Get()->SetUserWallpaperNow(account_id.GetUserEmail()); | 685 WallpaperManager::Get()->SetUserWallpaperNow(account_id); |
| 678 | 686 |
| 679 GetUserImageManager(account_id)->UserLoggedIn(IsCurrentUserNew(), false); | 687 GetUserImageManager(account_id)->UserLoggedIn(IsCurrentUserNew(), false); |
| 680 | 688 |
| 681 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); | 689 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); |
| 682 | 690 |
| 683 // Make sure that new data is persisted to Local State. | 691 // Make sure that new data is persisted to Local State. |
| 684 GetLocalState()->CommitPendingWrite(); | 692 GetLocalState()->CommitPendingWrite(); |
| 685 } | 693 } |
| 686 | 694 |
| 687 void ChromeUserManagerImpl::RegularUserLoggedInAsEphemeral( | 695 void ChromeUserManagerImpl::RegularUserLoggedInAsEphemeral( |
| 688 const AccountId& account_id) { | 696 const AccountId& account_id) { |
| 689 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 697 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 690 ChromeUserManager::RegularUserLoggedInAsEphemeral(account_id); | 698 ChromeUserManager::RegularUserLoggedInAsEphemeral(account_id); |
| 691 | 699 |
| 692 GetUserImageManager(account_id)->UserLoggedIn(IsCurrentUserNew(), false); | 700 GetUserImageManager(account_id)->UserLoggedIn(IsCurrentUserNew(), false); |
| 693 WallpaperManager::Get()->SetUserWallpaperNow(account_id.GetUserEmail()); | 701 WallpaperManager::Get()->SetUserWallpaperNow(account_id); |
| 694 } | 702 } |
| 695 | 703 |
| 696 void ChromeUserManagerImpl::SupervisedUserLoggedIn( | 704 void ChromeUserManagerImpl::SupervisedUserLoggedIn( |
| 697 const AccountId& account_id) { | 705 const AccountId& account_id) { |
| 698 // TODO(nkostylev): Refactor, share code with RegularUserLoggedIn(). | 706 // TODO(nkostylev): Refactor, share code with RegularUserLoggedIn(). |
| 699 | 707 |
| 700 // Remove the user from the user list. | 708 // Remove the user from the user list. |
| 701 active_user_ = RemoveRegularOrSupervisedUserFromList(account_id); | 709 active_user_ = RemoveRegularOrSupervisedUserFromList(account_id); |
| 702 | 710 |
| 703 // If the user was not found on the user list, create a new user. | 711 // If the user was not found on the user list, create a new user. |
| 704 if (!GetActiveUser()) { | 712 if (!GetActiveUser()) { |
| 705 SetIsCurrentUserNew(true); | 713 SetIsCurrentUserNew(true); |
| 706 active_user_ = user_manager::User::CreateSupervisedUser(account_id); | 714 active_user_ = user_manager::User::CreateSupervisedUser(account_id); |
| 707 // Leaving OAuth token status at the default state = unknown. | 715 // Leaving OAuth token status at the default state = unknown. |
| 708 WallpaperManager::Get()->SetUserWallpaperNow(account_id.GetUserEmail()); | 716 WallpaperManager::Get()->SetUserWallpaperNow(account_id); |
| 709 } else { | 717 } else { |
| 710 if (supervised_user_manager_->CheckForFirstRun(account_id.GetUserEmail())) { | 718 if (supervised_user_manager_->CheckForFirstRun(account_id.GetUserEmail())) { |
| 711 SetIsCurrentUserNew(true); | 719 SetIsCurrentUserNew(true); |
| 712 WallpaperManager::Get()->SetUserWallpaperNow(account_id.GetUserEmail()); | 720 WallpaperManager::Get()->SetUserWallpaperNow(account_id); |
| 713 } else { | 721 } else { |
| 714 SetIsCurrentUserNew(false); | 722 SetIsCurrentUserNew(false); |
| 715 } | 723 } |
| 716 } | 724 } |
| 717 | 725 |
| 718 // Add the user to the front of the user list. | 726 // Add the user to the front of the user list. |
| 719 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); | 727 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); |
| 720 prefs_users_update->Insert(0, | 728 prefs_users_update->Insert(0, |
| 721 new base::StringValue(account_id.GetUserEmail())); | 729 new base::StringValue(account_id.GetUserEmail())); |
| 722 users_.insert(users_.begin(), active_user_); | 730 users_.insert(users_.begin(), active_user_); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 device_local_account_type); | 769 device_local_account_type); |
| 762 | 770 |
| 763 active_user_ = user_manager::User::CreateKioskAppUser(kiosk_app_account_id); | 771 active_user_ = user_manager::User::CreateKioskAppUser(kiosk_app_account_id); |
| 764 active_user_->SetStubImage( | 772 active_user_->SetStubImage( |
| 765 user_manager::UserImage( | 773 user_manager::UserImage( |
| 766 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 774 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 767 IDR_PROFILE_PICTURE_LOADING)), | 775 IDR_PROFILE_PICTURE_LOADING)), |
| 768 user_manager::User::USER_IMAGE_INVALID, | 776 user_manager::User::USER_IMAGE_INVALID, |
| 769 false); | 777 false); |
| 770 | 778 |
| 771 WallpaperManager::Get()->SetUserWallpaperNow( | 779 WallpaperManager::Get()->SetUserWallpaperNow(kiosk_app_account_id); |
| 772 kiosk_app_account_id.GetUserEmail()); | |
| 773 | 780 |
| 774 // TODO(bartfab): Add KioskAppUsers to the users_ list and keep metadata like | 781 // TODO(bartfab): Add KioskAppUsers to the users_ list and keep metadata like |
| 775 // the kiosk_app_id in these objects, removing the need to re-parse the | 782 // the kiosk_app_id in these objects, removing the need to re-parse the |
| 776 // device-local account list here to extract the kiosk_app_id. | 783 // device-local account list here to extract the kiosk_app_id. |
| 777 const std::vector<policy::DeviceLocalAccount> device_local_accounts = | 784 const std::vector<policy::DeviceLocalAccount> device_local_accounts = |
| 778 policy::GetDeviceLocalAccounts(cros_settings_); | 785 policy::GetDeviceLocalAccounts(cros_settings_); |
| 779 const policy::DeviceLocalAccount* account = NULL; | 786 const policy::DeviceLocalAccount* account = NULL; |
| 780 for (std::vector<policy::DeviceLocalAccount>::const_iterator it = | 787 for (std::vector<policy::DeviceLocalAccount>::const_iterator it = |
| 781 device_local_accounts.begin(); | 788 device_local_accounts.begin(); |
| 782 it != device_local_accounts.end(); | 789 it != device_local_accounts.end(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 806 | 813 |
| 807 void ChromeUserManagerImpl::DemoAccountLoggedIn() { | 814 void ChromeUserManagerImpl::DemoAccountLoggedIn() { |
| 808 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 815 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 809 active_user_ = user_manager::User::CreateKioskAppUser(login::DemoAccountId()); | 816 active_user_ = user_manager::User::CreateKioskAppUser(login::DemoAccountId()); |
| 810 active_user_->SetStubImage( | 817 active_user_->SetStubImage( |
| 811 user_manager::UserImage( | 818 user_manager::UserImage( |
| 812 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 819 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 813 IDR_PROFILE_PICTURE_LOADING)), | 820 IDR_PROFILE_PICTURE_LOADING)), |
| 814 user_manager::User::USER_IMAGE_INVALID, | 821 user_manager::User::USER_IMAGE_INVALID, |
| 815 false); | 822 false); |
| 816 WallpaperManager::Get()->SetUserWallpaperNow( | 823 WallpaperManager::Get()->SetUserWallpaperNow(login::DemoAccountId()); |
| 817 login::DemoAccountId().GetUserEmail()); | |
| 818 | 824 |
| 819 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 825 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 820 command_line->AppendSwitch(::switches::kForceAppMode); | 826 command_line->AppendSwitch(::switches::kForceAppMode); |
| 821 command_line->AppendSwitchASCII(::switches::kAppId, | 827 command_line->AppendSwitchASCII(::switches::kAppId, |
| 822 DemoAppLauncher::kDemoAppId); | 828 DemoAppLauncher::kDemoAppId); |
| 823 | 829 |
| 824 // Disable window animation since the demo app runs in a single full screen | 830 // Disable window animation since the demo app runs in a single full screen |
| 825 // window and window animation causes start-up janks. | 831 // window and window animation causes start-up janks. |
| 826 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 832 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 827 wm::switches::kWindowAnimationsDisabled); | 833 wm::switches::kWindowAnimationsDisabled); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 850 FakeOwnership() || DeviceSettingsService::Get()->HasPrivateOwnerKey(); | 856 FakeOwnership() || DeviceSettingsService::Get()->HasPrivateOwnerKey(); |
| 851 VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner"); | 857 VLOG(1) << "Current user " << (is_owner ? "is owner" : "is not owner"); |
| 852 | 858 |
| 853 SetCurrentUserIsOwner(is_owner); | 859 SetCurrentUserIsOwner(is_owner); |
| 854 } | 860 } |
| 855 | 861 |
| 856 void ChromeUserManagerImpl::RemoveNonCryptohomeData( | 862 void ChromeUserManagerImpl::RemoveNonCryptohomeData( |
| 857 const AccountId& account_id) { | 863 const AccountId& account_id) { |
| 858 ChromeUserManager::RemoveNonCryptohomeData(account_id); | 864 ChromeUserManager::RemoveNonCryptohomeData(account_id); |
| 859 | 865 |
| 860 WallpaperManager::Get()->RemoveUserWallpaperInfo(account_id.GetUserEmail()); | 866 WallpaperManager::Get()->RemoveUserWallpaperInfo(account_id); |
| 861 GetUserImageManager(account_id)->DeleteUserImage(); | 867 GetUserImageManager(account_id)->DeleteUserImage(); |
| 862 | 868 |
| 863 supervised_user_manager_->RemoveNonCryptohomeData(account_id.GetUserEmail()); | 869 supervised_user_manager_->RemoveNonCryptohomeData(account_id.GetUserEmail()); |
| 864 | 870 |
| 865 multi_profile_user_controller_->RemoveCachedValues(account_id.GetUserEmail()); | 871 multi_profile_user_controller_->RemoveCachedValues(account_id.GetUserEmail()); |
| 866 | 872 |
| 867 EasyUnlockService::ResetLocalStateForUser(account_id.GetUserEmail()); | 873 EasyUnlockService::ResetLocalStateForUser(account_id.GetUserEmail()); |
| 868 } | 874 } |
| 869 | 875 |
| 870 void | 876 void |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 new base::StringValue(account_id.GetUserEmail())); | 1192 new base::StringValue(account_id.GetUserEmail())); |
| 1187 } | 1193 } |
| 1188 | 1194 |
| 1189 void ChromeUserManagerImpl::RemoveReportingUser(const AccountId& account_id) { | 1195 void ChromeUserManagerImpl::RemoveReportingUser(const AccountId& account_id) { |
| 1190 ListPrefUpdate users_update(GetLocalState(), kReportingUsers); | 1196 ListPrefUpdate users_update(GetLocalState(), kReportingUsers); |
| 1191 users_update->Remove( | 1197 users_update->Remove( |
| 1192 base::StringValue(FullyCanonicalize(account_id.GetUserEmail())), NULL); | 1198 base::StringValue(FullyCanonicalize(account_id.GetUserEmail())), NULL); |
| 1193 } | 1199 } |
| 1194 | 1200 |
| 1195 } // namespace chromeos | 1201 } // namespace chromeos |
| OLD | NEW |