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 fc2dfc5e207677ec2afb5945c2435edbb3f7979f..161260e3df7b1390a4b97c072bc4fa331b8d05d7 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 |
@@ -140,8 +140,15 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
ChromeActivity activity = mTargetActivity.get(); |
if (activity == null) return; |
getInstance(activity).mDonSucceeded = true; |
- ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)) |
- .moveTaskToFront(activity.getTaskId(), 0); |
+ if (sInstance.mPaused) { |
+ ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)) |
+ .moveTaskToFront(activity.getTaskId(), 0); |
+ } else { |
+ // If a WebVR app calls requestPresent in response to the displayactivate event |
+ // after the DON flow completes, the DON flow is skipped, meaning our app won't be |
+ // paused when daydream fires our BroadcastReceiver, so onResume won't be called. |
+ sInstance.handleDonFlowSuccess(); |
+ } |
} |
/** |
@@ -613,12 +620,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
} |
if (mDonSucceeded) { |
- mDonSucceeded = false; |
- // If we fail to enter VR when we should have entered VR, return to the home screen. |
- if (!enterVrAfterDon()) { |
- maybeSetPresentResult(false); |
- mVrDaydreamApi.launchVrHomescreen(); |
- } |
+ handleDonFlowSuccess(); |
} else if (mRestoreOrientation != null) { |
// This means the user backed out of the DON flow, and we won't be entering VR. |
maybeSetPresentResult(false); |
@@ -626,6 +628,15 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, |
} |
} |
+ private void handleDonFlowSuccess() { |
+ mDonSucceeded = false; |
+ // If we fail to enter VR when we should have entered VR, return to the home screen. |
+ if (!enterVrAfterDon()) { |
+ maybeSetPresentResult(false); |
+ mVrDaydreamApi.launchVrHomescreen(); |
+ } |
+ } |
+ |
private void pauseVr() { |
mPaused = true; |
if (mVrSupportLevel == VR_NOT_AVAILABLE) return; |