| 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 "components/user_manager/user_manager_base.h" | 5 #include "components/user_manager/user_manager_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 DeleteUser(*it); | 98 DeleteUser(*it); |
| 99 } | 99 } |
| 100 // These are pointers to the same User instances that were in users_ list. | 100 // These are pointers to the same User instances that were in users_ list. |
| 101 logged_in_users_.clear(); | 101 logged_in_users_.clear(); |
| 102 lru_logged_in_users_.clear(); | 102 lru_logged_in_users_.clear(); |
| 103 | 103 |
| 104 DeleteUser(active_user_); | 104 DeleteUser(active_user_); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void UserManagerBase::Shutdown() { | 107 void UserManagerBase::Shutdown() { |
| 108 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 108 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 const UserList& UserManagerBase::GetUsers() const { | 111 const UserList& UserManagerBase::GetUsers() const { |
| 112 const_cast<UserManagerBase*>(this)->EnsureUsersLoaded(); | 112 const_cast<UserManagerBase*>(this)->EnsureUsersLoaded(); |
| 113 return users_; | 113 return users_; |
| 114 } | 114 } |
| 115 | 115 |
| 116 const UserList& UserManagerBase::GetLoggedInUsers() const { | 116 const UserList& UserManagerBase::GetLoggedInUsers() const { |
| 117 return logged_in_users_; | 117 return logged_in_users_; |
| 118 } | 118 } |
| 119 | 119 |
| 120 const UserList& UserManagerBase::GetLRULoggedInUsers() const { | 120 const UserList& UserManagerBase::GetLRULoggedInUsers() const { |
| 121 return lru_logged_in_users_; | 121 return lru_logged_in_users_; |
| 122 } | 122 } |
| 123 | 123 |
| 124 const AccountId& UserManagerBase::GetOwnerAccountId() const { | 124 const AccountId& UserManagerBase::GetOwnerAccountId() const { |
| 125 return owner_account_id_; | 125 return owner_account_id_; |
| 126 } | 126 } |
| 127 | 127 |
| 128 void UserManagerBase::UserLoggedIn(const AccountId& account_id, | 128 void UserManagerBase::UserLoggedIn(const AccountId& account_id, |
| 129 const std::string& username_hash, | 129 const std::string& username_hash, |
| 130 bool browser_restart) { | 130 bool browser_restart) { |
| 131 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 131 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 132 | 132 |
| 133 if (!last_session_active_account_id_initialized_) { | 133 if (!last_session_active_account_id_initialized_) { |
| 134 last_session_active_account_id_ = | 134 last_session_active_account_id_ = |
| 135 AccountId::FromUserEmail(GetLocalState()->GetString(kLastActiveUser)); | 135 AccountId::FromUserEmail(GetLocalState()->GetString(kLastActiveUser)); |
| 136 last_session_active_account_id_initialized_ = true; | 136 last_session_active_account_id_initialized_ = true; |
| 137 } | 137 } |
| 138 | 138 |
| 139 User* user = FindUserInListAndModify(account_id); | 139 User* user = FindUserInListAndModify(account_id); |
| 140 if (active_user_ && user) { | 140 if (active_user_ && user) { |
| 141 user->set_is_logged_in(true); | 141 user->set_is_logged_in(true); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (AccountId::FromUserEmail( | 252 if (AccountId::FromUserEmail( |
| 253 GetActiveUser()->GetAccountId().GetUserEmail()) != | 253 GetActiveUser()->GetAccountId().GetUserEmail()) != |
| 254 last_session_active_account_id_) | 254 last_session_active_account_id_) |
| 255 SwitchActiveUser(last_session_active_account_id_); | 255 SwitchActiveUser(last_session_active_account_id_); |
| 256 | 256 |
| 257 // Make sure that this function gets run only once. | 257 // Make sure that this function gets run only once. |
| 258 last_session_active_account_id_.clear(); | 258 last_session_active_account_id_.clear(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void UserManagerBase::OnSessionStarted() { | 261 void UserManagerBase::OnSessionStarted() { |
| 262 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 262 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 263 | 263 |
| 264 CallUpdateLoginState(); | 264 CallUpdateLoginState(); |
| 265 GetLocalState()->CommitPendingWrite(); | 265 GetLocalState()->CommitPendingWrite(); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void UserManagerBase::OnProfileInitialized(User* user) { | 268 void UserManagerBase::OnProfileInitialized(User* user) { |
| 269 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 269 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 270 | 270 |
| 271 // Mark the user as having an initialized session and persist this in | 271 // Mark the user as having an initialized session and persist this in |
| 272 // the known_user DB. | 272 // the known_user DB. |
| 273 user->set_profile_ever_initialized(true); | 273 user->set_profile_ever_initialized(true); |
| 274 known_user::SetProfileEverInitialized(user->GetAccountId(), true); | 274 known_user::SetProfileEverInitialized(user->GetAccountId(), true); |
| 275 GetLocalState()->CommitPendingWrite(); | 275 GetLocalState()->CommitPendingWrite(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void UserManagerBase::RemoveUser(const AccountId& account_id, | 278 void UserManagerBase::RemoveUser(const AccountId& account_id, |
| 279 RemoveUserDelegate* delegate) { | 279 RemoveUserDelegate* delegate) { |
| 280 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 280 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 281 | 281 |
| 282 if (!CanUserBeRemoved(FindUser(account_id))) | 282 if (!CanUserBeRemoved(FindUser(account_id))) |
| 283 return; | 283 return; |
| 284 | 284 |
| 285 RemoveUserInternal(account_id, delegate); | 285 RemoveUserInternal(account_id, delegate); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void UserManagerBase::RemoveUserInternal(const AccountId& account_id, | 288 void UserManagerBase::RemoveUserInternal(const AccountId& account_id, |
| 289 RemoveUserDelegate* delegate) { | 289 RemoveUserDelegate* delegate) { |
| 290 RemoveNonOwnerUserInternal(account_id, delegate); | 290 RemoveNonOwnerUserInternal(account_id, delegate); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void UserManagerBase::RemoveNonOwnerUserInternal(const AccountId& account_id, | 293 void UserManagerBase::RemoveNonOwnerUserInternal(const AccountId& account_id, |
| 294 RemoveUserDelegate* delegate) { | 294 RemoveUserDelegate* delegate) { |
| 295 if (delegate) | 295 if (delegate) |
| 296 delegate->OnBeforeUserRemoved(account_id); | 296 delegate->OnBeforeUserRemoved(account_id); |
| 297 AsyncRemoveCryptohome(account_id); | 297 AsyncRemoveCryptohome(account_id); |
| 298 RemoveUserFromList(account_id); | 298 RemoveUserFromList(account_id); |
| 299 | 299 |
| 300 if (delegate) | 300 if (delegate) |
| 301 delegate->OnUserRemoved(account_id); | 301 delegate->OnUserRemoved(account_id); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void UserManagerBase::RemoveUserFromList(const AccountId& account_id) { | 304 void UserManagerBase::RemoveUserFromList(const AccountId& account_id) { |
| 305 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 305 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 306 RemoveNonCryptohomeData(account_id); | 306 RemoveNonCryptohomeData(account_id); |
| 307 if (user_loading_stage_ == STAGE_LOADED) { | 307 if (user_loading_stage_ == STAGE_LOADED) { |
| 308 DeleteUser(RemoveRegularOrSupervisedUserFromList(account_id)); | 308 DeleteUser(RemoveRegularOrSupervisedUserFromList(account_id)); |
| 309 } else if (user_loading_stage_ == STAGE_LOADING) { | 309 } else if (user_loading_stage_ == STAGE_LOADING) { |
| 310 DCHECK(IsSupervisedAccountId(account_id) || | 310 DCHECK(IsSupervisedAccountId(account_id) || |
| 311 HasPendingBootstrap(account_id)); | 311 HasPendingBootstrap(account_id)); |
| 312 // Special case, removing partially-constructed supervised user or | 312 // Special case, removing partially-constructed supervised user or |
| 313 // boostrapping user during user list loading. | 313 // boostrapping user during user list loading. |
| 314 ListPrefUpdate users_update(GetLocalState(), kRegularUsers); | 314 ListPrefUpdate users_update(GetLocalState(), kRegularUsers); |
| 315 users_update->Remove(base::Value(account_id.GetUserEmail()), nullptr); | 315 users_update->Remove(base::Value(account_id.GetUserEmail()), nullptr); |
| 316 OnUserRemoved(account_id); | 316 OnUserRemoved(account_id); |
| 317 } else { | 317 } else { |
| 318 NOTREACHED() << "Users are not loaded yet."; | 318 NOTREACHED() << "Users are not loaded yet."; |
| 319 return; | 319 return; |
| 320 } | 320 } |
| 321 | 321 |
| 322 // Make sure that new data is persisted to Local State. | 322 // Make sure that new data is persisted to Local State. |
| 323 GetLocalState()->CommitPendingWrite(); | 323 GetLocalState()->CommitPendingWrite(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 bool UserManagerBase::IsKnownUser(const AccountId& account_id) const { | 326 bool UserManagerBase::IsKnownUser(const AccountId& account_id) const { |
| 327 return FindUser(account_id) != nullptr; | 327 return FindUser(account_id) != nullptr; |
| 328 } | 328 } |
| 329 | 329 |
| 330 const User* UserManagerBase::FindUser(const AccountId& account_id) const { | 330 const User* UserManagerBase::FindUser(const AccountId& account_id) const { |
| 331 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 331 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 332 if (active_user_ && active_user_->GetAccountId() == account_id) | 332 if (active_user_ && active_user_->GetAccountId() == account_id) |
| 333 return active_user_; | 333 return active_user_; |
| 334 return FindUserInList(account_id); | 334 return FindUserInList(account_id); |
| 335 } | 335 } |
| 336 | 336 |
| 337 User* UserManagerBase::FindUserAndModify(const AccountId& account_id) { | 337 User* UserManagerBase::FindUserAndModify(const AccountId& account_id) { |
| 338 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 338 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 339 if (active_user_ && active_user_->GetAccountId() == account_id) | 339 if (active_user_ && active_user_->GetAccountId() == account_id) |
| 340 return active_user_; | 340 return active_user_; |
| 341 return FindUserInListAndModify(account_id); | 341 return FindUserInListAndModify(account_id); |
| 342 } | 342 } |
| 343 | 343 |
| 344 const User* UserManagerBase::GetActiveUser() const { | 344 const User* UserManagerBase::GetActiveUser() const { |
| 345 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 345 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 346 return active_user_; | 346 return active_user_; |
| 347 } | 347 } |
| 348 | 348 |
| 349 User* UserManagerBase::GetActiveUser() { | 349 User* UserManagerBase::GetActiveUser() { |
| 350 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 350 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 351 return active_user_; | 351 return active_user_; |
| 352 } | 352 } |
| 353 | 353 |
| 354 const User* UserManagerBase::GetPrimaryUser() const { | 354 const User* UserManagerBase::GetPrimaryUser() const { |
| 355 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 355 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 356 return primary_user_; | 356 return primary_user_; |
| 357 } | 357 } |
| 358 | 358 |
| 359 void UserManagerBase::SaveUserOAuthStatus( | 359 void UserManagerBase::SaveUserOAuthStatus( |
| 360 const AccountId& account_id, | 360 const AccountId& account_id, |
| 361 User::OAuthTokenStatus oauth_token_status) { | 361 User::OAuthTokenStatus oauth_token_status) { |
| 362 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 362 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 363 | 363 |
| 364 DVLOG(1) << "Saving user OAuth token status in Local State"; | 364 DVLOG(1) << "Saving user OAuth token status in Local State"; |
| 365 User* user = FindUserAndModify(account_id); | 365 User* user = FindUserAndModify(account_id); |
| 366 if (user) | 366 if (user) |
| 367 user->set_oauth_token_status(oauth_token_status); | 367 user->set_oauth_token_status(oauth_token_status); |
| 368 | 368 |
| 369 // Do not update local state if data stored or cached outside the user's | 369 // Do not update local state if data stored or cached outside the user's |
| 370 // cryptohome is to be treated as ephemeral. | 370 // cryptohome is to be treated as ephemeral. |
| 371 if (IsUserNonCryptohomeDataEphemeral(account_id)) | 371 if (IsUserNonCryptohomeDataEphemeral(account_id)) |
| 372 return; | 372 return; |
| 373 | 373 |
| 374 { | 374 { |
| 375 DictionaryPrefUpdate oauth_status_update(GetLocalState(), | 375 DictionaryPrefUpdate oauth_status_update(GetLocalState(), |
| 376 kUserOAuthTokenStatus); | 376 kUserOAuthTokenStatus); |
| 377 oauth_status_update->SetIntegerWithoutPathExpansion( | 377 oauth_status_update->SetIntegerWithoutPathExpansion( |
| 378 account_id.GetUserEmail(), static_cast<int>(oauth_token_status)); | 378 account_id.GetUserEmail(), static_cast<int>(oauth_token_status)); |
| 379 } | 379 } |
| 380 GetLocalState()->CommitPendingWrite(); | 380 GetLocalState()->CommitPendingWrite(); |
| 381 } | 381 } |
| 382 | 382 |
| 383 void UserManagerBase::SaveForceOnlineSignin(const AccountId& account_id, | 383 void UserManagerBase::SaveForceOnlineSignin(const AccountId& account_id, |
| 384 bool force_online_signin) { | 384 bool force_online_signin) { |
| 385 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 385 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 386 | 386 |
| 387 // Do not update local state if data stored or cached outside the user's | 387 // Do not update local state if data stored or cached outside the user's |
| 388 // cryptohome is to be treated as ephemeral. | 388 // cryptohome is to be treated as ephemeral. |
| 389 if (IsUserNonCryptohomeDataEphemeral(account_id)) | 389 if (IsUserNonCryptohomeDataEphemeral(account_id)) |
| 390 return; | 390 return; |
| 391 | 391 |
| 392 { | 392 { |
| 393 DictionaryPrefUpdate force_online_update(GetLocalState(), | 393 DictionaryPrefUpdate force_online_update(GetLocalState(), |
| 394 kUserForceOnlineSignin); | 394 kUserForceOnlineSignin); |
| 395 force_online_update->SetBooleanWithoutPathExpansion( | 395 force_online_update->SetBooleanWithoutPathExpansion( |
| 396 account_id.GetUserEmail(), force_online_signin); | 396 account_id.GetUserEmail(), force_online_signin); |
| 397 } | 397 } |
| 398 GetLocalState()->CommitPendingWrite(); | 398 GetLocalState()->CommitPendingWrite(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 void UserManagerBase::SaveUserDisplayName(const AccountId& account_id, | 401 void UserManagerBase::SaveUserDisplayName(const AccountId& account_id, |
| 402 const base::string16& display_name) { | 402 const base::string16& display_name) { |
| 403 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 403 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 404 | 404 |
| 405 if (User* user = FindUserAndModify(account_id)) { | 405 if (User* user = FindUserAndModify(account_id)) { |
| 406 user->set_display_name(display_name); | 406 user->set_display_name(display_name); |
| 407 | 407 |
| 408 // Do not update local state if data stored or cached outside the user's | 408 // Do not update local state if data stored or cached outside the user's |
| 409 // cryptohome is to be treated as ephemeral. | 409 // cryptohome is to be treated as ephemeral. |
| 410 if (!IsUserNonCryptohomeDataEphemeral(account_id)) { | 410 if (!IsUserNonCryptohomeDataEphemeral(account_id)) { |
| 411 DictionaryPrefUpdate display_name_update(GetLocalState(), | 411 DictionaryPrefUpdate display_name_update(GetLocalState(), |
| 412 kUserDisplayName); | 412 kUserDisplayName); |
| 413 display_name_update->SetStringWithoutPathExpansion( | 413 display_name_update->SetStringWithoutPathExpansion( |
| 414 account_id.GetUserEmail(), display_name); | 414 account_id.GetUserEmail(), display_name); |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 | 418 |
| 419 base::string16 UserManagerBase::GetUserDisplayName( | 419 base::string16 UserManagerBase::GetUserDisplayName( |
| 420 const AccountId& account_id) const { | 420 const AccountId& account_id) const { |
| 421 const User* user = FindUser(account_id); | 421 const User* user = FindUser(account_id); |
| 422 return user ? user->display_name() : base::string16(); | 422 return user ? user->display_name() : base::string16(); |
| 423 } | 423 } |
| 424 | 424 |
| 425 void UserManagerBase::SaveUserDisplayEmail(const AccountId& account_id, | 425 void UserManagerBase::SaveUserDisplayEmail(const AccountId& account_id, |
| 426 const std::string& display_email) { | 426 const std::string& display_email) { |
| 427 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 427 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 428 | 428 |
| 429 User* user = FindUserAndModify(account_id); | 429 User* user = FindUserAndModify(account_id); |
| 430 if (!user) { | 430 if (!user) { |
| 431 LOG(ERROR) << "User not found: " << account_id.GetUserEmail(); | 431 LOG(ERROR) << "User not found: " << account_id.GetUserEmail(); |
| 432 return; // Ignore if there is no such user. | 432 return; // Ignore if there is no such user. |
| 433 } | 433 } |
| 434 | 434 |
| 435 user->set_display_email(display_email); | 435 user->set_display_email(display_email); |
| 436 | 436 |
| 437 // Do not update local state if data stored or cached outside the user's | 437 // Do not update local state if data stored or cached outside the user's |
| 438 // cryptohome is to be treated as ephemeral. | 438 // cryptohome is to be treated as ephemeral. |
| 439 if (IsUserNonCryptohomeDataEphemeral(account_id)) | 439 if (IsUserNonCryptohomeDataEphemeral(account_id)) |
| 440 return; | 440 return; |
| 441 | 441 |
| 442 DictionaryPrefUpdate display_email_update(GetLocalState(), kUserDisplayEmail); | 442 DictionaryPrefUpdate display_email_update(GetLocalState(), kUserDisplayEmail); |
| 443 display_email_update->SetStringWithoutPathExpansion(account_id.GetUserEmail(), | 443 display_email_update->SetStringWithoutPathExpansion(account_id.GetUserEmail(), |
| 444 display_email); | 444 display_email); |
| 445 } | 445 } |
| 446 | 446 |
| 447 std::string UserManagerBase::GetUserDisplayEmail( | 447 std::string UserManagerBase::GetUserDisplayEmail( |
| 448 const AccountId& account_id) const { | 448 const AccountId& account_id) const { |
| 449 const User* user = FindUser(account_id); | 449 const User* user = FindUser(account_id); |
| 450 return user ? user->display_email() : account_id.GetUserEmail(); | 450 return user ? user->display_email() : account_id.GetUserEmail(); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void UserManagerBase::SaveUserType(const AccountId& account_id, | 453 void UserManagerBase::SaveUserType(const AccountId& account_id, |
| 454 const UserType& user_type) { | 454 const UserType& user_type) { |
| 455 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 455 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 456 | 456 |
| 457 User* user = FindUserAndModify(account_id); | 457 User* user = FindUserAndModify(account_id); |
| 458 if (!user) { | 458 if (!user) { |
| 459 LOG(ERROR) << "User not found: " << account_id.GetUserEmail(); | 459 LOG(ERROR) << "User not found: " << account_id.GetUserEmail(); |
| 460 return; // Ignore if there is no such user. | 460 return; // Ignore if there is no such user. |
| 461 } | 461 } |
| 462 | 462 |
| 463 // Do not update local state if data stored or cached outside the user's | 463 // Do not update local state if data stored or cached outside the user's |
| 464 // cryptohome is to be treated as ephemeral. | 464 // cryptohome is to be treated as ephemeral. |
| 465 if (IsUserNonCryptohomeDataEphemeral(account_id)) | 465 if (IsUserNonCryptohomeDataEphemeral(account_id)) |
| 466 return; | 466 return; |
| 467 | 467 |
| 468 DictionaryPrefUpdate user_type_update(GetLocalState(), kUserType); | 468 DictionaryPrefUpdate user_type_update(GetLocalState(), kUserType); |
| 469 user_type_update->SetIntegerWithoutPathExpansion(account_id.GetUserEmail(), | 469 user_type_update->SetIntegerWithoutPathExpansion(account_id.GetUserEmail(), |
| 470 static_cast<int>(user_type)); | 470 static_cast<int>(user_type)); |
| 471 GetLocalState()->CommitPendingWrite(); | 471 GetLocalState()->CommitPendingWrite(); |
| 472 } | 472 } |
| 473 | 473 |
| 474 void UserManagerBase::UpdateUserAccountData( | 474 void UserManagerBase::UpdateUserAccountData( |
| 475 const AccountId& account_id, | 475 const AccountId& account_id, |
| 476 const UserAccountData& account_data) { | 476 const UserAccountData& account_data) { |
| 477 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 477 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 478 | 478 |
| 479 SaveUserDisplayName(account_id, account_data.display_name()); | 479 SaveUserDisplayName(account_id, account_data.display_name()); |
| 480 | 480 |
| 481 if (User* user = FindUserAndModify(account_id)) { | 481 if (User* user = FindUserAndModify(account_id)) { |
| 482 base::string16 given_name = account_data.given_name(); | 482 base::string16 given_name = account_data.given_name(); |
| 483 user->set_given_name(given_name); | 483 user->set_given_name(given_name); |
| 484 if (!IsUserNonCryptohomeDataEphemeral(account_id)) { | 484 if (!IsUserNonCryptohomeDataEphemeral(account_id)) { |
| 485 DictionaryPrefUpdate given_name_update(GetLocalState(), kUserGivenName); | 485 DictionaryPrefUpdate given_name_update(GetLocalState(), kUserGivenName); |
| 486 given_name_update->SetStringWithoutPathExpansion( | 486 given_name_update->SetStringWithoutPathExpansion( |
| 487 account_id.GetUserEmail(), given_name); | 487 account_id.GetUserEmail(), given_name); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 510 if (existing_users.find(account_id) != existing_users.end() || | 510 if (existing_users.find(account_id) != existing_users.end() || |
| 511 !users_set->insert(account_id).second) { | 511 !users_set->insert(account_id).second) { |
| 512 LOG(ERROR) << "Duplicate user: " << email; | 512 LOG(ERROR) << "Duplicate user: " << email; |
| 513 continue; | 513 continue; |
| 514 } | 514 } |
| 515 users_vector->push_back(account_id); | 515 users_vector->push_back(account_id); |
| 516 } | 516 } |
| 517 } | 517 } |
| 518 | 518 |
| 519 bool UserManagerBase::IsCurrentUserOwner() const { | 519 bool UserManagerBase::IsCurrentUserOwner() const { |
| 520 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 520 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 521 return !owner_account_id_.empty() && active_user_ && | 521 return !owner_account_id_.empty() && active_user_ && |
| 522 active_user_->GetAccountId() == owner_account_id_; | 522 active_user_->GetAccountId() == owner_account_id_; |
| 523 } | 523 } |
| 524 | 524 |
| 525 bool UserManagerBase::IsCurrentUserNew() const { | 525 bool UserManagerBase::IsCurrentUserNew() const { |
| 526 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 526 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 527 return is_current_user_new_; | 527 return is_current_user_new_; |
| 528 } | 528 } |
| 529 | 529 |
| 530 bool UserManagerBase::IsCurrentUserNonCryptohomeDataEphemeral() const { | 530 bool UserManagerBase::IsCurrentUserNonCryptohomeDataEphemeral() const { |
| 531 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 531 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 532 return IsUserLoggedIn() && | 532 return IsUserLoggedIn() && |
| 533 IsUserNonCryptohomeDataEphemeral(GetActiveUser()->GetAccountId()); | 533 IsUserNonCryptohomeDataEphemeral(GetActiveUser()->GetAccountId()); |
| 534 } | 534 } |
| 535 | 535 |
| 536 bool UserManagerBase::IsCurrentUserCryptohomeDataEphemeral() const { | 536 bool UserManagerBase::IsCurrentUserCryptohomeDataEphemeral() const { |
| 537 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 537 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 538 return IsUserLoggedIn() && | 538 return IsUserLoggedIn() && |
| 539 IsUserCryptohomeDataEphemeral(GetActiveUser()->GetAccountId()); | 539 IsUserCryptohomeDataEphemeral(GetActiveUser()->GetAccountId()); |
| 540 } | 540 } |
| 541 | 541 |
| 542 bool UserManagerBase::CanCurrentUserLock() const { | 542 bool UserManagerBase::CanCurrentUserLock() const { |
| 543 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 543 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 544 return IsUserLoggedIn() && active_user_->can_lock(); | 544 return IsUserLoggedIn() && active_user_->can_lock(); |
| 545 } | 545 } |
| 546 | 546 |
| 547 bool UserManagerBase::IsUserLoggedIn() const { | 547 bool UserManagerBase::IsUserLoggedIn() const { |
| 548 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 548 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 549 return active_user_; | 549 return active_user_; |
| 550 } | 550 } |
| 551 | 551 |
| 552 bool UserManagerBase::IsLoggedInAsUserWithGaiaAccount() const { | 552 bool UserManagerBase::IsLoggedInAsUserWithGaiaAccount() const { |
| 553 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 553 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 554 return IsUserLoggedIn() && active_user_->HasGaiaAccount(); | 554 return IsUserLoggedIn() && active_user_->HasGaiaAccount(); |
| 555 } | 555 } |
| 556 | 556 |
| 557 bool UserManagerBase::IsLoggedInAsChildUser() const { | 557 bool UserManagerBase::IsLoggedInAsChildUser() const { |
| 558 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 558 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 559 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_CHILD; | 559 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_CHILD; |
| 560 } | 560 } |
| 561 | 561 |
| 562 bool UserManagerBase::IsLoggedInAsPublicAccount() const { | 562 bool UserManagerBase::IsLoggedInAsPublicAccount() const { |
| 563 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 563 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 564 return IsUserLoggedIn() && | 564 return IsUserLoggedIn() && |
| 565 active_user_->GetType() == USER_TYPE_PUBLIC_ACCOUNT; | 565 active_user_->GetType() == USER_TYPE_PUBLIC_ACCOUNT; |
| 566 } | 566 } |
| 567 | 567 |
| 568 bool UserManagerBase::IsLoggedInAsGuest() const { | 568 bool UserManagerBase::IsLoggedInAsGuest() const { |
| 569 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 569 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 570 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_GUEST; | 570 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_GUEST; |
| 571 } | 571 } |
| 572 | 572 |
| 573 bool UserManagerBase::IsLoggedInAsSupervisedUser() const { | 573 bool UserManagerBase::IsLoggedInAsSupervisedUser() const { |
| 574 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 574 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 575 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_SUPERVISED; | 575 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_SUPERVISED; |
| 576 } | 576 } |
| 577 | 577 |
| 578 bool UserManagerBase::IsLoggedInAsKioskApp() const { | 578 bool UserManagerBase::IsLoggedInAsKioskApp() const { |
| 579 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 579 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 580 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_KIOSK_APP; | 580 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_KIOSK_APP; |
| 581 } | 581 } |
| 582 | 582 |
| 583 bool UserManagerBase::IsLoggedInAsArcKioskApp() const { | 583 bool UserManagerBase::IsLoggedInAsArcKioskApp() const { |
| 584 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 584 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 585 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_ARC_KIOSK_APP; | 585 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_ARC_KIOSK_APP; |
| 586 } | 586 } |
| 587 | 587 |
| 588 bool UserManagerBase::IsLoggedInAsStub() const { | 588 bool UserManagerBase::IsLoggedInAsStub() const { |
| 589 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 589 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 590 return IsUserLoggedIn() && IsStubAccountId(active_user_->GetAccountId()); | 590 return IsUserLoggedIn() && IsStubAccountId(active_user_->GetAccountId()); |
| 591 } | 591 } |
| 592 | 592 |
| 593 bool UserManagerBase::IsUserNonCryptohomeDataEphemeral( | 593 bool UserManagerBase::IsUserNonCryptohomeDataEphemeral( |
| 594 const AccountId& account_id) const { | 594 const AccountId& account_id) const { |
| 595 // Data belonging to the guest and stub users is always ephemeral. | 595 // Data belonging to the guest and stub users is always ephemeral. |
| 596 if (IsGuestAccountId(account_id) || IsStubAccountId(account_id)) | 596 if (IsGuestAccountId(account_id) || IsStubAccountId(account_id)) |
| 597 return true; | 597 return true; |
| 598 | 598 |
| 599 // Data belonging to the owner, anyone found on the user list and obsolete | 599 // Data belonging to the owner, anyone found on the user list and obsolete |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 if (AreEphemeralUsersEnabled() && user && | 641 if (AreEphemeralUsersEnabled() && user && |
| 642 user->GetType() == USER_TYPE_REGULAR && | 642 user->GetType() == USER_TYPE_REGULAR && |
| 643 FindUserInList(account_id) == nullptr) { | 643 FindUserInList(account_id) == nullptr) { |
| 644 return true; | 644 return true; |
| 645 } | 645 } |
| 646 | 646 |
| 647 return false; | 647 return false; |
| 648 } | 648 } |
| 649 | 649 |
| 650 void UserManagerBase::AddObserver(UserManager::Observer* obs) { | 650 void UserManagerBase::AddObserver(UserManager::Observer* obs) { |
| 651 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 651 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 652 observer_list_.AddObserver(obs); | 652 observer_list_.AddObserver(obs); |
| 653 } | 653 } |
| 654 | 654 |
| 655 void UserManagerBase::RemoveObserver(UserManager::Observer* obs) { | 655 void UserManagerBase::RemoveObserver(UserManager::Observer* obs) { |
| 656 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 656 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 657 observer_list_.RemoveObserver(obs); | 657 observer_list_.RemoveObserver(obs); |
| 658 } | 658 } |
| 659 | 659 |
| 660 void UserManagerBase::AddSessionStateObserver( | 660 void UserManagerBase::AddSessionStateObserver( |
| 661 UserManager::UserSessionStateObserver* obs) { | 661 UserManager::UserSessionStateObserver* obs) { |
| 662 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 662 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 663 session_state_observer_list_.AddObserver(obs); | 663 session_state_observer_list_.AddObserver(obs); |
| 664 } | 664 } |
| 665 | 665 |
| 666 void UserManagerBase::RemoveSessionStateObserver( | 666 void UserManagerBase::RemoveSessionStateObserver( |
| 667 UserManager::UserSessionStateObserver* obs) { | 667 UserManager::UserSessionStateObserver* obs) { |
| 668 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 668 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 669 session_state_observer_list_.RemoveObserver(obs); | 669 session_state_observer_list_.RemoveObserver(obs); |
| 670 } | 670 } |
| 671 | 671 |
| 672 void UserManagerBase::NotifyLocalStateChanged() { | 672 void UserManagerBase::NotifyLocalStateChanged() { |
| 673 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 673 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 674 for (auto& observer : observer_list_) | 674 for (auto& observer : observer_list_) |
| 675 observer.LocalStateChanged(this); | 675 observer.LocalStateChanged(this); |
| 676 } | 676 } |
| 677 | 677 |
| 678 void UserManagerBase::NotifyUserImageChanged(const User& user) { | 678 void UserManagerBase::NotifyUserImageChanged(const User& user) { |
| 679 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 679 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 680 for (auto& observer : observer_list_) | 680 for (auto& observer : observer_list_) |
| 681 observer.OnUserImageChanged(user); | 681 observer.OnUserImageChanged(user); |
| 682 } | 682 } |
| 683 | 683 |
| 684 void UserManagerBase::NotifyUserProfileImageUpdateFailed(const User& user) { | 684 void UserManagerBase::NotifyUserProfileImageUpdateFailed(const User& user) { |
| 685 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 685 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 686 for (auto& observer : observer_list_) | 686 for (auto& observer : observer_list_) |
| 687 observer.OnUserProfileImageUpdateFailed(user); | 687 observer.OnUserProfileImageUpdateFailed(user); |
| 688 } | 688 } |
| 689 | 689 |
| 690 void UserManagerBase::NotifyUserProfileImageUpdated( | 690 void UserManagerBase::NotifyUserProfileImageUpdated( |
| 691 const User& user, | 691 const User& user, |
| 692 const gfx::ImageSkia& profile_image) { | 692 const gfx::ImageSkia& profile_image) { |
| 693 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 693 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 694 for (auto& observer : observer_list_) | 694 for (auto& observer : observer_list_) |
| 695 observer.OnUserProfileImageUpdated(user, profile_image); | 695 observer.OnUserProfileImageUpdated(user, profile_image); |
| 696 } | 696 } |
| 697 | 697 |
| 698 bool UserManagerBase::CanUserBeRemoved(const User* user) const { | 698 bool UserManagerBase::CanUserBeRemoved(const User* user) const { |
| 699 // Only regular and supervised users are allowed to be manually removed. | 699 // Only regular and supervised users are allowed to be manually removed. |
| 700 if (!user || | 700 if (!user || |
| 701 !(user->HasGaiaAccount() || user->IsSupervised() || | 701 !(user->HasGaiaAccount() || user->IsSupervised() || |
| 702 user->IsActiveDirectoryUser())) | 702 user->IsActiveDirectoryUser())) |
| 703 return false; | 703 return false; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 | 745 |
| 746 const AccountId& UserManagerBase::GetPendingUserSwitchID() const { | 746 const AccountId& UserManagerBase::GetPendingUserSwitchID() const { |
| 747 return pending_user_switch_; | 747 return pending_user_switch_; |
| 748 } | 748 } |
| 749 | 749 |
| 750 void UserManagerBase::SetPendingUserSwitchId(const AccountId& account_id) { | 750 void UserManagerBase::SetPendingUserSwitchId(const AccountId& account_id) { |
| 751 pending_user_switch_ = account_id; | 751 pending_user_switch_ = account_id; |
| 752 } | 752 } |
| 753 | 753 |
| 754 void UserManagerBase::EnsureUsersLoaded() { | 754 void UserManagerBase::EnsureUsersLoaded() { |
| 755 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 755 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 756 if (!GetLocalState()) | 756 if (!GetLocalState()) |
| 757 return; | 757 return; |
| 758 | 758 |
| 759 if (user_loading_stage_ != STAGE_NOT_LOADED) | 759 if (user_loading_stage_ != STAGE_NOT_LOADED) |
| 760 return; | 760 return; |
| 761 user_loading_stage_ = STAGE_LOADING; | 761 user_loading_stage_ = STAGE_LOADING; |
| 762 | 762 |
| 763 PerformPreUserListLoadingActions(); | 763 PerformPreUserListLoadingActions(); |
| 764 | 764 |
| 765 PrefService* local_state = GetLocalState(); | 765 PrefService* local_state = GetLocalState(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 User* UserManagerBase::FindUserInListAndModify(const AccountId& account_id) { | 856 User* UserManagerBase::FindUserInListAndModify(const AccountId& account_id) { |
| 857 UserList& users = GetUsersAndModify(); | 857 UserList& users = GetUsersAndModify(); |
| 858 for (UserList::iterator it = users.begin(); it != users.end(); ++it) { | 858 for (UserList::iterator it = users.begin(); it != users.end(); ++it) { |
| 859 if ((*it)->GetAccountId() == account_id) | 859 if ((*it)->GetAccountId() == account_id) |
| 860 return *it; | 860 return *it; |
| 861 } | 861 } |
| 862 return nullptr; | 862 return nullptr; |
| 863 } | 863 } |
| 864 | 864 |
| 865 void UserManagerBase::GuestUserLoggedIn() { | 865 void UserManagerBase::GuestUserLoggedIn() { |
| 866 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 866 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 867 active_user_ = User::CreateGuestUser(GetGuestAccountId()); | 867 active_user_ = User::CreateGuestUser(GetGuestAccountId()); |
| 868 } | 868 } |
| 869 | 869 |
| 870 void UserManagerBase::AddUserRecord(User* user) { | 870 void UserManagerBase::AddUserRecord(User* user) { |
| 871 // Add the user to the front of the user list. | 871 // Add the user to the front of the user list. |
| 872 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); | 872 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); |
| 873 prefs_users_update->Insert( | 873 prefs_users_update->Insert( |
| 874 0, base::MakeUnique<base::Value>(user->GetAccountId().GetUserEmail())); | 874 0, base::MakeUnique<base::Value>(user->GetAccountId().GetUserEmail())); |
| 875 users_.insert(users_.begin(), user); | 875 users_.insert(users_.begin(), user); |
| 876 } | 876 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 891 } | 891 } |
| 892 | 892 |
| 893 AddUserRecord(active_user_); | 893 AddUserRecord(active_user_); |
| 894 | 894 |
| 895 // Make sure that new data is persisted to Local State. | 895 // Make sure that new data is persisted to Local State. |
| 896 GetLocalState()->CommitPendingWrite(); | 896 GetLocalState()->CommitPendingWrite(); |
| 897 } | 897 } |
| 898 | 898 |
| 899 void UserManagerBase::RegularUserLoggedInAsEphemeral( | 899 void UserManagerBase::RegularUserLoggedInAsEphemeral( |
| 900 const AccountId& account_id) { | 900 const AccountId& account_id) { |
| 901 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 901 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 902 SetIsCurrentUserNew(true); | 902 SetIsCurrentUserNew(true); |
| 903 is_current_user_ephemeral_regular_user_ = true; | 903 is_current_user_ephemeral_regular_user_ = true; |
| 904 active_user_ = User::CreateRegularUser(account_id); | 904 active_user_ = User::CreateRegularUser(account_id); |
| 905 } | 905 } |
| 906 | 906 |
| 907 void UserManagerBase::NotifyOnLogin() { | 907 void UserManagerBase::NotifyOnLogin() { |
| 908 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 908 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 909 | 909 |
| 910 NotifyActiveUserHashChanged(active_user_->username_hash()); | 910 NotifyActiveUserHashChanged(active_user_->username_hash()); |
| 911 NotifyActiveUserChanged(active_user_); | 911 NotifyActiveUserChanged(active_user_); |
| 912 CallUpdateLoginState(); | 912 CallUpdateLoginState(); |
| 913 } | 913 } |
| 914 | 914 |
| 915 User::OAuthTokenStatus UserManagerBase::LoadUserOAuthStatus( | 915 User::OAuthTokenStatus UserManagerBase::LoadUserOAuthStatus( |
| 916 const AccountId& account_id) const { | 916 const AccountId& account_id) const { |
| 917 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 917 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 918 | 918 |
| 919 const base::DictionaryValue* prefs_oauth_status = | 919 const base::DictionaryValue* prefs_oauth_status = |
| 920 GetLocalState()->GetDictionary(kUserOAuthTokenStatus); | 920 GetLocalState()->GetDictionary(kUserOAuthTokenStatus); |
| 921 int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN; | 921 int oauth_token_status = User::OAUTH_TOKEN_STATUS_UNKNOWN; |
| 922 if (prefs_oauth_status && | 922 if (prefs_oauth_status && |
| 923 prefs_oauth_status->GetIntegerWithoutPathExpansion( | 923 prefs_oauth_status->GetIntegerWithoutPathExpansion( |
| 924 account_id.GetUserEmail(), &oauth_token_status)) { | 924 account_id.GetUserEmail(), &oauth_token_status)) { |
| 925 User::OAuthTokenStatus status = | 925 User::OAuthTokenStatus status = |
| 926 static_cast<User::OAuthTokenStatus>(oauth_token_status); | 926 static_cast<User::OAuthTokenStatus>(oauth_token_status); |
| 927 HandleUserOAuthTokenStatusChange(account_id, status); | 927 HandleUserOAuthTokenStatusChange(account_id, status); |
| 928 | 928 |
| 929 return status; | 929 return status; |
| 930 } | 930 } |
| 931 return User::OAUTH_TOKEN_STATUS_UNKNOWN; | 931 return User::OAUTH_TOKEN_STATUS_UNKNOWN; |
| 932 } | 932 } |
| 933 | 933 |
| 934 bool UserManagerBase::LoadForceOnlineSignin(const AccountId& account_id) const { | 934 bool UserManagerBase::LoadForceOnlineSignin(const AccountId& account_id) const { |
| 935 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 935 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 936 | 936 |
| 937 const base::DictionaryValue* prefs_force_online = | 937 const base::DictionaryValue* prefs_force_online = |
| 938 GetLocalState()->GetDictionary(kUserForceOnlineSignin); | 938 GetLocalState()->GetDictionary(kUserForceOnlineSignin); |
| 939 bool force_online_signin = false; | 939 bool force_online_signin = false; |
| 940 if (prefs_force_online) { | 940 if (prefs_force_online) { |
| 941 prefs_force_online->GetBooleanWithoutPathExpansion( | 941 prefs_force_online->GetBooleanWithoutPathExpansion( |
| 942 account_id.GetUserEmail(), &force_online_signin); | 942 account_id.GetUserEmail(), &force_online_signin); |
| 943 } | 943 } |
| 944 return force_online_signin; | 944 return force_online_signin; |
| 945 } | 945 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 prefs_users_update->AppendString(user_email); | 990 prefs_users_update->AppendString(user_email); |
| 991 } | 991 } |
| 992 ++it; | 992 ++it; |
| 993 } | 993 } |
| 994 } | 994 } |
| 995 OnUserRemoved(account_id); | 995 OnUserRemoved(account_id); |
| 996 return user; | 996 return user; |
| 997 } | 997 } |
| 998 | 998 |
| 999 void UserManagerBase::NotifyActiveUserChanged(const User* active_user) { | 999 void UserManagerBase::NotifyActiveUserChanged(const User* active_user) { |
| 1000 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 1000 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 1001 for (auto& observer : session_state_observer_list_) | 1001 for (auto& observer : session_state_observer_list_) |
| 1002 observer.ActiveUserChanged(active_user); | 1002 observer.ActiveUserChanged(active_user); |
| 1003 } | 1003 } |
| 1004 | 1004 |
| 1005 void UserManagerBase::NotifyUserAddedToSession(const User* added_user, | 1005 void UserManagerBase::NotifyUserAddedToSession(const User* added_user, |
| 1006 bool user_switch_pending) { | 1006 bool user_switch_pending) { |
| 1007 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 1007 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 1008 for (auto& observer : session_state_observer_list_) | 1008 for (auto& observer : session_state_observer_list_) |
| 1009 observer.UserAddedToSession(added_user); | 1009 observer.UserAddedToSession(added_user); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 void UserManagerBase::NotifyActiveUserHashChanged(const std::string& hash) { | 1012 void UserManagerBase::NotifyActiveUserHashChanged(const std::string& hash) { |
| 1013 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 1013 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 1014 for (auto& observer : session_state_observer_list_) | 1014 for (auto& observer : session_state_observer_list_) |
| 1015 observer.ActiveUserHashChanged(hash); | 1015 observer.ActiveUserHashChanged(hash); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 void UserManagerBase::ChangeUserChildStatus(User* user, bool is_child) { | 1018 void UserManagerBase::ChangeUserChildStatus(User* user, bool is_child) { |
| 1019 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 1019 DCHECK(!task_runner_ || task_runner_->RunsTasksOnCurrentThread()); |
| 1020 if (user->IsSupervised() == is_child) | 1020 if (user->IsSupervised() == is_child) |
| 1021 return; | 1021 return; |
| 1022 user->SetIsChild(is_child); | 1022 user->SetIsChild(is_child); |
| 1023 SaveUserType(user->GetAccountId(), is_child | 1023 SaveUserType(user->GetAccountId(), is_child |
| 1024 ? user_manager::USER_TYPE_CHILD | 1024 ? user_manager::USER_TYPE_CHILD |
| 1025 : user_manager::USER_TYPE_REGULAR); | 1025 : user_manager::USER_TYPE_REGULAR); |
| 1026 for (auto& observer : session_state_observer_list_) | 1026 for (auto& observer : session_state_observer_list_) |
| 1027 observer.UserChangedChildStatus(user); | 1027 observer.UserChangedChildStatus(user); |
| 1028 } | 1028 } |
| 1029 | 1029 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 } | 1094 } |
| 1095 | 1095 |
| 1096 void UserManagerBase::DeleteUser(User* user) { | 1096 void UserManagerBase::DeleteUser(User* user) { |
| 1097 const bool is_active_user = (user == active_user_); | 1097 const bool is_active_user = (user == active_user_); |
| 1098 delete user; | 1098 delete user; |
| 1099 if (is_active_user) | 1099 if (is_active_user) |
| 1100 active_user_ = nullptr; | 1100 active_user_ = nullptr; |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 } // namespace user_manager | 1103 } // namespace user_manager |
| OLD | NEW |