Commit 63b4c854 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Handle links on interstitial pages in ephemeral tab

This CL handles the following issues on intestitial pages
1 - The links for privacy, support etc will be open in a CCT. This is
accomplished by any time there is a request to open in new tab, we will use CCT.
2 - The link Back to Safety will go to the previous page. If there is
no previous page, i.e. previous page is NTP, the preview tab will be closed.

Bug: 1014689
Change-Id: I469fd4597800796bc1eaa47569012d9e937082c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1868094
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: default avatarDonn Denman <donnd@chromium.org>
Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711931}
parent 7f878343
......@@ -29,18 +29,18 @@ public class OverlayContentDelegate {
public void onMainFrameNavigation(
String url, boolean isExternalUrl, boolean isFailure, boolean isError) {}
/**
* Called when the URL is requested to be opened in a new tab.
* @param url The URL associated with this request.
*/
public void onOpenNewTabRequested(String url) {}
/**
* Called when a page title gets updated.
* @param title Title string
*/
public void onTitleUpdated(String title) {}
/*
* Called when the URL is requested to be opened in a new, separate tab.
* @param url The URL associated with this request.
*/
public void onOpenNewTabRequested(String url) {}
/**
* Called when content started loading in the panel.
* @param url The URL that is loading.
......
......@@ -19,6 +19,7 @@ import org.chromium.chrome.browser.compositor.bottombar.OverlayContentProgressOb
import org.chromium.chrome.browser.compositor.bottombar.OverlayPanelContent;
import org.chromium.chrome.browser.favicon.FaviconHelper;
import org.chromium.chrome.browser.favicon.FaviconUtils;
import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.ssl.SecurityStateModel;
import org.chromium.chrome.browser.tab.Tab;
......@@ -205,16 +206,31 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
* Observes the ephemeral tab web contents and loads the associated favicon.
*/
private class EphemeralTabPanelContentDelegate extends OverlayContentDelegate {
/** Whether the currently loaded page is an error (interstitial) page. */
private boolean mIsOnErrorPage;
private String mCurrentUrl;
@Override
public void onMainFrameLoadStarted(String url, boolean isExternalUrl) {
if (TextUtils.equals(mCurrentUrl, url)) return;
if (mIsOnErrorPage && NewTabPage.isNTPUrl(url)) {
mBottomSheetController.hideContent(mSheetContent, /* animate= */ true);
mCurrentUrl = null;
return;
}
mCurrentUrl = url;
mFaviconLoader.loadFavicon(url, (drawable) -> onFaviconAvailable(drawable));
}
@Override
public void onMainFrameNavigation(
String url, boolean isExternalUrl, boolean isFailure, boolean isError) {
mIsOnErrorPage = isError;
}
@Override
public void onSSLStateUpdated() {
if (mSheetContent == null) return;
......@@ -223,6 +239,12 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
mSheetContent.setSecurityIcon(getSecurityIconResource(securityLevel));
mSheetContent.updateURL(mPanelContent.getWebContents().getVisibleUrl());
}
@Override
public void onOpenNewTabRequested(String url) {
// We never open a separate tab when navigating in a preview tab.
getContent().getWebContents().getNavigationController().loadUrl(new LoadUrlParams(url));
}
}
/** Observes the ephemeral tab page load progress and updates the progress bar. */
......
......@@ -157,9 +157,6 @@ public class EphemeralTabPanel extends OverlayPanel {
@Override
public void onMainFrameNavigation(
String url, boolean isExternalUrl, boolean isFailure, boolean isError) {
// Force WebContents to be visible. URLs that are supposed to create a separate tab but
// ended up on the preview tab needs this.
getWebContents().onShow();
updateCaption();
mIsOnErrorPage = isError;
}
......@@ -176,8 +173,8 @@ public class EphemeralTabPanel extends OverlayPanel {
@Override
public void onOpenNewTabRequested(String url) {
// We never open a new tab when navigating in an overlay.
loadUrlInPanel(url);
// We never open a separate tab when navigating in an overlay.
getWebContents().getNavigationController().loadUrl(new LoadUrlParams(url));
requestPanelShow(StateChangeReason.CLICK);
}
}
......
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