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

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

Issue 1024103002: [Android WebView] Provide user-initiated provisional load detection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments and build fix Created 5 years, 9 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/AwWebContentsObserver.java
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 f985369e29e2eb195163db7f9069bd24197fa6fc..f600470c5bf1e7e959072320d79bec518f21a947 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java
@@ -6,9 +6,11 @@ package org.chromium.android_webview;
import org.chromium.android_webview.AwContents.VisualStateCallback;
import org.chromium.base.ThreadUtils;
+import org.chromium.content_public.browser.NavigationEntry;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.WebContentsObserver;
import org.chromium.net.NetError;
+import org.chromium.ui.base.PageTransition;
import java.lang.ref.WeakReference;
@@ -22,7 +24,7 @@ public class AwWebContentsObserver extends WebContentsObserver {
// and should be found and cleaned up.
private final WeakReference<AwContents> mAwContents;
private final AwContentsClient mAwContentsClient;
- private boolean mHasStartedAnyProvisionalLoad = false;
+ private boolean mStartedNonApiProvisionalLoadInMainFrame = false;
public AwWebContentsObserver(
WebContents webContents, AwContents awContents, AwContentsClient awContentsClient) {
@@ -31,8 +33,8 @@ public class AwWebContentsObserver extends WebContentsObserver {
mAwContentsClient = awContentsClient;
}
- boolean hasStartedAnyProvisionalLoad() {
- return mHasStartedAnyProvisionalLoad;
+ boolean hasStartedNonApiProvisionalLoadInMainFrame() {
+ return mStartedNonApiProvisionalLoadInMainFrame;
}
@Override
@@ -99,6 +101,14 @@ public class AwWebContentsObserver extends WebContentsObserver {
String validatedUrl,
boolean isErrorPage,
boolean isIframeSrcdoc) {
- mHasStartedAnyProvisionalLoad = true;
+ if (!isMainFrame) return;
+ AwContents awContents = mAwContents.get();
+ if (awContents != null) {
+ NavigationEntry pendingEntry = awContents.getNavigationController().getPendingEntry();
+ if (pendingEntry != null
+ && (pendingEntry.getTransition() & PageTransition.FROM_API) == 0) {
+ mStartedNonApiProvisionalLoadInMainFrame = true;
+ }
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698