blob: 9d9b6ed3846979d9642951dc98ad47cf42fa29a7 [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>
11#include <chromeos/dbus/service_constants.h>
12#include <dbus-c++/dbus.h>
13#include <session_manager/dbus_proxies/org.chromium.SessionManagerInterface.h>
14
15namespace debugd {
16
17// Talks to Session Manager DBus interface. It also exposes
18// convenience method to enable Chrome remote debugging and listens to Session
19// Manager signal to ensure Chrome remote debugging is on when it is supposed
20// to be.
21class SessionManagerProxy : public org::chromium::SessionManagerInterface_proxy,
22 public DBus::ObjectProxy {
23 public:
24 explicit SessionManagerProxy(DBus::Connection* connection)
25 : DBus::ObjectProxy(*connection,
26 login_manager::kSessionManagerServicePath,
27 login_manager::kSessionManagerServiceName) {}
28 ~SessionManagerProxy() override = default;
29 void LoginPromptVisible() override;
30 void SessionStateChanged(const std::string &state,
31 const std::string &user) override {};
32 void ScreenIsLocked() override {};
33 void ScreenIsUnlocked() override {};
34
35 // Sets up the proxy for Chrome remote debugging and tries to enable it.
36 void EnableChromeRemoteDebugging();
37
38 private:
39 // Tries to enable Chrome remote debugging.
40 void EnableChromeRemoteDebuggingInternal();
41
42 // Should the proxy try to enable Chrome remote debugging.
43 bool should_enable_chrome_remote_debugging_ = false;
44 // Whether Chrome remote debugging is already successfully enabled.
45 bool is_chrome_remote_debugging_enabled_ = false;
46
47 DISALLOW_COPY_AND_ASSIGN(SessionManagerProxy);
48};
49
50} // namespace debugd
51
52#endif // DEBUGD_SRC_SESSION_MANAGER_PROXY_H_