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

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: Fix forward declaration. 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 if (!CommandLine::ForCurrentProcess()->HasSwitch(::switches::kMultiProfiles)) 261 if (!CommandLine::ForCurrentProcess()->HasSwitch(::switches::kMultiProfiles))
260 DCHECK(!IsUserLoggedIn()); 262 DCHECK(!IsUserLoggedIn());
261 263
262 if (active_user_) 264 if (active_user_)
263 active_user_->set_is_active(false); 265 active_user_->set_is_active(false);
264 266
265 if (email == UserManager::kGuestUserName) { 267 if (email == UserManager::kGuestUserName) {
266 GuestUserLoggedIn(); 268 GuestUserLoggedIn();
267 } else if (email == UserManager::kRetailModeUserName) { 269 } else if (email == UserManager::kRetailModeUserName) {
268 RetailModeUserLoggedIn(); 270 RetailModeUserLoggedIn();
269 } else if (gaia::ExtractDomainName(email) == 271 } else if (policy::IsKioskAppUser(email)) {
270 UserManager::kKioskAppUserDomain) {
271 KioskAppLoggedIn(email); 272 KioskAppLoggedIn(email);
272 } else { 273 } else {
273 EnsureUsersLoaded(); 274 EnsureUsersLoaded();
274 275
275 User* user = FindUserInListAndModify(email); 276 User* user = FindUserInListAndModify(email);
276 if (user && user->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) { 277 if (user && user->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) {
277 PublicAccountUserLoggedIn(user); 278 PublicAccountUserLoggedIn(user);
278 } else if ((user && 279 } else if ((user &&
279 user->GetType() == User::USER_TYPE_LOCALLY_MANAGED) || 280 user->GetType() == User::USER_TYPE_LOCALLY_MANAGED) ||
280 (!user && 281 (!user &&
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 // http://crbug.com/230860 657 // http://crbug.com/230860
657 // TODO(nkostylev): Figure out whether we want to have observers 658 // TODO(nkostylev): Figure out whether we want to have observers
658 // for each logged in user. 659 // for each logged in user.
659 // TODO(nkostyelv): Change observer after active user has changed. 660 // TODO(nkostyelv): Change observer after active user has changed.
660 SaveUserOAuthStatus( 661 SaveUserOAuthStatus(
661 active_user_->email(), 662 active_user_->email(),
662 User::OAUTH2_TOKEN_STATUS_INVALID); 663 User::OAUTH2_TOKEN_STATUS_INVALID);
663 } 664 }
664 } 665 }
665 666
666 void UserManagerImpl::OnPolicyUpdated(const std::string& account_id) { 667 void UserManagerImpl::OnPolicyUpdated(const std::string& user_id) {
667 UpdatePublicAccountDisplayName(account_id); 668 UpdatePublicAccountDisplayName(user_id);
668 NotifyUserListChanged(); 669 NotifyUserListChanged();
669 } 670 }
670 671
671 void UserManagerImpl::OnDeviceLocalAccountsChanged() { 672 void UserManagerImpl::OnDeviceLocalAccountsChanged() {
672 // No action needed here, changes to the list of device-local accounts get 673 // No action needed here, changes to the list of device-local accounts get
673 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer. 674 // handled via the kAccountsPrefDeviceLocalAccounts device setting observer.
674 } 675 }
675 676
676 bool UserManagerImpl::IsCurrentUserOwner() const { 677 bool UserManagerImpl::IsCurrentUserOwner() const {
677 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 678 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 // Schedule a callback if device policy has not yet been verified. 911 // Schedule a callback if device policy has not yet been verified.
911 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues( 912 if (CrosSettingsProvider::TRUSTED != cros_settings_->PrepareTrustedValues(
912 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies, 913 base::Bind(&UserManagerImpl::RetrieveTrustedDevicePolicies,
913 base::Unretained(this)))) { 914 base::Unretained(this)))) {
914 return; 915 return;
915 } 916 }
916 917
917 cros_settings_->GetBoolean(kAccountsPrefEphemeralUsersEnabled, 918 cros_settings_->GetBoolean(kAccountsPrefEphemeralUsersEnabled,
918 &ephemeral_users_enabled_); 919 &ephemeral_users_enabled_);
919 cros_settings_->GetString(kDeviceOwner, &owner_email_); 920 cros_settings_->GetString(kDeviceOwner, &owner_email_);
920 base::ListValue public_accounts;
921 ReadPublicAccounts(&public_accounts);
922 921
923 EnsureUsersLoaded(); 922 EnsureUsersLoaded();
924 923
925 bool changed = UpdateAndCleanUpPublicAccounts(public_accounts); 924 bool changed = UpdateAndCleanUpPublicAccounts(
925 policy::GetDeviceLocalAccounts(cros_settings_));
926 926
927 // If ephemeral users are enabled and we are on the login screen, take this 927 // If ephemeral users are enabled and we are on the login screen, take this
928 // opportunity to clean up by removing all regular users except the owner. 928 // opportunity to clean up by removing all regular users except the owner.
929 if (ephemeral_users_enabled_ && !IsUserLoggedIn()) { 929 if (ephemeral_users_enabled_ && !IsUserLoggedIn()) {
930 ListPrefUpdate prefs_users_update(g_browser_process->local_state(), 930 ListPrefUpdate prefs_users_update(g_browser_process->local_state(),
931 kRegularUsers); 931 kRegularUsers);
932 prefs_users_update->Clear(); 932 prefs_users_update->Clear();
933 for (UserList::iterator it = users_.begin(); it != users_.end(); ) { 933 for (UserList::iterator it = users_.begin(); it != users_.end(); ) {
934 const std::string user_email = (*it)->email(); 934 const std::string user_email = (*it)->email();
935 if ((*it)->GetType() == User::USER_TYPE_REGULAR && 935 if ((*it)->GetType() == User::USER_TYPE_REGULAR &&
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 active_user_ = user; 1088 active_user_ = user;
1089 // The UserImageManager chooses a random avatar picture when a user logs in 1089 // The UserImageManager chooses a random avatar picture when a user logs in
1090 // for the first time. Tell the UserImageManager that this user is not new to 1090 // for the first time. Tell the UserImageManager that this user is not new to
1091 // prevent the avatar from getting changed. 1091 // prevent the avatar from getting changed.
1092 user_image_manager_->UserLoggedIn(user->email(), false, true); 1092 user_image_manager_->UserLoggedIn(user->email(), false, true);
1093 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded(); 1093 WallpaperManager::Get()->EnsureLoggedInUserWallpaperLoaded();
1094 } 1094 }
1095 1095
1096 void UserManagerImpl::KioskAppLoggedIn(const std::string& username) { 1096 void UserManagerImpl::KioskAppLoggedIn(const std::string& username) {
1097 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1097 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1098 DCHECK_EQ(gaia::ExtractDomainName(username), 1098 DCHECK(policy::IsKioskAppUser(username));
1099 UserManager::kKioskAppUserDomain);
1100 1099
1101 WallpaperManager::Get()->SetInitialUserWallpaper(username, false); 1100 WallpaperManager::Get()->SetInitialUserWallpaper(username, false);
1102 active_user_ = User::CreateKioskAppUser(username); 1101 active_user_ = User::CreateKioskAppUser(username);
1103 active_user_->SetStubImage(User::kInvalidImageIndex, false); 1102 active_user_->SetStubImage(User::kInvalidImageIndex, false);
1104 1103
1104 // TODO(bartfab): Add KioskAppUsers to the users_ list and keep metadata like
1105 // the kiosk_app_id in these objects, removing the need to re-parse the
1106 // device-local account list here to extract the kiosk_app_id.
1107 const std::vector<policy::DeviceLocalAccount> device_local_accounts =
1108 policy::GetDeviceLocalAccounts(cros_settings_);
1109 const policy::DeviceLocalAccount* account = NULL;
1110 for (std::vector<policy::DeviceLocalAccount>::const_iterator
1111 it = device_local_accounts.begin();
1112 it != device_local_accounts.end(); ++it) {
1113 if (it->user_id == username) {
1114 account = &*it;
1115 break;
1116 }
1117 }
1118 std::string kiosk_app_id;
1119 if (account) {
1120 kiosk_app_id = account->kiosk_app_id;
1121 } else {
1122 LOG(ERROR) << "Logged into nonexistent kiosk-app account: " << username;
1123 NOTREACHED();
1124 }
1125
1105 CommandLine* command_line = CommandLine::ForCurrentProcess(); 1126 CommandLine* command_line = CommandLine::ForCurrentProcess();
1106 command_line->AppendSwitch(::switches::kForceAppMode); 1127 command_line->AppendSwitch(::switches::kForceAppMode);
1107 command_line->AppendSwitchASCII(::switches::kAppId, 1128 command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id);
1108 active_user_->GetAccountName(false)); 1129
1109 // Disable window animation since kiosk app runs in a single full screen 1130 // Disable window animation since kiosk app runs in a single full screen
1110 // window and window animation causes start-up janks. 1131 // window and window animation causes start-up janks.
1111 command_line->AppendSwitch( 1132 command_line->AppendSwitch(
1112 views::corewm::switches::kWindowAnimationsDisabled); 1133 views::corewm::switches::kWindowAnimationsDisabled);
1113 } 1134 }
1114 1135
1115 void UserManagerImpl::RetailModeUserLoggedIn() { 1136 void UserManagerImpl::RetailModeUserLoggedIn() {
1116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1117 is_current_user_new_ = true; 1138 is_current_user_new_ = true;
1118 active_user_ = User::CreateRetailModeUser(); 1139 active_user_ = User::CreateRetailModeUser();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 if ((*it)->GetType() == User::USER_TYPE_REGULAR || 1208 if ((*it)->GetType() == User::USER_TYPE_REGULAR ||
1188 (*it)->GetType() == User::USER_TYPE_LOCALLY_MANAGED) { 1209 (*it)->GetType() == User::USER_TYPE_LOCALLY_MANAGED) {
1189 prefs_users_update->Append(new base::StringValue(user_email)); 1210 prefs_users_update->Append(new base::StringValue(user_email));
1190 } 1211 }
1191 ++it; 1212 ++it;
1192 } 1213 }
1193 } 1214 }
1194 return user; 1215 return user;
1195 } 1216 }
1196 1217
1218 void UserManagerImpl::CleanUpPublicAccountNonCryptohomeDataPendingRemoval() {
1219 PrefService* local_state = g_browser_process->local_state();
1220 const std::string public_account_pending_data_removal =
1221 local_state->GetString(kPublicAccountPendingDataRemoval);
1222 if (public_account_pending_data_removal.empty() ||
1223 (IsUserLoggedIn() &&
1224 public_account_pending_data_removal == GetActiveUser()->email())) {
1225 return;
1226 }
1227
1228 RemoveNonCryptohomeData(public_account_pending_data_removal);
1229 local_state->ClearPref(kPublicAccountPendingDataRemoval);
1230 }
1231
1197 void UserManagerImpl::CleanUpPublicAccountNonCryptohomeData( 1232 void UserManagerImpl::CleanUpPublicAccountNonCryptohomeData(
1198 const std::vector<std::string>& old_public_accounts) { 1233 const std::vector<std::string>& old_public_accounts) {
1199 std::set<std::string> users; 1234 std::set<std::string> users;
1200 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) 1235 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it)
1201 users.insert((*it)->email()); 1236 users.insert((*it)->email());
1202 1237
1203 // If the user is logged into a public account that has been removed from the 1238 // If the user is logged into a public account that has been removed from the
1204 // user list, mark the account's data as pending removal after logout. 1239 // user list, mark the account's data as pending removal after logout.
1205 if (IsLoggedInAsPublicAccount()) { 1240 if (IsLoggedInAsPublicAccount()) {
1206 const std::string active_user_id = GetActiveUser()->email(); 1241 const std::string active_user_id = GetActiveUser()->email();
1207 if (users.find(active_user_id) == users.end()) { 1242 if (users.find(active_user_id) == users.end()) {
1208 g_browser_process->local_state()->SetString( 1243 g_browser_process->local_state()->SetString(
1209 kPublicAccountPendingDataRemoval, active_user_id); 1244 kPublicAccountPendingDataRemoval, active_user_id);
1210 users.insert(active_user_id); 1245 users.insert(active_user_id);
1211 } 1246 }
1212 } 1247 }
1213 1248
1214 // Remove the data belonging to any other public accounts that are no longer 1249 // Remove the data belonging to any other public accounts that are no longer
1215 // found on the user list. 1250 // found on the user list.
1216 for (std::vector<std::string>::const_iterator 1251 for (std::vector<std::string>::const_iterator
1217 it = old_public_accounts.begin(); 1252 it = old_public_accounts.begin();
1218 it != old_public_accounts.end(); ++it) { 1253 it != old_public_accounts.end(); ++it) {
1219 if (users.find(*it) == users.end()) 1254 if (users.find(*it) == users.end())
1220 RemoveNonCryptohomeData(*it); 1255 RemoveNonCryptohomeData(*it);
1221 } 1256 }
1222 } 1257 }
1223 1258
1224 bool UserManagerImpl::UpdateAndCleanUpPublicAccounts( 1259 bool UserManagerImpl::UpdateAndCleanUpPublicAccounts(
1225 const base::ListValue& public_accounts) { 1260 const std::vector<policy::DeviceLocalAccount>& device_local_accounts) {
1226 PrefService* local_state = g_browser_process->local_state(); 1261 // Try to remove any public account data marked as pending removal.
1262 CleanUpPublicAccountNonCryptohomeDataPendingRemoval();
1227 1263
1228 // Determine the currently logged-in user's email. 1264 // Get the current list of public accounts.
1229 std::string active_user_email;
1230 if (IsUserLoggedIn())
1231 active_user_email = GetLoggedInUser()->email();
1232
1233 // If there is a public account whose data is pending removal and the user is
1234 // not currently logged in with that account, take this opportunity to remove
1235 // the data.
1236 std::string public_account_pending_data_removal =
1237 local_state->GetString(kPublicAccountPendingDataRemoval);
1238 if (!public_account_pending_data_removal.empty() &&
1239 public_account_pending_data_removal != active_user_email) {
1240 RemoveNonCryptohomeData(public_account_pending_data_removal);
1241 local_state->ClearPref(kPublicAccountPendingDataRemoval);
1242 }
1243
1244 // Split the current user list public accounts and regular users.
1245 std::vector<std::string> old_public_accounts; 1265 std::vector<std::string> old_public_accounts;
1246 std::set<std::string> regular_users;
1247 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) { 1266 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) {
1248 if ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) 1267 if ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT)
1249 old_public_accounts.push_back((*it)->email()); 1268 old_public_accounts.push_back((*it)->email());
1250 else
1251 regular_users.insert((*it)->email());
1252 } 1269 }
1253 1270
1254 // Get the new list of public accounts from policy. 1271 // Get the new list of public accounts from policy.
1255 std::vector<std::string> new_public_accounts; 1272 std::vector<std::string> new_public_accounts;
1256 std::set<std::string> new_public_accounts_set; 1273 for (std::vector<policy::DeviceLocalAccount>::const_iterator it =
1257 ParseUserList(public_accounts, regular_users, 1274 device_local_accounts.begin();
1258 &new_public_accounts, &new_public_accounts_set); 1275 it != device_local_accounts.end(); ++it) {
1259 1276 // TODO(mnissler, nkostylev, bartfab): Process Kiosk Apps within the
1260 // Persist the new list of public accounts in a pref. 1277 // standard login framework: http://crbug.com/234694
1261 ListPrefUpdate prefs_public_accounts_update(local_state, kPublicAccounts); 1278 if (it->type == policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)
1262 scoped_ptr<base::ListValue> prefs_public_accounts(public_accounts.DeepCopy()); 1279 new_public_accounts.push_back(it->user_id);
1263 prefs_public_accounts_update->Swap(prefs_public_accounts.get()); 1280 }
1264 1281
1265 // If the list of public accounts has not changed, return. 1282 // If the list of public accounts has not changed, return.
1266 if (new_public_accounts.size() == old_public_accounts.size()) { 1283 if (new_public_accounts.size() == old_public_accounts.size()) {
1267 bool changed = false; 1284 bool changed = false;
1268 for (size_t i = 0; i < new_public_accounts.size(); ++i) { 1285 for (size_t i = 0; i < new_public_accounts.size(); ++i) {
1269 if (new_public_accounts[i] != old_public_accounts[i]) { 1286 if (new_public_accounts[i] != old_public_accounts[i]) {
1270 changed = true; 1287 changed = true;
1271 break; 1288 break;
1272 } 1289 }
1273 } 1290 }
1274 if (!changed) 1291 if (!changed)
1275 return false; 1292 return false;
1276 } 1293 }
1277 1294
1295 // Persist the new list of public accounts in a pref.
1296 ListPrefUpdate prefs_public_accounts_update(g_browser_process->local_state(),
1297 kPublicAccounts);
1298 prefs_public_accounts_update->Clear();
1299 for (std::vector<std::string>::const_iterator
1300 it = new_public_accounts.begin();
1301 it != new_public_accounts.end(); ++it) {
1302 prefs_public_accounts_update->AppendString(*it);
1303 }
1304
1278 // Remove the old public accounts from the user list. 1305 // Remove the old public accounts from the user list.
1279 for (UserList::iterator it = users_.begin(); it != users_.end(); ) { 1306 for (UserList::iterator it = users_.begin(); it != users_.end(); ) {
1280 if ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) { 1307 if ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) {
1281 if (*it != GetLoggedInUser()) 1308 if (*it != GetLoggedInUser())
1282 delete *it; 1309 delete *it;
1283 it = users_.erase(it); 1310 it = users_.erase(it);
1284 } else { 1311 } else {
1285 ++it; 1312 ++it;
1286 } 1313 }
1287 } 1314 }
1288 1315
1289 // Add the new public accounts to the front of the user list. 1316 // Add the new public accounts to the front of the user list.
1290 for (std::vector<std::string>::const_reverse_iterator 1317 for (std::vector<std::string>::const_reverse_iterator
1291 it = new_public_accounts.rbegin(); 1318 it = new_public_accounts.rbegin();
1292 it != new_public_accounts.rend(); ++it) { 1319 it != new_public_accounts.rend(); ++it) {
1293 if (IsLoggedInAsPublicAccount() && *it == active_user_email) 1320 if (IsLoggedInAsPublicAccount() && *it == GetActiveUser()->email())
1294 users_.insert(users_.begin(), GetLoggedInUser()); 1321 users_.insert(users_.begin(), GetLoggedInUser());
1295 else 1322 else
1296 users_.insert(users_.begin(), User::CreatePublicAccountUser(*it)); 1323 users_.insert(users_.begin(), User::CreatePublicAccountUser(*it));
1297 UpdatePublicAccountDisplayName(*it); 1324 UpdatePublicAccountDisplayName(*it);
1298 } 1325 }
1299 1326
1300 user_image_manager_->LoadUserImages( 1327 user_image_manager_->LoadUserImages(
1301 UserList(users_.begin(), users_.begin() + new_public_accounts.size())); 1328 UserList(users_.begin(), users_.begin() + new_public_accounts.size()));
1302 1329
1303 // Remove data belonging to public accounts that are no longer found on the 1330 // Remove data belonging to public accounts that are no longer found on the
1304 // user list. 1331 // user list.
1305 CleanUpPublicAccountNonCryptohomeData(old_public_accounts); 1332 CleanUpPublicAccountNonCryptohomeData(old_public_accounts);
1306 1333
1307 return true; 1334 return true;
1308 } 1335 }
1309 1336
1310 void UserManagerImpl::UpdatePublicAccountDisplayName( 1337 void UserManagerImpl::UpdatePublicAccountDisplayName(
1311 const std::string& username) { 1338 const std::string& username) {
1312 std::string display_name; 1339 std::string display_name;
1313 1340
1314 if (device_local_account_policy_service_) { 1341 if (device_local_account_policy_service_) {
1315 policy::DeviceLocalAccountPolicyBroker* broker = 1342 policy::DeviceLocalAccountPolicyBroker* broker =
1316 device_local_account_policy_service_->GetBrokerForAccount(username); 1343 device_local_account_policy_service_->GetBrokerForUser(username);
1317 if (broker) 1344 if (broker)
1318 display_name = broker->GetDisplayName(); 1345 display_name = broker->GetDisplayName();
1319 } 1346 }
1320 1347
1321 // Set or clear the display name. 1348 // Set or clear the display name.
1322 SaveUserDisplayName(username, UTF8ToUTF16(display_name)); 1349 SaveUserDisplayName(username, UTF8ToUTF16(display_name));
1323 } 1350 }
1324 1351
1325 void UserManagerImpl::StartLocallyManagedUserCreationTransaction( 1352 void UserManagerImpl::StartLocallyManagedUserCreationTransaction(
1326 const string16& display_name) { 1353 const string16& display_name) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 else if (active_user_->GetType() == User::USER_TYPE_LOCALLY_MANAGED) 1518 else if (active_user_->GetType() == User::USER_TYPE_LOCALLY_MANAGED)
1492 login_user_type = LoginState::LOGGED_IN_USER_LOCALLY_MANAGED; 1519 login_user_type = LoginState::LOGGED_IN_USER_LOCALLY_MANAGED;
1493 else if (active_user_->GetType() == User::USER_TYPE_KIOSK_APP) 1520 else if (active_user_->GetType() == User::USER_TYPE_KIOSK_APP)
1494 login_user_type = LoginState::LOGGED_IN_USER_KIOSK_APP; 1521 login_user_type = LoginState::LOGGED_IN_USER_KIOSK_APP;
1495 else 1522 else
1496 login_user_type = LoginState::LOGGED_IN_USER_REGULAR; 1523 login_user_type = LoginState::LOGGED_IN_USER_REGULAR;
1497 1524
1498 LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type); 1525 LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type);
1499 } 1526 }
1500 1527
1501 void UserManagerImpl::ReadPublicAccounts(base::ListValue* public_accounts) {
1502 const base::ListValue* accounts = NULL;
1503 if (cros_settings_->GetList(kAccountsPrefDeviceLocalAccounts, &accounts)) {
1504 for (base::ListValue::const_iterator entry(accounts->begin());
1505 entry != accounts->end(); ++entry) {
1506 const base::DictionaryValue* entry_dict = NULL;
1507 if (!(*entry)->GetAsDictionary(&entry_dict)) {
1508 NOTREACHED();
1509 continue;
1510 }
1511
1512 int type = DEVICE_LOCAL_ACCOUNT_TYPE_PUBLIC_SESSION;
1513 entry_dict->GetIntegerWithoutPathExpansion(
1514 kAccountsPrefDeviceLocalAccountsKeyType, &type);
1515 switch (type) {
1516 case DEVICE_LOCAL_ACCOUNT_TYPE_PUBLIC_SESSION: {
1517 std::string id;
1518 if (entry_dict->GetStringWithoutPathExpansion(
1519 kAccountsPrefDeviceLocalAccountsKeyId, &id)) {
1520 public_accounts->AppendString(id);
1521 }
1522 break;
1523 }
1524 case DEVICE_LOCAL_ACCOUNT_TYPE_KIOSK_APP:
1525 // TODO(mnissler, nkostylev, bartfab): Process Kiosk Apps within the
1526 // standard login framework: http://crbug.com/234694
1527 break;
1528 }
1529 }
1530 }
1531 }
1532
1533 void UserManagerImpl::SetLRUUser(User* user) { 1528 void UserManagerImpl::SetLRUUser(User* user) {
1534 UserList::iterator it = std::find(lru_logged_in_users_.begin(), 1529 UserList::iterator it = std::find(lru_logged_in_users_.begin(),
1535 lru_logged_in_users_.end(), 1530 lru_logged_in_users_.end(),
1536 user); 1531 user);
1537 if (it != lru_logged_in_users_.end()) 1532 if (it != lru_logged_in_users_.end())
1538 lru_logged_in_users_.erase(it); 1533 lru_logged_in_users_.erase(it);
1539 lru_logged_in_users_.insert(lru_logged_in_users_.begin(), user); 1534 lru_logged_in_users_.insert(lru_logged_in_users_.begin(), user);
1540 } 1535 }
1541 1536
1542 } // namespace chromeos 1537 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_manager_impl.h ('k') | chrome/browser/chromeos/login/wizard_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698