Commit 80510be8 authored by bshe's avatar bshe Committed by Commit Bot

Show DOFF instead of non VR content

non VR content includes:
1. 2D Dialog for external navigation request while in incognito mode
2. external 2D app


Bug: 739778, 740742
Change-Id: Idd1de302a1412a1815b6d64fc7db5ac6b8a458ed
Reviewed-on: https://chromium-review.googlesource.com/563883Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Biao She <bshe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485942}
parent 9eef0593
...@@ -11,6 +11,7 @@ import org.chromium.chrome.R; ...@@ -11,6 +11,7 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.AppHooks; import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.datausage.DataUseTabUIManager; import org.chromium.chrome.browser.datausage.DataUseTabUIManager;
import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl;
import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler; import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler;
import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler.OverrideUrlLoadingResult; import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler.OverrideUrlLoadingResult;
import org.chromium.chrome.browser.externalnav.ExternalNavigationParams; import org.chromium.chrome.browser.externalnav.ExternalNavigationParams;
...@@ -50,6 +51,14 @@ public class InterceptNavigationDelegateImpl implements InterceptNavigationDeleg ...@@ -50,6 +51,14 @@ public class InterceptNavigationDelegateImpl implements InterceptNavigationDeleg
this(new ExternalNavigationHandler(tab), tab); this(new ExternalNavigationHandler(tab), tab);
} }
/**
* Constructs a new instance of {@link InterceptNavigationDelegateImpl} with the given
* {@link ExternalNavigationDelegate}.
*/
public InterceptNavigationDelegateImpl(ExternalNavigationDelegateImpl delegate, Tab tab) {
this(new ExternalNavigationHandler(delegate), tab);
}
/** /**
* Constructs a new instance of {@link InterceptNavigationDelegateImpl} with the given * Constructs a new instance of {@link InterceptNavigationDelegateImpl} with the given
* {@link ExternalNavigationHandler}. * {@link ExternalNavigationHandler}.
......
...@@ -2794,8 +2794,7 @@ public class Tab ...@@ -2794,8 +2794,7 @@ public class Tab
/** /**
* See {@link #mInterceptNavigationDelegate}. * See {@link #mInterceptNavigationDelegate}.
*/ */
@VisibleForTesting public void setInterceptNavigationDelegate(InterceptNavigationDelegateImpl delegate) {
protected void setInterceptNavigationDelegate(InterceptNavigationDelegateImpl delegate) {
mInterceptNavigationDelegate = delegate; mInterceptNavigationDelegate = delegate;
nativeSetInterceptNavigationDelegate(mNativeTabAndroid, delegate); nativeSetInterceptNavigationDelegate(mNativeTabAndroid, delegate);
} }
......
// 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.content.Intent;
import org.chromium.chrome.browser.externalnav.ExternalNavigationDelegateImpl;
import org.chromium.chrome.browser.tab.Tab;
/**
* A custom external navigation delegate that show DOFF instead of sending intent to external app.
*/
public class VrExternalNavigationDelegate extends ExternalNavigationDelegateImpl {
public VrExternalNavigationDelegate(Tab tab) {
super(tab);
}
@Override
public void startActivity(Intent intent, boolean proxy) {
VrShellDelegate.showDoffAndExitVr(false);
}
@Override
public boolean startActivityIfNeeded(Intent intent, boolean proxy) {
return false;
}
@Override
public void startIncognitoIntent(Intent intent, String referrerUrl, String fallbackUrl, Tab tab,
boolean needsToCloseTab, boolean proxy) {
VrShellDelegate.showDoffAndExitVr(false);
}
@Override
public void startFileIntent(
Intent intent, String referrerUrl, Tab tab, boolean needsToCloseTab) {
VrShellDelegate.showDoffAndExitVr(false);
}
}
...@@ -363,6 +363,11 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -363,6 +363,11 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
} }
} }
public static void showDoffAndExitVr(boolean optional) {
assert sInstance != null;
sInstance.showDoffAndExitVrInternal(optional);
}
@CalledByNative @CalledByNative
private static VrShellDelegate getInstance() { private static VrShellDelegate getInstance() {
Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
...@@ -1145,7 +1150,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -1145,7 +1150,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
mShouldShowPageInfo = false; mShouldShowPageInfo = false;
} }
/* package */ void showDoffAndExitVr(boolean optional) { private void showDoffAndExitVrInternal(boolean optional) {
if (mShowingDaydreamDoff) return; if (mShowingDaydreamDoff) return;
if (showDoff(optional)) return; if (showDoff(optional)) return;
shutdownVr(true /* disableVrMode */, false /* canReenter */, true /* stayingInChrome */); shutdownVr(true /* disableVrMode */, false /* canReenter */, true /* stayingInChrome */);
...@@ -1153,7 +1158,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -1153,7 +1158,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
/* package */ void onUnhandledPageInfo() { /* package */ void onUnhandledPageInfo() {
mShouldShowPageInfo = true; mShouldShowPageInfo = true;
showDoffAndExitVr(true); showDoffAndExitVrInternal(true);
} }
/* package */ void exitCct() { /* package */ void exitCct() {
......
...@@ -35,6 +35,7 @@ import org.chromium.chrome.browser.NativePage; ...@@ -35,6 +35,7 @@ import org.chromium.chrome.browser.NativePage;
import org.chromium.chrome.browser.UrlConstants; import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.tab.EmptyTabObserver; import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabObserver; import org.chromium.chrome.browser.tab.TabObserver;
import org.chromium.chrome.browser.tab.TabRedirectHandler; import org.chromium.chrome.browser.tab.TabRedirectHandler;
...@@ -87,6 +88,7 @@ public class VrShellImpl ...@@ -87,6 +88,7 @@ public class VrShellImpl
private final ChromeActivity mActivity; private final ChromeActivity mActivity;
private final VrShellDelegate mDelegate; private final VrShellDelegate mDelegate;
private final VirtualDisplayAndroid mContentVirtualDisplay; private final VirtualDisplayAndroid mContentVirtualDisplay;
private final InterceptNavigationDelegateImpl mInterceptNavigationDelegate;
private final TabRedirectHandler mTabRedirectHandler; private final TabRedirectHandler mTabRedirectHandler;
private final TabObserver mTabObserver; private final TabObserver mTabObserver;
private final TabModelSelectorObserver mTabModelSelectorObserver; private final TabModelSelectorObserver mTabModelSelectorObserver;
...@@ -111,6 +113,7 @@ public class VrShellImpl ...@@ -111,6 +113,7 @@ public class VrShellImpl
private boolean mReprojectedRendering; private boolean mReprojectedRendering;
private InterceptNavigationDelegateImpl mNonVrInterceptNavigationDelegate;
private TabRedirectHandler mNonVrTabRedirectHandler; private TabRedirectHandler mNonVrTabRedirectHandler;
private TabModelSelector mTabModelSelector; private TabModelSelector mTabModelSelector;
private float mLastContentWidth; private float mLastContentWidth;
...@@ -163,6 +166,10 @@ public class VrShellImpl ...@@ -163,6 +166,10 @@ public class VrShellImpl
mContentVirtualDisplay = VirtualDisplayAndroid.createVirtualDisplay(); mContentVirtualDisplay = VirtualDisplayAndroid.createVirtualDisplay();
mContentVirtualDisplay.setTo(primaryDisplay); mContentVirtualDisplay.setTo(primaryDisplay);
mInterceptNavigationDelegate = new InterceptNavigationDelegateImpl(
new VrExternalNavigationDelegate(mActivity.getActivityTab()),
mActivity.getActivityTab());
mTabRedirectHandler = new TabRedirectHandler(mActivity) { mTabRedirectHandler = new TabRedirectHandler(mActivity) {
@Override @Override
public boolean shouldStayInChrome(boolean hasExternalProtocol) { public boolean shouldStayInChrome(boolean hasExternalProtocol) {
...@@ -404,6 +411,8 @@ public class VrShellImpl ...@@ -404,6 +411,8 @@ public class VrShellImpl
} }
private void initializeTabForVR() { private void initializeTabForVR() {
mNonVrInterceptNavigationDelegate = mTab.getInterceptNavigationDelegate();
mTab.setInterceptNavigationDelegate(mInterceptNavigationDelegate);
// Make sure we are not redirecting to another app, i.e. out of VR mode. // Make sure we are not redirecting to another app, i.e. out of VR mode.
mNonVrTabRedirectHandler = mTab.getTabRedirectHandler(); mNonVrTabRedirectHandler = mTab.getTabRedirectHandler();
mTab.setTabRedirectHandler(mTabRedirectHandler); mTab.setTabRedirectHandler(mTabRedirectHandler);
...@@ -411,6 +420,7 @@ public class VrShellImpl ...@@ -411,6 +420,7 @@ public class VrShellImpl
} }
private void restoreTabFromVR() { private void restoreTabFromVR() {
mTab.setInterceptNavigationDelegate(mNonVrInterceptNavigationDelegate);
mTab.setTabRedirectHandler(mNonVrTabRedirectHandler); mTab.setTabRedirectHandler(mNonVrTabRedirectHandler);
mNonVrTabRedirectHandler = null; mNonVrTabRedirectHandler = null;
} }
...@@ -436,7 +446,7 @@ public class VrShellImpl ...@@ -436,7 +446,7 @@ public class VrShellImpl
// Exits VR, telling the user to remove their headset, and returning to Chromium. // Exits VR, telling the user to remove their headset, and returning to Chromium.
@CalledByNative @CalledByNative
public void forceExitVr() { public void forceExitVr() {
mDelegate.showDoffAndExitVr(false); VrShellDelegate.showDoffAndExitVr(false);
} }
// Called because showing PageInfo isn't supported in VR. This happens when the user clicks on // Called because showing PageInfo isn't supported in VR. This happens when the user clicks on
......
...@@ -1303,6 +1303,7 @@ chrome_vr_java_sources = [ ...@@ -1303,6 +1303,7 @@ chrome_vr_java_sources = [
"java/src/org/chromium/chrome/browser/vr_shell/VrCoreInfo.java", "java/src/org/chromium/chrome/browser/vr_shell/VrCoreInfo.java",
"java/src/org/chromium/chrome/browser/vr_shell/VrCoreVersionCheckerImpl.java", "java/src/org/chromium/chrome/browser/vr_shell/VrCoreVersionCheckerImpl.java",
"java/src/org/chromium/chrome/browser/vr_shell/VrDaydreamApiImpl.java", "java/src/org/chromium/chrome/browser/vr_shell/VrDaydreamApiImpl.java",
"java/src/org/chromium/chrome/browser/vr_shell/VrExternalNavigationDelegate.java",
"java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java", "java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java",
"java/src/org/chromium/chrome/browser/vr_shell/VrWindowAndroid.java", "java/src/org/chromium/chrome/browser/vr_shell/VrWindowAndroid.java",
"java/src/org/chromium/chrome/browser/vr_shell/OnDispatchTouchEventCallback.java", "java/src/org/chromium/chrome/browser/vr_shell/OnDispatchTouchEventCallback.java",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment