| 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 #include "services/ui/input_manager/input_associate.h" | 5 #include "services/ui/input_manager/input_associate.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "mojo/public/cpp/bindings/interface_request.h" | 9 #include "mojo/public/cpp/bindings/interface_request.h" |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 input_dispatchers_.AddBinding( | 47 input_dispatchers_.AddBinding( |
| 48 new InputDispatcherImpl(this, view_tree_token.Pass()), | 48 new InputDispatcherImpl(this, view_tree_token.Pass()), |
| 49 mojo::MakeRequest<mojo::ui::InputDispatcher>(client_handle.Pass())); | 49 mojo::MakeRequest<mojo::ui::InputDispatcher>(client_handle.Pass())); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 void InputAssociate::SetListener(mojo::ui::ViewToken* view_token, | 53 void InputAssociate::SetListener(mojo::ui::ViewToken* view_token, |
| 54 mojo::ui::InputListenerPtr listener) { | 54 mojo::ui::InputListenerPtr listener) { |
| 55 // TODO(jeffbrown): This simple hack just hooks up the first listener | 55 // TODO(jeffbrown): This simple hack just hooks up the first listener |
| 56 // ever seen. | 56 // ever seen. |
| 57 listener_ = listener.Pass(); | 57 if (!listener_) |
| 58 listener_ = listener.Pass(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 void InputAssociate::DispatchEvent(mojo::ui::ViewTreeToken* view_tree_token, | 61 void InputAssociate::DispatchEvent(mojo::ui::ViewTreeToken* view_tree_token, |
| 61 mojo::EventPtr event) { | 62 mojo::EventPtr event) { |
| 62 if (listener_) | 63 if (listener_) |
| 63 listener_->OnEvent( | 64 listener_->OnEvent( |
| 64 event.Pass(), | 65 event.Pass(), |
| 65 base::Bind(&InputAssociate::OnEventFinished, base::Unretained(this))); | 66 base::Bind(&InputAssociate::OnEventFinished, base::Unretained(this))); |
| 66 } | 67 } |
| 67 | 68 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 92 DCHECK(view_tree_token_); | 93 DCHECK(view_tree_token_); |
| 93 } | 94 } |
| 94 | 95 |
| 95 InputAssociate::InputDispatcherImpl::~InputDispatcherImpl() {} | 96 InputAssociate::InputDispatcherImpl::~InputDispatcherImpl() {} |
| 96 | 97 |
| 97 void InputAssociate::InputDispatcherImpl::DispatchEvent(mojo::EventPtr event) { | 98 void InputAssociate::InputDispatcherImpl::DispatchEvent(mojo::EventPtr event) { |
| 98 associate_->DispatchEvent(view_tree_token_.get(), event.Pass()); | 99 associate_->DispatchEvent(view_tree_token_.get(), event.Pass()); |
| 99 } | 100 } |
| 100 | 101 |
| 101 } // namespace input_manager | 102 } // namespace input_manager |
| OLD | NEW |