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

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

Issue 992593003: [Android WebView] Lay the groundwork for a better onReceivedError (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed 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 926d77fb1d486143e717a92aea20e8cb14cf76ad..36d02657fbe71e798aa8242cb3a9f5b45d2794f7 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.java
@@ -40,18 +40,27 @@ public class AwWebContentsObserver extends WebContentsObserver {
String unreachableWebDataUrl = AwContentsStatics.getUnreachableWebDataUrl();
boolean isErrorUrl =
unreachableWebDataUrl != null && unreachableWebDataUrl.equals(failingUrl);
- if (isMainFrame && !isErrorUrl) {
- if (errorCode != NetError.ERR_ABORTED) {
- // This error code is generated for the following reasons:
- // - WebView.stopLoading is called,
- // - the navigation is intercepted by the embedder via shouldOverrideNavigation.
- //
- // The Android WebView does not notify the embedder of these situations using
- // this error code with the WebViewClient.onReceivedError callback.
- mAwContentsClient.onReceivedError(
- ErrorCodeConversionHelper.convertErrorCode(errorCode), description,
- failingUrl);
- }
+ if (isErrorUrl) return;
+ if (errorCode != NetError.ERR_ABORTED) {
+ // This error code is generated for the following reasons:
+ // - WebView.stopLoading is called,
+ // - the navigation is intercepted by the embedder via shouldOverrideNavigation.
+ //
+ // The Android WebView does not notify the embedder of these situations using
+ // this error code with the WebViewClient.onReceivedError callback.
+ AwContentsClient.AwWebResourceRequest request =
+ new AwContentsClient.AwWebResourceRequest();
+ request.url = failingUrl;
+ request.isMainFrame = isMainFrame;
+ // TODO(mnaganov): Fill in the rest of AwWebResourceRequest fields. Probably,
+ // we will have to actually invoke the error callback from the network delegate
+ // in order to catch load errors for all resources.
+ AwContentsClient.AwWebResourceError error = new AwContentsClient.AwWebResourceError();
+ error.errorCode = ErrorCodeConversionHelper.convertErrorCode(errorCode);
+ error.description = description;
+ mAwContentsClient.onReceivedError(request, error);
+ }
+ if (isMainFrame) {
// Need to call onPageFinished after onReceivedError (if there is an error) for
// backwards compatibility with the classic webview.
mAwContentsClient.onPageFinished(failingUrl);

Powered by Google App Engine
This is Rietveld 408576698