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

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

Issue 2980453002: [vr] Show DOFF when starting Chrome with a VR intent without FRE completion (Closed)
Patch Set: rebase Created 3 years, 5 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
Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrFirstRunActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrFirstRunActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrFirstRunActivity.java
new file mode 100644
index 0000000000000000000000000000000000000000..3496ae76917b9381ef6cdc31a400edfe3ee250d6
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrFirstRunActivity.java
@@ -0,0 +1,68 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.vr_shell;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+
+import org.chromium.chrome.browser.util.IntentUtils;
+
+/**
+ * Handles the DOFF flow when Chrome is launched in VR mode and the FRE is not complete. This is
+ * needed because VrCore doesn't allow calling DOFF from a non-active VR activity (b/63435686), so
+ * we can't do it from {@link FirstRunActivity}. The android:enableVrMode attribute in the manifest
+ * makes this a VR activity allowing us to call DOFF before triggering the standard 2D FRE flow.
+ * This should be removed when b/63435686 is fixed.
+ */
+public class VrFirstRunActivity extends Activity {
+ private static final long SHOW_DOFF_TIMEOUT_MS = 500;
+
+ private VrDaydreamApi mApi;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ assert VrShellDelegate.isVrIntent(getIntent());
+ VrClassesWrapper wrapper = VrShellDelegate.createVrClassesWrapper();
+ if (wrapper != null) {
mthiesse 2017/07/12 14:44:46 nit: if (wrapper == null) { showFre(); return;
ymalik 2017/07/12 15:33:03 Done.
+ wrapper.setVrModeEnabled(this, true);
mthiesse 2017/07/12 14:44:46 Please add a comment on why we appear to call setV
ymalik 2017/07/12 15:33:03 Done.
+ mApi = wrapper.createVrDaydreamApi(this);
+ if (mApi.isDaydreamCurrentViewer()) {
mthiesse 2017/07/12 14:44:46 nit: if (!mApi.isDaydreamCurrentViewer()) { show
ymalik 2017/07/12 15:33:03 Done.
+ // Show DOFF with a timeout so that this activity has enough time to be the active
+ // VR app.
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ mApi.exitFromVr(VrShellDelegate.EXIT_VR_RESULT, new Intent());
+ }
+ }, SHOW_DOFF_TIMEOUT_MS);
+ return;
+ }
+ }
+ showFre();
+ finish();
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
+ if (requestCode == VrShellDelegate.EXIT_VR_RESULT) {
mthiesse 2017/07/12 14:44:46 nit: if (requestCode != VrShellDelegate.EXIT_VR_RE
ymalik 2017/07/12 15:33:03 Done.
+ if (resultCode != Activity.RESULT_OK) {
+ mApi.launchVrHomescreen();
+ } else {
+ showFre();
+ }
+ finish();
+ }
+ }
+
+ private void showFre() {
+ // Start the actual 2D FRE if the user successfully exited VR.
+ Intent freIntent = (Intent) IntentUtils.safeGetParcelableExtra(
+ getIntent(), VrShellDelegate.VR_FRE_INTENT_EXTRA);
+ IntentUtils.safeStartActivity(this, freIntent);
mthiesse 2017/07/12 14:44:46 nit: call finish() from showFre(), then you can cl
ymalik 2017/07/12 15:33:03 Done.
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698