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

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

Issue 2301633002: Refactor Vr activity into ChromeTabbedActivity. (Closed)
Patch Set: Address comments and rebase Created 4 years, 3 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/ChromeTabbedActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
index e4516704b844dbf988ed4a45b330130a1d1772ca..62ce11d43cf8e9ca78e552c86fe184a6348501f5 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
@@ -95,6 +95,7 @@ import org.chromium.chrome.browser.tabmodel.TabWindowManager;
import org.chromium.chrome.browser.toolbar.ToolbarControlContainer;
import org.chromium.chrome.browser.util.FeatureUtilities;
import org.chromium.chrome.browser.util.IntentUtils;
+import org.chromium.chrome.browser.vr_shell.VrShellDelegate;
import org.chromium.chrome.browser.widget.emptybackground.EmptyBackgroundViewWrapper;
import org.chromium.chrome.browser.widget.findinpage.FindToolbarManager;
import org.chromium.content.browser.ContentVideoView;
@@ -215,6 +216,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
// Time at which an intent was received and handled.
private long mIntentHandlingTimeMs = 0;
+ private VrShellDelegate mVrShellDelegate;
+
private class TabbedAssistStatusHandler extends AssistStatusHandler {
public TabbedAssistStatusHandler(Activity activity) {
super(activity);
@@ -367,12 +370,14 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
}
mMergeTabsOnResume = false;
}
+ if (mVrShellDelegate.isInVR()) mVrShellDelegate.resumeVR();
}
@Override
public void onPauseWithNative() {
mTabModelSelectorImpl.commitAllTabClosures();
CookiesFetcher.persistCookies(this);
+ if (mVrShellDelegate.isInVR()) mVrShellDelegate.pauseVR();
super.onPauseWithNative();
}
@@ -411,6 +416,9 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
if (CommandLine.getInstance().hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS)) {
handleDebugIntent(intent);
}
+ if (!mVrShellDelegate.isInVR() && mVrShellDelegate.isVrIntent(intent)) {
+ mVrShellDelegate.enterVRIfNecessary();
+ }
} finally {
TraceEvent.end("ChromeTabbedActivity.onNewIntentWithNative");
}
@@ -593,9 +601,15 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
}
mIntentWithEffect = false;
- if ((mIsOnFirstRun || getSavedInstanceState() == null) && intent != null
- && !mIntentHandler.shouldIgnoreIntent(ChromeTabbedActivity.this, intent)) {
- mIntentWithEffect = mIntentHandler.onNewIntent(ChromeTabbedActivity.this, intent);
+ if ((mIsOnFirstRun || getSavedInstanceState() == null) && intent != null) {
+ if (mVrShellDelegate.isVrIntent(intent)) {
+ // TODO(mthiesse): Improve startup when started from a VR intent. Right now
+ // we launch out of VR, partially load out of VR, then switch into VR.
+ mVrShellDelegate.enterVRIfNecessary();
+ } else if (!mIntentHandler.shouldIgnoreIntent(ChromeTabbedActivity.this, intent)) {
+ mIntentWithEffect = mIntentHandler.onNewIntent(ChromeTabbedActivity.this,
+ intent);
+ }
}
mCreatedTabOnStartup = getCurrentTabModel().getCount() > 0
@@ -940,6 +954,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
mUndoBarPopupController = new UndoBarController(this, mTabModelSelectorImpl,
getSnackbarManager());
+
+ mVrShellDelegate = new VrShellDelegate(this, mContentContainer);
}
@Override
@@ -1118,6 +1134,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
TabModel currentModel = mTabModelSelectorImpl.getCurrentModel();
if (!currentModel.isIncognito()) currentModel.openMostRecentlyClosedTab();
RecordUserAction.record("MobileTabClosedUndoShortCut");
+ } else if (id == R.id.enter_vr_id) {
+ mVrShellDelegate.enterVRIfNecessary();
} else {
return super.onMenuOrKeyboardAction(id, fromMenu);
}
@@ -1155,6 +1173,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
if (!mUIInitialized) return false;
final Tab currentTab = getActivityTab();
+ if (mVrShellDelegate.exitVRIfNecessary()) return true;
+
if (currentTab == null) {
recordBackPressedUma("currentTab is null", BACK_PRESSED_TAB_IS_NULL);
moveTaskToBack(true);
@@ -1370,6 +1390,10 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
mUndoBarPopupController = null;
}
+ if (mVrShellDelegate != null) {
+ mVrShellDelegate.destroyVrShell();
+ }
+
super.onDestroyInternal();
}
@@ -1565,4 +1589,12 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
RecordUserAction.record("Android.MergeState.Live");
mTabModelSelectorImpl.mergeState();
}
+
+ /**
+ * See VrShellDelegate#isVrShellEnabled()
+ */
+ @Override
+ public boolean isVrShellEnabled() {
+ return mVrShellDelegate.isVrShellEnabled();
+ }
}

Powered by Google App Engine
This is Rietveld 408576698