| 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 "chrome/browser/chromeos/login/users/user_manager_impl.h" | 5 #include "chrome/browser/chromeos/login/users/user_manager_impl.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "ash/multi_profile_uma.h" | 10 #include "ash/multi_profile_uma.h" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 317 } |
| 318 | 318 |
| 319 UserList UserManagerImpl::GetUsersAdmittedForMultiProfile() const { | 319 UserList UserManagerImpl::GetUsersAdmittedForMultiProfile() const { |
| 320 // Supervised users are not allowed to use multi-profiles. | 320 // Supervised users are not allowed to use multi-profiles. |
| 321 if (logged_in_users_.size() == 1 && | 321 if (logged_in_users_.size() == 1 && |
| 322 GetPrimaryUser()->GetType() != User::USER_TYPE_REGULAR) { | 322 GetPrimaryUser()->GetType() != User::USER_TYPE_REGULAR) { |
| 323 return UserList(); | 323 return UserList(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 UserList result; | 326 UserList result; |
| 327 int num_users_allowed = 0; | |
| 328 const UserList& users = GetUsers(); | 327 const UserList& users = GetUsers(); |
| 329 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 328 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
| 330 if ((*it)->GetType() == User::USER_TYPE_REGULAR && !(*it)->is_logged_in()) { | 329 if ((*it)->GetType() == User::USER_TYPE_REGULAR && !(*it)->is_logged_in()) { |
| 331 MultiProfileUserController::UserAllowedInSessionResult check = | 330 MultiProfileUserController::UserAllowedInSessionResult check = |
| 332 multi_profile_user_controller_-> | 331 multi_profile_user_controller_-> |
| 333 IsUserAllowedInSession((*it)->email()); | 332 IsUserAllowedInSession((*it)->email()); |
| 334 if (check == MultiProfileUserController:: | 333 if (check == MultiProfileUserController:: |
| 335 NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS) { | 334 NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS) { |
| 336 return UserList(); | 335 return UserList(); |
| 337 } | 336 } |
| 338 | 337 |
| 339 // Users with a policy that prevents them being added to a session will be | 338 // Users with a policy that prevents them being added to a session will be |
| 340 // shown in login UI but will be grayed out. | 339 // shown in login UI but will be grayed out. |
| 341 // Same applies to owner account (see http://crbug.com/385034). | 340 // Same applies to owner account (see http://crbug.com/385034). |
| 342 if (check == MultiProfileUserController::ALLOWED || | 341 if (check == MultiProfileUserController::ALLOWED || |
| 343 check == MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS || | 342 check == MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS || |
| 344 check == MultiProfileUserController::NOT_ALLOWED_OWNER_AS_SECONDARY) { | 343 check == MultiProfileUserController::NOT_ALLOWED_OWNER_AS_SECONDARY) { |
| 345 result.push_back(*it); | 344 result.push_back(*it); |
| 346 if (check == MultiProfileUserController::ALLOWED) | |
| 347 num_users_allowed++; | |
| 348 } | 345 } |
| 349 } | 346 } |
| 350 } | 347 } |
| 351 | 348 |
| 352 // We only show multi-profiles sign in UI if there's at least one user that | |
| 353 // is allowed to be added to the session. | |
| 354 if (!num_users_allowed) | |
| 355 result.clear(); | |
| 356 | |
| 357 return result; | 349 return result; |
| 358 } | 350 } |
| 359 | 351 |
| 360 const UserList& UserManagerImpl::GetLoggedInUsers() const { | 352 const UserList& UserManagerImpl::GetLoggedInUsers() const { |
| 361 return logged_in_users_; | 353 return logged_in_users_; |
| 362 } | 354 } |
| 363 | 355 |
| 364 const UserList& UserManagerImpl::GetLRULoggedInUsers() { | 356 const UserList& UserManagerImpl::GetLRULoggedInUsers() { |
| 365 // If there is no user logged in, we return the active user as the only one. | 357 // If there is no user logged in, we return the active user as the only one. |
| 366 if (lru_logged_in_users_.empty() && active_user_) { | 358 if (lru_logged_in_users_.empty() && active_user_) { |
| (...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2108 } | 2100 } |
| 2109 | 2101 |
| 2110 void UserManagerImpl::DeleteUser(User* user) { | 2102 void UserManagerImpl::DeleteUser(User* user) { |
| 2111 const bool is_active_user = (user == active_user_); | 2103 const bool is_active_user = (user == active_user_); |
| 2112 delete user; | 2104 delete user; |
| 2113 if (is_active_user) | 2105 if (is_active_user) |
| 2114 active_user_ = NULL; | 2106 active_user_ = NULL; |
| 2115 } | 2107 } |
| 2116 | 2108 |
| 2117 } // namespace chromeos | 2109 } // namespace chromeos |
| OLD | NEW |