Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Side by Side Diff: components/user_manager/user_manager_base.cc

Issue 2519823006: Chromad: Add authentication flow (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 } 664 }
665 665
666 void UserManagerBase::NotifyLocalStateChanged() { 666 void UserManagerBase::NotifyLocalStateChanged() {
667 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 667 DCHECK(task_runner_->RunsTasksOnCurrentThread());
668 for (auto& observer : observer_list_) 668 for (auto& observer : observer_list_)
669 observer.LocalStateChanged(this); 669 observer.LocalStateChanged(this);
670 } 670 }
671 671
672 bool UserManagerBase::CanUserBeRemoved(const User* user) const { 672 bool UserManagerBase::CanUserBeRemoved(const User* user) const {
673 // Only regular and supervised users are allowed to be manually removed. 673 // Only regular and supervised users are allowed to be manually removed.
674 if (!user || !(user->HasGaiaAccount() || user->IsSupervised())) 674 if (!user ||
675 !(user->HasGaiaAccount() || user->IsSupervised() || user->IsAdUser()))
675 return false; 676 return false;
676 677
677 // Sanity check: we must not remove single user unless it's an enterprise 678 // Sanity check: we must not remove single user unless it's an enterprise
678 // device. This check may seem redundant at a first sight because 679 // device. This check may seem redundant at a first sight because
679 // this single user must be an owner and we perform special check later 680 // this single user must be an owner and we perform special check later
680 // in order not to remove an owner. However due to non-instant nature of 681 // in order not to remove an owner. However due to non-instant nature of
681 // ownership assignment this later check may sometimes fail. 682 // ownership assignment this later check may sometimes fail.
682 // See http://crosbug.com/12723 683 // See http://crosbug.com/12723
683 if (users_.size() < 2 && !IsEnterpriseManaged()) 684 if (users_.size() < 2 && !IsEnterpriseManaged())
684 return false; 685 return false;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 User* UserManagerBase::RemoveRegularOrSupervisedUserFromList( 946 User* UserManagerBase::RemoveRegularOrSupervisedUserFromList(
946 const AccountId& account_id) { 947 const AccountId& account_id) {
947 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); 948 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers);
948 prefs_users_update->Clear(); 949 prefs_users_update->Clear();
949 User* user = nullptr; 950 User* user = nullptr;
950 for (UserList::iterator it = users_.begin(); it != users_.end();) { 951 for (UserList::iterator it = users_.begin(); it != users_.end();) {
951 if ((*it)->GetAccountId() == account_id) { 952 if ((*it)->GetAccountId() == account_id) {
952 user = *it; 953 user = *it;
953 it = users_.erase(it); 954 it = users_.erase(it);
954 } else { 955 } else {
955 if ((*it)->HasGaiaAccount() || (*it)->IsSupervised()) { 956 if ((*it)->HasGaiaAccount() || (*it)->IsSupervised() ||
957 (*it)->IsAdUser()) {
956 const std::string user_email = (*it)->GetAccountId().GetUserEmail(); 958 const std::string user_email = (*it)->GetAccountId().GetUserEmail();
957 prefs_users_update->AppendString(user_email); 959 prefs_users_update->AppendString(user_email);
958 } 960 }
959 ++it; 961 ++it;
960 } 962 }
961 } 963 }
962 OnUserRemoved(account_id); 964 OnUserRemoved(account_id);
963 return user; 965 return user;
964 } 966 }
965 967
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 } 1063 }
1062 1064
1063 void UserManagerBase::DeleteUser(User* user) { 1065 void UserManagerBase::DeleteUser(User* user) {
1064 const bool is_active_user = (user == active_user_); 1066 const bool is_active_user = (user == active_user_);
1065 delete user; 1067 delete user;
1066 if (is_active_user) 1068 if (is_active_user)
1067 active_user_ = nullptr; 1069 active_user_ = nullptr;
1068 } 1070 }
1069 1071
1070 } // namespace user_manager 1072 } // namespace user_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698