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 <map> |
| 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 class AcceleratorRegistrarImpl : public mus::mojom::AcceleratorRegistrar { |
| 28 public: |
| 29 using DestroyCallback = base::Callback<void(AcceleratorRegistrarImpl*)>; |
| 30 AcceleratorRegistrarImpl(mus::mojom::WindowTreeHost* host, |
| 31 uint32_t accelerator_namespace, |
| 32 mojo::InterfaceRequest<AcceleratorRegistrar> request, |
| 33 const DestroyCallback& destroy_callback); |
| 34 |
| 35 bool OwnsAccelerator(uint32_t accelerator_id) const; |
| 36 void ProcessAccelerator(uint32_t accelerator_id, mus::mojom::EventPtr event); |
| 37 |
| 38 private: |
| 39 ~AcceleratorRegistrarImpl() override; |
| 40 |
| 41 uint32_t ComputeAcceleratorId(uint32_t accelerator_id) const; |
| 42 void OnBindingGone(); |
| 43 void OnHandlerGone(uint32_t accelerator_id); |
| 44 |
| 45 // mus::mojom::AcceleratorRegistrar: |
| 46 void AddAccelerator(uint32_t accelerator_id, |
| 47 mus::mojom::EventMatcherPtr matcher, |
| 48 mus::mojom::AcceleratorHandlerPtr handler, |
| 49 const AddAcceleratorCallback& callback) override; |
| 50 void RemoveAccelerator(uint32_t accelerator_id) override; |
| 51 |
| 52 mus::mojom::WindowTreeHost* host_; |
| 53 uint32_t accelerator_namespace_; |
| 54 mojo::Binding<AcceleratorRegistrar> binding_; |
| 55 std::map<uint32_t, mus::mojom::AcceleratorHandlerPtr> accelerator_handlers_; |
| 56 DestroyCallback destroy_callback_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarImpl); |
| 59 }; |
| 60 |
| 61 } // namespace wm |
| 62 } // namespace mash |
| 63 |
| 64 #endif // MASH_WM_ACCELERATOR_REGISTRAR_IMPL_H_ |
OLD | NEW |