Commit 91253b09 authored by Peter E Conn's avatar Peter E Conn Committed by Commit Bot

🛃 Add pending URL to BrowserSessionContentHandler.

Bug: 806749
Change-Id: If2867aceffe6c3ea9463eb1f5c36715d981ba97b
Reviewed-on: https://chromium-review.googlesource.com/891222Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Commit-Queue: Peter Conn <peconn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532431}
parent b4d0890a
......@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.browserservices;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Bitmap;
import android.support.annotation.Nullable;
import android.support.customtabs.CustomTabsSessionToken;
import android.widget.RemoteViews;
......@@ -55,5 +56,10 @@ public interface BrowserSessionContentHandler {
/**
* @return The current url being displayed to the user.
*/
String getCurrentUrl();
@Nullable String getCurrentUrl();
/**
* @return The url of a pending navigation, if any.
*/
@Nullable String getPendingUrl();
}
......@@ -110,6 +110,15 @@ public class BrowserSessionContentUtils {
return sActiveContentHandler.getCurrentUrl();
}
/**
* @return The pending url for the page about to be displayed using the current {@link
* BrowserSessionContentHandler}.
*/
public static String getPendingUrlForActiveBrowserSession() {
if (sActiveContentHandler == null) return null;
return sActiveContentHandler.getPendingUrl();
}
/**
* Checks whether the active {@link BrowserSessionContentHandler} belongs to the given session,
* and if true, update toolbar's custom button.
......
......@@ -22,6 +22,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.StrictMode;
import android.provider.Browser;
import android.support.annotation.Nullable;
import android.support.customtabs.CustomTabsCallback;
import android.support.customtabs.CustomTabsIntent;
import android.support.customtabs.CustomTabsSessionToken;
......@@ -85,6 +86,7 @@ import org.chromium.chrome.browser.util.UrlUtilities;
import org.chromium.chrome.browser.webapps.WebappInterceptNavigationDelegate;
import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.NavigationEntry;
import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.PageTransition;
import org.chromium.ui.base.WindowAndroid;
......@@ -493,9 +495,18 @@ public class CustomTabActivity extends ChromeActivity {
}
@Override
@Nullable
public String getCurrentUrl() {
return getActivityTab() == null ? null : getActivityTab().getUrl();
}
@Override
@Nullable
public String getPendingUrl() {
NavigationEntry entry = getActivityTab().getWebContents().getNavigationController()
.getPendingEntry();
return entry != null ? entry.getUrl() : null;
}
};
recordClientPackageName();
mConnection.showSignInToastIfNecessary(mSession, getIntent());
......
......@@ -63,6 +63,7 @@ import org.chromium.chrome.browser.widget.TintedDrawable;
import org.chromium.content.browser.ScreenOrientationProvider;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.NavigationEntry;
import org.chromium.net.NetworkChangeNotifier;
import org.chromium.ui.base.PageTransition;
......@@ -149,12 +150,21 @@ public class WebappActivity extends SingleTabActivity {
}
@Override
@Nullable
public String getCurrentUrl() {
if (getActivityTab() == null) return null;
return getActivityTab().getUrl();
}
@Override
@Nullable
public String getPendingUrl() {
NavigationEntry entry = getActivityTab().getWebContents().getNavigationController()
.getPendingEntry();
return entry != null ? entry.getUrl() : null;
}
/**
* Verify the Digital Asset Links declared by the Android native client with the currently
* loading origin. See {@link TrustedWebContentProvider#didVerificationFail()} for the
......
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