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

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

Issue 2727873002: Implement lazy initialization for VrShellDelegate (Closed)
Patch Set: Add comments + Fix test file Created 3 years, 10 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 72953632b6831547c65aa076d4d81870469ed646..1547af72fc7c68a1ca6980e4c9857eb82e4910f1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
@@ -238,8 +238,6 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
// Time at which an intent was received and handled.
private long mIntentHandlingTimeMs;
- private VrShellDelegate mVrShellDelegate;
-
private class TabbedAssistStatusHandler extends AssistStatusHandler {
public TabbedAssistStatusHandler(Activity activity) {
super(activity);
@@ -256,6 +254,7 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
}
}
+ // TODO(mthiesse): Move VR control visibility handling into ChromeActivity. crbug.com/688611
private class TabbedModeBrowserControlsVisibilityDelegate
extends TabStateBrowserControlsVisibilityDelegate {
public TabbedModeBrowserControlsVisibilityDelegate(Tab tab) {
@@ -264,13 +263,13 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
@Override
public boolean isShowingBrowserControlsEnabled() {
- if (mVrShellDelegate.isInVR()) return false;
+ if (VrShellDelegate.isInVR()) return false;
return super.isShowingBrowserControlsEnabled();
}
@Override
public boolean isHidingBrowserControlsEnabled() {
- if (mVrShellDelegate.isInVR()) return true;
+ if (VrShellDelegate.isInVR()) return true;
return super.isHidingBrowserControlsEnabled();
}
}
@@ -312,7 +311,6 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
super.initializeCompositor();
mTabModelSelectorImpl.onNativeLibraryReady(getTabContentManager());
- mVrShellDelegate.onNativeLibraryReady();
mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSelectorImpl) {
@Override
@@ -486,6 +484,7 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
} else {
CookiesFetcher.restoreCookies(this);
}
+
StartupMetrics.getInstance().recordHistogram(false);
if (FeatureUtilities.isTabModelMergingEnabled()) {
@@ -499,7 +498,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
}
VideoPersister.getInstance().stopPersist(this);
- mVrShellDelegate.maybeResumeVR();
+ // TODO(mthiesse): Move this call into ChromeActivity. crbug.com/697694
+ VrShellDelegate.maybeResumeVR(this);
mLocaleManager.setSnackbarManager(getSnackbarManager());
mLocaleManager.startObservingPhoneChanges();
@@ -521,7 +521,6 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
public void onPauseWithNative() {
mTabModelSelectorImpl.commitAllTabClosures();
CookiesFetcher.persistCookies(this);
- mVrShellDelegate.maybePauseVR();
mLocaleManager.setSnackbarManager(null);
mLocaleManager.stopObservingPhoneChanges();
@@ -564,8 +563,9 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
if (CommandLine.getInstance().hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS)) {
handleDebugIntent(intent);
}
- if (mVrShellDelegate.isDaydreamVrIntent(intent)) {
- mVrShellDelegate.enterVRFromIntent(intent);
+ if (VrShellDelegate.isDaydreamVrIntent(intent)) {
+ // TODO(mthiesse): Move this into ChromeActivity. crbug.com/688611
+ VrShellDelegate.enterVRFromIntent(intent);
} else if (ShortcutHelper.isShowToastIntent(intent)) {
ShortcutHelper.showAddedToHomescreenToastFromIntent(intent);
}
@@ -735,10 +735,11 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
mIntentWithEffect = false;
if ((mIsOnFirstRun || getSavedInstanceState() == null) && intent != null) {
- if (mVrShellDelegate.isDaydreamVrIntent(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();
+ if (VrShellDelegate.isDaydreamVrIntent(intent)) {
+ // TODO(mthiesse): Improve startup when started from a VR intent.
+ // crbug.com/668541
+ // TODO(mthiesse): Move this into ChromeActivity. crbug.com/688611
+ VrShellDelegate.enterVRIfNecessary();
} else if (!mIntentHandler.shouldIgnoreIntent(intent)) {
mIntentWithEffect = mIntentHandler.onNewIntent(intent);
}
@@ -808,7 +809,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
}
return true;
} else if (requestCode == VrShellDelegate.EXIT_VR_RESULT) {
- mVrShellDelegate.onExitVRResult(resultCode);
+ // TODO(mthiesse): Move this into ChromeActivity. crbug.com/688611
+ VrShellDelegate.onExitVRResult(resultCode);
return true;
}
return false;
@@ -1090,8 +1092,6 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
mUndoBarPopupController = new UndoBarController(this, mTabModelSelectorImpl,
getSnackbarManager());
-
- mVrShellDelegate = new VrShellDelegate(this);
}
@Override
@@ -1326,7 +1326,7 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
if (!currentModel.isIncognito()) currentModel.openMostRecentlyClosedTab();
RecordUserAction.record("MobileTabClosedUndoShortCut");
} else if (id == R.id.enter_vr_id) {
- mVrShellDelegate.enterVRIfNecessary();
+ VrShellDelegate.enterVRIfNecessary();
} else if (id == R.id.content_suggestions_standalone_ui) {
ContentSuggestionsActivity.launch(this);
} else {
@@ -1367,8 +1367,6 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
if (!mUIInitialized) return false;
final Tab currentTab = getActivityTab();
- if (mVrShellDelegate.onBackPressed()) return true;
-
if (currentTab == null) {
recordBackPressedUma("currentTab is null", BACK_PRESSED_TAB_IS_NULL);
moveTaskToBack(true);
@@ -1580,10 +1578,6 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
mUndoBarPopupController = null;
}
- if (mVrShellDelegate != null) {
- mVrShellDelegate.destroyVrShell();
- }
-
super.onDestroyInternal();
}
@@ -1788,11 +1782,16 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
setMergedInstanceTaskId(getTaskId());
}
- // TODO(mthiesse): Toggle toolbar overlay, popups, etc.
- public void setUIVisibilityForVR(int visibility) {
- mControlContainer.setVisibility(visibility);
- getCompositorViewHolder().getSurfaceView().setVisibility(visibility);
- getCompositorViewHolder().setVisibility(visibility);
+ @Override
+ public void onEnterVR() {
+ super.onEnterVR();
+ mControlContainer.setVisibility(View.INVISIBLE);
+ }
+
+ @Override
+ public void onExitVR() {
+ super.onExitVR();
+ mControlContainer.setVisibility(View.VISIBLE);
}
/**
@@ -1814,10 +1813,6 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
}
}
- public VrShellDelegate getVrShellDelegate() {
- return mVrShellDelegate;
- }
-
@Override
protected ChromeFullscreenManager createFullscreenManager() {
return new ChromeFullscreenManager(this, FeatureUtilities.isChromeHomeEnabled());

Powered by Google App Engine
This is Rietveld 408576698