Index: chrome/browser/chromeos/login/user_manager_impl.cc |
diff --git a/chrome/browser/chromeos/login/user_manager_impl.cc b/chrome/browser/chromeos/login/user_manager_impl.cc |
index afa66d86249f97bf394b0483a761d5f2c71481de..588c6d8168322c696e5dc376da605ac0a71a23f2 100644 |
--- a/chrome/browser/chromeos/login/user_manager_impl.cc |
+++ b/chrome/browser/chromeos/login/user_manager_impl.cc |
@@ -43,6 +43,7 @@ |
#include "chrome/common/pref_names.h" |
#include "chromeos/chromeos_switches.h" |
#include "chromeos/cryptohome/async_method_caller.h" |
+#include "chromeos/login/login_state.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/notification_service.h" |
#include "google_apis/gaia/gaia_auth_util.h" |
@@ -206,6 +207,7 @@ UserManagerImpl::UserManagerImpl() |
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, |
content::NotificationService::AllSources()); |
RetrieveTrustedDevicePolicies(); |
+ UpdateLoginState(); |
} |
UserManagerImpl::~UserManagerImpl() { |
@@ -413,6 +415,7 @@ void UserManagerImpl::RegularUserLoggedInAsEphemeral(const std::string& email) { |
void UserManagerImpl::SessionStarted() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
session_started_ = true; |
+ UpdateLoginState(); |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_SESSION_STARTED, |
content::NotificationService::AllSources(), |
@@ -714,6 +717,7 @@ void UserManagerImpl::SetCurrentUserIsOwner(bool is_current_user_owner) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
base::AutoLock lk(is_current_user_owner_lock_); |
is_current_user_owner_ = is_current_user_owner; |
+ UpdateLoginState(); |
} |
bool UserManagerImpl::IsCurrentUserNew() const { |
@@ -987,6 +991,7 @@ const User* UserManagerImpl::FindUserInList(const std::string& email) const { |
void UserManagerImpl::NotifyOnLogin() { |
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ UpdateLoginState(); |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
content::Source<UserManager>(this), |
@@ -1300,4 +1305,32 @@ void UserManagerImpl::NotifyMergeSessionStateChanged() { |
MergeSessionStateChanged(merge_session_state_)); |
} |
+void UserManagerImpl::UpdateLoginState() { |
+ if (!LoginState::IsInitialized()) |
+ return; // LoginState may not be intialized in tests. |
+ LoginState::LoggedInState logged_in_state; |
+ logged_in_state = logged_in_user_ ? LoginState::LOGGED_IN_ACTIVE |
+ : LoginState::LOGGED_IN_NONE; |
+ |
+ LoginState::LoggedInUserType login_user_type; |
+ if (logged_in_state == LoginState::LOGGED_IN_NONE) |
+ login_user_type = LoginState::LOGGED_IN_USER_NONE; |
+ else if (is_current_user_owner_) |
+ login_user_type = LoginState::LOGGED_IN_USER_OWNER; |
+ else if (logged_in_user_->GetType() == User::USER_TYPE_GUEST) |
+ login_user_type = LoginState::LOGGED_IN_USER_GUEST; |
+ else if (logged_in_user_->GetType() == User::USER_TYPE_RETAIL_MODE) |
+ login_user_type = LoginState::LOGGED_IN_USER_RETAIL_MODE; |
+ else if (logged_in_user_->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT) |
+ login_user_type = LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT; |
+ else if (logged_in_user_->GetType() == User::USER_TYPE_LOCALLY_MANAGED) |
+ login_user_type = LoginState::LOGGED_IN_USER_LOCALLY_MANAGED; |
+ else if (logged_in_user_->GetType() == User::USER_TYPE_KIOSK_APP) |
+ login_user_type = LoginState::LOGGED_IN_USER_KIOSK_APP; |
+ else |
+ login_user_type = LoginState::LOGGED_IN_USER_REGULAR; |
+ |
+ LoginState::Get()->SetLoggedInState(logged_in_state, login_user_type); |
+} |
+ |
} // namespace chromeos |