| 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 231e66c2be535904305c99d43281b289ea842a9f..d824cb229fbfcf2d8b4d3b1e6ffeca0d7dec3bc4 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
|
| @@ -94,6 +94,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
|
|
|
| private static final String DAYDREAM_VR_EXTRA = "android.intent.extra.VR_LAUNCH";
|
| private static final String DAYDREAM_HOME_PACKAGE = "com.google.android.vr.home";
|
| + static final String VR_FRE_INTENT_EXTRA = "org.chromium.chrome.browser.vr_shell.VR_FRE";
|
|
|
| // Linter and formatter disagree on how the line below should be formatted.
|
| /* package */
|
| @@ -420,7 +421,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
|
| }
|
|
|
| @SuppressWarnings("unchecked")
|
| - private static VrClassesWrapper createVrClassesWrapper() {
|
| + /* package */ static VrClassesWrapper createVrClassesWrapper() {
|
| try {
|
| Class<? extends VrClassesWrapper> vrClassesBuilderClass =
|
| (Class<? extends VrClassesWrapper>) Class.forName(
|
| @@ -484,6 +485,13 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
|
| return ChromeFeatureList.isEnabled(ChromeFeatureList.VR_SHELL);
|
| }
|
|
|
| + /**
|
| + * @return Whether or not VR is supported on this platform.
|
| + */
|
| + private static boolean isVrEnabled() {
|
| + return getVrClassesWrapper() != null;
|
| + }
|
| +
|
| private class VSyncEstimator {
|
| private static final long NANOS_PER_SECOND = 1000000000;
|
|
|
| @@ -869,6 +877,20 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
|
| }
|
| }
|
|
|
| + /**
|
| + * @return An intent that will launch a VR activity that will prompt the
|
| + * user to take off their headset and foward the freIntent to the standard
|
| + * 2D FRE activity.
|
| + */
|
| + public static Intent setupVrFreIntent(Context context, Intent freIntent) {
|
| + if (!isVrEnabled()) return freIntent;
|
| + Intent intent = new Intent();
|
| + intent.setClassName(context, VrFirstRunActivity.class.getName());
|
| + intent.putExtra(VR_FRE_INTENT_EXTRA, new Intent(freIntent));
|
| + intent.putExtra(DAYDREAM_VR_EXTRA, true);
|
| + return intent;
|
| + }
|
| +
|
| /**
|
| * @return Whether or not the given intent is a VR-specific intent.
|
| */
|
| @@ -876,6 +898,13 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
|
| return IntentUtils.safeGetBooleanExtra(intent, DAYDREAM_VR_EXTRA, false);
|
| }
|
|
|
| + /*
|
| + * Remove VR-specific extras from the given intent.
|
| + */
|
| + public static void removeVrExtras(Intent intent) {
|
| + intent.removeExtra(DAYDREAM_VR_EXTRA);
|
| + }
|
| +
|
| /**
|
| * @return Options that a VR-specific Chrome activity should be launched with.
|
| */
|
|
|