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

Unified Diff: android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.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
« no previous file with comments | « no previous file | android_webview/java/src/org/chromium/android_webview/AwContents.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java
index 8413a716660ff86c612dd634543b045ef2e7c1fe..08b877b71a25b7a135b1f77290ba09c76acfae8b 100644
--- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java
+++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java
@@ -578,6 +578,10 @@ public class WebViewContentsClientAdapter extends AwContentsClient {
*/
@Override
public void onReceivedError(int errorCode, String description, String failingUrl) {
+ // TODO(mnaganov): In the next version of glue, this will look as follows:
+ // if (<next-level-api>) return;
+ // Currently, we should just run this code always.
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.CUR_DEVELOPMENT + 1) return;
try {
TraceEvent.begin("WebViewContentsClientAdapter.onReceivedError");
if (description == null || description.isEmpty()) {
@@ -587,7 +591,35 @@ public class WebViewContentsClientAdapter extends AwContentsClient {
description = mWebViewDelegate.getErrorString(mContext, errorCode);
}
if (TRACE) Log.d(TAG, "onReceivedError=" + failingUrl);
- mWebViewClient.onReceivedError(mWebView, errorCode, description, failingUrl);
+ mWebViewClient.onReceivedError(
+ mWebView, errorCode, description, failingUrl);
+ } finally {
+ TraceEvent.end("WebViewContentsClientAdapter.onReceivedError");
+ }
+ }
+
+ /**
+ * @see ContentViewClient#onReceivedError(
+ * AwContentsClient.AwWebResourceRequest,AwContentsClient.AwWebResourceError)
+ */
+ @Override
+ public void onReceivedError2(AwContentsClient.AwWebResourceRequest request,
+ AwContentsClient.AwWebResourceError error) {
+ // TODO(mnaganov): In the next version of glue, this will look as follows:
+ // if (!<next-level-api>) return;
+ // Currently, we should never run this code.
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.CUR_DEVELOPMENT + 1) return;
+ try {
+ TraceEvent.begin("WebViewContentsClientAdapter.onReceivedError");
+ if (error.description == null || error.description.isEmpty()) {
+ // ErrorStrings is @hidden, so we can't do this in AwContents. Normally the net/
+ // layer will set a valid description, but for synthesized callbacks (like in the
+ // case for intercepted requests) AwContents will pass in null.
+ error.description = mWebViewDelegate.getErrorString(mContext, error.errorCode);
+ }
+ if (TRACE) Log.d(TAG, "onReceivedError=" + request.url);
+ // TODO(mnaganov): When the new API becomes available, uncomment the following:
+ // mWebViewClient.onReceivedError(request, error);
} finally {
TraceEvent.end("WebViewContentsClientAdapter.onReceivedError");
}
« no previous file with comments | « no previous file | android_webview/java/src/org/chromium/android_webview/AwContents.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698