| 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 1e30c192c26880425ac68970b29780f29cd3a9ac..ba6ef83a17581cdbd17186eccedbf09d26aed2a2 100644
|
| --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| @@ -477,23 +477,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) {
|
| - if (!mContentsClient.hasWebViewClient()) {
|
| - ignoreNavigation = AwContentsClient.sendBrowsingIntent(mContext, url);
|
| - } else {
|
| - 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) {
|
| + if (!mContentsClient.hasWebViewClient()) {
|
| + ignoreNavigation = AwContentsClient.sendBrowsingIntent(mContext, url);
|
| + } else {
|
| + 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;
|
|
|