Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 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 CROS_DISKS_SESSION_MANAGER_PROXY_H_ |
| 6 | #define CROS_DISKS_SESSION_MANAGER_PROXY_H_ |
| 7 | |
Ben Chan | 445852f | 2017-10-02 23:00:16 -0700 | [diff] [blame] | 8 | #include <string> |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 9 | |
Ben Chan | 445852f | 2017-10-02 23:00:16 -0700 | [diff] [blame] | 10 | #include <base/memory/ref_counted.h> |
| 11 | #include <base/memory/weak_ptr.h> |
Ben Chan | 89cf29e | 2011-08-10 13:11:05 -0700 | [diff] [blame] | 12 | #include <base/observer_list.h> |
Ben Chan | 445852f | 2017-10-02 23:00:16 -0700 | [diff] [blame] | 13 | #include <dbus/bus.h> |
| 14 | #include <session_manager/dbus-proxies.h> |
| 15 | |
| 16 | #include "cros-disks/session_manager_observer_interface.h" |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 17 | |
| 18 | namespace cros_disks { |
| 19 | |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 20 | // A proxy class that listens to DBus signals from the session manager and |
Ben Chan | 89cf29e | 2011-08-10 13:11:05 -0700 | [diff] [blame] | 21 | // notifies a list of registered observers for events. |
Ben Chan | 445852f | 2017-10-02 23:00:16 -0700 | [diff] [blame] | 22 | class SessionManagerProxy { |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 23 | public: |
Ben Chan | 445852f | 2017-10-02 23:00:16 -0700 | [diff] [blame] | 24 | explicit SessionManagerProxy(scoped_refptr<dbus::Bus> bus); |
Qijiang Fan | 6bc59e1 | 2020-11-11 02:51:06 +0900 | [diff] [blame] | 25 | SessionManagerProxy(const SessionManagerProxy&) = delete; |
| 26 | SessionManagerProxy& operator=(const SessionManagerProxy&) = delete; |
Ben Chan | 5512355 | 2014-08-24 16:22:16 -0700 | [diff] [blame] | 27 | ~SessionManagerProxy() = default; |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 28 | |
Ben Chan | 89cf29e | 2011-08-10 13:11:05 -0700 | [diff] [blame] | 29 | void AddObserver(SessionManagerObserverInterface* observer); |
| 30 | |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 31 | private: |
Ben Chan | 5988f29 | 2012-09-18 08:32:42 -0700 | [diff] [blame] | 32 | // Handles the ScreenIsLocked DBus signal. |
Ben Chan | 445852f | 2017-10-02 23:00:16 -0700 | [diff] [blame] | 33 | void OnScreenIsLocked(); |
Ben Chan | 5988f29 | 2012-09-18 08:32:42 -0700 | [diff] [blame] | 34 | |
| 35 | // Handles the ScreenIsUnlocked DBus signal. |
Ben Chan | 445852f | 2017-10-02 23:00:16 -0700 | [diff] [blame] | 36 | void OnScreenIsUnlocked(); |
Ben Chan | 5988f29 | 2012-09-18 08:32:42 -0700 | [diff] [blame] | 37 | |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 38 | // Handles the SessionStateChanged DBus signal. |
Ben Chan | 445852f | 2017-10-02 23:00:16 -0700 | [diff] [blame] | 39 | void OnSessionStateChanged(const std::string& state); |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 40 | |
Ben Chan | 445852f | 2017-10-02 23:00:16 -0700 | [diff] [blame] | 41 | org::chromium::SessionManagerInterfaceProxy proxy_; |
Alex Vakulenko | 5e5accd | 2015-06-15 12:53:22 -0700 | [diff] [blame] | 42 | base::ObserverList<SessionManagerObserverInterface> observer_list_; |
Ben Chan | 445852f | 2017-10-02 23:00:16 -0700 | [diff] [blame] | 43 | base::WeakPtrFactory<SessionManagerProxy> weak_ptr_factory_; |
Ben Chan | 6e72692 | 2011-06-28 15:54:32 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | } // namespace cros_disks |
| 47 | |
| 48 | #endif // CROS_DISKS_SESSION_MANAGER_PROXY_H_ |