OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium 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 MASH_WM_ACCELERATOR_REGISTRAR_IMPL_H_ |
| 6 #define MASH_WM_ACCELERATOR_REGISTRAR_IMPL_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/macros.h" |
| 12 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" |
| 13 #include "mojo/common/weak_binding_set.h" |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 15 |
| 16 namespace mus { |
| 17 namespace mojom { |
| 18 class WindowTreeHost; |
| 19 } |
| 20 } |
| 21 |
| 22 namespace mash { |
| 23 namespace wm { |
| 24 |
| 25 class WindowManagerApplication; |
| 26 |
| 27 // Manages AcceleratorHandlers from a particular AcceleratorRegistrar |
| 28 // connection. This manages its own lifetime, and destroys itself when the |
| 29 // AcceleratorRegistrar and all its AcceleratorHandlers are disconnected. Upon |
| 30 // destruction, it calls the DestroyCallback. |
| 31 class AcceleratorRegistrarImpl : public mus::mojom::AcceleratorRegistrar { |
| 32 public: |
| 33 using DestroyCallback = base::Callback<void(AcceleratorRegistrarImpl*)>; |
| 34 AcceleratorRegistrarImpl(mus::mojom::WindowTreeHost* host, |
| 35 uint32_t accelerator_namespace, |
| 36 mojo::InterfaceRequest<AcceleratorRegistrar> request, |
| 37 const DestroyCallback& destroy_callback); |
| 38 |
| 39 bool OwnsAccelerator(uint32_t accelerator_id) const; |
| 40 void ProcessAccelerator(uint32_t accelerator_id, mus::mojom::EventPtr event); |
| 41 |
| 42 private: |
| 43 ~AcceleratorRegistrarImpl() override; |
| 44 |
| 45 uint32_t ComputeAcceleratorId(uint32_t accelerator_id) const; |
| 46 void OnBindingGone(); |
| 47 void OnHandlerGone(); |
| 48 |
| 49 // mus::mojom::AcceleratorRegistrar: |
| 50 void SetHandler(mus::mojom::AcceleratorHandlerPtr handler) override; |
| 51 void AddAccelerator(uint32_t accelerator_id, |
| 52 mus::mojom::EventMatcherPtr matcher, |
| 53 const AddAcceleratorCallback& callback) override; |
| 54 void RemoveAccelerator(uint32_t accelerator_id) override; |
| 55 |
| 56 mus::mojom::WindowTreeHost* host_; |
| 57 mus::mojom::AcceleratorHandlerPtr accelerator_handler_; |
| 58 mojo::Binding<AcceleratorRegistrar> binding_; |
| 59 uint32_t accelerator_namespace_; |
| 60 std::set<uint32_t> accelerator_ids_; |
| 61 DestroyCallback destroy_callback_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarImpl); |
| 64 }; |
| 65 |
| 66 } // namespace wm |
| 67 } // namespace mash |
| 68 |
| 69 #endif // MASH_WM_ACCELERATOR_REGISTRAR_IMPL_H_ |
OLD | NEW |