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 gfx {
     15 class ImageSkia;
     16 }  // namespace gfx
     17 
     18 namespace ash {
     19 
     20 class SessionStateObserver;
     21 
     22 // The index for the multi-profile item to use. The list is always LRU sorted
     23 // So that the index #0 is the currently active user.
     24 typedef int MultiProfileIndex;
     25 
     26 // A list of user_id.
     27 typedef std::vector<std::string> UserIdList;
     28 
     29 // Delegate for checking and modifying the session state.
     30 class ASH_EXPORT SessionStateDelegate {
     31  public:
     32   virtual ~SessionStateDelegate() {};
     33 
     34   // Returns the maximum possible number of logged in users.
     35   virtual int GetMaximumNumberOfLoggedInUsers() const = 0;
     36 
     37   // Returns the number of signed in users. If 0 is returned, there is either
     38   // no session in progress or no active user.
     39   virtual int NumberOfLoggedInUsers() const = 0;
     40 
     41   // Returns |true| if the session has been fully started for the active user.
     42   // When a user becomes active, the profile and browser UI are not immediately
     43   // available. Only once this method starts returning |true| is the browser
     44   // startup complete and both profile and UI are fully available.
     45   virtual bool IsActiveUserSessionStarted() const = 0;
     46 
     47   // Returns true if the screen can be locked.
     48   virtual bool CanLockScreen() const = 0;
     49 
     50   // Returns true if the screen is currently locked.
     51   virtual bool IsScreenLocked() const = 0;
     52 
     53   // Locks the screen. The locking happens asynchronously.
     54   virtual void LockScreen() = 0;
     55 
     56   // Unlocks the screen.
     57   virtual void UnlockScreen() = 0;
     58 
     59   // Returns |true| if user session blocked by some overlying UI. It can be
     60   // login screen, lock screen or screen for adding users into multi-profile
     61   // session.
     62   virtual bool IsUserSessionBlocked() const = 0;
     63 
     64   // Gets the displayed name for the user with the given |index|.
     65   // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
     66   virtual const base::string16 GetUserDisplayName(
     67       MultiProfileIndex index) const = 0;
     68 
     69   // Gets the email address for the user with the given |index|.
     70   // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
     71   virtual const std::string GetUserEmail(MultiProfileIndex index) const = 0;
     72 
     73   // Gets the avatar image for the user with the given |index|.
     74   // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|.
     75   virtual const gfx::ImageSkia& GetUserImage(MultiProfileIndex index) const = 0;
     76 
     77   // Returns a list of all logged in users.
     78   virtual void GetLoggedInUsers(UserIdList* users) = 0;
     79 
     80   // Switches to another active user (if that user has already signed in).
     81   virtual void SwitchActiveUser(const std::string& user_id) = 0;
     82 
     83   // Adds or removes sessions state observer.
     84   virtual void AddSessionStateObserver(SessionStateObserver* observer) = 0;
     85   virtual void RemoveSessionStateObserver(SessionStateObserver* observer) = 0;
     86 };
     87 
     88 }  // namespace ash
     89 
     90 #endif  // ASH_SESSION_STATE_DELEGATE_H_
     91