Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6293)

Unified Diff: chrome/browser/android/vr_shell/vr_input_manager.cc

Issue 2380323003: Refactorings to vr controller code. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/vr_input_manager.cc
diff --git a/chrome/browser/android/vr_shell/vr_input_manager.cc b/chrome/browser/android/vr_shell/vr_input_manager.cc
index 94c08ad04e40696ee04b7c6948098eb75d73953e..969535513dfd730992f2e39b483527c144dce2fb 100644
--- a/chrome/browser/android/vr_shell/vr_input_manager.cc
+++ b/chrome/browser/android/vr_shell/vr_input_manager.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "base/android/scoped_java_ref.h"
+#include "base/task_runner_util.h"
#include "chrome/browser/android/vr_shell/vr_input_manager.h"
+#include "content/public/browser/browser_thread.h"
using blink::WebGestureEvent;
using blink::WebMouseEvent;
@@ -18,6 +20,35 @@ VrInputManager::VrInputManager(content::WebContents* web_contents)
VrInputManager::~VrInputManager() {}
+void VrInputManager::ProcessUpdatedGesture(VrGesture gesture) {
+ if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&VrInputManager::SendGesture, this, gesture));
+ } else {
+ SendGesture(gesture);
+ }
+}
+
+void VrInputManager::SendGesture(VrGesture gesture) {
+ int64_t event_time = gesture.start_time;
+ int64_t event_time_milliseconds = static_cast<int64_t>(event_time / 1000000);
+
+ if (gesture.type == WebInputEvent::GestureScrollBegin ||
+ gesture.type == WebInputEvent::GestureScrollUpdate ||
+ gesture.type == WebInputEvent::GestureScrollEnd) {
+ SendScrollEvent(event_time_milliseconds, 0.0f, 0.0f,
+ gesture.details.scroll.delta.x,
+ gesture.details.scroll.delta.y, gesture.type);
+ } else if (gesture.type == WebInputEvent::GestureTap) {
+ SendClickEvent(event_time_milliseconds, gesture.details.buttons.pos.x,
+ gesture.details.buttons.pos.y);
+ } else if (gesture.type == WebInputEvent::MouseMove) {
+ SendMouseMoveEvent(event_time_milliseconds, gesture.details.move.delta.x,
+ gesture.details.move.delta.y, gesture.details.move.type);
+ }
+}
+
void VrInputManager::ScrollBegin(int64_t time_ms,
float x,
float y,

Powered by Google App Engine
This is Rietveld 408576698