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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java

Issue 2879973002: Expose Gamepad API instance for Cardboard button (Closed)
Patch Set: fix crash in tests Created 3 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
index 8cad215216aa204435b6e495fc6ef353172ef254..c73f5bd5d3d460f57548499828a7f24903f334eb 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java
@@ -20,13 +20,11 @@ import android.widget.FrameLayout.LayoutParams;
import com.google.vr.ndk.base.AndroidCompat;
import com.google.vr.ndk.base.GvrLayout;
-import org.chromium.base.CommandLine;
import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.browser.ChromeActivity;
-import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.NativePage;
import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.tab.EmptyTabObserver;
@@ -229,9 +227,12 @@ public class VrShellImpl
@Override
@SuppressLint("ClickableViewAccessibility")
public boolean onTouch(View v, MotionEvent event) {
- if (!CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_VR_SHELL_DEV)
- && event.getActionMasked() == MotionEvent.ACTION_DOWN) {
- nativeOnTriggerEvent(mNativeVrShell);
+ if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ nativeOnTriggerEvent(mNativeVrShell, true);
+ return true;
+ } else if (event.getActionMasked() == MotionEvent.ACTION_UP
+ || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
+ nativeOnTriggerEvent(mNativeVrShell, false);
return true;
}
return false;
@@ -413,25 +414,6 @@ public class VrShellImpl
}
@Override
- public boolean dispatchTouchEvent(MotionEvent event) {
- // Normally, touch event is dispatched to presentation view only if the phone is paired with
- // a Cardboard viewer. This is annoying when we just want to quickly verify a Cardboard
- // behavior. This allows us to trigger cardboard trigger event without pair to a Cardboard.
- boolean cardboardTriggered = false;
- if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_VR_SHELL_DEV)
- && event.getActionMasked() == MotionEvent.ACTION_DOWN) {
- nativeOnTriggerEvent(mNativeVrShell);
- cardboardTriggered = true;
- }
- boolean parentConsumed = super.dispatchTouchEvent(event);
- if (mOnDispatchTouchEventForTesting != null) {
- mOnDispatchTouchEventForTesting.onDispatchTouchEvent(
- parentConsumed, cardboardTriggered);
- }
- return parentConsumed;
- }
-
- @Override
public void onResume() {
super.onResume();
if (mNativeVrShell != 0) {
@@ -626,7 +608,7 @@ public class VrShellImpl
private native void nativeSwapContents(
long nativeVrShell, WebContents webContents, MotionEventSynthesizer eventSynthesizer);
private native void nativeDestroy(long nativeVrShell);
- private native void nativeOnTriggerEvent(long nativeVrShell);
+ private native void nativeOnTriggerEvent(long nativeVrShell, boolean touched);
private native void nativeOnPause(long nativeVrShell);
private native void nativeOnResume(long nativeVrShell);
private native void nativeOnLoadProgressChanged(long nativeVrShell, double progress);
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698