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 ASH_SESSION_SESSION_STATE_DELEGATE_H_
6 #define ASH_SESSION_SESSION_STATE_DELEGATE_H_
11 #include "ash/ash_export.h"
12 #include "base/strings/string16.h"
28 class SessionStateObserver
;
31 // The index for the multi-profile item to use. The list is always LRU sorted
32 // So that the index #0 is the currently active user.
33 typedef int MultiProfileIndex
;
36 typedef std::vector
<std::string
> UserIdList
;
38 // Delegate for checking and modifying the session state.
39 // TODO(oshima): Replace MultiProfileIndex with BrowsreContext, bacause
40 // GetUserXXX are useful for non multi profile scenario in ash_shell.
41 class ASH_EXPORT SessionStateDelegate
{
43 // Defines the cycle direction for |CycleActiveUser|.
45 CYCLE_TO_NEXT_USER
= 0, // Cycle to the next user.
46 CYCLE_TO_PREVIOUS_USER
, // Cycle to the previous user.
49 // Defines session state i.e. whether session is running or not and
50 // whether user session is blocked by things like multi-profile login.
52 // When primary user login UI is shown i.e. after boot or sign out,
53 // no active user session exists yet.
54 SESSION_STATE_LOGIN_PRIMARY
= 0,
56 // Inside user session (including lock screen),
57 // no login UI (primary or multi-profiles) is shown.
60 // When secondary user login UI is shown i.e. other users are
61 // already logged in and is currently adding another user to the session.
62 SESSION_STATE_LOGIN_SECONDARY
,
65 virtual ~SessionStateDelegate() {};
67 // Returns the browser context for the user given by |index|.
68 virtual content::BrowserContext
* GetBrowserContextByIndex(
69 MultiProfileIndex index
) = 0;
71 // Returns the browser context associated with the window.
72 virtual content::BrowserContext
* GetBrowserContextForWindow(
73 aura::Window
* window
) = 0;
75 // Returns the maximum possible number of logged in users.
76 virtual int GetMaximumNumberOfLoggedInUsers() const = 0;
78 // Returns the number of signed in users. If 0 is returned, there is either
79 // no session in progress or no active user.
80 virtual int NumberOfLoggedInUsers() const = 0;
82 // Returns |true| if the session has been fully started for the active user.
83 // When a user becomes active, the profile and browser UI are not immediately
84 // available. Only once this method starts returning |true| is the browser
85 // startup complete and both profile and UI are fully available.
86 virtual bool IsActiveUserSessionStarted() const = 0;
88 // Returns true if the screen can be locked.
89 virtual bool CanLockScreen() const = 0;
91 // Returns true if the screen is currently locked.
92 virtual bool IsScreenLocked() const = 0;
94 // Returns true if the screen should be locked when the system is about to
96 virtual bool ShouldLockScreenBeforeSuspending() const = 0;
98 // Locks the screen. The locking happens asynchronously.
99 virtual void LockScreen() = 0;
101 // Unlocks the screen.
102 virtual void UnlockScreen() = 0;
104 // Returns |true| if user session blocked by some overlying UI. It can be
105 // login screen, lock screen or screen for adding users into multi-profile
107 virtual bool IsUserSessionBlocked() const = 0;
109 // Returns current session state.
110 virtual SessionState
GetSessionState() const = 0;
112 // TODO(oshima): consolidate these two GetUserInfo.
114 // Gets the user info for the user with the given |index|.
115 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
116 virtual const UserInfo
* GetUserInfo(MultiProfileIndex index
) const = 0;
118 // Gets the avatar image for the user associated with the |context|.
119 virtual const UserInfo
* GetUserInfo(
120 content::BrowserContext
* context
) const = 0;
122 // Whether or not the window's title should show the avatar.
123 virtual bool ShouldShowAvatar(aura::Window
* window
) const = 0;
125 // Switches to another active user with |user_id|
126 // (if that user has already signed in).
127 virtual void SwitchActiveUser(const std::string
& user_id
) = 0;
129 // Switches the active user to the next or previous user, with the same
130 // ordering as GetLoggedInUsers.
131 virtual void CycleActiveUser(CycleUser cycle_user
) = 0;
133 // Adds or removes sessions state observer.
134 virtual void AddSessionStateObserver(SessionStateObserver
* observer
) = 0;
135 virtual void RemoveSessionStateObserver(SessionStateObserver
* observer
) = 0;
140 #endif // ASH_SESSION_SESSION_STATE_DELEGATE_H_