| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/android/vr_shell/vr_input_manager.h" | 5 #include "chrome/browser/android/vr_shell/vr_input_manager.h" |
| 6 | 6 |
| 7 #include "base/task_runner_util.h" | 7 #include "base/task_runner_util.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/render_widget_host.h" | 9 #include "content/public/browser/render_widget_host.h" |
| 10 #include "content/public/browser/render_widget_host_view.h" | 10 #include "content/public/browser/render_widget_host_view.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 float y) { | 23 float y) { |
| 24 WebGestureEvent result(type, WebInputEvent::NoModifiers, time); | 24 WebGestureEvent result(type, WebInputEvent::NoModifiers, time); |
| 25 result.x = x; | 25 result.x = x; |
| 26 result.y = y; | 26 result.y = y; |
| 27 result.sourceDevice = blink::WebGestureDeviceTouchpad; | 27 result.sourceDevice = blink::WebGestureDeviceTouchpad; |
| 28 return result; | 28 return result; |
| 29 } | 29 } |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 VrInputManager::VrInputManager(content::WebContents* web_contents) | 32 VrInputManager::VrInputManager(content::WebContents* web_contents) |
| 33 : web_contents_(web_contents), | 33 : web_contents_(web_contents) { |
| 34 weak_ptr_factory_(this) { | |
| 35 } | 34 } |
| 36 | 35 |
| 37 VrInputManager::~VrInputManager() = default; | 36 VrInputManager::~VrInputManager() = default; |
| 38 | 37 |
| 39 base::WeakPtr<VrInputManager> VrInputManager::GetWeakPtr() { | |
| 40 return weak_ptr_factory_.GetWeakPtr(); | |
| 41 } | |
| 42 | |
| 43 void VrInputManager::ProcessUpdatedGesture( | 38 void VrInputManager::ProcessUpdatedGesture( |
| 44 std::unique_ptr<blink::WebInputEvent> event) { | 39 std::unique_ptr<blink::WebInputEvent> event) { |
| 45 if (WebInputEvent::isMouseEventType(event->type())) { | 40 if (WebInputEvent::isMouseEventType(event->type())) { |
| 46 ForwardMouseEvent(static_cast<const blink::WebMouseEvent&>(*event)); | 41 ForwardMouseEvent(static_cast<const blink::WebMouseEvent&>(*event)); |
| 47 } else { | 42 } else { |
| 48 SendGesture(static_cast<const blink::WebGestureEvent&>(*event)); | 43 SendGesture(static_cast<const blink::WebGestureEvent&>(*event)); |
| 49 } | 44 } |
| 50 } | 45 } |
| 51 | 46 |
| 52 void VrInputManager::SendGesture(const WebGestureEvent& gesture) { | 47 void VrInputManager::SendGesture(const WebGestureEvent& gesture) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 78 const blink::WebMouseEvent& mouse_event) { | 73 const blink::WebMouseEvent& mouse_event) { |
| 79 if (!web_contents_->GetRenderWidgetHostView()) | 74 if (!web_contents_->GetRenderWidgetHostView()) |
| 80 return; | 75 return; |
| 81 content::RenderWidgetHost* rwh = | 76 content::RenderWidgetHost* rwh = |
| 82 web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(); | 77 web_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost(); |
| 83 if (rwh) | 78 if (rwh) |
| 84 rwh->ForwardMouseEvent(mouse_event); | 79 rwh->ForwardMouseEvent(mouse_event); |
| 85 } | 80 } |
| 86 | 81 |
| 87 } // namespace vr_shell | 82 } // namespace vr_shell |
| OLD | NEW |