OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_ |
6 #define CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_ | 6 #define CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_ |
7 | 7 |
8 #include "ash/session_state_delegate.h" | 8 #include "ash/session_state_delegate.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "chrome/browser/chromeos/login/user_adding_screen.h" |
12 #include "chrome/browser/chromeos/login/user_manager.h" | 13 #include "chrome/browser/chromeos/login/user_manager.h" |
| 14 #include "chromeos/login/login_state.h" |
13 | 15 |
14 namespace ash { | 16 namespace ash { |
15 class SessionStateObserver; | 17 class SessionStateObserver; |
16 } // namespace ash | 18 } // namespace ash |
17 | 19 |
18 class SessionStateDelegateChromeos | 20 class SessionStateDelegateChromeos |
19 : public ash::SessionStateDelegate, | 21 : public ash::SessionStateDelegate, |
20 public chromeos::UserManager::UserSessionStateObserver { | 22 public chromeos::LoginState::Observer, |
| 23 public chromeos::UserManager::UserSessionStateObserver, |
| 24 public chromeos::UserAddingScreen::Observer { |
21 public: | 25 public: |
22 SessionStateDelegateChromeos(); | 26 SessionStateDelegateChromeos(); |
23 virtual ~SessionStateDelegateChromeos(); | 27 virtual ~SessionStateDelegateChromeos(); |
24 | 28 |
25 // ash::SessionStateDelegate: | 29 // ash::SessionStateDelegate: |
26 virtual content::BrowserContext* GetBrowserContextByIndex( | 30 virtual content::BrowserContext* GetBrowserContextByIndex( |
27 ash::MultiProfileIndex index) OVERRIDE; | 31 ash::MultiProfileIndex index) OVERRIDE; |
28 virtual content::BrowserContext* GetBrowserContextForWindow( | 32 virtual content::BrowserContext* GetBrowserContextForWindow( |
29 aura::Window* window) OVERRIDE; | 33 aura::Window* window) OVERRIDE; |
30 virtual int GetMaximumNumberOfLoggedInUsers() const OVERRIDE; | 34 virtual int GetMaximumNumberOfLoggedInUsers() const OVERRIDE; |
31 virtual int NumberOfLoggedInUsers() const OVERRIDE; | 35 virtual int NumberOfLoggedInUsers() const OVERRIDE; |
32 virtual bool IsActiveUserSessionStarted() const OVERRIDE; | 36 virtual bool IsActiveUserSessionStarted() const OVERRIDE; |
33 virtual bool CanLockScreen() const OVERRIDE; | 37 virtual bool CanLockScreen() const OVERRIDE; |
34 virtual bool IsScreenLocked() const OVERRIDE; | 38 virtual bool IsScreenLocked() const OVERRIDE; |
35 virtual bool ShouldLockScreenBeforeSuspending() const OVERRIDE; | 39 virtual bool ShouldLockScreenBeforeSuspending() const OVERRIDE; |
36 virtual void LockScreen() OVERRIDE; | 40 virtual void LockScreen() OVERRIDE; |
37 virtual void UnlockScreen() OVERRIDE; | 41 virtual void UnlockScreen() OVERRIDE; |
38 virtual bool IsUserSessionBlocked() const OVERRIDE; | 42 virtual bool IsUserSessionBlocked() const OVERRIDE; |
| 43 virtual SessionState GetSessionState() const OVERRIDE; |
39 virtual const base::string16 GetUserDisplayName( | 44 virtual const base::string16 GetUserDisplayName( |
40 ash::MultiProfileIndex index) const OVERRIDE; | 45 ash::MultiProfileIndex index) const OVERRIDE; |
41 virtual const base::string16 GetUserGivenName( | 46 virtual const base::string16 GetUserGivenName( |
42 ash::MultiProfileIndex index) const OVERRIDE; | 47 ash::MultiProfileIndex index) const OVERRIDE; |
43 virtual const std::string GetUserEmail( | 48 virtual const std::string GetUserEmail( |
44 ash::MultiProfileIndex index) const OVERRIDE; | 49 ash::MultiProfileIndex index) const OVERRIDE; |
45 virtual const std::string GetUserID( | 50 virtual const std::string GetUserID( |
46 ash::MultiProfileIndex index) const OVERRIDE; | 51 ash::MultiProfileIndex index) const OVERRIDE; |
47 virtual const gfx::ImageSkia& GetUserImage( | 52 virtual const gfx::ImageSkia& GetUserImage( |
48 content::BrowserContext* context) const OVERRIDE; | 53 content::BrowserContext* context) const OVERRIDE; |
49 virtual bool ShouldShowAvatar(aura::Window* window) OVERRIDE; | 54 virtual bool ShouldShowAvatar(aura::Window* window) OVERRIDE; |
50 virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE; | 55 virtual void SwitchActiveUser(const std::string& user_id) OVERRIDE; |
51 virtual void CycleActiveUser(CycleUser cycle_user) OVERRIDE; | 56 virtual void CycleActiveUser(CycleUser cycle_user) OVERRIDE; |
52 virtual void AddSessionStateObserver( | 57 virtual void AddSessionStateObserver( |
53 ash::SessionStateObserver* observer) OVERRIDE; | 58 ash::SessionStateObserver* observer) OVERRIDE; |
54 virtual void RemoveSessionStateObserver( | 59 virtual void RemoveSessionStateObserver( |
55 ash::SessionStateObserver* observer) OVERRIDE; | 60 ash::SessionStateObserver* observer) OVERRIDE; |
56 // UserManager::UserSessionStateObserver: | 61 |
| 62 // chromeos::LoginState::Observer overrides. |
| 63 virtual void LoggedInStateChanged() OVERRIDE; |
| 64 |
| 65 // chromeos::UserManager::UserSessionStateObserver: |
57 virtual void ActiveUserChanged(const chromeos::User* active_user) OVERRIDE; | 66 virtual void ActiveUserChanged(const chromeos::User* active_user) OVERRIDE; |
58 virtual void UserAddedToSession(const chromeos::User* added_user) OVERRIDE; | 67 virtual void UserAddedToSession(const chromeos::User* added_user) OVERRIDE; |
59 | 68 |
| 69 // chromeos::UserAddingScreen::Observer: |
| 70 virtual void OnUserAddingStarted() OVERRIDE; |
| 71 virtual void OnUserAddingFinished() OVERRIDE; |
| 72 |
60 private: | 73 private: |
| 74 // Sets session state to |new_state|. |
| 75 // If |force| is true then |new_state| is set even if existing session |
| 76 // state is the same (used for explicit initialization). |
| 77 void SetSessionState(SessionState new_state, bool force); |
| 78 |
| 79 // Notify observers about session state change. |
| 80 void NotifySessionStateChanged(); |
| 81 |
61 // List of observers is only used on Chrome OS for now. | 82 // List of observers is only used on Chrome OS for now. |
62 ObserverList<ash::SessionStateObserver> session_state_observer_list_; | 83 ObserverList<ash::SessionStateObserver> session_state_observer_list_; |
63 | 84 |
| 85 // Session state (e.g. login screen vs. user session). |
| 86 SessionState session_state_; |
| 87 |
64 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateChromeos); | 88 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateChromeos); |
65 }; | 89 }; |
66 | 90 |
67 #endif // CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_ | 91 #endif // CHROME_BROWSER_UI_ASH_SESSION_STATE_DELEGATE_CHROMEOS_H_ |
OLD | NEW |