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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 24228003: Upstream ShouldOverrideUrlLoading changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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: android_webview/java/src/org/chromium/android_webview/AwContents.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 2805af26f729bf2fdf0bbfd2bafbe0f17055a99c..6ac7350812881a489426dc03f9f545ce4c52a784 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -48,7 +48,6 @@ import org.chromium.content.browser.LoadUrlParams;
import org.chromium.content.browser.NavigationHistory;
import org.chromium.content.browser.PageTransitionTypes;
import org.chromium.content.common.CleanupReference;
-import org.chromium.components.navigation_interception.InterceptNavigationDelegate;
import org.chromium.components.navigation_interception.NavigationParams;
import org.chromium.net.GURLUtils;
import org.chromium.ui.gfx.DeviceDisplayInfo;
@@ -149,7 +148,6 @@ public class AwContents {
private final AwContentsClientBridge mContentsClientBridge;
private final AwWebContentsDelegate mWebContentsDelegate;
private final AwContentsIoThreadClient mIoThreadClient;
- private final InterceptNavigationDelegateImpl mInterceptNavigationDelegate;
private final InternalAccessDelegate mInternalAccessAdapter;
private final AwLayoutSizer mLayoutSizer;
private final AwZoomControls mZoomControls;
@@ -276,67 +274,6 @@ public class AwContents {
}
//--------------------------------------------------------------------------------------------
- private class InterceptNavigationDelegateImpl implements InterceptNavigationDelegate {
- private String mLastLoadUrlAddress;
-
- public void onUrlLoadRequested(String url) {
- mLastLoadUrlAddress = url;
- }
-
- @Override
- public boolean shouldIgnoreNavigation(NavigationParams navigationParams) {
- final String url = navigationParams.url;
- final int transitionType = navigationParams.pageTransitionType;
- final boolean isLoadUrl =
- (transitionType & PageTransitionTypes.PAGE_TRANSITION_FROM_API) != 0;
- final boolean isBackForward =
- (transitionType & PageTransitionTypes.PAGE_TRANSITION_FORWARD_BACK) != 0;
- final boolean isReload =
- (transitionType & PageTransitionTypes.PAGE_TRANSITION_CORE_MASK) ==
- PageTransitionTypes.PAGE_TRANSITION_RELOAD;
- final boolean isRedirect = navigationParams.isRedirect;
-
- boolean ignoreNavigation = false;
-
- // Any navigation from loadUrl, goBack/Forward, or reload, are considered application
- // initiated and hence will not yield a shouldOverrideUrlLoading() callback.
- // TODO(joth): Using PageTransitionTypes should be sufficient to determine all app
- // initiated navigations, and so mLastLoadUrlAddress should be removed.
- if ((isLoadUrl && !isRedirect) || isBackForward || isReload ||
- mLastLoadUrlAddress != null && mLastLoadUrlAddress.equals(url)) {
- // Support the case where the user clicks on a link that takes them back to the
- // same page.
- mLastLoadUrlAddress = null;
-
- // If the embedder requested the load of a certain URL via the loadUrl API, then we
- // do not offer it to AwContentsClient.shouldOverrideUrlLoading.
- // The embedder is also not allowed to intercept POST requests because of
- // crbug.com/155250.
- } else if (!navigationParams.isPost) {
- ignoreNavigation = mContentsClient.shouldOverrideUrlLoading(url);
- }
-
- // The existing contract is that shouldOverrideUrlLoading callbacks are delivered before
- // onPageStarted callbacks; third party apps depend on this behavior.
- // Using a ResouceThrottle to implement the navigation interception feature results in
- // the WebContentsObserver.didStartLoading callback happening before the
- // ResourceThrottle has a chance to run.
- // To preserve the ordering the onPageStarted callback is synthesized from the
- // shouldOverrideUrlLoading, and only if the navigation was not ignored (this
- // balances out with the onPageFinished callback, which is suppressed in the
- // AwContentsClient if the navigation was ignored).
- if (!ignoreNavigation) {
- // The shouldOverrideUrlLoading call might have resulted in posting messages to the
- // UI thread. Using sendMessage here (instead of calling onPageStarted directly)
- // will allow those to run in order.
- mContentsClient.getCallbackHelper().postOnPageStarted(url);
- }
-
- return ignoreNavigation;
- }
- }
-
- //--------------------------------------------------------------------------------------------
private class AwLayoutSizerDelegate implements AwLayoutSizer.Delegate {
@Override
public void requestLayout() {
@@ -502,7 +439,6 @@ public class AwContents {
mContentsClientBridge = new AwContentsClientBridge(contentsClient);
mZoomControls = new AwZoomControls(this);
mIoThreadClient = new IoThreadClientImpl();
- mInterceptNavigationDelegate = new InterceptNavigationDelegateImpl();
boolean hasInternetPermission = containerView.getContext().checkPermission(
android.Manifest.permission.INTERNET,
@@ -565,7 +501,7 @@ public class AwContents {
new AwGestureStateListener(), mContentsClient.getContentViewClient(),
mZoomControls);
nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mContentsClientBridge,
- mIoThreadClient, mInterceptNavigationDelegate);
+ mIoThreadClient);
mContentsClient.installWebContentsObserver(mContentViewCore);
mContentViewCore.setUpdateFrameInfoListener(new AwContentUpdateFrameInfoListener());
mSettings.setWebContents(nativeWebContents);
@@ -875,8 +811,6 @@ public class AwContents {
mContentViewCore.loadUrl(params);
- suppressInterceptionForThisNavigation();
-
// The behavior of WebViewClassic uses the populateVisitedLinks callback in WebKit.
// Chromium does not use this use code path and the best emulation of this behavior to call
// request visited links once on the first URL load of the WebView.
@@ -886,14 +820,6 @@ public class AwContents {
}
}
- private void suppressInterceptionForThisNavigation() {
- if (mInterceptNavigationDelegate != null) {
- // getUrl returns a sanitized address in the same format that will be used for
- // callbacks, so it's safe to use string comparison as an equality check later on.
- mInterceptNavigationDelegate.onUrlLoadRequested(mContentViewCore.getUrl());
- }
- }
-
/**
* Get the URL of the current page.
*
@@ -1105,8 +1031,6 @@ public class AwContents {
*/
public void goBack() {
mContentViewCore.goBack();
-
- suppressInterceptionForThisNavigation();
}
/**
@@ -1121,8 +1045,6 @@ public class AwContents {
*/
public void goForward() {
mContentViewCore.goForward();
-
- suppressInterceptionForThisNavigation();
}
/**
@@ -1137,8 +1059,6 @@ public class AwContents {
*/
public void goBackOrForward(int steps) {
mContentViewCore.goToOffset(steps);
-
- suppressInterceptionForThisNavigation();
}
/**
@@ -1823,6 +1743,11 @@ public class AwContents {
}
@CalledByNative
+ private boolean onShouldOverrideUrlLoading(String url) {
+ return mContentsClient.shouldOverrideUrlLoading(url);
+ }
+
+ @CalledByNative
private void scrollContainerViewTo(int x, int y) {
mScrollOffsetManager.scrollContainerViewTo(x, y);
}
@@ -1910,8 +1835,7 @@ public class AwContents {
private native void nativeSetJavaPeers(int nativeAwContents, AwContents awContents,
AwWebContentsDelegate webViewWebContentsDelegate,
AwContentsClientBridge contentsClientBridge,
- AwContentsIoThreadClient ioThreadClient,
- InterceptNavigationDelegate navigationInterceptionDelegate);
+ AwContentsIoThreadClient ioThreadClient);
private native int nativeGetWebContents(int nativeAwContents);
private native void nativeDocumentHasImages(int nativeAwContents, Message message);

Powered by Google App Engine
This is Rietveld 408576698