OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #include "services/ui/input_manager/input_connection_impl.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/logging.h" |
| 9 #include "services/ui/input_manager/input_associate.h" |
| 10 |
| 11 namespace input_manager { |
| 12 |
| 13 InputConnectionImpl::InputConnectionImpl( |
| 14 InputAssociate* associate, |
| 15 mojo::ui::ViewTokenPtr view_token, |
| 16 mojo::InterfaceRequest<mojo::ui::InputConnection> request) |
| 17 : associate_(associate), |
| 18 view_token_(view_token.Pass()), |
| 19 binding_(this, request.Pass()) { |
| 20 DCHECK(associate_); |
| 21 DCHECK(view_token_); |
| 22 binding_.set_connection_error_handler( |
| 23 base::Bind(&InputAssociate::OnInputConnectionDied, |
| 24 base::Unretained(associate_), base::Unretained(this))); |
| 25 } |
| 26 |
| 27 InputConnectionImpl::~InputConnectionImpl() {} |
| 28 |
| 29 void InputConnectionImpl::DeliverEvent(mojo::EventPtr event) { |
| 30 // TODO(jeffbrown): Pass the result back up the stack and handle errors. |
| 31 if (!listener_) { |
| 32 DVLOG(1) << "DeliverEvent: dropped because there was no listener"; |
| 33 return; |
| 34 } |
| 35 |
| 36 listener_->OnEvent(event.Pass(), |
| 37 base::Bind(&InputConnectionImpl::OnEventFinished, |
| 38 base::Unretained(this))); |
| 39 } |
| 40 |
| 41 void InputConnectionImpl::OnEventFinished(bool handled) { |
| 42 // TODO: this code doesn't really belong here |
| 43 } |
| 44 |
| 45 void InputConnectionImpl::SetListener( |
| 46 mojo::InterfaceHandle<mojo::ui::InputListener> listener) { |
| 47 listener_ = mojo::ui::InputListenerPtr::Create(std::move(listener)); |
| 48 } |
| 49 |
| 50 } // namespace input_manager |
OLD | NEW |