| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/native_viewport/native_viewport_impl.h" | 5 #include "services/native_viewport/native_viewport_impl.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 void NativeViewportImpl::GetContextProvider( | 87 void NativeViewportImpl::GetContextProvider( |
| 88 mojo::InterfaceRequest<mojo::ContextProvider> request) { | 88 mojo::InterfaceRequest<mojo::ContextProvider> request) { |
| 89 context_provider_.Bind(request.Pass()); | 89 context_provider_.Bind(request.Pass()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void NativeViewportImpl::SetEventDispatcher( | 92 void NativeViewportImpl::SetEventDispatcher( |
| 93 mojo::NativeViewportEventDispatcherPtr dispatcher) { | 93 mojo::NativeViewportEventDispatcherPtr dispatcher) { |
| 94 event_dispatcher_ = dispatcher.Pass(); | 94 event_dispatcher_ = dispatcher.Pass(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void NativeViewportImpl::SetKeyEventDispatcher( |
| 98 mojo::NativeViewportEventDispatcherPtr dispatcher) { |
| 99 key_event_dispatcher_ = dispatcher.Pass(); |
| 100 } |
| 101 |
| 97 void NativeViewportImpl::OnMetricsChanged(mojo::ViewportMetricsPtr metrics) { | 102 void NativeViewportImpl::OnMetricsChanged(mojo::ViewportMetricsPtr metrics) { |
| 98 if (metrics_->Equals(*metrics)) | 103 if (metrics_->Equals(*metrics)) |
| 99 return; | 104 return; |
| 100 | 105 |
| 101 metrics_ = metrics.Pass(); | 106 metrics_ = metrics.Pass(); |
| 102 sent_metrics_ = false; | 107 sent_metrics_ = false; |
| 103 | 108 |
| 104 if (!metrics_callback_.is_null()) { | 109 if (!metrics_callback_.is_null()) { |
| 105 metrics_callback_.Run(metrics_.Clone()); | 110 metrics_callback_.Run(metrics_.Clone()); |
| 106 metrics_callback_.reset(); | 111 metrics_callback_.reset(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 147 } |
| 143 | 148 |
| 144 case mojo::EventType::POINTER_CANCEL: | 149 case mojo::EventType::POINTER_CANCEL: |
| 145 pointers_waiting_on_ack_.clear(); | 150 pointers_waiting_on_ack_.clear(); |
| 146 break; | 151 break; |
| 147 | 152 |
| 148 case mojo::EventType::POINTER_UP: | 153 case mojo::EventType::POINTER_UP: |
| 149 pointers_waiting_on_ack_.erase(event->pointer_data->pointer_id); | 154 pointers_waiting_on_ack_.erase(event->pointer_data->pointer_id); |
| 150 break; | 155 break; |
| 151 | 156 |
| 157 case mojo::EventType::KEY_PRESSED: |
| 158 case mojo::EventType::KEY_RELEASED: |
| 159 if (key_event_dispatcher_.get()) |
| 160 key_event_dispatcher_->OnEvent(event.Pass(), callback); |
| 161 return false; |
| 162 break; |
| 163 |
| 152 default: | 164 default: |
| 153 break; | 165 break; |
| 154 } | 166 } |
| 155 | 167 |
| 156 event_dispatcher_->OnEvent(event.Pass(), callback); | 168 event_dispatcher_->OnEvent(event.Pass(), callback); |
| 157 return false; | 169 return false; |
| 158 } | 170 } |
| 159 | 171 |
| 160 void NativeViewportImpl::OnDestroyed() { | 172 void NativeViewportImpl::OnDestroyed() { |
| 161 delete this; | 173 delete this; |
| 162 } | 174 } |
| 163 | 175 |
| 164 void NativeViewportImpl::AckEvent(int32 pointer_id) { | 176 void NativeViewportImpl::AckEvent(int32 pointer_id) { |
| 165 pointers_waiting_on_ack_.erase(pointer_id); | 177 pointers_waiting_on_ack_.erase(pointer_id); |
| 166 } | 178 } |
| 167 | 179 |
| 168 } // namespace native_viewport | 180 } // namespace native_viewport |
| OLD | NEW |