blob: 554273addc7a0ebcf7374277c802bd07f9b451cd [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
James Cookb0bf8e82017-04-09 17:01:4441 protected:
Xiyuan Xia22b1a6c2017-04-18 22:46:0142 virtual ~SessionObserver() {}
James Cookb0bf8e82017-04-09 17:01:4443};
44
45// A class to attach / detach an object as a session state observer.
Xiyuan Xia22b1a6c2017-04-18 22:46:0146class ASH_EXPORT ScopedSessionObserver {
James Cookb0bf8e82017-04-09 17:01:4447 public:
Xiyuan Xia22b1a6c2017-04-18 22:46:0148 explicit ScopedSessionObserver(SessionObserver* observer);
49 virtual ~ScopedSessionObserver();
James Cookb0bf8e82017-04-09 17:01:4450
51 private:
Xiyuan Xia22b1a6c2017-04-18 22:46:0152 SessionObserver* const observer_;
James Cookb0bf8e82017-04-09 17:01:4453
Xiyuan Xia22b1a6c2017-04-18 22:46:0154 DISALLOW_COPY_AND_ASSIGN(ScopedSessionObserver);
James Cookb0bf8e82017-04-09 17:01:4455};
56
57} // namespace ash
58
Xiyuan Xia22b1a6c2017-04-18 22:46:0159#endif // ASH_SESSION_SESSION_OBSERVER_H_