Chromium Code Reviews| Index: chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc |
| diff --git a/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc b/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc |
| index 0ca91fd1b90d77857ae96d13c53395a3f3d9f46f..e05ae8f3954ce31bb1b4ddb73248c9ded903791d 100644 |
| --- a/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc |
| +++ b/chrome/browser/chromeos/login/users/chrome_user_manager_impl.cc |
| @@ -87,9 +87,6 @@ namespace { |
| // order. |
| const char kRegularUsers[] = "LoggedInUsers"; |
| -// A vector pref of the public accounts defined on this device. |
| -const char kPublicAccounts[] = "PublicAccounts"; |
| - |
| // Key for list of users that should be reported. |
| const char kReportingUsers[] = "reporting_users"; |
| @@ -131,7 +128,6 @@ void ResolveLocale(const std::string& raw_locale, |
| void ChromeUserManagerImpl::RegisterPrefs(PrefRegistrySimple* registry) { |
| ChromeUserManager::RegisterPrefs(registry); |
| - registry->RegisterListPref(kPublicAccounts); |
| registry->RegisterStringPref(kPublicAccountPendingDataRemoval, std::string()); |
| registry->RegisterListPref(kReportingUsers); |
| @@ -565,16 +561,33 @@ bool ChromeUserManagerImpl::IsEnterpriseManaged() const { |
| return connector->IsEnterpriseManaged(); |
| } |
| -void ChromeUserManagerImpl::LoadPublicAccounts( |
| - std::set<AccountId>* public_sessions_set) { |
| - const base::ListValue* prefs_public_sessions = |
| - GetLocalState()->GetList(kPublicAccounts); |
| - std::vector<AccountId> public_sessions; |
| - ParseUserList(*prefs_public_sessions, std::set<AccountId>(), &public_sessions, |
| - public_sessions_set); |
| - for (const AccountId& account_id : public_sessions) { |
| - users_.push_back(user_manager::User::CreatePublicAccountUser(account_id)); |
| - UpdatePublicAccountDisplayName(account_id.GetUserEmail()); |
| +void ChromeUserManagerImpl::LoadDeviceLocalAccounts( |
| + std::set<AccountId>* device_local_accounts_set) { |
| + const std::vector<policy::DeviceLocalAccount> device_local_accounts = |
|
bartfab (slow)
2016/04/08 09:44:15
We need to persist the current list of public sess
xiyuan
2016/04/08 15:52:14
We don't really need kPublicAccounts because devic
|
| + policy::GetDeviceLocalAccounts(cros_settings_); |
| + |
| + for (const auto& device_local_account : device_local_accounts) { |
| + const AccountId account_id = user_manager::known_user::GetAccountId( |
| + device_local_account.user_id, std::string()); |
| + if (!device_local_accounts_set->insert(account_id).second) { |
| + LOG(ERROR) << "Duplicate device local account: id=" |
| + << account_id.GetUserEmail(); |
| + continue; |
| + } |
| + |
| + switch (device_local_account.type) { |
| + case policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION: |
| + users_.push_back( |
| + user_manager::User::CreatePublicAccountUser(account_id)); |
| + UpdatePublicAccountDisplayName(account_id.GetUserEmail()); |
| + break; |
| + case policy::DeviceLocalAccount::TYPE_KIOSK_APP: |
| + users_.push_back(user_manager::User::CreateKioskAppUser(account_id)); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + break; |
| + } |
| } |
| } |
| @@ -609,14 +622,6 @@ bool ChromeUserManagerImpl::IsDemoApp(const AccountId& account_id) const { |
| return DemoAppLauncher::IsDemoAppSession(account_id); |
| } |
| -bool ChromeUserManagerImpl::IsKioskApp(const AccountId& account_id) const { |
| - policy::DeviceLocalAccount::Type device_local_account_type; |
| - return policy::IsDeviceLocalAccountUser(account_id.GetUserEmail(), |
| - &device_local_account_type) && |
| - device_local_account_type == |
| - policy::DeviceLocalAccount::TYPE_KIOSK_APP; |
| -} |
| - |
| bool ChromeUserManagerImpl::IsPublicAccountMarkedForRemoval( |
| const AccountId& account_id) const { |
| return account_id == AccountId::FromUserEmail(GetLocalState()->GetString( |
| @@ -786,16 +791,10 @@ void ChromeUserManagerImpl::PublicAccountUserLoggedIn( |
| WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); |
| } |
| -void ChromeUserManagerImpl::KioskAppLoggedIn( |
| - const AccountId& kiosk_app_account_id) { |
| +void ChromeUserManagerImpl::KioskAppLoggedIn(user_manager::User* user) { |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| - policy::DeviceLocalAccount::Type device_local_account_type; |
| - DCHECK(policy::IsDeviceLocalAccountUser(kiosk_app_account_id.GetUserEmail(), |
| - &device_local_account_type)); |
| - DCHECK_EQ(policy::DeviceLocalAccount::TYPE_KIOSK_APP, |
| - device_local_account_type); |
| - active_user_ = user_manager::User::CreateKioskAppUser(kiosk_app_account_id); |
| + active_user_ = user; |
| active_user_->SetStubImage( |
| user_manager::UserImage( |
| *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| @@ -803,6 +802,7 @@ void ChromeUserManagerImpl::KioskAppLoggedIn( |
| user_manager::User::USER_IMAGE_INVALID, |
| false); |
| + const AccountId& kiosk_app_account_id = user->GetAccountId(); |
| WallpaperManager::Get()->SetUserWallpaperNow(kiosk_app_account_id); |
| // TODO(bartfab): Add KioskAppUsers to the users_ list and keep metadata like |
| @@ -820,9 +820,9 @@ void ChromeUserManagerImpl::KioskAppLoggedIn( |
| break; |
| } |
| } |
| - std::string kiosk_app_name; |
| + std::string kiosk_app_id; |
| if (account) { |
| - kiosk_app_name = account->kiosk_app_id; |
| + kiosk_app_id = account->kiosk_app_id; |
| } else { |
| LOG(ERROR) << "Logged into nonexistent kiosk-app account: " |
| << kiosk_app_account_id.GetUserEmail(); |
| @@ -831,7 +831,7 @@ void ChromeUserManagerImpl::KioskAppLoggedIn( |
| base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| command_line->AppendSwitch(::switches::kForceAppMode); |
| - command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_name); |
| + command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id); |
| // Disable window animation since kiosk app runs in a single full screen |
| // window and window animation causes start-up janks. |
| @@ -985,16 +985,6 @@ bool ChromeUserManagerImpl::UpdateAndCleanUpPublicAccounts( |
| return false; |
| } |
| - // Persist the new list of public accounts in a pref. |
| - ListPrefUpdate prefs_public_accounts_update(GetLocalState(), kPublicAccounts); |
| - prefs_public_accounts_update->Clear(); |
| - for (std::vector<std::string>::const_iterator it = |
| - new_public_accounts.begin(); |
| - it != new_public_accounts.end(); |
| - ++it) { |
| - prefs_public_accounts_update->AppendString(*it); |
| - } |
| - |
| // Remove the old public accounts from the user list. |
| for (user_manager::UserList::iterator it = users_.begin(); |
| it != users_.end();) { |