| 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 d24cb7cbeccd81287981368ba41df25e6c645c9f..a3cdca94ddcd391ceb6a2a79b8236ecff7d130fe 100644
|
| --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| @@ -472,19 +472,38 @@ 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;
|
| - 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.shouldOverrideUrlLoading(url);
|
| - }
|
| + // Any navigation from loadUrl, goBack/Forward, or reload, are considered application
|
| + // initiated and hence will not yield a shouldOverrideUrlLoading() callback.
|
| + if ((!isLoadUrl || isRedirect)
|
| + && !isBackForward
|
| + && !navigationParams.isPost) {
|
| + ignoreNavigation = mContentsClient.shouldOverrideUrlLoading(url);
|
| }
|
| +
|
| // 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 (!ignoreNavigation) {
|
| + 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) {
|
| mContentsClient.getCallbackHelper().postOnPageStarted(url);
|
| }
|
| return ignoreNavigation;
|
|
|