Elim cr-checkbox
[chromium-blink-merge.git] / ash / session / session_state_delegate.h
blob5e73e58310c225049f33b2c449e0a91d053ea1ef
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_
8 #include <string>
9 #include <vector>
11 #include "ash/ash_export.h"
12 #include "base/strings/string16.h"
14 namespace aura {
15 class Window;
16 } // namespace aura
18 namespace content {
19 class BrowserContext;
22 namespace gfx {
23 class ImageSkia;
24 } // namespace gfx
26 namespace user_manager {
27 class UserInfo;
28 } // namespace user_manager
30 namespace ash {
32 class SessionStateObserver;
34 // The index for the multi-profile item to use. The list is always LRU sorted
35 // So that the index #0 is the currently active user.
36 typedef int MultiProfileIndex;
38 // A list of user_id.
39 typedef std::vector<std::string> UserIdList;
41 // Delegate for checking and modifying the session state.
42 // TODO(oshima): Replace MultiProfileIndex with BrowsreContext, bacause
43 // GetUserXXX are useful for non multi profile scenario in ash_shell.
44 class ASH_EXPORT SessionStateDelegate {
45 public:
46 // Defines the cycle direction for |CycleActiveUser|.
47 enum CycleUser {
48 CYCLE_TO_NEXT_USER = 0, // Cycle to the next user.
49 CYCLE_TO_PREVIOUS_USER, // Cycle to the previous user.
52 enum AddUserError {
53 ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER = 0,
54 ADD_USER_ERROR_OUT_OF_USERS,
55 ADD_USER_ERROR_MAXIMUM_USERS_REACHED,
58 // Defines session state i.e. whether session is running or not and
59 // whether user session is blocked by things like multi-profile login.
60 enum SessionState {
61 // When primary user login UI is shown i.e. after boot or sign out,
62 // no active user session exists yet.
63 SESSION_STATE_LOGIN_PRIMARY = 0,
65 // Inside user session (including lock screen),
66 // no login UI (primary or multi-profiles) is shown.
67 SESSION_STATE_ACTIVE,
69 // When secondary user login UI is shown i.e. other users are
70 // already logged in and is currently adding another user to the session.
71 SESSION_STATE_LOGIN_SECONDARY,
74 virtual ~SessionStateDelegate() {};
76 // Returns the browser context for the user given by |index|.
77 virtual content::BrowserContext* GetBrowserContextByIndex(
78 MultiProfileIndex index) = 0;
80 // Returns the browser context associated with the window.
81 virtual content::BrowserContext* GetBrowserContextForWindow(
82 aura::Window* window) = 0;
84 // Returns the browser context on which the window is currently shown. NULL
85 // means the window will be shown for every user.
86 virtual content::BrowserContext* GetUserPresentingBrowserContextForWindow(
87 aura::Window* window) = 0;
89 // Returns the maximum possible number of logged in users.
90 virtual int GetMaximumNumberOfLoggedInUsers() const = 0;
92 // Returns the number of signed in users. If 0 is returned, there is either
93 // no session in progress or no active user.
94 virtual int NumberOfLoggedInUsers() const = 0;
96 // Returns true if there is possible to add more users to multiprofile
97 // session. Error is stored in |error| if it is not NULL and function
98 // returned false.
99 virtual bool CanAddUserToMultiProfile(AddUserError* error) const;
101 // Returns |true| if the session has been fully started for the active user.
102 // When a user becomes active, the profile and browser UI are not immediately
103 // available. Only once this method starts returning |true| is the browser
104 // startup complete and both profile and UI are fully available.
105 virtual bool IsActiveUserSessionStarted() const = 0;
107 // Returns true if the screen can be locked.
108 virtual bool CanLockScreen() const = 0;
110 // Returns true if the screen is currently locked.
111 virtual bool IsScreenLocked() const = 0;
113 // Returns true if the screen should be locked when the system is about to
114 // suspend.
115 virtual bool ShouldLockScreenBeforeSuspending() const = 0;
117 // Locks the screen. The locking happens asynchronously.
118 virtual void LockScreen() = 0;
120 // Unlocks the screen.
121 virtual void UnlockScreen() = 0;
123 // Returns |true| if user session blocked by some overlying UI. It can be
124 // login screen, lock screen or screen for adding users into multi-profile
125 // session.
126 virtual bool IsUserSessionBlocked() const = 0;
128 // Returns current session state.
129 virtual SessionState GetSessionState() const = 0;
131 // TODO(oshima): consolidate these two GetUserInfo.
133 // Gets the user info for the user with the given |index|.
134 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
135 virtual const user_manager::UserInfo* GetUserInfo(
136 MultiProfileIndex index) const = 0;
138 // Gets the avatar image for the user associated with the |context|.
139 virtual const user_manager::UserInfo* GetUserInfo(
140 content::BrowserContext* context) const = 0;
142 // Whether or not the window's title should show the avatar.
143 virtual bool ShouldShowAvatar(aura::Window* window) const = 0;
145 // Switches to another active user with |user_id|
146 // (if that user has already signed in).
147 virtual void SwitchActiveUser(const std::string& user_id) = 0;
149 // Switches the active user to the next or previous user, with the same
150 // ordering as GetLoggedInUsers.
151 virtual void CycleActiveUser(CycleUser cycle_user) = 0;
153 // Returns true if primary user policy does not forbid multiple signin.
154 virtual bool IsMultiProfileAllowedByPrimaryUserPolicy() const = 0;
156 // Adds or removes sessions state observer.
157 virtual void AddSessionStateObserver(SessionStateObserver* observer) = 0;
158 virtual void RemoveSessionStateObserver(SessionStateObserver* observer) = 0;
160 bool IsInSecondaryLoginScreen() const;
163 } // namespace ash
165 #endif // ASH_SESSION_SESSION_STATE_DELEGATE_H_