| 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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 void UserManagerBase::NotifyUserProfileImageUpdated( | 689 void UserManagerBase::NotifyUserProfileImageUpdated( |
| 690 const User& user, | 690 const User& user, |
| 691 const gfx::ImageSkia& profile_image) { | 691 const gfx::ImageSkia& profile_image) { |
| 692 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 692 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 693 for (auto& observer : observer_list_) | 693 for (auto& observer : observer_list_) |
| 694 observer.OnUserProfileImageUpdated(user, profile_image); | 694 observer.OnUserProfileImageUpdated(user, profile_image); |
| 695 } | 695 } |
| 696 | 696 |
| 697 bool UserManagerBase::CanUserBeRemoved(const User* user) const { | 697 bool UserManagerBase::CanUserBeRemoved(const User* user) const { |
| 698 // Only regular and supervised users are allowed to be manually removed. | 698 // Only regular and supervised users are allowed to be manually removed. |
| 699 if (!user || !(user->HasGaiaAccount() || user->IsSupervised())) | 699 if (!user || |
| 700 !(user->HasGaiaAccount() || user->IsSupervised() || user->IsAdUser())) |
| 700 return false; | 701 return false; |
| 701 | 702 |
| 702 // Sanity check: we must not remove single user unless it's an enterprise | 703 // Sanity check: we must not remove single user unless it's an enterprise |
| 703 // device. This check may seem redundant at a first sight because | 704 // device. This check may seem redundant at a first sight because |
| 704 // this single user must be an owner and we perform special check later | 705 // this single user must be an owner and we perform special check later |
| 705 // in order not to remove an owner. However due to non-instant nature of | 706 // in order not to remove an owner. However due to non-instant nature of |
| 706 // ownership assignment this later check may sometimes fail. | 707 // ownership assignment this later check may sometimes fail. |
| 707 // See http://crosbug.com/12723 | 708 // See http://crosbug.com/12723 |
| 708 if (users_.size() < 2 && !IsEnterpriseManaged()) | 709 if (users_.size() < 2 && !IsEnterpriseManaged()) |
| 709 return false; | 710 return false; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 User* UserManagerBase::RemoveRegularOrSupervisedUserFromList( | 971 User* UserManagerBase::RemoveRegularOrSupervisedUserFromList( |
| 971 const AccountId& account_id) { | 972 const AccountId& account_id) { |
| 972 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); | 973 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); |
| 973 prefs_users_update->Clear(); | 974 prefs_users_update->Clear(); |
| 974 User* user = nullptr; | 975 User* user = nullptr; |
| 975 for (UserList::iterator it = users_.begin(); it != users_.end();) { | 976 for (UserList::iterator it = users_.begin(); it != users_.end();) { |
| 976 if ((*it)->GetAccountId() == account_id) { | 977 if ((*it)->GetAccountId() == account_id) { |
| 977 user = *it; | 978 user = *it; |
| 978 it = users_.erase(it); | 979 it = users_.erase(it); |
| 979 } else { | 980 } else { |
| 980 if ((*it)->HasGaiaAccount() || (*it)->IsSupervised()) { | 981 if ((*it)->HasGaiaAccount() || (*it)->IsSupervised() || |
| 982 (*it)->IsAdUser()) { |
| 981 const std::string user_email = (*it)->GetAccountId().GetUserEmail(); | 983 const std::string user_email = (*it)->GetAccountId().GetUserEmail(); |
| 982 prefs_users_update->AppendString(user_email); | 984 prefs_users_update->AppendString(user_email); |
| 983 } | 985 } |
| 984 ++it; | 986 ++it; |
| 985 } | 987 } |
| 986 } | 988 } |
| 987 OnUserRemoved(account_id); | 989 OnUserRemoved(account_id); |
| 988 return user; | 990 return user; |
| 989 } | 991 } |
| 990 | 992 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 } | 1088 } |
| 1087 | 1089 |
| 1088 void UserManagerBase::DeleteUser(User* user) { | 1090 void UserManagerBase::DeleteUser(User* user) { |
| 1089 const bool is_active_user = (user == active_user_); | 1091 const bool is_active_user = (user == active_user_); |
| 1090 delete user; | 1092 delete user; |
| 1091 if (is_active_user) | 1093 if (is_active_user) |
| 1092 active_user_ = nullptr; | 1094 active_user_ = nullptr; |
| 1093 } | 1095 } |
| 1094 | 1096 |
| 1095 } // namespace user_manager | 1097 } // namespace user_manager |
| OLD | NEW |