| Index: android_webview/java/src/org/chromium/android_webview/AwContentsClient.java
|
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java
|
| index a81b2ed48452b74ec0e6dcd16ee959e6c00b831f..2b5514bc844ca75921e66cae73cac21bd1b39cf1 100644
|
| --- a/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java
|
| +++ b/android_webview/java/src/org/chromium/android_webview/AwContentsClient.java
|
| @@ -92,6 +92,14 @@ public abstract class AwContentsClient {
|
| public HashMap<String, String> requestHeaders;
|
| }
|
|
|
| + /**
|
| + * Parameters for {@link AwContentsClient#onReceivedError} method.
|
| + */
|
| + public static class AwWebResourceError {
|
| + public int errorCode = ErrorCodeConversionHelper.ERROR_UNKNOWN;
|
| + public String description;
|
| + }
|
| +
|
| public abstract void getVisitedHistory(ValueCallback<String[]> callback);
|
|
|
| public abstract void doUpdateVisitedHistory(String url, boolean isReload);
|
| @@ -256,7 +264,33 @@ public abstract class AwContentsClient {
|
|
|
| public abstract void onPageFinished(String url);
|
|
|
| - public abstract void onReceivedError(int errorCode, String description, String failingUrl);
|
| + public final void onReceivedError(AwWebResourceRequest request, AwWebResourceError error) {
|
| + // Only one of these callbacks actually reaches out the client code. The first callback
|
| + // is used on API versions up to and including L, the second on subsequent releases.
|
| + // Below is the calls diagram:
|
| + //
|
| + // Old (<= L) glue Old (<= L) android.webkit API
|
| + // onReceivedError ---------> onReceivedError
|
| + // AwContentsClient onReceivedError2 ->X /
|
| + // abs. onReceivedError /
|
| + // abs. onReceivedError2 /
|
| + // New (M+) glue / New (M+) android.webkit API
|
| + // onReceivedError / -> onReceviedError <new>
|
| + // "->X" = "do nothing" if (!<M API>) --- / if (isMainFrame) -\
|
| + // else ->X / else ->X |
|
| + // onReceivedError2 / V
|
| + // if (<M API>) ------- onReceivedError <old>
|
| + // else ->X
|
| + if (request.isMainFrame) {
|
| + onReceivedError(error.errorCode, error.description, request.url);
|
| + }
|
| + onReceivedError2(request, error);
|
| + }
|
| +
|
| + protected abstract void onReceivedError(int errorCode, String description, String failingUrl);
|
| +
|
| + protected abstract void onReceivedError2(
|
| + AwWebResourceRequest request, AwWebResourceError error);
|
|
|
| // TODO (michaelbai): Remove this method once the same method remove from
|
| // WebViewContentsClientAdapter.
|
|
|