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

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: PreviousURL Fix Created 3 years, 10 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..ac4cf7a7b0073cc604a8a3adcb16ae2d9b8a1b32 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,28 @@ 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);
jam 2017/02/07 05:10:32 i'm not sure I follow why this change is made? did
shaktisahu 2017/02/07 07:35:51 This is to account for the fact that DidFailProvis
jam 2017/02/07 17:12:38 ah, ok thanks for the explanation, I missed that.
+ return;
+ }
+
+ if (hasCommitted) mCommittedNavigation = true;
jam 2017/02/07 05:10:32 to maintain the same behavior as before, this line
shaktisahu 2017/02/08 01:00:46 Done.
+
+ AwContentsClient client = mAwContentsClient.get();
+ if (hasCommitted && client != null) {
+ boolean isReload = pageTransition != null
+ && ((pageTransition & PageTransition.CORE_MASK) == PageTransition.RELOAD);
+ client.getCallbackHelper().postDoUpdateVisitedHistory(url, isReload);
+ }
+
+ if (!isInMainFrame) return;
+
// 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 && !isSamePage) {
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
@@ -111,23 +129,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 && 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