| Index: chrome/browser/chromeos/login/user_manager_impl.cc
|
| diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc
|
| index bc853bb2bca4781fc129303bcae6eadbd8e5f52c..63284c737b8122533512caca4a8a8afdcd5c09a1 100644
|
| --- a/chrome/browser/chromeos/login/user_manager_impl.cc
|
| +++ b/chrome/browser/chromeos/login/user_manager_impl.cc
|
| @@ -6,7 +6,6 @@
|
|
|
| #include <cstddef>
|
| #include <set>
|
| -#include <vector>
|
|
|
| #include "ash/shell.h"
|
| #include "base/bind.h"
|
| @@ -32,7 +31,9 @@
|
| #include "chrome/browser/chromeos/login/remove_user_delegate.h"
|
| #include "chrome/browser/chromeos/login/user_image_manager_impl.h"
|
| #include "chrome/browser/chromeos/login/wizard_controller.h"
|
| +#include "chrome/browser/chromeos/policy/device_local_account.h"
|
| #include "chrome/browser/chromeos/session_length_limiter.h"
|
| +#include "chrome/browser/chromeos/settings/cros_settings_names.h"
|
| #include "chrome/browser/policy/browser_policy_connector.h"
|
| #include "chrome/browser/prefs/scoped_user_pref_update.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| @@ -656,8 +657,8 @@ void UserManagerImpl::OnStateChanged() {
|
| }
|
| }
|
|
|
| -void UserManagerImpl::OnPolicyUpdated(const std::string& account_id) {
|
| - UpdatePublicAccountDisplayName(account_id);
|
| +void UserManagerImpl::OnPolicyUpdated(const std::string& user_id) {
|
| + UpdatePublicAccountDisplayName(user_id);
|
| NotifyUserListChanged();
|
| }
|
|
|
| @@ -909,12 +910,14 @@ void UserManagerImpl::RetrieveTrustedDevicePolicies() {
|
| cros_settings_->GetBoolean(kAccountsPrefEphemeralUsersEnabled,
|
| &ephemeral_users_enabled_);
|
| cros_settings_->GetString(kDeviceOwner, &owner_email_);
|
| - base::ListValue public_accounts;
|
| - ReadPublicAccounts(&public_accounts);
|
| + const base::ListValue* device_local_accounts;
|
| + cros_settings_->GetList(kAccountsPrefDeviceLocalAccounts,
|
| + &device_local_accounts);
|
|
|
| EnsureUsersLoaded();
|
|
|
| - bool changed = UpdateAndCleanUpPublicAccounts(public_accounts);
|
| + bool changed = UpdateAndCleanUpPublicAccounts(
|
| + policy::DecodeDeviceLocalAccountsList(device_local_accounts));
|
|
|
| // If ephemeral users are enabled and we are on the login screen, take this
|
| // opportunity to clean up by removing all regular users except the owner.
|
| @@ -1184,7 +1187,7 @@ User* UserManagerImpl::RemoveRegularOrLocallyManagedUserFromList(
|
| }
|
|
|
| bool UserManagerImpl::UpdateAndCleanUpPublicAccounts(
|
| - const base::ListValue& public_accounts) {
|
| + const std::vector<policy::DeviceLocalAccount>& device_local_accounts) {
|
| PrefService* local_state = g_browser_process->local_state();
|
|
|
| // Determine the currently logged-in user's email.
|
| @@ -1214,21 +1217,31 @@ bool UserManagerImpl::UpdateAndCleanUpPublicAccounts(
|
| }
|
|
|
| // Get the new list of public accounts from policy.
|
| + scoped_ptr<base::ListValue> prefs_public_accounts(new base::ListValue);
|
| std::vector<std::string> new_public_accounts;
|
| - std::set<std::string> new_public_accounts_set;
|
| - if (!ParseUserList(public_accounts, regular_users, active_user_email,
|
| - &new_public_accounts, &new_public_accounts_set) &&
|
| - IsLoggedInAsPublicAccount()) {
|
| - // If the user is currently logged into a public account that has been
|
| - // removed from the list, mark the account's data as pending removal after
|
| - // logout.
|
| + bool logged_in_user_on_list = false;
|
| + for (std::vector<policy::DeviceLocalAccount>::const_iterator it =
|
| + device_local_accounts.begin();
|
| + it != device_local_accounts.end(); ++it) {
|
| + if (it->type != policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)
|
| + continue;
|
| + prefs_public_accounts->AppendString(it->user_id);
|
| + if (it->user_id == active_user_email) {
|
| + logged_in_user_on_list = true;
|
| + continue;
|
| + }
|
| + new_public_accounts.push_back(it->user_id);
|
| + }
|
| +
|
| + // If the user is currently logged into a public account that has been removed
|
| + // from the list, mark the account's data as pending removal after logout.
|
| + if (!logged_in_user_on_list && IsLoggedInAsPublicAccount()) {
|
| local_state->SetString(kPublicAccountPendingDataRemoval,
|
| active_user_email);
|
| }
|
|
|
| // Persist the new list of public accounts in a pref.
|
| ListPrefUpdate prefs_public_accounts_update(local_state, kPublicAccounts);
|
| - scoped_ptr<base::ListValue> prefs_public_accounts(public_accounts.DeepCopy());
|
| prefs_public_accounts_update->Swap(prefs_public_accounts.get());
|
|
|
| // If the list of public accounts has not changed, return.
|
| @@ -1278,7 +1291,7 @@ void UserManagerImpl::UpdatePublicAccountDisplayName(
|
|
|
| if (device_local_account_policy_service_) {
|
| policy::DeviceLocalAccountPolicyBroker* broker =
|
| - device_local_account_policy_service_->GetBrokerForAccount(username);
|
| + device_local_account_policy_service_->GetBrokerForUser(username);
|
| if (broker)
|
| display_name = broker->GetDisplayName();
|
| }
|
| @@ -1463,36 +1476,4 @@ void UserManagerImpl::UpdateLoginState() {
|
| LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type);
|
| }
|
|
|
| -void UserManagerImpl::ReadPublicAccounts(base::ListValue* public_accounts) {
|
| - const base::ListValue* accounts = NULL;
|
| - if (cros_settings_->GetList(kAccountsPrefDeviceLocalAccounts, &accounts)) {
|
| - for (base::ListValue::const_iterator entry(accounts->begin());
|
| - entry != accounts->end(); ++entry) {
|
| - const base::DictionaryValue* entry_dict = NULL;
|
| - if (!(*entry)->GetAsDictionary(&entry_dict)) {
|
| - NOTREACHED();
|
| - continue;
|
| - }
|
| -
|
| - int type = DEVICE_LOCAL_ACCOUNT_TYPE_PUBLIC_SESSION;
|
| - entry_dict->GetIntegerWithoutPathExpansion(
|
| - kAccountsPrefDeviceLocalAccountsKeyType, &type);
|
| - switch (type) {
|
| - case DEVICE_LOCAL_ACCOUNT_TYPE_PUBLIC_SESSION: {
|
| - std::string id;
|
| - if (entry_dict->GetStringWithoutPathExpansion(
|
| - kAccountsPrefDeviceLocalAccountsKeyId, &id)) {
|
| - public_accounts->AppendString(id);
|
| - }
|
| - break;
|
| - }
|
| - case DEVICE_LOCAL_ACCOUNT_TYPE_KIOSK_APP:
|
| - // TODO(mnissler, nkostylev, bartfab): Process Kiosk Apps within the
|
| - // standard login framework: http://crbug.com/234694
|
| - break;
|
| - }
|
| - }
|
| - }
|
| -}
|
| -
|
| } // namespace chromeos
|
|
|