diff options
author | gsennton <gsennton@chromium.org> | 2016-01-12 03:07:32 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-12 11:08:16 +0000 |
commit | 68afca713e53e857cbc6c2d25aeb0bb1d76cd4ac (patch) | |
tree | 87c838ebe00c70fea70fbb42f47ee4a1374cbd53 /android_webview/java | |
parent | 9eb67a8f0290d89f19a9cadc7519aac0ef371e60 (diff) | |
download | chromium_src-68afca713e53e857cbc6c2d25aeb0bb1d76cd4ac.zip chromium_src-68afca713e53e857cbc6c2d25aeb0bb1d76cd4ac.tar.gz chromium_src-68afca713e53e857cbc6c2d25aeb0bb1d76cd4ac.tar.bz2 |
Revert 3 CLs for shouldOverrideUrlLoading implementation.
Since https://codereview.chromium.org/1424263003 does not handle
overriding about:blank loads (or rather, about:blank loads are
handled synchronously and can thus be finished before we have a chance
to override them) we cannot land that patch without potentially breaking
lots of apps using WebView.
The second CL being reverted is a fix for the first one to post
didStopLoad and didFailLoad in the correct order.
The third CL being reverted here is a small change removing code that
is not used by https://codereview.chromium.org/1424263003 but is used
now that we revert that CL.
This reverts commit bae3ff13e6959b713b872df3c4a734d6a1ea01ad.
This reverts commit e1da704f67f34022b7aaf3afe277c86217844114.
This reverts commit c002c7ea9c5a3dbeb665e4070d852e6724d1ff86.
TBR=palmer@chromium.org,jam@chromium.org
BUG=325351,462306
Review URL: https://codereview.chromium.org/1530183004
Cr-Commit-Position: refs/heads/master@{#368849}
Diffstat (limited to 'android_webview/java')
4 files changed, 25 insertions, 35 deletions
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 2352b57..c2ce4c9 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -291,6 +291,10 @@ public class AwContents implements SmartClipProvider, private PostMessageSender mPostMessageSender; + // This flag indicates that ShouldOverrideUrlNavigation should be posted + // through the resourcethrottle. This is only used for popup windows. + private boolean mDeferredShouldOverrideUrlLoadingIsPendingForPopup; + // This is a workaround for some qualcomm devices discarding buffer on // Activity restore. private boolean mInvalidateRootViewOnNextDraw; @@ -500,38 +504,23 @@ public class AwContents implements SmartClipProvider, @Override public boolean shouldIgnoreNavigation(NavigationParams navigationParams) { final String url = navigationParams.url; - - final int transitionType = navigationParams.pageTransitionType; - final boolean isLoadUrl = (transitionType & PageTransition.FROM_API) != 0; - final boolean isBackForward = (transitionType & PageTransition.FORWARD_BACK) != 0; - final boolean isReload = - (transitionType & PageTransition.CORE_MASK) == PageTransition.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. - if ((!isLoadUrl || isRedirect) && !isBackForward && !isReload - && !navigationParams.isPost) { - ignoreNavigation = mContentsClient.shouldIgnoreNavigation(mContext, url, - navigationParams.isMainFrame, - navigationParams.hasUserGesture || navigationParams.hasUserGestureCarryover, - navigationParams.isRedirect); + if (mDeferredShouldOverrideUrlLoadingIsPendingForPopup) { + mDeferredShouldOverrideUrlLoadingIsPendingForPopup = false; + // If this is used for all navigations in future, cases for application initiated + // load, redirect and backforward should also be filtered out. + if (!navigationParams.isPost) { + ignoreNavigation = mContentsClient.shouldIgnoreNavigation( + mContext, url, navigationParams.isMainFrame, + navigationParams.hasUserGesture + || navigationParams.hasUserGestureCarryover, + navigationParams.isRedirect); + } } - // 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. - if (isRedirect) { - mContentsClient.getCallbackHelper().postOnPageStarted(url); - // We can post onPageFinished here since we know that the navigation will fail. - // Also AwWebContentsObserver.didFail does not call OnPageFinished when the - // navigation is overridden because we don't want an onPageFinished for such a - // navigation unless it is a redirect. - if (ignoreNavigation) { - mContentsClient.getCallbackHelper().postOnPageFinished(url); - } - } else if (!ignoreNavigation) { + if (!ignoreNavigation) { mContentsClient.getCallbackHelper().postOnPageStarted(url); } return ignoreNavigation; @@ -1030,6 +1019,7 @@ public class AwContents implements SmartClipProvider, // Recap: supplyContentsForPopup() is called on the parent window's content, this method is // called on the popup window's content. private void receivePopupContents(long popupNativeAwContents) { + mDeferredShouldOverrideUrlLoadingIsPendingForPopup = true; // Save existing view state. final boolean wasAttached = mIsAttachedToWindow; final boolean wasViewVisible = mIsViewVisible; diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java index ba9385f..47d0f28 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java @@ -334,8 +334,6 @@ public abstract class AwContentsClient { public abstract void onPageCommitVisible(String url); - public void onFailedLoadForTesting(String url) {} - public final void onReceivedError(AwWebResourceRequest request, AwWebResourceError error) { // Only one of these callbacks actually reaches out the client code. The first callback // is used on API versions up to and including L, the second on subsequent releases. diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java b/android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java index efca3d0..8c29c2d 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContentsClientBridge.java @@ -250,6 +250,13 @@ public class AwContentsClientBridge { mClient.handleJsBeforeUnload(url, message, handler); } + @CalledByNative + private boolean shouldOverrideUrlLoading( + String url, boolean hasUserGesture, boolean isRedirect, boolean isMainFrame) { + return mClient.shouldIgnoreNavigation( + mContext, url, isMainFrame, hasUserGesture, isRedirect); + } + void confirmJsResult(int id, String prompt) { if (mNativeContentsClientBridge == 0) return; nativeConfirmJsResult(mNativeContentsClientBridge, id, prompt); diff --git a/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java b/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java index d9b709a..3c08c30 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java +++ b/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java @@ -72,16 +72,11 @@ public class AwWebContentsObserver extends WebContentsObserver { String unreachableWebDataUrl = AwContentsStatics.getUnreachableWebDataUrl(); boolean isErrorUrl = unreachableWebDataUrl != null && unreachableWebDataUrl.equals(failingUrl); - if (isMainFrame && !isErrorUrl && errorCode == NetError.ERR_ABORTED - && !wasIgnoredByHandler) { + if (isMainFrame && !isErrorUrl && errorCode == NetError.ERR_ABORTED) { // Need to call onPageFinished for backwards compatibility with the classic webview. // See also AwContents.IoThreadClientImpl.onReceivedError. - // If the navigation was ignored because of shouldOverrideUrlLoading we have already - // called onPageFinished in - // AwContents.InterceptNavigationDelegateImpl.shouldIgnoreNavigation instead. client.getCallbackHelper().postOnPageFinished(failingUrl); } - client.onFailedLoadForTesting(failingUrl); } @Override |