Chromium Code Reviews| 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..54c20217f4840a898e9897cbd14c81d0a46b712e 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,39 @@ 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; |
| + // Any navigation from loadUrl, goBack/Forward, or reload, are considered application |
| + // initiated and hence will not yield a shouldOverrideUrlLoading() callback. |
| + if ((isLoadUrl && !isRedirect) || isBackForward) { |
| // If this is used for all navigations in future, cases for application initiated |
| // load, redirect and backforward should also be filtered out. |
|
sgurun-gerrit only
2015/06/05 07:52:49
no-op if expression is true? you should be able to
gsennton
2015/06/08 14:07:23
Done.
|
| - if (!navigationParams.isPost) { |
| - ignoreNavigation = mContentsClient.shouldOverrideUrlLoading(url); |
| - } |
| + } else if (!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; |