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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_
6 #define CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_
8 #include "ash/session/session_state_delegate.h"
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/observer_list.h"
12 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
13 #include "chromeos/login/login_state.h"
14 #include "components/user_manager/user_manager.h"
17 class SessionStateObserver
;
20 class SessionStateDelegateChromeos
21 : public ash::SessionStateDelegate
,
22 public chromeos::LoginState::Observer
,
23 public user_manager::UserManager::UserSessionStateObserver
,
24 public chromeos::UserAddingScreen::Observer
{
26 SessionStateDelegateChromeos();
27 ~SessionStateDelegateChromeos() override
;
29 // ash::SessionStateDelegate:
30 content::BrowserContext
* GetBrowserContextByIndex(
31 ash::MultiProfileIndex index
) override
;
32 content::BrowserContext
* GetBrowserContextForWindow(
33 aura::Window
* window
) override
;
34 int GetMaximumNumberOfLoggedInUsers() const override
;
35 int NumberOfLoggedInUsers() const override
;
36 bool CanAddUserToMultiProfile(AddUserError
* error
) const override
;
37 bool IsActiveUserSessionStarted() const override
;
38 bool CanLockScreen() const override
;
39 bool IsScreenLocked() const override
;
40 bool ShouldLockScreenBeforeSuspending() const override
;
41 void LockScreen() override
;
42 void UnlockScreen() override
;
43 bool IsUserSessionBlocked() const override
;
44 SessionState
GetSessionState() const override
;
45 const user_manager::UserInfo
* GetUserInfo(
46 ash::MultiProfileIndex index
) const override
;
47 const user_manager::UserInfo
* GetUserInfo(
48 content::BrowserContext
* context
) const override
;
49 bool ShouldShowAvatar(aura::Window
* window
) const override
;
50 void SwitchActiveUser(const std::string
& user_id
) override
;
51 void CycleActiveUser(CycleUser cycle_user
) override
;
52 bool IsMultiProfileAllowedByPrimaryUserPolicy() const override
;
53 void AddSessionStateObserver(ash::SessionStateObserver
* observer
) override
;
54 void RemoveSessionStateObserver(ash::SessionStateObserver
* observer
) override
;
56 // chromeos::LoginState::Observer overrides.
57 void LoggedInStateChanged() override
;
59 // user_manager::UserManager::UserSessionStateObserver:
60 void ActiveUserChanged(const user_manager::User
* active_user
) override
;
61 void UserAddedToSession(const user_manager::User
* added_user
) override
;
63 // chromeos::UserAddingScreen::Observer:
64 void OnUserAddingStarted() override
;
65 void OnUserAddingFinished() override
;
68 // Sets session state to |new_state|.
69 // If |force| is true then |new_state| is set even if existing session
70 // state is the same (used for explicit initialization).
71 void SetSessionState(SessionState new_state
, bool force
);
73 // Notify observers about session state change.
74 void NotifySessionStateChanged();
76 // Switches to a new user. This call might show a dialog asking the user if he
77 // wants to stop desktop casting before switching.
78 void TryToSwitchUser(const std::string
& user_id
);
80 // List of observers is only used on Chrome OS for now.
81 ObserverList
<ash::SessionStateObserver
> session_state_observer_list_
;
83 // Session state (e.g. login screen vs. user session).
84 SessionState session_state_
;
86 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateChromeos
);
89 #endif // CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_