Home | History | Annotate | Download | only in ash
      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.
      4 
      5 #ifndef ASH_SESSION_STATE_DELEGATE_H_
      6 #define ASH_SESSION_STATE_DELEGATE_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "ash/ash_export.h"
     12 #include "base/strings/string16.h"
     13 
     14 namespace aura {
     15 class Window;
     16 }  // namespace aura
     17 
     18 namespace gfx {
     19 class ImageSkia;
     20 }  // namespace gfx
     21 
     22 namespace ash {
     23 
     24 class SessionStateObserver;
     25 
     26 // The index for the multi-profile item to use. The list is always LRU sorted
     27 // So that the index #0 is the currently active user.
     28 typedef int MultiProfileIndex;
     29 
     30 // A list of user_id.
     31 typedef std::vector<std::string> UserIdList;
     32 
     33 // Delegate for checking and modifying the session state.
     34 class ASH_EXPORT SessionStateDelegate {
     35  public:
     36   // Defines the cycle direction for |CycleActiveUser|.
     37   enum CycleUser {
     38     CYCLE_TO_NEXT_USER = 0,  // Cycle to the next user.
     39     CYCLE_TO_PREVIOUS_USER,  // Cycle to the previous user.
     40   };
     41 
     42   virtual ~SessionStateDelegate() {};
     43 
     44   // Returns the maximum possible number of logged in users.
     45   virtual int GetMaximumNumberOfLoggedInUsers() const = 0;
     46 
     47   // Returns the number of signed in users. If 0 is returned, there is either
     48   // no session in progress or no active user.
     49   virtual int NumberOfLoggedInUsers() const = 0;
     50 
     51   // Returns |true| if the session has been fully started for the active user.
     52   // When a user becomes active, the profile and browser UI are not immediately
     53   // available. Only once this method starts returning |true| is the browser
     54   // startup complete and both profile and UI are fully available.
     55   virtual bool IsActiveUserSessionStarted() const = 0;
     56 
     57   // Returns true if the screen can be locked.
     58   virtual bool CanLockScreen() const = 0;
     59 
     60   // Returns true if the screen is currently locked.
     61   virtual bool IsScreenLocked() const = 0;
     62 
     63   // Returns true if the screen should be locked when the system is about to
     64   // suspend.
     65   virtual bool ShouldLockScreenBeforeSuspending() const = 0;
     66 
     67   // Locks the screen. The locking happens asynchronously.
     68   virtual void LockScreen() = 0;
     69 
     70   // Unlocks the screen.
     71   virtual void UnlockScreen() = 0;
     72 
     73   // Returns |true| if user session blocked by some overlying UI. It can be
     74   // login screen, lock screen or screen for adding users into multi-profile
     75   // session.
     76   virtual bool IsUserSessionBlocked() const = 0;
     77 
     78   // Gets the displayed name for the user with the given |index|.
     79   // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
     80   virtual const base::string16 GetUserDisplayName(
     81       MultiProfileIndex index) const = 0;
     82 
     83   // Gets the display email address for the user with the given |index|.
     84   // The display email address might contains some periods in the email name
     85   // as well as capitalized letters. For example: "Foo.Bar (at) mock.com".
     86   // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
     87   virtual const std::string GetUserEmail(MultiProfileIndex index) const = 0;
     88 
     89   // Gets the user id (sanitized email address) for the user with the given
     90   // |index|. The function would return something like "foobar (at) mock.com".
     91   // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
     92   virtual const std::string GetUserID(MultiProfileIndex index) const = 0;
     93 
     94   // Gets the avatar image for the user with the given |index|.
     95   // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
     96   virtual const gfx::ImageSkia& GetUserImage(MultiProfileIndex index) const = 0;
     97 
     98   // Returns a list of all logged in users.
     99   virtual void GetLoggedInUsers(UserIdList* users) = 0;
    100 
    101   // Switches to another active user with |user_id|
    102   // (if that user has already signed in).
    103   virtual void SwitchActiveUser(const std::string& user_id) = 0;
    104 
    105   // Switches the active user to the next or previous user, with the same
    106   // ordering as GetLoggedInUsers.
    107   virtual void CycleActiveUser(CycleUser cycle_user) = 0;
    108 
    109   // Adds or removes sessions state observer.
    110   virtual void AddSessionStateObserver(SessionStateObserver* observer) = 0;
    111   virtual void RemoveSessionStateObserver(SessionStateObserver* observer) = 0;
    112 
    113   // Transfers the visibility of a window to another user. Returns true when
    114   // transfer was done. This could fail if the |window| belongs to no one and
    115   // is therefore shown on the desktop of every user.
    116   virtual bool TransferWindowToDesktopOfUser(
    117       aura::Window* window,
    118       ash::MultiProfileIndex index) = 0;
    119 };
    120 
    121 }  // namespace ash
    122 
    123 #endif  // ASH_SESSION_STATE_DELEGATE_H_
    124