Xiaohui Chen | a8bced8 | 2015-02-27 10:35:26 -0800 | [diff] [blame] | 1 | // 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 Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 11 | #include <base/memory/ref_counted.h> |
| 12 | #include <base/memory/weak_ptr.h> |
| 13 | #include <dbus/bus.h> |
| 14 | |
| 15 | namespace dbus { |
| 16 | class ObjectProxy; |
| 17 | class Signal; |
| 18 | } // namespace dbus |
Xiaohui Chen | a8bced8 | 2015-02-27 10:35:26 -0800 | [diff] [blame] | 19 | |
| 20 | namespace 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 Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 26 | class SessionManagerProxy { |
Xiaohui Chen | a8bced8 | 2015-02-27 10:35:26 -0800 | [diff] [blame] | 27 | public: |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 28 | explicit SessionManagerProxy(scoped_refptr<dbus::Bus> bus); |
| 29 | ~SessionManagerProxy() = default; |
Xiaohui Chen | a8bced8 | 2015-02-27 10:35:26 -0800 | [diff] [blame] | 30 | // Sets up the proxy for Chrome remote debugging and tries to enable it. |
| 31 | void EnableChromeRemoteDebugging(); |
| 32 | |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 33 | // Handler for LoginPromptVisible signal. |
| 34 | void OnLoginPromptVisible(dbus::Signal*); |
| 35 | |
Xiaohui Chen | a8bced8 | 2015-02-27 10:35:26 -0800 | [diff] [blame] | 36 | private: |
| 37 | // Tries to enable Chrome remote debugging. |
| 38 | void EnableChromeRemoteDebuggingInternal(); |
| 39 | |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 40 | scoped_refptr<dbus::Bus> bus_; |
| 41 | dbus::ObjectProxy* proxy_; // weak, owned by |bus_| |
| 42 | |
Xiaohui Chen | a8bced8 | 2015-02-27 10:35:26 -0800 | [diff] [blame] | 43 | // 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 Chen | a8bced8 | 2015-02-27 10:35:26 -0800 | [diff] [blame] | 47 | |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 48 | base::WeakPtrFactory<SessionManagerProxy> weak_ptr_factory_; |
| 49 | |
Xiaohui Chen | a8bced8 | 2015-02-27 10:35:26 -0800 | [diff] [blame] | 50 | DISALLOW_COPY_AND_ASSIGN(SessionManagerProxy); |
| 51 | }; |
| 52 | |
| 53 | } // namespace debugd |
| 54 | |
| 55 | #endif // DEBUGD_SRC_SESSION_MANAGER_PROXY_H_ |