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 browser context associated with the window.
55 virtual content::BrowserContext
* GetBrowserContextForWindow(
56 aura::Window
* window
) = 0;
58 // Returns the maximum possible number of logged in users.
59 virtual int GetMaximumNumberOfLoggedInUsers() const = 0;
61 // Returns the number of signed in users. If 0 is returned, there is either
62 // no session in progress or no active user.
63 virtual int NumberOfLoggedInUsers() const = 0;
65 // Returns |true| if the session has been fully started for the active user.
66 // When a user becomes active, the profile and browser UI are not immediately
67 // available. Only once this method starts returning |true| is the browser
68 // startup complete and both profile and UI are fully available.
69 virtual bool IsActiveUserSessionStarted() const = 0;
71 // Returns true if the screen can be locked.
72 virtual bool CanLockScreen() const = 0;
74 // Returns true if the screen is currently locked.
75 virtual bool IsScreenLocked() const = 0;
77 // Returns true if the screen should be locked when the system is about to
79 virtual bool ShouldLockScreenBeforeSuspending() const = 0;
81 // Locks the screen. The locking happens asynchronously.
82 virtual void LockScreen() = 0;
84 // Unlocks the screen.
85 virtual void UnlockScreen() = 0;
87 // Returns |true| if user session blocked by some overlying UI. It can be
88 // login screen, lock screen or screen for adding users into multi-profile
90 virtual bool IsUserSessionBlocked() const = 0;
92 // Gets the displayed name for the user with the given |index|.
93 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
94 virtual const base::string16
GetUserDisplayName(
95 MultiProfileIndex index
) const = 0;
97 // Gets the display email address for the user with the given |index|.
98 // The display email address might contains some periods in the email name
99 // as well as capitalized letters. For example: "Foo.Bar@mock.com".
100 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
101 virtual const std::string
GetUserEmail(MultiProfileIndex index
) const = 0;
103 // Gets the user id (sanitized email address) for the user with the given
104 // |index|. The function would return something like "foobar@mock.com".
105 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
106 virtual const std::string
GetUserID(MultiProfileIndex index
) const = 0;
108 // Gets the avatar image for the user associated with the |context|.
109 virtual const gfx::ImageSkia
& GetUserImage(
110 content::BrowserContext
* context
) const = 0;
112 // Whether or not the window's title should show the avatar.
113 virtual bool ShouldShowAvatar(aura::Window
* window
) = 0;
115 // Switches to another active user with |user_id|
116 // (if that user has already signed in).
117 virtual void SwitchActiveUser(const std::string
& user_id
) = 0;
119 // Switches the active user to the next or previous user, with the same
120 // ordering as GetLoggedInUsers.
121 virtual void CycleActiveUser(CycleUser cycle_user
) = 0;
123 // Adds or removes sessions state observer.
124 virtual void AddSessionStateObserver(SessionStateObserver
* observer
) = 0;
125 virtual void RemoveSessionStateObserver(SessionStateObserver
* observer
) = 0;
130 #endif // ASH_SESSION_STATE_DELEGATE_H_