| 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 SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_ | 5 #ifndef SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_ |
| 6 #define SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_ | 6 #define SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "mojo/common/strong_binding_set.h" | 9 #include "mojo/common/strong_binding_set.h" |
| 10 #include "mojo/public/cpp/bindings/interface_handle.h" |
| 10 #include "mojo/services/ui/input/interfaces/input_connection.mojom.h" | 11 #include "mojo/services/ui/input/interfaces/input_connection.mojom.h" |
| 11 #include "mojo/services/ui/input/interfaces/input_dispatcher.mojom.h" | 12 #include "mojo/services/ui/input/interfaces/input_dispatcher.mojom.h" |
| 12 #include "mojo/services/ui/views/interfaces/view_associates.mojom.h" | 13 #include "mojo/services/ui/views/interfaces/view_associates.mojom.h" |
| 13 | 14 |
| 14 namespace input_manager { | 15 namespace input_manager { |
| 15 | 16 |
| 16 // InputManager's ViewAssociate interface implementation. | 17 // InputManager's ViewAssociate interface implementation. |
| 17 class InputAssociate : public mojo::ui::ViewAssociate { | 18 class InputAssociate : public mojo::ui::ViewAssociate { |
| 18 public: | 19 public: |
| 19 InputAssociate(); | 20 InputAssociate(); |
| 20 ~InputAssociate() override; | 21 ~InputAssociate() override; |
| 21 | 22 |
| 22 private: | 23 private: |
| 23 // InputConnection implementation. | 24 // InputConnection implementation. |
| 24 // Binds incoming requests to the relevant view token. | 25 // Binds incoming requests to the relevant view token. |
| 25 class InputConnectionImpl : public mojo::ui::InputConnection { | 26 class InputConnectionImpl : public mojo::ui::InputConnection { |
| 26 public: | 27 public: |
| 27 InputConnectionImpl(InputAssociate* associate, | 28 InputConnectionImpl(InputAssociate* associate, |
| 28 mojo::ui::ViewTokenPtr view_token); | 29 mojo::ui::ViewTokenPtr view_token); |
| 29 ~InputConnectionImpl() override; | 30 ~InputConnectionImpl() override; |
| 30 | 31 |
| 31 private: | 32 private: |
| 32 void SetListener(mojo::ui::InputListenerPtr listener) override; | 33 void SetListener( |
| 34 mojo::InterfaceHandle<mojo::ui::InputListener> listener) override; |
| 33 | 35 |
| 34 InputAssociate* const associate_; | 36 InputAssociate* const associate_; |
| 35 mojo::ui::ViewTokenPtr view_token_; | 37 mojo::ui::ViewTokenPtr view_token_; |
| 36 | 38 |
| 37 DISALLOW_COPY_AND_ASSIGN(InputConnectionImpl); | 39 DISALLOW_COPY_AND_ASSIGN(InputConnectionImpl); |
| 38 }; | 40 }; |
| 39 | 41 |
| 40 // InputDispatcher implementation. | 42 // InputDispatcher implementation. |
| 41 // Binds incoming requests to the relevant view token. | 43 // Binds incoming requests to the relevant view token. |
| 42 class InputDispatcherImpl : public mojo::ui::InputDispatcher { | 44 class InputDispatcherImpl : public mojo::ui::InputDispatcher { |
| 43 public: | 45 public: |
| 44 InputDispatcherImpl(InputAssociate* associate, | 46 InputDispatcherImpl(InputAssociate* associate, |
| 45 mojo::ui::ViewTreeTokenPtr view_tree_token); | 47 mojo::ui::ViewTreeTokenPtr view_tree_token); |
| 46 ~InputDispatcherImpl() override; | 48 ~InputDispatcherImpl() override; |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 void DispatchEvent(mojo::EventPtr event) override; | 51 void DispatchEvent(mojo::EventPtr event) override; |
| 50 | 52 |
| 51 InputAssociate* const associate_; | 53 InputAssociate* const associate_; |
| 52 mojo::ui::ViewTreeTokenPtr view_tree_token_; | 54 mojo::ui::ViewTreeTokenPtr view_tree_token_; |
| 53 | 55 |
| 54 DISALLOW_COPY_AND_ASSIGN(InputDispatcherImpl); | 56 DISALLOW_COPY_AND_ASSIGN(InputDispatcherImpl); |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 // |ViewAssociate|: | 59 // |ViewAssociate|: |
| 58 void Connect(mojo::ui::ViewInspectorPtr inspector, | 60 void Connect(mojo::InterfaceHandle<mojo::ui::ViewInspector> inspector, |
| 59 const ConnectCallback& callback) override; | 61 const ConnectCallback& callback) override; |
| 60 void ConnectToViewService( | 62 void ConnectToViewService( |
| 61 mojo::ui::ViewTokenPtr view_token, | 63 mojo::ui::ViewTokenPtr view_token, |
| 62 const mojo::String& service_name, | 64 const mojo::String& service_name, |
| 63 mojo::ScopedMessagePipeHandle client_handle) override; | 65 mojo::ScopedMessagePipeHandle client_handle) override; |
| 64 void ConnectToViewTreeService( | 66 void ConnectToViewTreeService( |
| 65 mojo::ui::ViewTreeTokenPtr view_tree_token, | 67 mojo::ui::ViewTreeTokenPtr view_tree_token, |
| 66 const mojo::String& service_name, | 68 const mojo::String& service_name, |
| 67 mojo::ScopedMessagePipeHandle client_handle) override; | 69 mojo::ScopedMessagePipeHandle client_handle) override; |
| 68 | 70 |
| 69 // Incoming service calls. | 71 // Incoming service calls. |
| 70 void SetListener(mojo::ui::ViewToken* view_token, | 72 void SetListener(mojo::ui::ViewToken* view_token, |
| 71 mojo::ui::InputListenerPtr listener); | 73 mojo::InterfaceHandle<mojo::ui::InputListener> listener); |
| 72 void DispatchEvent(mojo::ui::ViewTreeToken* view_tree_token, | 74 void DispatchEvent(mojo::ui::ViewTreeToken* view_tree_token, |
| 73 mojo::EventPtr event); | 75 mojo::EventPtr event); |
| 74 | 76 |
| 75 // Callbacks. | 77 // Callbacks. |
| 76 void OnEventFinished(bool handled); | 78 void OnEventFinished(bool handled); |
| 77 | 79 |
| 78 mojo::StrongBindingSet<mojo::ui::InputConnection> input_connections_; | 80 mojo::StrongBindingSet<mojo::ui::InputConnection> input_connections_; |
| 79 mojo::StrongBindingSet<mojo::ui::InputDispatcher> input_dispatchers_; | 81 mojo::StrongBindingSet<mojo::ui::InputDispatcher> input_dispatchers_; |
| 80 | 82 |
| 81 mojo::ui::InputListenerPtr listener_; | 83 mojo::ui::InputListenerPtr listener_; |
| 82 | 84 |
| 83 DISALLOW_COPY_AND_ASSIGN(InputAssociate); | 85 DISALLOW_COPY_AND_ASSIGN(InputAssociate); |
| 84 }; | 86 }; |
| 85 | 87 |
| 86 } // namespace input_manager | 88 } // namespace input_manager |
| 87 | 89 |
| 88 #endif // SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_ | 90 #endif // SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_ |
| OLD | NEW |