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

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

Issue 2694103006: Inject vr controller events into Android Native UI. (Closed)
Patch Set: autoformat Created 3 years, 10 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_shell.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc
index 974f167258de82f2deaad5885a55e2c0f81286ae..9cca2d58cc7443a049f8a5a25f1275fa2e74fb74 100644
--- a/chrome/browser/android/vr_shell/vr_shell.cc
+++ b/chrome/browser/android/vr_shell/vr_shell.cc
@@ -18,6 +18,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "chrome/browser/android/tab_android.h"
+#include "chrome/browser/android/vr_shell/android_ui_gesture_target.h"
#include "chrome/browser/android/vr_shell/ui_interface.h"
#include "chrome/browser/android/vr_shell/vr_compositor.h"
#include "chrome/browser/android/vr_shell/vr_gl_thread.h"
@@ -106,15 +107,19 @@ void VrShell::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
delete this;
}
-void VrShell::SwapContents(JNIEnv* env, const JavaParamRef<jobject>& obj,
- const JavaParamRef<jobject>& web_contents) {
+void VrShell::SwapContents(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& obj,
+ const JavaParamRef<jobject>& web_contents,
+ const JavaParamRef<jobject>& touch_event_synthesizer) {
content::WebContents* contents =
content::WebContents::FromJavaWebContents(web_contents);
- if (contents == main_contents_)
+ if (contents == main_contents_ &&
+ touch_event_synthesizer.obj() == j_motion_event_synthesizer_.obj())
return;
SetIsInVR(main_contents_, false);
-
+ j_motion_event_synthesizer_.Reset(env, touch_event_synthesizer);
main_contents_ = contents;
content_compositor_->SetLayer(main_contents_);
SetIsInVR(main_contents_, true);
@@ -122,6 +127,9 @@ void VrShell::SwapContents(JNIEnv* env, const JavaParamRef<jobject>& obj,
SetUiState();
if (!main_contents_) {
+ android_ui_gesture_target_ = base::MakeUnique<AndroidUiGestureTarget>(
+ j_motion_event_synthesizer_.obj(),
+ Java_VrShellImpl_getNativePageScrollRatio(env, j_vr_shell_.obj()));
content_input_manager_ = nullptr;
vr_web_contents_observer_ = nullptr;
metrics_helper_ = nullptr;
@@ -552,6 +560,8 @@ void VrShell::ProcessContentGesture(
std::unique_ptr<blink::WebInputEvent> event) {
if (content_input_manager_) {
content_input_manager_->ProcessUpdatedGesture(std::move(event));
+ } else if (android_ui_gesture_target_) {
+ android_ui_gesture_target_->DispatchWebInputEvent(std::move(event));
}
}

Powered by Google App Engine
This is Rietveld 408576698