| Index: chrome/browser/ui/ash/session_state_delegate_chromeos.cc
|
| diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
|
| index 2341781f58215f13df01b9658a63e56a04f33597..ee59fcaedd1a95dfe1aec867bcdb5cd0381b46c0 100644
|
| --- a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
|
| +++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
|
| @@ -20,13 +20,23 @@
|
| #include "chromeos/chromeos_switches.h"
|
| #include "chromeos/dbus/dbus_thread_manager.h"
|
| #include "chromeos/dbus/session_manager_client.h"
|
| +#include "chromeos/login/login_state.h"
|
| #include "google_apis/gaia/gaia_auth_util.h"
|
|
|
| -SessionStateDelegateChromeos::SessionStateDelegateChromeos() {
|
| +SessionStateDelegateChromeos::SessionStateDelegateChromeos()
|
| + : session_state_(STATE_LOGIN_PRIMARY),
|
| + initialized_(false) {
|
| + chromeos::LoginState::Get()->AddObserver(this);
|
| chromeos::UserManager::Get()->AddSessionStateObserver(this);
|
| + chromeos::UserAddingScreen::Get()->AddObserver(this);
|
| + SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn() ?
|
| + STATE_SESSION : STATE_LOGIN_PRIMARY, true);
|
| }
|
|
|
| SessionStateDelegateChromeos::~SessionStateDelegateChromeos() {
|
| + chromeos::LoginState::Get()->RemoveObserver(this);
|
| + chromeos::UserManager::Get()->RemoveSessionStateObserver(this);
|
| + chromeos::UserAddingScreen::Get()->RemoveObserver(this);
|
| }
|
|
|
| content::BrowserContext* SessionStateDelegateChromeos::GetBrowserContextByIndex(
|
| @@ -111,6 +121,12 @@ bool SessionStateDelegateChromeos::IsUserSessionBlocked() const {
|
| chromeos::UserAddingScreen::Get()->IsRunning();
|
| }
|
|
|
| +ash::SessionStateDelegate::SessionState
|
| +SessionStateDelegateChromeos::GetSessionState() const {
|
| + DCHECK(initialized_);
|
| + return session_state_;
|
| +}
|
| +
|
| const base::string16 SessionStateDelegateChromeos::GetUserDisplayName(
|
| ash::MultiProfileIndex index) const {
|
| DCHECK_LT(index, NumberOfLoggedInUsers());
|
| @@ -208,6 +224,11 @@ void SessionStateDelegateChromeos::RemoveSessionStateObserver(
|
| session_state_observer_list_.RemoveObserver(observer);
|
| }
|
|
|
| +void SessionStateDelegateChromeos::LoggedInStateChanged() {
|
| + SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn() ?
|
| + STATE_SESSION : STATE_LOGIN_PRIMARY, false);
|
| +}
|
| +
|
| void SessionStateDelegateChromeos::ActiveUserChanged(
|
| const chromeos::User* active_user) {
|
| FOR_EACH_OBSERVER(ash::SessionStateObserver,
|
| @@ -221,3 +242,28 @@ void SessionStateDelegateChromeos::UserAddedToSession(
|
| session_state_observer_list_,
|
| UserAddedToSession(added_user->email()));
|
| }
|
| +
|
| +void SessionStateDelegateChromeos::OnUserAddingStarted() {
|
| + SetSessionState(STATE_LOGIN_SECONDARY, false);
|
| +}
|
| +
|
| +void SessionStateDelegateChromeos::OnUserAddingFinished() {
|
| + SetSessionState(STATE_SESSION, false);
|
| +}
|
| +
|
| +void SessionStateDelegateChromeos::SetSessionState(SessionState new_state,
|
| + bool force) {
|
| + if (session_state_ == new_state && !force)
|
| + return;
|
| +
|
| + initialized_ = true;
|
| + session_state_ = new_state;
|
| + NotifySessionStateChanged();
|
| +}
|
| +
|
| +void SessionStateDelegateChromeos::NotifySessionStateChanged() {
|
| + DCHECK(initialized_);
|
| + FOR_EACH_OBSERVER(ash::SessionStateObserver,
|
| + session_state_observer_list_,
|
| + SessionStateChanged(session_state_));
|
| +}
|
|
|