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_STATE_DELEGATE_H_
6 #define ASH_SESSION_STATE_DELEGATE_H_
11 #include "ash/ash_export.h"
12 #include "base/strings/string16.h"
28 class SessionStateObserver
;
30 // The index for the multi-profile item to use. The list is always LRU sorted
31 // So that the index #0 is the currently active user.
32 typedef int MultiProfileIndex
;
35 typedef std::vector
<std::string
> UserIdList
;
37 // Delegate for checking and modifying the session state.
38 // TODO(oshima): Replace MultiProfileIndex with BrowsreContext, bacause
39 // GetUserXXX are useful for non multi profile scenario in ash_shell.
40 class ASH_EXPORT SessionStateDelegate
{
42 // Defines the cycle direction for |CycleActiveUser|.
44 CYCLE_TO_NEXT_USER
= 0, // Cycle to the next user.
45 CYCLE_TO_PREVIOUS_USER
, // Cycle to the previous user.
48 virtual ~SessionStateDelegate() {};
50 // Returns the browser context for the user given by |index|.
51 virtual content::BrowserContext
* GetBrowserContextByIndex(
52 MultiProfileIndex index
) = 0;
54 // Returns the maximum possible number of logged in users.
55 virtual int GetMaximumNumberOfLoggedInUsers() const = 0;
57 // Returns the number of signed in users. If 0 is returned, there is either
58 // no session in progress or no active user.
59 virtual int NumberOfLoggedInUsers() const = 0;
61 // Returns |true| if the session has been fully started for the active user.
62 // When a user becomes active, the profile and browser UI are not immediately
63 // available. Only once this method starts returning |true| is the browser
64 // startup complete and both profile and UI are fully available.
65 virtual bool IsActiveUserSessionStarted() const = 0;
67 // Returns true if the screen can be locked.
68 virtual bool CanLockScreen() const = 0;
70 // Returns true if the screen is currently locked.
71 virtual bool IsScreenLocked() const = 0;
73 // Returns true if the screen should be locked when the system is about to
75 virtual bool ShouldLockScreenBeforeSuspending() const = 0;
77 // Locks the screen. The locking happens asynchronously.
78 virtual void LockScreen() = 0;
80 // Unlocks the screen.
81 virtual void UnlockScreen() = 0;
83 // Returns |true| if user session blocked by some overlying UI. It can be
84 // login screen, lock screen or screen for adding users into multi-profile
86 virtual bool IsUserSessionBlocked() const = 0;
88 // Gets the displayed name for the user with the given |index|.
89 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
90 virtual const base::string16
GetUserDisplayName(
91 MultiProfileIndex index
) const = 0;
93 // Gets the display email address for the user with the given |index|.
94 // The display email address might contains some periods in the email name
95 // as well as capitalized letters. For example: "Foo.Bar@mock.com".
96 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
97 virtual const std::string
GetUserEmail(MultiProfileIndex index
) const = 0;
99 // Gets the user id (sanitized email address) for the user with the given
100 // |index|. The function would return something like "foobar@mock.com".
101 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
102 virtual const std::string
GetUserID(MultiProfileIndex index
) const = 0;
104 // Gets the avatar image for the user associated with the |context|.
105 virtual const gfx::ImageSkia
& GetUserImage(
106 content::BrowserContext
* context
) const = 0;
108 // Whether or not the window's title should show the avatar.
109 virtual bool ShouldShowAvatar(aura::Window
* window
) = 0;
111 // Switches to another active user with |user_id|
112 // (if that user has already signed in).
113 virtual void SwitchActiveUser(const std::string
& user_id
) = 0;
115 // Switches the active user to the next or previous user, with the same
116 // ordering as GetLoggedInUsers.
117 virtual void CycleActiveUser(CycleUser cycle_user
) = 0;
119 // Adds or removes sessions state observer.
120 virtual void AddSessionStateObserver(SessionStateObserver
* observer
) = 0;
121 virtual void RemoveSessionStateObserver(SessionStateObserver
* observer
) = 0;
126 #endif // ASH_SESSION_STATE_DELEGATE_H_