blob: f87a0544c459d712aa8878e7287edd400b005e3e [file] [log] [blame]
James Cookb0bf8e82017-04-09 17:01:441// 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 Xia22b1a6c2017-04-18 22:46:015#ifndef ASH_SESSION_SESSION_OBSERVER_H_
6#define ASH_SESSION_SESSION_OBSERVER_H_
James Cookb0bf8e82017-04-09 17:01:447
8#include "ash/ash_export.h"
9#include "base/macros.h"
10#include "components/session_manager/session_manager_types.h"
11
12class AccountId;
13
14namespace ash {
15
16enum class LoginStatus;
17
Xiyuan Xia22b1a6c2017-04-18 22:46:0118class ASH_EXPORT SessionObserver {
James Cookb0bf8e82017-04-09 17:01:4419 public:
Xiyuan Xiab64fd0a2017-04-13 17:53:1420 // Called when the active user session has changed.
21 virtual void OnActiveUserSessionChanged(const AccountId& account_id) {}
James Cookb0bf8e82017-04-09 17:01:4422
Xiyuan Xiab64fd0a2017-04-13 17:53:1423 // Called when a user session gets added to the existing session.
24 virtual void OnUserSessionAdded(const AccountId& account_id) {}
James Cookb0bf8e82017-04-09 17:01:4425
26 // Called when a user session is updated, such as avatar change.
Xiyuan Xiab64fd0a2017-04-13 17:53:1427 virtual void OnUserSessionUpdated(const AccountId& account_id) {}
James Cookb0bf8e82017-04-09 17:01:4428
29 // Called when the session state is changed.
Xiyuan Xiab64fd0a2017-04-13 17:53:1430 virtual void OnSessionStateChanged(session_manager::SessionState state) {}
James Cookb0bf8e82017-04-09 17:01:4431
32 // Called when the login status is changed. |login_status| is the new status.
Xiyuan Xiab64fd0a2017-04-13 17:53:1433 virtual void OnLoginStatusChanged(LoginStatus login_status) {}
James Cookb0bf8e82017-04-09 17:01:4434
xiyuan7ebbf7f2017-04-10 16:49:1035 // Called when the lock state is changed. |locked| is the current lock stated.
Xiyuan Xiab64fd0a2017-04-13 17:53:1436 virtual void OnLockStateChanged(bool locked) {}
xiyuan7ebbf7f2017-04-10 16:49:1037
Xiyuan Xia8d741372017-04-18 20:51:5838 // Called when chrome is terminating.
39 virtual void OnChromeTerminating() {}
40
jamescookc9348962017-06-07 15:10:3541 // Called when the limit becomes available and when it changes.
42 virtual void OnSessionLengthLimitChanged() {}
43
James Cookb0bf8e82017-04-09 17:01:4444 protected:
Xiyuan Xia22b1a6c2017-04-18 22:46:0145 virtual ~SessionObserver() {}
James Cookb0bf8e82017-04-09 17:01:4446};
47
48// A class to attach / detach an object as a session state observer.
Xiyuan Xia22b1a6c2017-04-18 22:46:0149class ASH_EXPORT ScopedSessionObserver {
James Cookb0bf8e82017-04-09 17:01:4450 public:
Xiyuan Xia22b1a6c2017-04-18 22:46:0151 explicit ScopedSessionObserver(SessionObserver* observer);
52 virtual ~ScopedSessionObserver();
James Cookb0bf8e82017-04-09 17:01:4453
54 private:
Xiyuan Xia22b1a6c2017-04-18 22:46:0155 SessionObserver* const observer_;
James Cookb0bf8e82017-04-09 17:01:4456
Xiyuan Xia22b1a6c2017-04-18 22:46:0157 DISALLOW_COPY_AND_ASSIGN(ScopedSessionObserver);
James Cookb0bf8e82017-04-09 17:01:4458};
59
60} // namespace ash
61
Xiyuan Xia22b1a6c2017-04-18 22:46:0162#endif // ASH_SESSION_SESSION_OBSERVER_H_