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

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

Issue 2642303002: PlzNavigate: Chrome UI changes for new methods of WebContentsObserver (Closed)
Patch Set: some comments from Ted Created 3 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/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 9a444fef9b00c0c7c53fbc506336eb7e4d43cc5c..98e3286e00811338cd32201efe7cf11edc473674 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java
@@ -9,6 +9,7 @@ import org.chromium.base.ThreadUtils;
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;
@@ -65,8 +66,8 @@ public class AwWebContentsObserver extends WebContentsObserver {
}
@Override
- public void didFailLoad(boolean isProvisionalLoad, boolean isMainFrame, int errorCode,
- String description, String failingUrl, boolean wasIgnoredByHandler) {
+ public void didFailLoad(
+ boolean isMainFrame, int errorCode, String description, String failingUrl) {
AwContentsClient client = mAwContentsClient.get();
if (client == null) return;
String unreachableWebDataUrl = AwContentsStatics.getUnreachableWebDataUrl();
@@ -87,11 +88,26 @@ public class AwWebContentsObserver extends WebContentsObserver {
}
@Override
- public void didNavigateMainFrame(final String url, String baseUrl,
- boolean isNavigationToDifferentPage, boolean isFragmentNavigation, int statusCode) {
+ public void didFinishNavigation(final String url, boolean isInMainFrame, boolean isErrorPage,
+ boolean hasCommitted, boolean isSamePage, boolean isFragmentNavigation,
+ Integer pageTransition, int errorCode, int httpStatusCode) {
+ if (errorCode != 0) {
+ didFailLoad(isInMainFrame, errorCode, "", url);
boliu 2017/02/06 15:16:34 under what circumstances will errorCode be non-zer
shaktisahu 2017/02/07 20:09:49 I believe this is orthogonal. If this is failed he
boliu 2017/02/07 22:08:23 Can you double check to make sure then? Changing c
shaktisahu 2017/02/08 00:05:07 I double checked. This is not called twice.
+ return;
+ }
+
+ if (hasCommitted) mCommittedNavigation = true;
+
+ AwContentsClient client = mAwContentsClient.get();
+ if (hasCommitted && client != null) {
+ boolean isReload = pageTransition != null
+ && ((pageTransition & PageTransition.CORE_MASK) == PageTransition.RELOAD);
+ client.getCallbackHelper().postDoUpdateVisitedHistory(url, isReload);
+ }
+
boliu 2017/02/06 15:16:34 nit: could early out if (!isInMainFrame) here
shaktisahu 2017/02/07 07:35:51 Done.
// Only invoke the onPageCommitVisible callback when navigating to a different page,
// but not when navigating to a different fragment within the same page.
- if (isNavigationToDifferentPage) {
+ if (hasCommitted && isInMainFrame && !isSamePage) {
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
@@ -111,23 +127,11 @@ public class AwWebContentsObserver extends WebContentsObserver {
});
}
- // This is here to emulate the Classic WebView firing onPageFinished for main frame
- // navigations where only the hash fragment changes.
- if (isFragmentNavigation) {
- AwContentsClient client = mAwContentsClient.get();
- if (client == null) return;
+ if (client != null && isInMainFrame && isFragmentNavigation) {
client.getCallbackHelper().postOnPageFinished(url);
}
}
- @Override
- public void didNavigateAnyFrame(String url, String baseUrl, boolean isReload) {
- mCommittedNavigation = true;
- final AwContentsClient client = mAwContentsClient.get();
- if (client == null) return;
- client.getCallbackHelper().postDoUpdateVisitedHistory(url, isReload);
- }
-
public boolean didEverCommitNavigation() {
return mCommittedNavigation;
}

Powered by Google App Engine
This is Rietveld 408576698