| 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() || |
| 701 user->IsActiveDirectoryUser())) |
| 700 return false; | 702 return false; |
| 701 | 703 |
| 702 // Sanity check: we must not remove single user unless it's an enterprise | 704 // 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 | 705 // 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 | 706 // 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 | 707 // in order not to remove an owner. However due to non-instant nature of |
| 706 // ownership assignment this later check may sometimes fail. | 708 // ownership assignment this later check may sometimes fail. |
| 707 // See http://crosbug.com/12723 | 709 // See http://crosbug.com/12723 |
| 708 if (users_.size() < 2 && !IsEnterpriseManaged()) | 710 if (users_.size() < 2 && !IsEnterpriseManaged()) |
| 709 return false; | 711 return false; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 User* UserManagerBase::RemoveRegularOrSupervisedUserFromList( | 972 User* UserManagerBase::RemoveRegularOrSupervisedUserFromList( |
| 971 const AccountId& account_id) { | 973 const AccountId& account_id) { |
| 972 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); | 974 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); |
| 973 prefs_users_update->Clear(); | 975 prefs_users_update->Clear(); |
| 974 User* user = nullptr; | 976 User* user = nullptr; |
| 975 for (UserList::iterator it = users_.begin(); it != users_.end();) { | 977 for (UserList::iterator it = users_.begin(); it != users_.end();) { |
| 976 if ((*it)->GetAccountId() == account_id) { | 978 if ((*it)->GetAccountId() == account_id) { |
| 977 user = *it; | 979 user = *it; |
| 978 it = users_.erase(it); | 980 it = users_.erase(it); |
| 979 } else { | 981 } else { |
| 980 if ((*it)->HasGaiaAccount() || (*it)->IsSupervised()) { | 982 if ((*it)->HasGaiaAccount() || (*it)->IsSupervised() || |
| 983 (*it)->IsActiveDirectoryUser()) { |
| 981 const std::string user_email = (*it)->GetAccountId().GetUserEmail(); | 984 const std::string user_email = (*it)->GetAccountId().GetUserEmail(); |
| 982 prefs_users_update->AppendString(user_email); | 985 prefs_users_update->AppendString(user_email); |
| 983 } | 986 } |
| 984 ++it; | 987 ++it; |
| 985 } | 988 } |
| 986 } | 989 } |
| 987 OnUserRemoved(account_id); | 990 OnUserRemoved(account_id); |
| 988 return user; | 991 return user; |
| 989 } | 992 } |
| 990 | 993 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 } | 1089 } |
| 1087 | 1090 |
| 1088 void UserManagerBase::DeleteUser(User* user) { | 1091 void UserManagerBase::DeleteUser(User* user) { |
| 1089 const bool is_active_user = (user == active_user_); | 1092 const bool is_active_user = (user == active_user_); |
| 1090 delete user; | 1093 delete user; |
| 1091 if (is_active_user) | 1094 if (is_active_user) |
| 1092 active_user_ = nullptr; | 1095 active_user_ = nullptr; |
| 1093 } | 1096 } |
| 1094 | 1097 |
| 1095 } // namespace user_manager | 1098 } // namespace user_manager |
| OLD | NEW |