blob: 7d3495a34feec4a7abb8c91e0e08e76022a3234a [file] [log] [blame]
Xiaohui Chena8bced82015-02-27 10:35:26 -08001// Copyright 2015 The Chromium OS 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
5#ifndef DEBUGD_SRC_SESSION_MANAGER_PROXY_H_
6#define DEBUGD_SRC_SESSION_MANAGER_PROXY_H_
7
8#include <string>
9
10#include <base/macros.h>
Eric Carusocc7106c2017-04-27 14:22:42 -070011#include <base/memory/ref_counted.h>
12#include <base/memory/weak_ptr.h>
13#include <dbus/bus.h>
14
15namespace dbus {
16class ObjectProxy;
17class Signal;
18} // namespace dbus
Xiaohui Chena8bced82015-02-27 10:35:26 -080019
20namespace debugd {
21
22// Talks to Session Manager DBus interface. It also exposes
23// convenience method to enable Chrome remote debugging and listens to Session
24// Manager signal to ensure Chrome remote debugging is on when it is supposed
25// to be.
Eric Carusocc7106c2017-04-27 14:22:42 -070026class SessionManagerProxy {
Xiaohui Chena8bced82015-02-27 10:35:26 -080027 public:
Eric Carusocc7106c2017-04-27 14:22:42 -070028 explicit SessionManagerProxy(scoped_refptr<dbus::Bus> bus);
29 ~SessionManagerProxy() = default;
Xiaohui Chena8bced82015-02-27 10:35:26 -080030 // Sets up the proxy for Chrome remote debugging and tries to enable it.
31 void EnableChromeRemoteDebugging();
32
Eric Carusocc7106c2017-04-27 14:22:42 -070033 // Handler for LoginPromptVisible signal.
34 void OnLoginPromptVisible(dbus::Signal*);
35
Xiaohui Chena8bced82015-02-27 10:35:26 -080036 private:
37 // Tries to enable Chrome remote debugging.
38 void EnableChromeRemoteDebuggingInternal();
39
Eric Carusocc7106c2017-04-27 14:22:42 -070040 scoped_refptr<dbus::Bus> bus_;
41 dbus::ObjectProxy* proxy_; // weak, owned by |bus_|
42
Xiaohui Chena8bced82015-02-27 10:35:26 -080043 // Should the proxy try to enable Chrome remote debugging.
44 bool should_enable_chrome_remote_debugging_ = false;
45 // Whether Chrome remote debugging is already successfully enabled.
46 bool is_chrome_remote_debugging_enabled_ = false;
Xiaohui Chena8bced82015-02-27 10:35:26 -080047
Eric Carusocc7106c2017-04-27 14:22:42 -070048 base::WeakPtrFactory<SessionManagerProxy> weak_ptr_factory_;
49
Xiaohui Chena8bced82015-02-27 10:35:26 -080050 DISALLOW_COPY_AND_ASSIGN(SessionManagerProxy);
51};
52
53} // namespace debugd
54
55#endif // DEBUGD_SRC_SESSION_MANAGER_PROXY_H_