Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java |
| index 393aba6c96bf6928e16868bc8f961663ac019066..acbf146bf9146712e4fc29f7641b0eb479cc03a3 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java |
| @@ -84,6 +84,7 @@ public class VrShellDelegate { |
| private boolean mRequestedWebVR; |
| private long mLastVRExit; |
| private boolean mListeningForWebVrActivate; |
| + private boolean mListeningForWebVrActivateBeforePause; |
| public VrShellDelegate(ChromeTabbedActivity activity) { |
| mActivity = activity; |
| @@ -149,10 +150,14 @@ public class VrShellDelegate { |
| public void enterVRFromIntent(Intent intent) { |
| if (!mVrAvailable) return; |
| assert isVrIntent(intent); |
| - if (mListeningForWebVrActivate && !mRequestedWebVR) { |
| + if (mListeningForWebVrActivateBeforePause && !mRequestedWebVR) { |
| nativeDisplayActivate(mNativeVrShellDelegate); |
| return; |
| } |
| + if (!mListeningForWebVrActivateBeforePause && !mRequestedWebVR && !isVrShellEnabled()) { |
|
mthiesse
2016/11/30 22:03:32
nit: add a comment about why we have to do this.
bshe
2016/11/30 23:10:12
Done.
|
| + mVrDaydreamApi.launchVrHomescreen(); |
| + return; |
| + } |
| if (enterVR()) { |
| if (mRequestedWebVR) nativeSetPresentResult(mNativeVrShellDelegate, true); |
| } else { |
| @@ -277,7 +282,7 @@ public class VrShellDelegate { |
| */ |
| public void maybeResumeVR() { |
| if (!mVrAvailable) return; |
| - if (isVrShellEnabled() || mListeningForWebVrActivate) { |
| + if (isVrShellEnabled() || mListeningForWebVrActivateBeforePause) { |
| registerDaydreamIntent(); |
| } |
| // If this is still set, it means the user backed out of the DON flow, and we won't be |
| @@ -323,6 +328,14 @@ public class VrShellDelegate { |
| if (!mVrAvailable) return; |
| unregisterDaydreamIntent(); |
| + // When the active web page has a vrdisplayactivate event handler, |
| + // mListeningForWebVrActivate should be set to true, which means a vrdisplayactive event |
| + // should be fired once DON flow finished. However, DON flow will pause our activity, which |
| + // makes the active page becomes invisible. And the event fires before the active page |
| + // becomes visible again after DON finished. So here we remember the value of |
| + // mListeningForWebVrActivity before pause and use this value to decide if vrdisplayactivate |
| + // event should be dispatched in enterVRFromIntent. |
| + mListeningForWebVrActivateBeforePause = mListeningForWebVrActivate; |
| if (mNonPresentingGvrContext != null) { |
| mNonPresentingGvrContext.pause(); |
| } |