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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 last_session_active_account_id_.clear(); | 257 last_session_active_account_id_.clear(); |
258 } | 258 } |
259 | 259 |
260 void UserManagerBase::OnSessionStarted() { | 260 void UserManagerBase::OnSessionStarted() { |
261 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 261 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
262 | 262 |
263 CallUpdateLoginState(); | 263 CallUpdateLoginState(); |
264 GetLocalState()->CommitPendingWrite(); | 264 GetLocalState()->CommitPendingWrite(); |
265 } | 265 } |
266 | 266 |
| 267 void UserManagerBase::OnProfileInitialized(User* user) { |
| 268 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 269 |
| 270 // Mark the user as having an initialized session and persist this in |
| 271 // the known_user DB. |
| 272 user->set_profile_ever_initialized(true); |
| 273 known_user::SetProfileEverInitialized(user->GetAccountId(), true); |
| 274 GetLocalState()->CommitPendingWrite(); |
| 275 } |
| 276 |
267 void UserManagerBase::RemoveUser(const AccountId& account_id, | 277 void UserManagerBase::RemoveUser(const AccountId& account_id, |
268 RemoveUserDelegate* delegate) { | 278 RemoveUserDelegate* delegate) { |
269 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 279 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
270 | 280 |
271 if (!CanUserBeRemoved(FindUser(account_id))) | 281 if (!CanUserBeRemoved(FindUser(account_id))) |
272 return; | 282 return; |
273 | 283 |
274 RemoveUserInternal(account_id, delegate); | 284 RemoveUserInternal(account_id, delegate); |
275 } | 285 } |
276 | 286 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 int user_type; | 802 int user_type; |
793 if (prefs_user_types->GetIntegerWithoutPathExpansion(it->GetUserEmail(), | 803 if (prefs_user_types->GetIntegerWithoutPathExpansion(it->GetUserEmail(), |
794 &user_type) && | 804 &user_type) && |
795 user_type == USER_TYPE_CHILD) { | 805 user_type == USER_TYPE_CHILD) { |
796 ChangeUserChildStatus(user, true /* is child */); | 806 ChangeUserChildStatus(user, true /* is child */); |
797 } | 807 } |
798 } | 808 } |
799 const AccountId account_id = user->GetAccountId(); | 809 const AccountId account_id = user->GetAccountId(); |
800 user->set_oauth_token_status(LoadUserOAuthStatus(*it)); | 810 user->set_oauth_token_status(LoadUserOAuthStatus(*it)); |
801 user->set_force_online_signin(LoadForceOnlineSignin(*it)); | 811 user->set_force_online_signin(LoadForceOnlineSignin(*it)); |
| 812 user->set_profile_ever_initialized( |
| 813 known_user::WasProfileEverInitialized(*it)); |
802 user->set_using_saml(known_user::IsUsingSAML(*it)); | 814 user->set_using_saml(known_user::IsUsingSAML(*it)); |
803 users_.push_back(user); | 815 users_.push_back(user); |
804 | 816 |
805 base::string16 display_name; | 817 base::string16 display_name; |
806 if (prefs_display_names->GetStringWithoutPathExpansion(it->GetUserEmail(), | 818 if (prefs_display_names->GetStringWithoutPathExpansion(it->GetUserEmail(), |
807 &display_name)) { | 819 &display_name)) { |
808 user->set_display_name(display_name); | 820 user->set_display_name(display_name); |
809 } | 821 } |
810 | 822 |
811 base::string16 given_name; | 823 base::string16 given_name; |
812 if (prefs_given_names->GetStringWithoutPathExpansion(it->GetUserEmail(), | 824 if (prefs_given_names->GetStringWithoutPathExpansion(it->GetUserEmail(), |
813 &given_name)) { | 825 &given_name)) { |
814 user->set_given_name(given_name); | 826 user->set_given_name(given_name); |
815 } | 827 } |
816 | 828 |
817 std::string display_email; | 829 std::string display_email; |
818 if (prefs_display_emails->GetStringWithoutPathExpansion(it->GetUserEmail(), | 830 if (prefs_display_emails->GetStringWithoutPathExpansion(it->GetUserEmail(), |
819 &display_email)) { | 831 &display_email)) { |
820 user->set_display_email(display_email); | 832 user->set_display_email(display_email); |
821 } | 833 } |
822 } | 834 } |
823 | |
824 user_loading_stage_ = STAGE_LOADED; | 835 user_loading_stage_ = STAGE_LOADED; |
825 | 836 |
826 PerformPostUserListLoadingActions(); | 837 PerformPostUserListLoadingActions(); |
827 } | 838 } |
828 | 839 |
829 UserList& UserManagerBase::GetUsersAndModify() { | 840 UserList& UserManagerBase::GetUsersAndModify() { |
830 EnsureUsersLoaded(); | 841 EnsureUsersLoaded(); |
831 return users_; | 842 return users_; |
832 } | 843 } |
833 | 844 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 // Remove the user from the user list. | 887 // Remove the user from the user list. |
877 active_user_ = RemoveRegularOrSupervisedUserFromList(account_id); | 888 active_user_ = RemoveRegularOrSupervisedUserFromList(account_id); |
878 | 889 |
879 // If the user was not found on the user list, create a new user. | 890 // If the user was not found on the user list, create a new user. |
880 SetIsCurrentUserNew(!active_user_); | 891 SetIsCurrentUserNew(!active_user_); |
881 if (IsCurrentUserNew()) { | 892 if (IsCurrentUserNew()) { |
882 active_user_ = User::CreateRegularUser(account_id); | 893 active_user_ = User::CreateRegularUser(account_id); |
883 active_user_->set_oauth_token_status(LoadUserOAuthStatus(account_id)); | 894 active_user_->set_oauth_token_status(LoadUserOAuthStatus(account_id)); |
884 SaveUserDisplayName(active_user_->GetAccountId(), | 895 SaveUserDisplayName(active_user_->GetAccountId(), |
885 base::UTF8ToUTF16(active_user_->GetAccountName(true))); | 896 base::UTF8ToUTF16(active_user_->GetAccountName(true))); |
| 897 known_user::SetProfileEverInitialized( |
| 898 active_user_->GetAccountId(), active_user_->profile_ever_initialized()); |
886 } | 899 } |
887 | 900 |
888 AddUserRecord(active_user_); | 901 AddUserRecord(active_user_); |
889 | 902 |
890 // Make sure that new data is persisted to Local State. | 903 // Make sure that new data is persisted to Local State. |
891 GetLocalState()->CommitPendingWrite(); | 904 GetLocalState()->CommitPendingWrite(); |
892 } | 905 } |
893 | 906 |
894 void UserManagerBase::RegularUserLoggedInAsEphemeral( | 907 void UserManagerBase::RegularUserLoggedInAsEphemeral( |
895 const AccountId& account_id) { | 908 const AccountId& account_id) { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 } | 1102 } |
1090 | 1103 |
1091 void UserManagerBase::DeleteUser(User* user) { | 1104 void UserManagerBase::DeleteUser(User* user) { |
1092 const bool is_active_user = (user == active_user_); | 1105 const bool is_active_user = (user == active_user_); |
1093 delete user; | 1106 delete user; |
1094 if (is_active_user) | 1107 if (is_active_user) |
1095 active_user_ = nullptr; | 1108 active_user_ = nullptr; |
1096 } | 1109 } |
1097 | 1110 |
1098 } // namespace user_manager | 1111 } // namespace user_manager |
OLD | NEW |