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

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

Issue 2821433003: Fix auto-presentation on headset insertion (Closed)
Patch Set: Add comment Created 3 years, 8 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 | no next file » | 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/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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698