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 CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_
6#define CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_
7
8#include "ash/session/session_state_delegate.h"
9#include "base/basictypes.h"
10#include "base/compiler_specific.h"
11#include "base/observer_list.h"
12#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
13#include "chromeos/login/login_state.h"
14#include "components/user_manager/user_manager.h"
15
16namespace ash {
17class SessionStateObserver;
18}  // namespace ash
19
20class SessionStateDelegateChromeos
21    : public ash::SessionStateDelegate,
22      public chromeos::LoginState::Observer,
23      public user_manager::UserManager::UserSessionStateObserver,
24      public chromeos::UserAddingScreen::Observer {
25 public:
26  SessionStateDelegateChromeos();
27  virtual ~SessionStateDelegateChromeos();
28
29  // ash::SessionStateDelegate:
30  virtual content::BrowserContext* GetBrowserContextByIndex(
31      ash::MultiProfileIndex index) OVERRIDE;
32  virtual content::BrowserContext* GetBrowserContextForWindow(
33      aura::Window* window) OVERRIDE;
34  virtual int GetMaximumNumberOfLoggedInUsers() const OVERRIDE;
35  virtual int NumberOfLoggedInUsers() const OVERRIDE;
36  virtual bool CanAddUserToMultiProfile(AddUserError* error) const OVERRIDE;
37  virtual bool IsActiveUserSessionStarted() const OVERRIDE;
38  virtual bool CanLockScreen() const OVERRIDE;
39  virtual bool IsScreenLocked() const OVERRIDE;
40  virtual bool ShouldLockScreenBeforeSuspending() const OVERRIDE;
41  virtual void LockScreen() OVERRIDE;
42  virtual void UnlockScreen() OVERRIDE;
43  virtual bool IsUserSessionBlocked() const OVERRIDE;
44  virtual SessionState GetSessionState() const OVERRIDE;
45  virtual const user_manager::UserInfo* GetUserInfo(
46      ash::MultiProfileIndex index) const OVERRIDE;
47  virtual const user_manager::UserInfo* GetUserInfo(
48      content::BrowserContext* context) const OVERRIDE;
49  virtual bool ShouldShowAvatar(aura::Window* window) const OVERRIDE;
50  virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE;
51  virtual void CycleActiveUser(CycleUser cycle_user) OVERRIDE;
52  virtual bool IsMultiProfileAllowedByPrimaryUserPolicy() const OVERRIDE;
53  virtual void AddSessionStateObserver(
54      ash::SessionStateObserver* observer) OVERRIDE;
55  virtual void RemoveSessionStateObserver(
56      ash::SessionStateObserver* observer) OVERRIDE;
57
58  // chromeos::LoginState::Observer overrides.
59  virtual void LoggedInStateChanged() OVERRIDE;
60
61  // user_manager::UserManager::UserSessionStateObserver:
62  virtual void ActiveUserChanged(
63      const user_manager::User* active_user) OVERRIDE;
64  virtual void UserAddedToSession(
65      const user_manager::User* added_user) OVERRIDE;
66
67  // chromeos::UserAddingScreen::Observer:
68  virtual void OnUserAddingStarted() OVERRIDE;
69  virtual void OnUserAddingFinished() OVERRIDE;
70
71 private:
72  // Sets session state to |new_state|.
73  // If |force| is true then |new_state| is set even if existing session
74  // state is the same (used for explicit initialization).
75  void SetSessionState(SessionState new_state, bool force);
76
77  // Notify observers about session state change.
78  void NotifySessionStateChanged();
79
80  // Switches to a new user. This call might show a dialog asking the user if he
81  // wants to stop desktop casting before switching.
82  void TryToSwitchUser(const std::string& user_id);
83
84  // List of observers is only used on Chrome OS for now.
85  ObserverList<ash::SessionStateObserver> session_state_observer_list_;
86
87  // Session state (e.g. login screen vs. user session).
88  SessionState session_state_;
89
90  DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateChromeos);
91};
92
93#endif  // CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_
94