Commit c0e15d75 authored by Yash Malik's avatar Yash Malik Committed by Commit Bot

[vr] Handle unsupported auto-present VR intents

1) Classify an intent as a VR intent only if the platform supports VR mode.
2) Return to Daydream home screen if VrShell is disabled. The splash screen
depends on VrShell features so the easiest thing to do is bail. This can only
happen if VrShell is manually disabled from chrome://flags and should be rare.

Bug: 
Change-Id: Ie14c164d6ac1c74de041e24073349c498df5f6a7
Reviewed-on: https://chromium-review.googlesource.com/572620Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Yash Malik <ymalik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487199}
parent df5364b9
...@@ -849,6 +849,15 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -849,6 +849,15 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
mAutopresentWebVr = true; mAutopresentWebVr = true;
} }
private void onAutopresentUnsupported() {
// Auto-presentation is unsupported, but we still need to remove the black overlay before we
// exit to Daydream so that the user doesn't see black when they come back to Chrome. The
// overlay will be removed when we get paused by Daydream.
assert !mInVr;
mNeedsAnimationCancel = false;
mVrDaydreamApi.launchVrHomescreen();
}
private void onVrIntent() { private void onVrIntent() {
// We assume that when we get a VR intent, we're in the headset. // We assume that when we get a VR intent, we're in the headset.
mNeedsAnimationCancel = true; mNeedsAnimationCancel = true;
...@@ -862,9 +871,13 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -862,9 +871,13 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
VrShellDelegate instance = getInstance(activity); VrShellDelegate instance = getInstance(activity);
if (instance == null) return; if (instance == null) return;
instance.onVrIntent(); instance.onVrIntent();
if (isTrustedDaydreamIntent(intent) if (isTrustedDaydreamIntent(intent)) {
&& ChromeFeatureList.isEnabled(ChromeFeatureList.WEBVR_AUTOPRESENT) if (!ChromeFeatureList.isEnabled(ChromeFeatureList.WEBVR_AUTOPRESENT)
&& activitySupportsAutopresentation(activity)) { || !activitySupportsPresentation(activity)
|| !isVrShellEnabled(instance.mVrSupportLevel)) {
instance.onAutopresentUnsupported();
return;
}
instance.onAutopresentIntent(); instance.onAutopresentIntent();
} }
} }
...@@ -900,7 +913,8 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -900,7 +913,8 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
* @return Whether or not the given intent is a VR-specific intent. * @return Whether or not the given intent is a VR-specific intent.
*/ */
public static boolean isVrIntent(Intent intent) { public static boolean isVrIntent(Intent intent) {
return IntentUtils.safeGetBooleanExtra(intent, DAYDREAM_VR_EXTRA, false); // For simplicity, we only return true here if VR is enabled on the platform.
return IntentUtils.safeGetBooleanExtra(intent, DAYDREAM_VR_EXTRA, false) && isVrEnabled();
} }
/* /*
...@@ -1101,6 +1115,8 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -1101,6 +1115,8 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
if (mInVr) mVSyncEstimator.pause(); if (mInVr) mVSyncEstimator.pause();
// TODO(ymalik): We should be able to remove this if we handle it for multi-window in
// {@link onMultiWindowModeChanged} since we're calling it in onStop.
if (!mInVr) cancelPendingVrEntry(); if (!mInVr) cancelPendingVrEntry();
// When the active web page has a vrdisplayactivate event handler, // When the active web page has a vrdisplayactivate event handler,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment