OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/chromeos/login/user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/user_manager_impl.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 return FindUser(user_id) != NULL; | 538 return FindUser(user_id) != NULL; |
539 } | 539 } |
540 | 540 |
541 const User* UserManagerImpl::FindUser(const std::string& user_id) const { | 541 const User* UserManagerImpl::FindUser(const std::string& user_id) const { |
542 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 542 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
543 if (active_user_ && active_user_->email() == user_id) | 543 if (active_user_ && active_user_->email() == user_id) |
544 return active_user_; | 544 return active_user_; |
545 return FindUserInList(user_id); | 545 return FindUserInList(user_id); |
546 } | 546 } |
547 | 547 |
| 548 User* UserManagerImpl::FindUserAndModify(const std::string& user_id) { |
| 549 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 550 if (active_user_ && active_user_->email() == user_id) |
| 551 return active_user_; |
| 552 return FindUserInListAndModify(user_id); |
| 553 } |
| 554 |
548 const User* UserManagerImpl::GetLoggedInUser() const { | 555 const User* UserManagerImpl::GetLoggedInUser() const { |
549 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 556 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
550 return active_user_; | 557 return active_user_; |
551 } | 558 } |
552 | 559 |
553 User* UserManagerImpl::GetLoggedInUser() { | 560 User* UserManagerImpl::GetLoggedInUser() { |
554 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 561 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
555 return active_user_; | 562 return active_user_; |
556 } | 563 } |
557 | 564 |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 return ephemeral_users_enabled_ && | 1168 return ephemeral_users_enabled_ && |
1162 (g_browser_process->browser_policy_connector()->IsEnterpriseManaged() || | 1169 (g_browser_process->browser_policy_connector()->IsEnterpriseManaged() || |
1163 !owner_email_.empty()); | 1170 !owner_email_.empty()); |
1164 } | 1171 } |
1165 | 1172 |
1166 UserList& UserManagerImpl::GetUsersAndModify() { | 1173 UserList& UserManagerImpl::GetUsersAndModify() { |
1167 EnsureUsersLoaded(); | 1174 EnsureUsersLoaded(); |
1168 return users_; | 1175 return users_; |
1169 } | 1176 } |
1170 | 1177 |
1171 User* UserManagerImpl::FindUserAndModify(const std::string& user_id) { | |
1172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
1173 if (active_user_ && active_user_->email() == user_id) | |
1174 return active_user_; | |
1175 return FindUserInListAndModify(user_id); | |
1176 } | |
1177 | |
1178 const User* UserManagerImpl::FindUserInList(const std::string& user_id) const { | 1178 const User* UserManagerImpl::FindUserInList(const std::string& user_id) const { |
1179 const UserList& users = GetUsers(); | 1179 const UserList& users = GetUsers(); |
1180 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 1180 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
1181 if ((*it)->email() == user_id) | 1181 if ((*it)->email() == user_id) |
1182 return *it; | 1182 return *it; |
1183 } | 1183 } |
1184 return NULL; | 1184 return NULL; |
1185 } | 1185 } |
1186 | 1186 |
1187 const bool UserManagerImpl::UserExistsInList(const std::string& user_id) const { | 1187 const bool UserManagerImpl::UserExistsInList(const std::string& user_id) const { |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 } | 1835 } |
1836 } | 1836 } |
1837 | 1837 |
1838 void UserManagerImpl::OnUserNotAllowed() { | 1838 void UserManagerImpl::OnUserNotAllowed() { |
1839 LOG(ERROR) << "Shutdown session because a user is not allowed to be in the " | 1839 LOG(ERROR) << "Shutdown session because a user is not allowed to be in the " |
1840 "current session"; | 1840 "current session"; |
1841 chrome::AttemptUserExit(); | 1841 chrome::AttemptUserExit(); |
1842 } | 1842 } |
1843 | 1843 |
1844 } // namespace chromeos | 1844 } // namespace chromeos |
OLD | NEW |