| 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 <cstddef> | 7 #include <cstddef> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 // Reset the new user flag if the user already exists. | 179 // Reset the new user flag if the user already exists. |
| 180 SetIsCurrentUserNew(false); | 180 SetIsCurrentUserNew(false); |
| 181 NotifyUserAddedToSession(user, true /* user switch pending */); | 181 NotifyUserAddedToSession(user, true /* user switch pending */); |
| 182 | 182 |
| 183 return; | 183 return; |
| 184 } | 184 } |
| 185 | 185 |
| 186 if (user_id == chromeos::login::kGuestUserName) { | 186 if (user_id == chromeos::login::kGuestUserName) { |
| 187 GuestUserLoggedIn(); | 187 GuestUserLoggedIn(); |
| 188 } else if (user_id == chromeos::login::kRetailModeUserName) { | |
| 189 RetailModeUserLoggedIn(); | |
| 190 } else if (IsKioskApp(user_id)) { | 188 } else if (IsKioskApp(user_id)) { |
| 191 KioskAppLoggedIn(user_id); | 189 KioskAppLoggedIn(user_id); |
| 192 } else if (IsDemoApp(user_id)) { | 190 } else if (IsDemoApp(user_id)) { |
| 193 DemoAccountLoggedIn(); | 191 DemoAccountLoggedIn(); |
| 194 } else { | 192 } else { |
| 195 EnsureUsersLoaded(); | 193 EnsureUsersLoaded(); |
| 196 | 194 |
| 197 if (user && user->GetType() == USER_TYPE_PUBLIC_ACCOUNT) { | 195 if (user && user->GetType() == USER_TYPE_PUBLIC_ACCOUNT) { |
| 198 PublicAccountUserLoggedIn(user); | 196 PublicAccountUserLoggedIn(user); |
| 199 } else if ((user && user->GetType() == USER_TYPE_SUPERVISED) || | 197 } else if ((user && user->GetType() == USER_TYPE_SUPERVISED) || |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 bool UserManagerBase::IsLoggedInAsUserWithGaiaAccount() const { | 577 bool UserManagerBase::IsLoggedInAsUserWithGaiaAccount() const { |
| 580 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 578 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 581 return IsUserLoggedIn() && active_user_->HasGaiaAccount(); | 579 return IsUserLoggedIn() && active_user_->HasGaiaAccount(); |
| 582 } | 580 } |
| 583 | 581 |
| 584 bool UserManagerBase::IsLoggedInAsChildUser() const { | 582 bool UserManagerBase::IsLoggedInAsChildUser() const { |
| 585 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 583 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 586 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_CHILD; | 584 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_CHILD; |
| 587 } | 585 } |
| 588 | 586 |
| 589 bool UserManagerBase::IsLoggedInAsDemoUser() const { | |
| 590 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | |
| 591 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_RETAIL_MODE; | |
| 592 } | |
| 593 | |
| 594 bool UserManagerBase::IsLoggedInAsPublicAccount() const { | 587 bool UserManagerBase::IsLoggedInAsPublicAccount() const { |
| 595 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 588 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 596 return IsUserLoggedIn() && | 589 return IsUserLoggedIn() && |
| 597 active_user_->GetType() == USER_TYPE_PUBLIC_ACCOUNT; | 590 active_user_->GetType() == USER_TYPE_PUBLIC_ACCOUNT; |
| 598 } | 591 } |
| 599 | 592 |
| 600 bool UserManagerBase::IsLoggedInAsGuest() const { | 593 bool UserManagerBase::IsLoggedInAsGuest() const { |
| 601 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 594 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 602 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_GUEST; | 595 return IsUserLoggedIn() && active_user_->GetType() == USER_TYPE_GUEST; |
| 603 } | 596 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 618 active_user_->email() == chromeos::login::kStubUser; | 611 active_user_->email() == chromeos::login::kStubUser; |
| 619 } | 612 } |
| 620 | 613 |
| 621 bool UserManagerBase::IsSessionStarted() const { | 614 bool UserManagerBase::IsSessionStarted() const { |
| 622 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 615 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 623 return session_started_; | 616 return session_started_; |
| 624 } | 617 } |
| 625 | 618 |
| 626 bool UserManagerBase::IsUserNonCryptohomeDataEphemeral( | 619 bool UserManagerBase::IsUserNonCryptohomeDataEphemeral( |
| 627 const std::string& user_id) const { | 620 const std::string& user_id) const { |
| 628 // Data belonging to the guest, retail mode and stub users is always | 621 // Data belonging to the guest and stub users is always ephemeral. |
| 629 // ephemeral. | |
| 630 if (user_id == chromeos::login::kGuestUserName || | 622 if (user_id == chromeos::login::kGuestUserName || |
| 631 user_id == chromeos::login::kRetailModeUserName || | |
| 632 user_id == chromeos::login::kStubUser) { | 623 user_id == chromeos::login::kStubUser) { |
| 633 return true; | 624 return true; |
| 634 } | 625 } |
| 635 | 626 |
| 636 // Data belonging to the owner, anyone found on the user list and obsolete | 627 // Data belonging to the owner, anyone found on the user list and obsolete |
| 637 // public accounts whose data has not been removed yet is not ephemeral. | 628 // public accounts whose data has not been removed yet is not ephemeral. |
| 638 if (user_id == GetOwnerEmail() || UserExistsInList(user_id) || | 629 if (user_id == GetOwnerEmail() || UserExistsInList(user_id) || |
| 639 IsPublicAccountMarkedForRemoval(user_id)) { | 630 IsPublicAccountMarkedForRemoval(user_id)) { |
| 640 return false; | 631 return false; |
| 641 } | 632 } |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 logged_in_state = active_user_ ? chromeos::LoginState::LOGGED_IN_ACTIVE | 999 logged_in_state = active_user_ ? chromeos::LoginState::LOGGED_IN_ACTIVE |
| 1009 : chromeos::LoginState::LOGGED_IN_NONE; | 1000 : chromeos::LoginState::LOGGED_IN_NONE; |
| 1010 | 1001 |
| 1011 chromeos::LoginState::LoggedInUserType login_user_type; | 1002 chromeos::LoginState::LoggedInUserType login_user_type; |
| 1012 if (logged_in_state == chromeos::LoginState::LOGGED_IN_NONE) | 1003 if (logged_in_state == chromeos::LoginState::LOGGED_IN_NONE) |
| 1013 login_user_type = chromeos::LoginState::LOGGED_IN_USER_NONE; | 1004 login_user_type = chromeos::LoginState::LOGGED_IN_USER_NONE; |
| 1014 else if (is_current_user_owner_) | 1005 else if (is_current_user_owner_) |
| 1015 login_user_type = chromeos::LoginState::LOGGED_IN_USER_OWNER; | 1006 login_user_type = chromeos::LoginState::LOGGED_IN_USER_OWNER; |
| 1016 else if (active_user_->GetType() == USER_TYPE_GUEST) | 1007 else if (active_user_->GetType() == USER_TYPE_GUEST) |
| 1017 login_user_type = chromeos::LoginState::LOGGED_IN_USER_GUEST; | 1008 login_user_type = chromeos::LoginState::LOGGED_IN_USER_GUEST; |
| 1018 else if (active_user_->GetType() == USER_TYPE_RETAIL_MODE) | |
| 1019 login_user_type = chromeos::LoginState::LOGGED_IN_USER_RETAIL_MODE; | |
| 1020 else if (active_user_->GetType() == USER_TYPE_PUBLIC_ACCOUNT) | 1009 else if (active_user_->GetType() == USER_TYPE_PUBLIC_ACCOUNT) |
| 1021 login_user_type = chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT; | 1010 login_user_type = chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT; |
| 1022 else if (active_user_->GetType() == USER_TYPE_SUPERVISED) | 1011 else if (active_user_->GetType() == USER_TYPE_SUPERVISED) |
| 1023 login_user_type = chromeos::LoginState::LOGGED_IN_USER_SUPERVISED; | 1012 login_user_type = chromeos::LoginState::LOGGED_IN_USER_SUPERVISED; |
| 1024 else if (active_user_->GetType() == USER_TYPE_KIOSK_APP) | 1013 else if (active_user_->GetType() == USER_TYPE_KIOSK_APP) |
| 1025 login_user_type = chromeos::LoginState::LOGGED_IN_USER_KIOSK_APP; | 1014 login_user_type = chromeos::LoginState::LOGGED_IN_USER_KIOSK_APP; |
| 1026 else | 1015 else |
| 1027 login_user_type = chromeos::LoginState::LOGGED_IN_USER_REGULAR; | 1016 login_user_type = chromeos::LoginState::LOGGED_IN_USER_REGULAR; |
| 1028 | 1017 |
| 1029 if (primary_user_) { | 1018 if (primary_user_) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 } | 1085 } |
| 1097 | 1086 |
| 1098 void UserManagerBase::DeleteUser(User* user) { | 1087 void UserManagerBase::DeleteUser(User* user) { |
| 1099 const bool is_active_user = (user == active_user_); | 1088 const bool is_active_user = (user == active_user_); |
| 1100 delete user; | 1089 delete user; |
| 1101 if (is_active_user) | 1090 if (is_active_user) |
| 1102 active_user_ = NULL; | 1091 active_user_ = NULL; |
| 1103 } | 1092 } |
| 1104 | 1093 |
| 1105 } // namespace user_manager | 1094 } // namespace user_manager |
| OLD | NEW |