1c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// found in the LICENSE file. 4c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 55c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#ifndef ASH_SESSION_SESSION_STATE_DELEGATE_H_ 65c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#define ASH_SESSION_SESSION_STATE_DELEGATE_H_ 7c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <string> 990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <vector> 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 11c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ash/ash_export.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h" 1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)namespace aura { 154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class Window; 164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} // namespace aura 174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace content { 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class BrowserContext; 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace gfx { 2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class ImageSkia; 2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} // namespace gfx 25c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 26116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace user_manager { 27116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass UserInfo; 28116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} // namespace user_manager 29116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 30c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace ash { 31c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class SessionStateObserver; 33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// The index for the multi-profile item to use. The list is always LRU sorted 3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// So that the index #0 is the currently active user. 3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)typedef int MultiProfileIndex; 3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// A list of user_id. 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)typedef std::vector<std::string> UserIdList; 4090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 41c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Delegate for checking and modifying the session state. 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// TODO(oshima): Replace MultiProfileIndex with BrowsreContext, bacause 43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// GetUserXXX are useful for non multi profile scenario in ash_shell. 44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class ASH_EXPORT SessionStateDelegate { 45c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) public: 46a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Defines the cycle direction for |CycleActiveUser|. 47a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) enum CycleUser { 48a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) CYCLE_TO_NEXT_USER = 0, // Cycle to the next user. 49a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) CYCLE_TO_PREVIOUS_USER, // Cycle to the previous user. 50a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) }; 51a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci enum AddUserError { 531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER = 0, 541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ADD_USER_ERROR_OUT_OF_USERS, 551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ADD_USER_ERROR_MAXIMUM_USERS_REACHED, 561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci }; 571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 58a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // Defines session state i.e. whether session is running or not and 59a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // whether user session is blocked by things like multi-profile login. 60a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch enum SessionState { 61a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // When primary user login UI is shown i.e. after boot or sign out, 62a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // no active user session exists yet. 63a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch SESSION_STATE_LOGIN_PRIMARY = 0, 64a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 65a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // Inside user session (including lock screen), 66a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // no login UI (primary or multi-profiles) is shown. 67a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch SESSION_STATE_ACTIVE, 68a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 69a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // When secondary user login UI is shown i.e. other users are 70a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // already logged in and is currently adding another user to the session. 71a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch SESSION_STATE_LOGIN_SECONDARY, 72a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch }; 73a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual ~SessionStateDelegate() {}; 75c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 76a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Returns the browser context for the user given by |index|. 77a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual content::BrowserContext* GetBrowserContextByIndex( 78a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MultiProfileIndex index) = 0; 79a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 80effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // Returns the browser context associated with the window. 81effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch virtual content::BrowserContext* GetBrowserContextForWindow( 82effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch aura::Window* window) = 0; 83effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 8490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns the maximum possible number of logged in users. 8590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual int GetMaximumNumberOfLoggedInUsers() const = 0; 8690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 8790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // Returns the number of signed in users. If 0 is returned, there is either 8890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // no session in progress or no active user. 8990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual int NumberOfLoggedInUsers() const = 0; 90c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // Returns true if there is possible to add more users to multiprofile 921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // session. Error is stored in |error| if it is not NULL and function 931320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci // returned false. 941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual bool CanAddUserToMultiProfile(AddUserError* error) const; 951320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 96c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Returns |true| if the session has been fully started for the active user. 97c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // When a user becomes active, the profile and browser UI are not immediately 98c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // available. Only once this method starts returning |true| is the browser 99c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // startup complete and both profile and UI are fully available. 100c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual bool IsActiveUserSessionStarted() const = 0; 101c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 102c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Returns true if the screen can be locked. 103c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual bool CanLockScreen() const = 0; 104c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 105c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Returns true if the screen is currently locked. 106c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual bool IsScreenLocked() const = 0; 107c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1084e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // Returns true if the screen should be locked when the system is about to 1094e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // suspend. 1104e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) virtual bool ShouldLockScreenBeforeSuspending() const = 0; 1114e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 112c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Locks the screen. The locking happens asynchronously. 113c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual void LockScreen() = 0; 114c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 115c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) // Unlocks the screen. 116c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) virtual void UnlockScreen() = 0; 11790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 118bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // Returns |true| if user session blocked by some overlying UI. It can be 119bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // login screen, lock screen or screen for adding users into multi-profile 120bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch // session. 121bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch virtual bool IsUserSessionBlocked() const = 0; 122bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch 123a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // Returns current session state. 124a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch virtual SessionState GetSessionState() const = 0; 125a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 1265c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // TODO(oshima): consolidate these two GetUserInfo. 12790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1285c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // Gets the user info for the user with the given |index|. 1298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. 130116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual const user_manager::UserInfo* GetUserInfo( 131116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch MultiProfileIndex index) const = 0; 1328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 133a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Gets the avatar image for the user associated with the |context|. 134116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual const user_manager::UserInfo* GetUserInfo( 135a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) content::BrowserContext* context) const = 0; 13690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 137a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Whether or not the window's title should show the avatar. 1385c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu virtual bool ShouldShowAvatar(aura::Window* window) const = 0; 13990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Switches to another active user with |user_id| 141d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // (if that user has already signed in). 1428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void SwitchActiveUser(const std::string& user_id) = 0; 143868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 144a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Switches the active user to the next or previous user, with the same 145a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // ordering as GetLoggedInUsers. 146a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual void CycleActiveUser(CycleUser cycle_user) = 0; 14768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 1486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) // Returns true if primary user policy does not forbid multiple signin. 1496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) virtual bool IsMultiProfileAllowedByPrimaryUserPolicy() const = 0; 1506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 151868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Adds or removes sessions state observer. 152868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void AddSessionStateObserver(SessionStateObserver* observer) = 0; 153868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void RemoveSessionStateObserver(SessionStateObserver* observer) = 0; 1546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 1556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) bool IsInSecondaryLoginScreen() const; 156c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}; 157c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 158c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} // namespace ash 159c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 1605c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#endif // ASH_SESSION_SESSION_STATE_DELEGATE_H_ 161