James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 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 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 5 | #ifndef ASH_SESSION_SESSION_OBSERVER_H_ |
| 6 | #define ASH_SESSION_SESSION_OBSERVER_H_ |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 7 | |
| 8 | #include "ash/ash_export.h" |
| 9 | #include "base/macros.h" |
| 10 | #include "components/session_manager/session_manager_types.h" |
| 11 | |
| 12 | class AccountId; |
| 13 | |
| 14 | namespace ash { |
| 15 | |
| 16 | enum class LoginStatus; |
| 17 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 18 | class ASH_EXPORT SessionObserver { |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 19 | public: |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 20 | // Called when the active user session has changed. |
| 21 | virtual void OnActiveUserSessionChanged(const AccountId& account_id) {} |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 22 | |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 23 | // Called when a user session gets added to the existing session. |
| 24 | virtual void OnUserSessionAdded(const AccountId& account_id) {} |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 25 | |
| 26 | // Called when a user session is updated, such as avatar change. |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 27 | virtual void OnUserSessionUpdated(const AccountId& account_id) {} |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 28 | |
| 29 | // Called when the session state is changed. |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 30 | virtual void OnSessionStateChanged(session_manager::SessionState state) {} |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 31 | |
| 32 | // Called when the login status is changed. |login_status| is the new status. |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 33 | virtual void OnLoginStatusChanged(LoginStatus login_status) {} |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 34 | |
xiyuan | 7ebbf7f | 2017-04-10 16:49:10 | [diff] [blame] | 35 | // Called when the lock state is changed. |locked| is the current lock stated. |
Xiyuan Xia | b64fd0a | 2017-04-13 17:53:14 | [diff] [blame] | 36 | virtual void OnLockStateChanged(bool locked) {} |
xiyuan | 7ebbf7f | 2017-04-10 16:49:10 | [diff] [blame] | 37 | |
Xiyuan Xia | 8d74137 | 2017-04-18 20:51:58 | [diff] [blame] | 38 | // Called when chrome is terminating. |
| 39 | virtual void OnChromeTerminating() {} |
| 40 | |
jamescook | c934896 | 2017-06-07 15:10:35 | [diff] [blame] | 41 | // Called when the limit becomes available and when it changes. |
| 42 | virtual void OnSessionLengthLimitChanged() {} |
| 43 | |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 44 | protected: |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 45 | virtual ~SessionObserver() {} |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | // A class to attach / detach an object as a session state observer. |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 49 | class ASH_EXPORT ScopedSessionObserver { |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 50 | public: |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 51 | explicit ScopedSessionObserver(SessionObserver* observer); |
| 52 | virtual ~ScopedSessionObserver(); |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 53 | |
| 54 | private: |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 55 | SessionObserver* const observer_; |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 56 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 57 | DISALLOW_COPY_AND_ASSIGN(ScopedSessionObserver); |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | } // namespace ash |
| 61 | |
Xiyuan Xia | 22b1a6c | 2017-04-18 22:46:01 | [diff] [blame] | 62 | #endif // ASH_SESSION_SESSION_OBSERVER_H_ |