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

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

Issue 1530183004: Revert 3 CLs for shouldOverrideUrlLoading implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase (simple conflict in AwContentsClientShouldOverrideUrlLoadingTest). Created 4 years, 11 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 2352b57577895c3ca6e1c936436a30b5455bce96..c2ce4c9b9d8f6798446dce43380bd0e61b281caa 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;

Powered by Google App Engine
This is Rietveld 408576698