Commit 1011eb52 authored by Rayan Kanso's avatar Rayan Kanso Committed by Commit Bot

Show correct display-mode value in TWAs.

All custom tab activities were defaulting to browser mode. This CL sets
the display mode to `standalone` where applicable. The BrowserControlsVisibilityDelegate
is used to make this decision, since even with standalone TWAs,
navigations and failed verifications can lead the tab to go back browser
mode.

Bug: 941749
Change-Id: I2454f708dd6d99660513eac8353d3497eb9829d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1826887Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703293}
parent 193ddf44
......@@ -39,6 +39,7 @@ import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams;
import org.chromium.chrome.browser.tabmodel.document.TabDelegate;
import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.chrome.browser.util.UrlUtilities;
import org.chromium.chrome.browser.webapps.WebDisplayMode;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.common.ResourceRequestBody;
import org.chromium.ui.mojom.WindowOpenDisposition;
......@@ -151,15 +152,18 @@ public class CustomTabDelegateFactory implements TabDelegateFactory {
extends ActivityTabWebContentsDelegateAndroid {
private final MultiWindowUtils mMultiWindowUtils;
private final boolean mShouldEnableEmbeddedMediaExperience;
private final boolean mIsTrustedWebActivity;
/**
* See {@link TabWebContentsDelegateAndroid}.
*/
public CustomTabWebContentsDelegate(Tab tab, ChromeActivity activity,
MultiWindowUtils multiWindowUtils, boolean shouldEnableEmbeddedMediaExperience) {
MultiWindowUtils multiWindowUtils, boolean shouldEnableEmbeddedMediaExperience,
boolean isTrustedWebActivity) {
super(tab, activity);
mMultiWindowUtils = multiWindowUtils;
mShouldEnableEmbeddedMediaExperience = shouldEnableEmbeddedMediaExperience;
mIsTrustedWebActivity = isTrustedWebActivity;
}
@Override
......@@ -203,12 +207,17 @@ public class CustomTabDelegateFactory implements TabDelegateFactory {
super.openNewTab(url, extraHeaders, postData, disposition, isRendererInitiated);
}
@Override
protected @WebDisplayMode int getDisplayMode() {
return mIsTrustedWebActivity ? WebDisplayMode.STANDALONE : WebDisplayMode.BROWSER;
}
}
private final ChromeActivity mActivity;
private final boolean mShouldHideBrowserControls;
private final boolean mIsOpenedByChrome;
private final boolean mShouldAllowAppBanners;
private final boolean mIsTrustedWebActivity;
private final boolean mShouldEnableEmbeddedMediaExperience;
private final BrowserControlsVisibilityDelegate mBrowserStateVisibilityDelegate;
private final ExternalAuthUtils mExternalAuthUtils;
......@@ -220,20 +229,20 @@ public class CustomTabDelegateFactory implements TabDelegateFactory {
* @param activity {@link ChromeActivity} instance.
* @param shouldHideBrowserControls Whether or not the browser controls may auto-hide.
* @param isOpenedByChrome Whether the CustomTab was originally opened by Chrome.
* @param shouldAllowAppBanners Whether app install banners can be shown.
* @param isTrustedWebActivity Whether the CustomTab is a TWA.
* @param shouldEnableEmbeddedMediaExperience Whether embedded media experience is enabled.
* @param visibilityDelegate The delegate that handles browser control visibility associated
* with browser actions (as opposed to tab state).
*/
private CustomTabDelegateFactory(ChromeActivity activity, boolean shouldHideBrowserControls,
boolean isOpenedByChrome, boolean shouldAllowAppBanners,
boolean isOpenedByChrome, boolean isTrustedWebActivity,
boolean shouldEnableEmbeddedMediaExperience,
BrowserControlsVisibilityDelegate visibilityDelegate, ExternalAuthUtils authUtils,
MultiWindowUtils multiWindowUtils) {
mActivity = activity;
mShouldHideBrowserControls = shouldHideBrowserControls;
mIsOpenedByChrome = isOpenedByChrome;
mShouldAllowAppBanners = shouldAllowAppBanners;
mIsTrustedWebActivity = isTrustedWebActivity;
mShouldEnableEmbeddedMediaExperience = shouldEnableEmbeddedMediaExperience;
mBrowserStateVisibilityDelegate = visibilityDelegate;
mExternalAuthUtils = authUtils;
......@@ -248,7 +257,7 @@ public class CustomTabDelegateFactory implements TabDelegateFactory {
// Don't show an app install banner for the user of a Trusted Web Activity - they've already
// got an app installed!
this(activity, intentDataProvider.shouldEnableUrlBarHiding(),
intentDataProvider.isOpenedByChrome(), !intentDataProvider.isTrustedWebActivity(),
intentDataProvider.isOpenedByChrome(), intentDataProvider.isTrustedWebActivity(),
intentDataProvider.shouldEnableEmbeddedMediaExperience(), visibilityDelegate,
authUtils, multiWindowUtils);
}
......@@ -281,8 +290,8 @@ public class CustomTabDelegateFactory implements TabDelegateFactory {
@Override
public TabWebContentsDelegateAndroid createWebContentsDelegate(Tab tab) {
return new CustomTabWebContentsDelegate(
tab, mActivity, mMultiWindowUtils, mShouldEnableEmbeddedMediaExperience);
return new CustomTabWebContentsDelegate(tab, mActivity, mMultiWindowUtils,
mShouldEnableEmbeddedMediaExperience, mIsTrustedWebActivity);
}
@Override
......@@ -304,7 +313,7 @@ public class CustomTabDelegateFactory implements TabDelegateFactory {
@Override
public boolean canShowAppBanners() {
return mShouldAllowAppBanners;
return !mIsTrustedWebActivity;
}
/**
......
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