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

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

Issue 2301633002: Refactor Vr activity into ChromeTabbedActivity. (Closed)
Patch Set: UiElements are now structs 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 59e7a9b0295e83fe90f8bef94c7b4da2057b1e45..430315ba541563110d5ccdc95960ea074ee32729 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");
}
@@ -594,9 +602,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
@@ -941,6 +955,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
mUndoBarPopupController = new UndoBarController(this, mTabModelSelectorImpl,
getSnackbarManager());
+
+ mVrShellDelegate = new VrShellDelegate(this, mContentContainer);
}
@Override
@@ -1121,6 +1137,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);
}
@@ -1158,6 +1176,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);
@@ -1375,6 +1395,10 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
mUndoBarPopupController = null;
}
+ if (mVrShellDelegate != null) {
+ mVrShellDelegate.destroyVrShell();
+ }
+
super.onDestroyInternal();
}
@@ -1570,4 +1594,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