| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_ | 5 #ifndef ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_ |
| 6 #define ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_ | 6 #define ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "ash/mus/window_manager_observer.h" |
| 12 #include "base/callback.h" | 13 #include "base/callback.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" | 15 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" |
| 15 #include "mojo/public/cpp/bindings/binding_set.h" | 16 #include "mojo/public/cpp/bindings/binding_set.h" |
| 16 #include "mojo/public/cpp/bindings/strong_binding.h" | 17 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 namespace mus { | 20 namespace mus { |
| 20 | 21 |
| 21 class WindowManager; | 22 class WindowManager; |
| 22 | 23 |
| 23 // Manages AcceleratorHandlers from a particular AcceleratorRegistrar | 24 // Manages AcceleratorHandlers from a particular AcceleratorRegistrar |
| 24 // connection. This manages its own lifetime, and destroys itself when the | 25 // connection. This manages its own lifetime, and destroys itself when the |
| 25 // AcceleratorRegistrar and all its AcceleratorHandlers are disconnected. Upon | 26 // AcceleratorRegistrar and all its AcceleratorHandlers are disconnected. Upon |
| 26 // destruction, it calls the DestroyCallback. | 27 // destruction, it calls the DestroyCallback. |
| 27 class AcceleratorRegistrarImpl : public ::mus::mojom::AcceleratorRegistrar { | 28 class AcceleratorRegistrarImpl : public ::mus::mojom::AcceleratorRegistrar, |
| 29 public WindowManagerObserver { |
| 28 public: | 30 public: |
| 29 using DestroyCallback = base::Callback<void(AcceleratorRegistrarImpl*)>; | 31 using DestroyCallback = base::Callback<void(AcceleratorRegistrarImpl*)>; |
| 30 AcceleratorRegistrarImpl(WindowManager* window_manager, | 32 AcceleratorRegistrarImpl(WindowManager* window_manager, |
| 31 uint32_t accelerator_namespace, | 33 uint32_t accelerator_namespace, |
| 32 mojo::InterfaceRequest<AcceleratorRegistrar> request, | 34 mojo::InterfaceRequest<AcceleratorRegistrar> request, |
| 33 const DestroyCallback& destroy_callback); | 35 const DestroyCallback& destroy_callback); |
| 34 | 36 |
| 35 void Destroy(); | 37 void Destroy(); |
| 36 | 38 |
| 37 // Returns true if this AcceleratorRegistrar has an accelerator with the | 39 // Returns true if this AcceleratorRegistrar has an accelerator with the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 49 | 51 |
| 50 void RemoveAllAccelerators(); | 52 void RemoveAllAccelerators(); |
| 51 | 53 |
| 52 // ::mus::mojom::AcceleratorRegistrar: | 54 // ::mus::mojom::AcceleratorRegistrar: |
| 53 void SetHandler(::mus::mojom::AcceleratorHandlerPtr handler) override; | 55 void SetHandler(::mus::mojom::AcceleratorHandlerPtr handler) override; |
| 54 void AddAccelerator(uint32_t accelerator_id, | 56 void AddAccelerator(uint32_t accelerator_id, |
| 55 ::mus::mojom::EventMatcherPtr matcher, | 57 ::mus::mojom::EventMatcherPtr matcher, |
| 56 const AddAcceleratorCallback& callback) override; | 58 const AddAcceleratorCallback& callback) override; |
| 57 void RemoveAccelerator(uint32_t accelerator_id) override; | 59 void RemoveAccelerator(uint32_t accelerator_id) override; |
| 58 | 60 |
| 61 // WindowManagerObserver: |
| 62 void OnAccelerator(uint32_t id, const ui::Event& event) override; |
| 63 void OnWindowTreeClientDestroyed() override; |
| 64 |
| 59 WindowManager* window_manager_; | 65 WindowManager* window_manager_; |
| 60 ::mus::mojom::AcceleratorHandlerPtr accelerator_handler_; | 66 ::mus::mojom::AcceleratorHandlerPtr accelerator_handler_; |
| 61 mojo::Binding<AcceleratorRegistrar> binding_; | 67 mojo::Binding<AcceleratorRegistrar> binding_; |
| 62 uint32_t accelerator_namespace_; | 68 uint32_t accelerator_namespace_; |
| 63 std::set<uint32_t> accelerators_; | 69 std::set<uint32_t> accelerators_; |
| 64 DestroyCallback destroy_callback_; | 70 DestroyCallback destroy_callback_; |
| 65 | 71 |
| 66 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarImpl); | 72 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarImpl); |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 } // namespace mus | 75 } // namespace mus |
| 70 } // namespace ash | 76 } // namespace ash |
| 71 | 77 |
| 72 #endif // ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_ | 78 #endif // ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_ |
| OLD | NEW |