| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 249 } |
| 250 | 250 |
| 251 void UserManagerBase::SessionStarted() { | 251 void UserManagerBase::SessionStarted() { |
| 252 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 252 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 253 session_started_ = true; | 253 session_started_ = true; |
| 254 | 254 |
| 255 CallUpdateLoginState(); | 255 CallUpdateLoginState(); |
| 256 session_manager::SessionManager::Get()->SetSessionState( | 256 session_manager::SessionManager::Get()->SetSessionState( |
| 257 session_manager::SESSION_STATE_ACTIVE); | 257 session_manager::SESSION_STATE_ACTIVE); |
| 258 | 258 |
| 259 if (IsCurrentUserNew()) { | 259 GetLocalState()->CommitPendingWrite(); |
| 260 // Make sure that the new user's data is persisted to Local State. | |
| 261 GetLocalState()->CommitPendingWrite(); | |
| 262 } | |
| 263 } | 260 } |
| 264 | 261 |
| 265 void UserManagerBase::RemoveUser(const AccountId& account_id, | 262 void UserManagerBase::RemoveUser(const AccountId& account_id, |
| 266 RemoveUserDelegate* delegate) { | 263 RemoveUserDelegate* delegate) { |
| 267 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 264 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 268 | 265 |
| 269 if (!CanUserBeRemoved(FindUser(account_id))) | 266 if (!CanUserBeRemoved(FindUser(account_id))) |
| 270 return; | 267 return; |
| 271 | 268 |
| 272 RemoveUserInternal(account_id, delegate); | 269 RemoveUserInternal(account_id, delegate); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 DVLOG(1) << "Saving user OAuth token status in Local State"; | 358 DVLOG(1) << "Saving user OAuth token status in Local State"; |
| 362 User* user = FindUserAndModify(account_id); | 359 User* user = FindUserAndModify(account_id); |
| 363 if (user) | 360 if (user) |
| 364 user->set_oauth_token_status(oauth_token_status); | 361 user->set_oauth_token_status(oauth_token_status); |
| 365 | 362 |
| 366 // Do not update local state if data stored or cached outside the user's | 363 // Do not update local state if data stored or cached outside the user's |
| 367 // cryptohome is to be treated as ephemeral. | 364 // cryptohome is to be treated as ephemeral. |
| 368 if (IsUserNonCryptohomeDataEphemeral(account_id)) | 365 if (IsUserNonCryptohomeDataEphemeral(account_id)) |
| 369 return; | 366 return; |
| 370 | 367 |
| 371 DictionaryPrefUpdate oauth_status_update(GetLocalState(), | 368 { |
| 372 kUserOAuthTokenStatus); | 369 DictionaryPrefUpdate oauth_status_update(GetLocalState(), |
| 373 oauth_status_update->SetWithoutPathExpansion( | 370 kUserOAuthTokenStatus); |
| 374 account_id.GetUserEmail(), | 371 oauth_status_update->SetWithoutPathExpansion( |
| 375 new base::FundamentalValue(static_cast<int>(oauth_token_status))); | 372 account_id.GetUserEmail(), |
| 373 new base::FundamentalValue(static_cast<int>(oauth_token_status))); |
| 374 } |
| 375 GetLocalState()->CommitPendingWrite(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void UserManagerBase::SaveForceOnlineSignin(const AccountId& account_id, | 378 void UserManagerBase::SaveForceOnlineSignin(const AccountId& account_id, |
| 379 bool force_online_signin) { | 379 bool force_online_signin) { |
| 380 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 380 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 381 | 381 |
| 382 // Do not update local state if data stored or cached outside the user's | 382 // Do not update local state if data stored or cached outside the user's |
| 383 // cryptohome is to be treated as ephemeral. | 383 // cryptohome is to be treated as ephemeral. |
| 384 if (IsUserNonCryptohomeDataEphemeral(account_id)) | 384 if (IsUserNonCryptohomeDataEphemeral(account_id)) |
| 385 return; | 385 return; |
| 386 | 386 |
| 387 DictionaryPrefUpdate force_online_update(GetLocalState(), | 387 { |
| 388 kUserForceOnlineSignin); | 388 DictionaryPrefUpdate force_online_update(GetLocalState(), |
| 389 force_online_update->SetBooleanWithoutPathExpansion(account_id.GetUserEmail(), | 389 kUserForceOnlineSignin); |
| 390 force_online_signin); | 390 force_online_update->SetBooleanWithoutPathExpansion( |
| 391 account_id.GetUserEmail(), force_online_signin); |
| 392 } |
| 393 GetLocalState()->CommitPendingWrite(); |
| 391 } | 394 } |
| 392 | 395 |
| 393 void UserManagerBase::SaveUserDisplayName(const AccountId& account_id, | 396 void UserManagerBase::SaveUserDisplayName(const AccountId& account_id, |
| 394 const base::string16& display_name) { | 397 const base::string16& display_name) { |
| 395 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 398 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 396 | 399 |
| 397 if (User* user = FindUserAndModify(account_id)) { | 400 if (User* user = FindUserAndModify(account_id)) { |
| 398 user->set_display_name(display_name); | 401 user->set_display_name(display_name); |
| 399 | 402 |
| 400 // Do not update local state if data stored or cached outside the user's | 403 // Do not update local state if data stored or cached outside the user's |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 } | 1044 } |
| 1042 | 1045 |
| 1043 void UserManagerBase::DeleteUser(User* user) { | 1046 void UserManagerBase::DeleteUser(User* user) { |
| 1044 const bool is_active_user = (user == active_user_); | 1047 const bool is_active_user = (user == active_user_); |
| 1045 delete user; | 1048 delete user; |
| 1046 if (is_active_user) | 1049 if (is_active_user) |
| 1047 active_user_ = nullptr; | 1050 active_user_ = nullptr; |
| 1048 } | 1051 } |
| 1049 | 1052 |
| 1050 } // namespace user_manager | 1053 } // namespace user_manager |
| OLD | NEW |