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

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

Issue 14927015: Translate device-local account IDs to user IDs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. Kiosk apps fixed. Created 7 years, 7 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/user_manager_impl.h" 5 #include "chrome/browser/chromeos/login/user_manager_impl.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <set> 8 #include <set>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 12 matching lines...) Expand all
23 #include "base/values.h" 23 #include "base/values.h"
24 #include "chrome/browser/app_mode/app_mode_utils.h" 24 #include "chrome/browser/app_mode/app_mode_utils.h"
25 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/chromeos/cros/cert_library.h" 26 #include "chrome/browser/chromeos/cros/cert_library.h"
27 #include "chrome/browser/chromeos/cros/cros_library.h" 27 #include "chrome/browser/chromeos/cros/cros_library.h"
28 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h" 28 #include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h"
29 #include "chrome/browser/chromeos/login/login_display.h" 29 #include "chrome/browser/chromeos/login/login_display.h"
30 #include "chrome/browser/chromeos/login/remove_user_delegate.h" 30 #include "chrome/browser/chromeos/login/remove_user_delegate.h"
31 #include "chrome/browser/chromeos/login/user_image_manager_impl.h" 31 #include "chrome/browser/chromeos/login/user_image_manager_impl.h"
32 #include "chrome/browser/chromeos/login/wizard_controller.h" 32 #include "chrome/browser/chromeos/login/wizard_controller.h"
33 #include "chrome/browser/chromeos/policy/device_local_account.h"
33 #include "chrome/browser/chromeos/session_length_limiter.h" 34 #include "chrome/browser/chromeos/session_length_limiter.h"
35 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
34 #include "chrome/browser/policy/browser_policy_connector.h" 36 #include "chrome/browser/policy/browser_policy_connector.h"
35 #include "chrome/browser/prefs/scoped_user_pref_update.h" 37 #include "chrome/browser/prefs/scoped_user_pref_update.h"
36 #include "chrome/browser/profiles/profile_manager.h" 38 #include "chrome/browser/profiles/profile_manager.h"
37 #include "chrome/browser/sync/profile_sync_service.h" 39 #include "chrome/browser/sync/profile_sync_service.h"
38 #include "chrome/browser/sync/profile_sync_service_factory.h" 40 #include "chrome/browser/sync/profile_sync_service_factory.h"
39 #include "chrome/common/chrome_notification_types.h" 41 #include "chrome/common/chrome_notification_types.h"
40 #include "chrome/common/chrome_switches.h" 42 #include "chrome/common/chrome_switches.h"
41 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
42 #include "chromeos/chromeos_switches.h" 44 #include "chromeos/chromeos_switches.h"
43 #include "chromeos/cryptohome/async_method_caller.h" 45 #include "chromeos/cryptohome/async_method_caller.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (!CommandLine::ForCurrentProcess()->HasSwitch(::switches::kMultiProfiles)) 248 if (!CommandLine::ForCurrentProcess()->HasSwitch(::switches::kMultiProfiles))
247 DCHECK(!IsUserLoggedIn()); 249 DCHECK(!IsUserLoggedIn());
248 250
249 if (active_user_) 251 if (active_user_)
250 active_user_->set_is_active(false); 252 active_user_->set_is_active(false);
251 253
252 if (email == kGuestUserEMail) { 254 if (email == kGuestUserEMail) {
253 GuestUserLoggedIn(); 255 GuestUserLoggedIn();
254 } else if (email == kRetailModeUserEMail) { 256 } else if (email == kRetailModeUserEMail) {
255 RetailModeUserLoggedIn(); 257 RetailModeUserLoggedIn();
256 } else if (gaia::ExtractDomainName(email) == kKioskAppUserDomain) { 258 } else if (policy::IsKioskAppUser(email)) {
257 KioskAppLoggedIn(email); 259 KioskAppLoggedIn(email);
258 } else { 260 } else {
259 EnsureUsersLoaded(); 261 EnsureUsersLoaded();
260 262
261 User* user = FindUserInListAndModify(email); 263 User* user = FindUserInListAndModify(email);
262 if (user && user->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) { 264 if (user && user->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) {
263 PublicAccountUserLoggedIn(user); 265 PublicAccountUserLoggedIn(user);
264 } else if ((user && 266 } else if ((user &&
265 user->GetType() == User::USER_TYPE_LOCALLY_MANAGED) || 267 user->GetType() == User::USER_TYPE_LOCALLY_MANAGED) ||
266 (!user && 268 (!user &&
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 // http://crbug.com/230860 640 // http://crbug.com/230860
639 // TODO(nkostylev): Figure out whether we want to have observers 641 // TODO(nkostylev): Figure out whether we want to have observers
640 // for each logged in user. 642 // for each logged in user.
641 // TODO(nkostyelv): Change observer after active user has changed. 643 // TODO(nkostyelv): Change observer after active user has changed.
642 SaveUserOAuthStatus( 644 SaveUserOAuthStatus(
643 active_user_->email(), 645 active_user_->email(),
644 User::OAUTH2_TOKEN_STATUS_INVALID); 646 User::OAUTH2_TOKEN_STATUS_INVALID);
645 } 647 }
646 } 648 }
647 649
648 void UserManagerImpl::OnPolicyUpdated(const std::string& account_id) { 650 void UserManagerImpl::OnPolicyUpdated(const std::string& user_id) {
649 UpdatePublicAccountDisplayName(account_id); 651 UpdatePublicAccountDisplayName(user_id);
650 NotifyUserListChanged(); 652 NotifyUserListChanged();
651 } 653 }
652 654
653 void UserManagerImpl::OnDeviceLocalAccountsChanged() { 655 void UserManagerImpl::OnDeviceLocalAccountsChanged() {
654 // No action needed here, changes to the list of device-local accounts get 656 // No action needed here, changes to the list of device-local accounts get
655 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. 657 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer.
656 } 658 }
657 659
658 bool UserManagerImpl::IsCurrentUserOwner() const { 660 bool UserManagerImpl::IsCurrentUserOwner() const {
659 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 661 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 // Schedule a callback if device policy has not yet been verified. 893 // Schedule a callback if device policy has not yet been verified.
892 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( 894 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues(
893 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies, 895 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies,
894 base::Unretained(this)))) { 896 base::Unretained(this)))) {
895 return; 897 return;
896 } 898 }
897 899
898 cros_settings_->GetBoolean(kAccountsPrefEphemeralUsersEnabled, 900 cros_settings_->GetBoolean(kAccountsPrefEphemeralUsersEnabled,
899 &ephemeral_users_enabled_); 901 &ephemeral_users_enabled_);
900 cros_settings_->GetString(kDeviceOwner, &owner_email_); 902 cros_settings_->GetString(kDeviceOwner, &owner_email_);
901 base::ListValue public_accounts;
902 ReadPublicAccounts(&public_accounts);
903 903
904 EnsureUsersLoaded(); 904 EnsureUsersLoaded();
905 905
906 bool changed = UpdateAndCleanUpPublicAccounts(public_accounts); 906 bool changed = UpdateAndCleanUpPublicAccounts(
907 policy::GetDeviceLocalAccounts(cros_settings_));
907 908
908 // If ephemeral users are enabled and we are on the login screen, take this 909 // If ephemeral users are enabled and we are on the login screen, take this
909 // opportunity to clean up by removing all regular users except the owner. 910 // opportunity to clean up by removing all regular users except the owner.
910 if (ephemeral_users_enabled_ && !IsUserLoggedIn()) { 911 if (ephemeral_users_enabled_ && !IsUserLoggedIn()) {
911 ListPrefUpdate prefs_users_update(g_browser_process->local_state(), 912 ListPrefUpdate prefs_users_update(g_browser_process->local_state(),
912 kRegularUsers); 913 kRegularUsers);
913 prefs_users_update->Clear(); 914 prefs_users_update->Clear();
914 for (UserList::iterator it = users_.begin(); it != users_.end(); ) { 915 for (UserList::iterator it = users_.begin(); it != users_.end(); ) {
915 const std::string user_email = (*it)->email(); 916 const std::string user_email = (*it)->email();
916 if ((*it)->GetType() == User::USER_TYPE_REGULAR && 917 if ((*it)->GetType() == User::USER_TYPE_REGULAR &&
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 active_user_ = user; 1069 active_user_ = user;
1069 // The UserImageManager chooses a random avatar picture when a user logs in 1070 // The UserImageManager chooses a random avatar picture when a user logs in
1070 // for the first time. Tell the UserImageManager that this user is not new to 1071 // for the first time. Tell the UserImageManager that this user is not new to
1071 // prevent the avatar from getting changed. 1072 // prevent the avatar from getting changed.
1072 user_image_manager_->UserLoggedIn(user->email(), false, true); 1073 user_image_manager_->UserLoggedIn(user->email(), false, true);
1073 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); 1074 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded();
1074 } 1075 }
1075 1076
1076 void UserManagerImpl::KioskAppLoggedIn(const std::string& username) { 1077 void UserManagerImpl::KioskAppLoggedIn(const std::string& username) {
1077 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1078 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1078 DCHECK_EQ(gaia::ExtractDomainName(username), kKioskAppUserDomain); 1079 DCHECK(policy::IsKioskAppUser(username));
1079 1080
1080 WallpaperManager::Get()->SetInitialUserWallpaper(username, false); 1081 WallpaperManager::Get()->SetInitialUserWallpaper(username, false);
1081 active_user_ = User::CreateKioskAppUser(username); 1082 active_user_ = User::CreateKioskAppUser(username);
1082 active_user_->SetStubImage(User::kInvalidImageIndex, false); 1083 active_user_->SetStubImage(User::kInvalidImageIndex, false);
1083 1084
1085 // TODO(bartfab): Add KioskAppUsers to the users_ list and keep metadata like
Mattias Nissler (ping if slow) 2013/05/17 14:29:44 not sure whether we want to do this half-way. Mayb
bartfab (slow) 2013/05/17 16:08:47 I would prefer to go for ${opaque_identifier}@kios
1086 // the kiosk_app_id in these objects, removing the need to re-parse the
1087 // device-local account list here to extract the kiosk_app_id.
1088 const std::vector<policy::DeviceLocalAccount> device_local_accounts =
1089 policy::GetDeviceLocalAccounts(cros_settings_);
1090 const policy::DeviceLocalAccount* account = NULL;
1091 for (std::vector<policy::DeviceLocalAccount>::const_iterator
1092 it = device_local_accounts.begin();
1093 it != device_local_accounts.end(); ++it) {
1094 if (it->user_id == username) {
1095 account = &*it;
1096 break;
1097 }
1098 }
1099 std::string kiosk_app_id;
1100 if (account) {
1101 kiosk_app_id = account->kiosk_app_id;
1102 } else {
1103 LOG(ERROR) << "Logged into nonexistent kiosk-app account: " << username;
1104 NOTREACHED();
1105 }
1106
1084 CommandLine* command_line = CommandLine::ForCurrentProcess(); 1107 CommandLine* command_line = CommandLine::ForCurrentProcess();
1085 command_line->AppendSwitch(::switches::kForceAppMode); 1108 command_line->AppendSwitch(::switches::kForceAppMode);
1086 command_line->AppendSwitchASCII(::switches::kAppId, 1109 command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id);
1087 active_user_->GetAccountName(false)); 1110
1088 // Disable window animation since kiosk app runs in a single full screen 1111 // Disable window animation since kiosk app runs in a single full screen
1089 // window and window animation causes start-up janks. 1112 // window and window animation causes start-up janks.
1090 command_line->AppendSwitch( 1113 command_line->AppendSwitch(
1091 views::corewm::switches::kWindowAnimationsDisabled); 1114 views::corewm::switches::kWindowAnimationsDisabled);
1092 } 1115 }
1093 1116
1094 void UserManagerImpl::RetailModeUserLoggedIn() { 1117 void UserManagerImpl::RetailModeUserLoggedIn() {
1095 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1096 is_current_user_new_ = true; 1119 is_current_user_new_ = true;
1097 active_user_ = User::CreateRetailModeUser(); 1120 active_user_ = User::CreateRetailModeUser();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 if ((*it)->GetType() == User::USER_TYPE_REGULAR || 1188 if ((*it)->GetType() == User::USER_TYPE_REGULAR ||
1166 (*it)->GetType() == User::USER_TYPE_LOCALLY_MANAGED) { 1189 (*it)->GetType() == User::USER_TYPE_LOCALLY_MANAGED) {
1167 prefs_users_update->Append(new base::StringValue(user_email)); 1190 prefs_users_update->Append(new base::StringValue(user_email));
1168 } 1191 }
1169 ++it; 1192 ++it;
1170 } 1193 }
1171 } 1194 }
1172 return user; 1195 return user;
1173 } 1196 }
1174 1197
1198 void UserManagerImpl::CleanUpPublicAccountNonCryptohomeDataPendingRemoval() {
1199 PrefService* local_state = g_browser_process->local_state();
1200 const std::string public_account_pending_data_removal =
1201 local_state->GetString(kPublicAccountPendingDataRemoval);
1202 if (public_account_pending_data_removal.empty() ||
1203 (IsUserLoggedIn() &&
1204 public_account_pending_data_removal == GetActiveUser()->email())) {
1205 return;
1206 }
1207
1208 RemoveNonCryptohomeData(public_account_pending_data_removal);
1209 local_state->ClearPref(kPublicAccountPendingDataRemoval);
1210 }
1211
1175 void UserManagerImpl::CleanUpPublicAccountNonCryptohomeData( 1212 void UserManagerImpl::CleanUpPublicAccountNonCryptohomeData(
1176 const std::vector<std::string>& old_public_accounts) { 1213 const std::vector<std::string>& old_public_accounts) {
1177 std::set<std::string> users; 1214 std::set<std::string> users;
1178 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) 1215 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it)
1179 users.insert((*it)->email()); 1216 users.insert((*it)->email());
1180 1217
1181 // If the user is logged into a public account that has been removed from the 1218 // If the user is logged into a public account that has been removed from the
1182 // user list, mark the account's data as pending removal after logout. 1219 // user list, mark the account's data as pending removal after logout.
1183 if (IsLoggedInAsPublicAccount()) { 1220 if (IsLoggedInAsPublicAccount()) {
1184 const std::string active_user_id = GetActiveUser()->email(); 1221 const std::string active_user_id = GetActiveUser()->email();
1185 if (users.find(active_user_id) == users.end()) { 1222 if (users.find(active_user_id) == users.end()) {
1186 g_browser_process->local_state()->SetString( 1223 g_browser_process->local_state()->SetString(
1187 kPublicAccountPendingDataRemoval, active_user_id); 1224 kPublicAccountPendingDataRemoval, active_user_id);
1188 users.insert(active_user_id); 1225 users.insert(active_user_id);
1189 } 1226 }
1190 } 1227 }
1191 1228
1192 // Remove the data belonging to any other public accounts that are no longer 1229 // Remove the data belonging to any other public accounts that are no longer
1193 // found on the user list. 1230 // found on the user list.
1194 for (std::vector<std::string>::const_iterator 1231 for (std::vector<std::string>::const_iterator
1195 it = old_public_accounts.begin(); 1232 it = old_public_accounts.begin();
1196 it != old_public_accounts.end(); ++it) { 1233 it != old_public_accounts.end(); ++it) {
1197 if (users.find(*it) == users.end()) 1234 if (users.find(*it) == users.end())
1198 RemoveNonCryptohomeData(*it); 1235 RemoveNonCryptohomeData(*it);
1199 } 1236 }
1200 } 1237 }
1201 1238
1202 bool UserManagerImpl::UpdateAndCleanUpPublicAccounts( 1239 bool UserManagerImpl::UpdateAndCleanUpPublicAccounts(
1203 const base::ListValue& public_accounts) { 1240 const std::vector<policy::DeviceLocalAccount>& device_local_accounts) {
1204 PrefService* local_state = g_browser_process->local_state(); 1241 // Try to remove any public account data marked as pending removal.
1242 CleanUpPublicAccountNonCryptohomeDataPendingRemoval();
1205 1243
1206 // Determine the currently logged-in user's email. 1244 // Get the current list of public accounts.
1207 std::string active_user_email;
1208 if (IsUserLoggedIn())
1209 active_user_email = GetLoggedInUser()->email();
1210
1211 // If there is a public account whose data is pending removal and the user is
1212 // not currently logged in with that account, take this opportunity to remove
1213 // the data.
1214 std::string public_account_pending_data_removal =
1215 local_state->GetString(kPublicAccountPendingDataRemoval);
1216 if (!public_account_pending_data_removal.empty() &&
1217 public_account_pending_data_removal != active_user_email) {
1218 RemoveNonCryptohomeData(public_account_pending_data_removal);
1219 local_state->ClearPref(kPublicAccountPendingDataRemoval);
1220 }
1221
1222 // Split the current user list public accounts and regular users.
1223 std::vector<std::string> old_public_accounts; 1245 std::vector<std::string> old_public_accounts;
1224 std::set<std::string> regular_users;
1225 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) { 1246 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) {
1226 if ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) 1247 if ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT)
1227 old_public_accounts.push_back((*it)->email()); 1248 old_public_accounts.push_back((*it)->email());
1228 else
1229 regular_users.insert((*it)->email());
1230 } 1249 }
1231 1250
1232 // Get the new list of public accounts from policy. 1251 // Get the new list of public accounts from policy.
1233 std::vector<std::string> new_public_accounts; 1252 std::vector<std::string> new_public_accounts;
1234 std::set<std::string> new_public_accounts_set; 1253 for (std::vector<policy::DeviceLocalAccount>::const_iterator it =
1235 ParseUserList(public_accounts, regular_users, 1254 device_local_accounts.begin();
1236 &new_public_accounts, &new_public_accounts_set); 1255 it != device_local_accounts.end(); ++it) {
1237 1256 // TODO(mnissler, nkostylev, bartfab): Process Kiosk Apps within the
1238 // Persist the new list of public accounts in a pref. 1257 // standard login framework: http://crbug.com/234694
1239 ListPrefUpdate prefs_public_accounts_update(local_state, kPublicAccounts); 1258 if (it->type == policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)
1240 scoped_ptr<base::ListValue> prefs_public_accounts(public_accounts.DeepCopy()); 1259 new_public_accounts.push_back(it->user_id);
1241 prefs_public_accounts_update->Swap(prefs_public_accounts.get()); 1260 }
1242 1261
1243 // If the list of public accounts has not changed, return. 1262 // If the list of public accounts has not changed, return.
1244 if (new_public_accounts.size() == old_public_accounts.size()) { 1263 if (new_public_accounts.size() == old_public_accounts.size()) {
1245 bool changed = false; 1264 bool changed = false;
1246 for (size_t i = 0; i < new_public_accounts.size(); ++i) { 1265 for (size_t i = 0; i < new_public_accounts.size(); ++i) {
1247 if (new_public_accounts[i] != old_public_accounts[i]) { 1266 if (new_public_accounts[i] != old_public_accounts[i]) {
1248 changed = true; 1267 changed = true;
1249 break; 1268 break;
1250 } 1269 }
1251 } 1270 }
1252 if (!changed) 1271 if (!changed)
1253 return false; 1272 return false;
1254 } 1273 }
1255 1274
1275 // Persist the new list of public accounts in a pref.
1276 ListPrefUpdate prefs_public_accounts_update(g_browser_process->local_state(),
1277 kPublicAccounts);
1278 prefs_public_accounts_update->Clear();
1279 for (std::vector<std::string>::const_iterator
1280 it = new_public_accounts.begin();
1281 it != new_public_accounts.end(); ++it) {
1282 prefs_public_accounts_update->AppendString(*it);
1283 }
1284
1256 // Remove the old public accounts from the user list. 1285 // Remove the old public accounts from the user list.
1257 for (UserList::iterator it = users_.begin(); it != users_.end(); ) { 1286 for (UserList::iterator it = users_.begin(); it != users_.end(); ) {
1258 if ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) { 1287 if ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) {
1259 if (*it != GetLoggedInUser()) 1288 if (*it != GetLoggedInUser())
1260 delete *it; 1289 delete *it;
1261 it = users_.erase(it); 1290 it = users_.erase(it);
1262 } else { 1291 } else {
1263 ++it; 1292 ++it;
1264 } 1293 }
1265 } 1294 }
1266 1295
1267 // Add the new public accounts to the front of the user list. 1296 // Add the new public accounts to the front of the user list.
1268 for (std::vector<std::string>::const_reverse_iterator 1297 for (std::vector<std::string>::const_reverse_iterator
1269 it = new_public_accounts.rbegin(); 1298 it = new_public_accounts.rbegin();
1270 it != new_public_accounts.rend(); ++it) { 1299 it != new_public_accounts.rend(); ++it) {
1271 if (IsLoggedInAsPublicAccount() && *it == active_user_email) 1300 if (IsLoggedInAsPublicAccount() && *it == GetActiveUser()->email())
1272 users_.insert(users_.begin(), GetLoggedInUser()); 1301 users_.insert(users_.begin(), GetLoggedInUser());
1273 else 1302 else
1274 users_.insert(users_.begin(), User::CreatePublicAccountUser(*it)); 1303 users_.insert(users_.begin(), User::CreatePublicAccountUser(*it));
1275 UpdatePublicAccountDisplayName(*it); 1304 UpdatePublicAccountDisplayName(*it);
1276 } 1305 }
1277 1306
1278 user_image_manager_->LoadUserImages( 1307 user_image_manager_->LoadUserImages(
1279 UserList(users_.begin(), users_.begin() + new_public_accounts.size())); 1308 UserList(users_.begin(), users_.begin() + new_public_accounts.size()));
1280 1309
1281 // Remove data belonging to public accounts that are no longer found on the 1310 // Remove data belonging to public accounts that are no longer found on the
1282 // user list. 1311 // user list.
1283 CleanUpPublicAccountNonCryptohomeData(old_public_accounts); 1312 CleanUpPublicAccountNonCryptohomeData(old_public_accounts);
1284 1313
1285 return true; 1314 return true;
1286 } 1315 }
1287 1316
1288 void UserManagerImpl::UpdatePublicAccountDisplayName( 1317 void UserManagerImpl::UpdatePublicAccountDisplayName(
1289 const std::string& username) { 1318 const std::string& username) {
1290 std::string display_name; 1319 std::string display_name;
1291 1320
1292 if (device_local_account_policy_service_) { 1321 if (device_local_account_policy_service_) {
1293 policy::DeviceLocalAccountPolicyBroker* broker = 1322 policy::DeviceLocalAccountPolicyBroker* broker =
1294 device_local_account_policy_service_->GetBrokerForAccount(username); 1323 device_local_account_policy_service_->GetBrokerForUser(username);
1295 if (broker) 1324 if (broker)
1296 display_name = broker->GetDisplayName(); 1325 display_name = broker->GetDisplayName();
1297 } 1326 }
1298 1327
1299 // Set or clear the display name. 1328 // Set or clear the display name.
1300 SaveUserDisplayName(username, UTF8ToUTF16(display_name)); 1329 SaveUserDisplayName(username, UTF8ToUTF16(display_name));
1301 } 1330 }
1302 1331
1303 void UserManagerImpl::StartLocallyManagedUserCreationTransaction( 1332 void UserManagerImpl::StartLocallyManagedUserCreationTransaction(
1304 const string16& display_name) { 1333 const string16& display_name) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 else if (active_user_->GetType() == User::USER_TYPE_LOCALLY_MANAGED) 1498 else if (active_user_->GetType() == User::USER_TYPE_LOCALLY_MANAGED)
1470 login_user_type = LoginState::LOGGED_IN_USER_LOCALLY_MANAGED; 1499 login_user_type = LoginState::LOGGED_IN_USER_LOCALLY_MANAGED;
1471 else if (active_user_->GetType() == User::USER_TYPE_KIOSK_APP) 1500 else if (active_user_->GetType() == User::USER_TYPE_KIOSK_APP)
1472 login_user_type = LoginState::LOGGED_IN_USER_KIOSK_APP; 1501 login_user_type = LoginState::LOGGED_IN_USER_KIOSK_APP;
1473 else 1502 else
1474 login_user_type = LoginState::LOGGED_IN_USER_REGULAR; 1503 login_user_type = LoginState::LOGGED_IN_USER_REGULAR;
1475 1504
1476 LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type); 1505 LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type);
1477 } 1506 }
1478 1507
1479 void UserManagerImpl::ReadPublicAccounts(base::ListValue* public_accounts) {
1480 const base::ListValue* accounts = NULL;
1481 if (cros_settings_->GetList(kAccountsPrefDeviceLocalAccounts, &accounts)) {
1482 for (base::ListValue::const_iterator entry(accounts->begin());
1483 entry != accounts->end(); ++entry) {
1484 const base::DictionaryValue* entry_dict = NULL;
1485 if (!(*entry)->GetAsDictionary(&entry_dict)) {
1486 NOTREACHED();
1487 continue;
1488 }
1489
1490 int type = DEVICE_LOCAL_ACCOUNT_TYPE_PUBLIC_SESSION;
1491 entry_dict->GetIntegerWithoutPathExpansion(
1492 kAccountsPrefDeviceLocalAccountsKeyType, &type);
1493 switch (type) {
1494 case DEVICE_LOCAL_ACCOUNT_TYPE_PUBLIC_SESSION: {
1495 std::string id;
1496 if (entry_dict->GetStringWithoutPathExpansion(
1497 kAccountsPrefDeviceLocalAccountsKeyId, &id)) {
1498 public_accounts->AppendString(id);
1499 }
1500 break;
1501 }
1502 case DEVICE_LOCAL_ACCOUNT_TYPE_KIOSK_APP:
1503 // TODO(mnissler, nkostylev, bartfab): Process Kiosk Apps within the
1504 // standard login framework: http://crbug.com/234694
1505 break;
1506 }
1507 }
1508 }
1509 }
1510
1511 } // namespace chromeos 1508 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698