| 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 715f38e45b3d152860e2265d850488dd3fba1269..07997eac53c688a46e848e5223b4884ff443f958 100644
|
| --- a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
|
| +++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
|
| @@ -20,13 +20,29 @@
|
| #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_(SESSION_STATE_LOGIN_PRIMARY) {
|
| chromeos::UserManager::Get()->AddSessionStateObserver(this);
|
| + chromeos::UserAddingScreen::Get()->AddObserver(this);
|
| +
|
| + // LoginState is not initialized in unit_tests.
|
| + if (chromeos::LoginState::IsInitialized()) {
|
| + chromeos::LoginState::Get()->AddObserver(this);
|
| + SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn() ?
|
| + SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY, true);
|
| + }
|
| }
|
|
|
| SessionStateDelegateChromeos::~SessionStateDelegateChromeos() {
|
| + chromeos::UserManager::Get()->RemoveSessionStateObserver(this);
|
| + chromeos::UserAddingScreen::Get()->RemoveObserver(this);
|
| +
|
| + // LoginState is not initialized in unit_tests.
|
| + if (chromeos::LoginState::IsInitialized())
|
| + chromeos::LoginState::Get()->RemoveObserver(this);
|
| }
|
|
|
| content::BrowserContext* SessionStateDelegateChromeos::GetBrowserContextByIndex(
|
| @@ -111,6 +127,11 @@ bool SessionStateDelegateChromeos::IsUserSessionBlocked() const {
|
| chromeos::UserAddingScreen::Get()->IsRunning();
|
| }
|
|
|
| +ash::SessionStateDelegate::SessionState
|
| +SessionStateDelegateChromeos::GetSessionState() const {
|
| + return session_state_;
|
| +}
|
| +
|
| const base::string16 SessionStateDelegateChromeos::GetUserDisplayName(
|
| ash::MultiProfileIndex index) const {
|
| DCHECK_LT(index, NumberOfLoggedInUsers());
|
| @@ -216,6 +237,11 @@ void SessionStateDelegateChromeos::RemoveSessionStateObserver(
|
| session_state_observer_list_.RemoveObserver(observer);
|
| }
|
|
|
| +void SessionStateDelegateChromeos::LoggedInStateChanged() {
|
| + SetSessionState(chromeos::LoginState::Get()->IsUserLoggedIn() ?
|
| + SESSION_STATE_ACTIVE : SESSION_STATE_LOGIN_PRIMARY, false);
|
| +}
|
| +
|
| void SessionStateDelegateChromeos::ActiveUserChanged(
|
| const chromeos::User* active_user) {
|
| FOR_EACH_OBSERVER(ash::SessionStateObserver,
|
| @@ -229,3 +255,26 @@ void SessionStateDelegateChromeos::UserAddedToSession(
|
| session_state_observer_list_,
|
| UserAddedToSession(added_user->email()));
|
| }
|
| +
|
| +void SessionStateDelegateChromeos::OnUserAddingStarted() {
|
| + SetSessionState(SESSION_STATE_LOGIN_SECONDARY, false);
|
| +}
|
| +
|
| +void SessionStateDelegateChromeos::OnUserAddingFinished() {
|
| + SetSessionState(SESSION_STATE_ACTIVE, false);
|
| +}
|
| +
|
| +void SessionStateDelegateChromeos::SetSessionState(SessionState new_state,
|
| + bool force) {
|
| + if (session_state_ == new_state && !force)
|
| + return;
|
| +
|
| + session_state_ = new_state;
|
| + NotifySessionStateChanged();
|
| +}
|
| +
|
| +void SessionStateDelegateChromeos::NotifySessionStateChanged() {
|
| + FOR_EACH_OBSERVER(ash::SessionStateObserver,
|
| + session_state_observer_list_,
|
| + SessionStateChanged(session_state_));
|
| +}
|
|
|