-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsession_manager_proxy.h
58 lines (43 loc) · 1.79 KB
/
session_manager_proxy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FEDERATED_SESSION_MANAGER_PROXY_H_
#define FEDERATED_SESSION_MANAGER_PROXY_H_
#include <memory>
#include <string>
#include <base/memory/ref_counted.h>
#include <base/memory/weak_ptr.h>
#include <base/observer_list.h>
#include <dbus/bus.h>
#include <session_manager/dbus-proxies.h>
#include "federated/session_manager_observer_interface.h"
namespace federated {
// A proxy class that listens to DBus signals from the session manager and
// notifies a list of registered observers for events.
class SessionManagerProxy {
public:
explicit SessionManagerProxy(
std::unique_ptr<org::chromium::SessionManagerInterfaceProxyInterface>
proxy);
SessionManagerProxy(const SessionManagerProxy&) = delete;
SessionManagerProxy& operator=(const SessionManagerProxy&) = delete;
~SessionManagerProxy();
void AddObserver(SessionManagerObserverInterface* observer);
// Retrieves the session state immediately. Returns an empty string on error.
std::string RetrieveSessionState();
// Retrieves the sanitized username of the primary session.
std::string GetSanitizedUsername();
private:
// Handles the ScreenIsLocked DBus signal.
void OnScreenIsLocked();
// Handles the ScreenIsUnlocked DBus signal.
void OnScreenIsUnlocked();
// Handles the SessionStateChanged DBus signal.
void OnSessionStateChanged(const std::string& state);
const std::unique_ptr<org::chromium::SessionManagerInterfaceProxyInterface>
proxy_;
base::ObserverList<SessionManagerObserverInterface> observer_list_;
const base::WeakPtrFactory<SessionManagerProxy> weak_ptr_factory_;
};
} // namespace federated
#endif // FEDERATED_SESSION_MANAGER_PROXY_H_