Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1274)

Side by Side Diff: ash/common/session/session_controller.h

Issue 2734933004: ash: Use SessionController instead of SessionStateDelegate (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ 5 #ifndef ASH_COMMON_SESSION_SESSION_CONTROLLER_H_
6 #define ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ 6 #define ASH_COMMON_SESSION_SESSION_CONTROLLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Returns true if the screen can be locked. 54 // Returns true if the screen can be locked.
55 bool CanLockScreen() const; 55 bool CanLockScreen() const;
56 56
57 // Returns true if the screen is currently locked. 57 // Returns true if the screen is currently locked.
58 bool IsScreenLocked() const; 58 bool IsScreenLocked() const;
59 59
60 // Returns true if the screen should be locked automatically when the screen 60 // Returns true if the screen should be locked automatically when the screen
61 // is turned off or the system is suspended. 61 // is turned off or the system is suspended.
62 bool ShouldLockScreenAutomatically() const; 62 bool ShouldLockScreenAutomatically() const;
63 63
64 // Returns |true| if user session blocked by some overlying UI. It can be 64 // Returns true if user session blocked by some overlying UI. It can be
65 // login screen, lock screen or screen for adding users into multi-profile 65 // login screen, lock screen or screen for adding users into multi-profile
66 // session. 66 // session.
67 bool IsUserSessionBlocked() const; 67 bool IsUserSessionBlocked() const;
68 68
69 // Convenience function that returns true if session state is LOGIN_SECONDARY.
70 bool IsInSecondaryLoginScreen() const;
71
69 // Gets the ash session state. 72 // Gets the ash session state.
70 session_manager::SessionState GetSessionState() const; 73 session_manager::SessionState GetSessionState() const;
71 74
72 // Gets the user sessions in LRU order with the active session being first. 75 // Gets the user sessions in LRU order with the active session being first.
73 const std::vector<mojom::UserSessionPtr>& GetUserSessions() const; 76 const std::vector<mojom::UserSessionPtr>& GetUserSessions() const;
74 77
78 // Convenience helper to gets the user session at a given index. Returns
79 // nullptr if no user session is found for the index.
80 const mojom::UserSession* GetUserSession(UserIndex index) const;
81
75 // Locks the screen. The locking happens asynchronously. 82 // Locks the screen. The locking happens asynchronously.
76 void LockScreen(); 83 void LockScreen();
77 84
78 // Switches to another active user with |account_id| (if that user has 85 // Switches to another active user with |account_id| (if that user has
79 // already signed in). 86 // already signed in).
80 void SwitchActiveUser(const AccountId& account_id); 87 void SwitchActiveUser(const AccountId& account_id);
81 88
82 // Switches the active user to the next or previous user, with the same 89 // Switches the active user to the next or previous user, with the same
83 // ordering as user sessions are created. 90 // ordering as user sessions are created.
84 void CycleActiveUser(CycleUserDirection direction); 91 void CycleActiveUser(CycleUserDirection direction);
85 92
86 void AddSessionStateObserver(SessionStateObserver* observer); 93 void AddSessionStateObserver(SessionStateObserver* observer);
87 void RemoveSessionStateObserver(SessionStateObserver* observer); 94 void RemoveSessionStateObserver(SessionStateObserver* observer);
88 95
89 // Returns the ash notion of login status. 96 // Returns the ash notion of login status.
90 // NOTE: Prefer GetSessionState() in new code because the concept of 97 // NOTE: Prefer GetSessionState() in new code because the concept of
91 // SessionState more closes matches the state in chrome. 98 // SessionState more closes matches the state in chrome.
92 LoginStatus GetLoginStatus() const; 99 LoginStatus GetLoginStatus() const;
93 100
94 // mojom::SessionController 101 // mojom::SessionController
95 void SetClient(mojom::SessionControllerClientPtr client) override; 102 void SetClient(mojom::SessionControllerClientPtr client) override;
96 void SetSessionInfo(mojom::SessionInfoPtr info) override; 103 void SetSessionInfo(mojom::SessionInfoPtr info) override;
97 void UpdateUserSession(mojom::UserSessionPtr user_session) override; 104 void UpdateUserSession(mojom::UserSessionPtr user_session) override;
98 void SetUserSessionOrder( 105 void SetUserSessionOrder(
99 const std::vector<uint32_t>& user_session_order) override; 106 const std::vector<uint32_t>& user_session_order) override;
100 107
108 // Test helpers.
109 void ClearUserSessionsForTest();
110 void LockScreenAndFlushForTest();
111
101 private: 112 private:
102 void SetSessionState(session_manager::SessionState state); 113 void SetSessionState(session_manager::SessionState state);
103 void AddUserSession(mojom::UserSessionPtr user_session); 114 void AddUserSession(mojom::UserSessionPtr user_session);
104 115
105 // Helper that returns login status when the session state is ACTIVE. 116 // Helper that returns login status when the session state is ACTIVE.
106 LoginStatus GetLoginStatusForActiveSession() const; 117 LoginStatus GetLoginStatusForActiveSession() const;
107 118
108 // Bindings for mojom::SessionController interface. 119 // Bindings for mojom::SessionController interface.
109 mojo::BindingSet<mojom::SessionController> bindings_; 120 mojo::BindingSet<mojom::SessionController> bindings_;
110 121
(...skipping 17 matching lines...) Expand all
128 uint32_t active_session_id_ = 0u; 139 uint32_t active_session_id_ = 0u;
129 140
130 base::ObserverList<ash::SessionStateObserver> observers_; 141 base::ObserverList<ash::SessionStateObserver> observers_;
131 142
132 DISALLOW_COPY_AND_ASSIGN(SessionController); 143 DISALLOW_COPY_AND_ASSIGN(SessionController);
133 }; 144 };
134 145
135 } // namespace ash 146 } // namespace ash
136 147
137 #endif // ASH_COMMON_SESSION_SESSION_CONTROLLER_H_ 148 #endif // ASH_COMMON_SESSION_SESSION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698