| 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 "chromeos/login/login_state.h" | 5 #include "chromeos/login/login_state.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 10 #include "chromeos/chromeos_switches.h" | 10 #include "chromeos/chromeos_switches.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 LoggedInState state, | 61 LoggedInState state, |
| 62 LoggedInUserType type, | 62 LoggedInUserType type, |
| 63 const std::string& primary_user_hash) { | 63 const std::string& primary_user_hash) { |
| 64 DCHECK(type != LOGGED_IN_USER_NONE); | 64 DCHECK(type != LOGGED_IN_USER_NONE); |
| 65 primary_user_hash_ = primary_user_hash; | 65 primary_user_hash_ = primary_user_hash; |
| 66 VLOG(1) << "LoggedInStateUser: " << primary_user_hash; | 66 VLOG(1) << "LoggedInStateUser: " << primary_user_hash; |
| 67 SetLoggedInState(state, type); | 67 SetLoggedInState(state, type); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void LoginState::SetLoggedInState(LoggedInState state, LoggedInUserType type) { | 70 void LoginState::SetLoggedInState(LoggedInState state, LoggedInUserType type) { |
| 71 CHECK_NE(LOGGED_IN_USER_RETAIL_MODE, type); | |
| 72 if (state == logged_in_state_ && type == logged_in_user_type_) | 71 if (state == logged_in_state_ && type == logged_in_user_type_) |
| 73 return; | 72 return; |
| 74 VLOG(1) << "LoggedInState: " << state << " UserType: " << type; | 73 VLOG(1) << "LoggedInState: " << state << " UserType: " << type; |
| 75 logged_in_state_ = state; | 74 logged_in_state_ = state; |
| 76 logged_in_user_type_ = type; | 75 logged_in_user_type_ = type; |
| 77 NotifyObservers(); | 76 NotifyObservers(); |
| 78 } | 77 } |
| 79 | 78 |
| 80 LoginState::LoggedInUserType LoginState::GetLoggedInUserType() const { | 79 LoginState::LoggedInUserType LoginState::GetLoggedInUserType() const { |
| 81 return logged_in_user_type_; | 80 return logged_in_user_type_; |
| 82 } | 81 } |
| 83 | 82 |
| 84 bool LoginState::IsUserLoggedIn() const { | 83 bool LoginState::IsUserLoggedIn() const { |
| 85 if (always_logged_in_) | 84 if (always_logged_in_) |
| 86 return true; | 85 return true; |
| 87 return logged_in_state_ == LOGGED_IN_ACTIVE; | 86 return logged_in_state_ == LOGGED_IN_ACTIVE; |
| 88 } | 87 } |
| 89 | 88 |
| 90 bool LoginState::IsInSafeMode() const { | 89 bool LoginState::IsInSafeMode() const { |
| 91 DCHECK(!always_logged_in_ || logged_in_state_ != LOGGED_IN_SAFE_MODE); | 90 DCHECK(!always_logged_in_ || logged_in_state_ != LOGGED_IN_SAFE_MODE); |
| 92 return logged_in_state_ == LOGGED_IN_SAFE_MODE; | 91 return logged_in_state_ == LOGGED_IN_SAFE_MODE; |
| 93 } | 92 } |
| 94 | 93 |
| 95 bool LoginState::IsGuestSessionUser() const { | 94 bool LoginState::IsGuestSessionUser() const { |
| 96 return logged_in_user_type_ == LOGGED_IN_USER_GUEST; | 95 return logged_in_user_type_ == LOGGED_IN_USER_GUEST; |
| 97 } | 96 } |
| 98 | 97 |
| 99 bool LoginState::IsPublicSessionUser() const { | 98 bool LoginState::IsPublicSessionUser() const { |
| 100 return logged_in_user_type_ == LOGGED_IN_USER_PUBLIC_ACCOUNT; | 99 return logged_in_user_type_ == LOGGED_IN_USER_PUBLIC_ACCOUNT || |
| 100 logged_in_user_type_ == LOGGED_IN_USER_RETAIL_MODE; |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool LoginState::IsKioskApp() const { | 103 bool LoginState::IsKioskApp() const { |
| 104 return logged_in_user_type_ == LOGGED_IN_USER_KIOSK_APP; | 104 return logged_in_user_type_ == LOGGED_IN_USER_KIOSK_APP; |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool LoginState::UserHasNetworkProfile() const { | 107 bool LoginState::UserHasNetworkProfile() const { |
| 108 if (!IsUserLoggedIn()) | 108 if (!IsUserLoggedIn()) |
| 109 return false; | 109 return false; |
| 110 return logged_in_user_type_ != LOGGED_IN_USER_PUBLIC_ACCOUNT; | 110 return logged_in_user_type_ != LOGGED_IN_USER_PUBLIC_ACCOUNT; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 130 | 130 |
| 131 LoginState::~LoginState() { | 131 LoginState::~LoginState() { |
| 132 } | 132 } |
| 133 | 133 |
| 134 void LoginState::NotifyObservers() { | 134 void LoginState::NotifyObservers() { |
| 135 FOR_EACH_OBSERVER(LoginState::Observer, observer_list_, | 135 FOR_EACH_OBSERVER(LoginState::Observer, observer_list_, |
| 136 LoggedInStateChanged()); | 136 LoggedInStateChanged()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace chromeos | 139 } // namespace chromeos |
| OLD | NEW |