diff options
author | mnaganov <mnaganov@chromium.org> | 2015-03-09 10:18:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-09 17:19:10 +0000 |
commit | f0a8ffb2ca988fe7de628620f750ee241e5f5d35 (patch) | |
tree | 89081bd42deaa050eb286bf66bbba22060623aee /android_webview/glue | |
parent | 318afca092085cc5375a6b5547383d78baee3778 (diff) | |
download | chromium_src-f0a8ffb2ca988fe7de628620f750ee241e5f5d35.zip chromium_src-f0a8ffb2ca988fe7de628620f750ee241e5f5d35.tar.gz chromium_src-f0a8ffb2ca988fe7de628620f750ee241e5f5d35.tar.bz2 |
[Android WebView] Lay the groundwork for a better onReceivedError
This patch should not change any behaviour. It introduces a new version
of onReceviedError that will be called for all resources and provides
more information about the failed request.
BUG=456782
Review URL: https://codereview.chromium.org/992593003
Cr-Commit-Position: refs/heads/master@{#319664}
Diffstat (limited to 'android_webview/glue')
-rw-r--r-- | android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java | 34 |
1 files changed, 33 insertions, 1 deletions
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 8413a71..08b877b 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"); } |