Merge "Update the new error reporting API in android.webkit" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
822f1aaf2b
@@ -38811,8 +38811,7 @@ package android.webkit {
|
||||
}
|
||||
|
||||
public abstract class WebResourceError {
|
||||
ctor public WebResourceError();
|
||||
method public abstract java.lang.String getDescription();
|
||||
method public abstract java.lang.CharSequence getDescription();
|
||||
method public abstract int getErrorCode();
|
||||
}
|
||||
|
||||
@@ -38842,12 +38841,6 @@ package android.webkit {
|
||||
|
||||
public abstract class WebResourceResponseBase {
|
||||
ctor public WebResourceResponseBase();
|
||||
method public abstract java.io.InputStream getData();
|
||||
method public abstract java.lang.String getEncoding();
|
||||
method public abstract java.lang.String getMimeType();
|
||||
method public abstract java.lang.String getReasonPhrase();
|
||||
method public abstract java.util.Map<java.lang.String, java.lang.String> getResponseHeaders();
|
||||
method public abstract int getStatusCode();
|
||||
}
|
||||
|
||||
public abstract class WebSettings {
|
||||
@@ -39179,6 +39172,7 @@ package android.webkit {
|
||||
method public void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceError);
|
||||
method public void onReceivedHttpAuthRequest(android.webkit.WebView, android.webkit.HttpAuthHandler, java.lang.String, java.lang.String);
|
||||
method public void onReceivedHttpError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceResponseBase);
|
||||
method public void onReceivedHttpError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceResponse);
|
||||
method public void onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String);
|
||||
method public void onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError);
|
||||
method public void onScaleChanged(android.webkit.WebView, float, float);
|
||||
|
||||
@@ -41133,7 +41133,7 @@ package android.webkit {
|
||||
|
||||
public abstract class WebResourceError {
|
||||
ctor public WebResourceError();
|
||||
method public abstract java.lang.String getDescription();
|
||||
method public abstract java.lang.CharSequence getDescription();
|
||||
method public abstract int getErrorCode();
|
||||
}
|
||||
|
||||
@@ -41148,6 +41148,7 @@ package android.webkit {
|
||||
public class WebResourceResponse extends android.webkit.WebResourceResponseBase {
|
||||
ctor public WebResourceResponse(java.lang.String, java.lang.String, java.io.InputStream);
|
||||
ctor public WebResourceResponse(java.lang.String, java.lang.String, int, java.lang.String, java.util.Map<java.lang.String, java.lang.String>, java.io.InputStream);
|
||||
ctor public WebResourceResponse(boolean, java.lang.String, java.lang.String, int, java.lang.String, java.util.Map<java.lang.String, java.lang.String>, java.io.InputStream);
|
||||
method public java.io.InputStream getData();
|
||||
method public java.lang.String getEncoding();
|
||||
method public java.lang.String getMimeType();
|
||||
@@ -41163,12 +41164,6 @@ package android.webkit {
|
||||
|
||||
public abstract class WebResourceResponseBase {
|
||||
ctor public WebResourceResponseBase();
|
||||
method public abstract java.io.InputStream getData();
|
||||
method public abstract java.lang.String getEncoding();
|
||||
method public abstract java.lang.String getMimeType();
|
||||
method public abstract java.lang.String getReasonPhrase();
|
||||
method public abstract java.util.Map<java.lang.String, java.lang.String> getResponseHeaders();
|
||||
method public abstract int getStatusCode();
|
||||
}
|
||||
|
||||
public abstract class WebSettings {
|
||||
@@ -41545,6 +41540,7 @@ package android.webkit {
|
||||
method public void onReceivedError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceError);
|
||||
method public void onReceivedHttpAuthRequest(android.webkit.WebView, android.webkit.HttpAuthHandler, java.lang.String, java.lang.String);
|
||||
method public void onReceivedHttpError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceResponseBase);
|
||||
method public void onReceivedHttpError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceResponse);
|
||||
method public void onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String);
|
||||
method public void onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError);
|
||||
method public void onScaleChanged(android.webkit.WebView, float, float);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.webkit;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
|
||||
/**
|
||||
* Encapsulates information about errors occured during loading of web resources. See
|
||||
* {@link WebViewClient#onReceivedError(WebView, WebResourceRequest, WebResourceError) WebViewClient.onReceivedError(WebView, WebResourceRequest, WebResourceError)}
|
||||
@@ -35,5 +37,12 @@ public abstract class WebResourceError {
|
||||
*
|
||||
* @return The description of the error
|
||||
*/
|
||||
public abstract String getDescription();
|
||||
public abstract CharSequence getDescription();
|
||||
|
||||
/**
|
||||
* This class can not be subclassed by applications.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public WebResourceError() {}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,15 @@ import java.io.InputStream;
|
||||
import java.io.StringBufferInputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
|
||||
/**
|
||||
* Encapsulates a resource response. Applications can return an instance of this
|
||||
* class from {@link WebViewClient#shouldInterceptRequest} to provide a custom
|
||||
* response when the WebView requests a particular resource.
|
||||
*/
|
||||
public class WebResourceResponse extends WebResourceResponseBase {
|
||||
private boolean mImmutable;
|
||||
private String mMimeType;
|
||||
private String mEncoding;
|
||||
private int mStatusCode;
|
||||
@@ -80,13 +83,15 @@ public class WebResourceResponse extends WebResourceResponseBase {
|
||||
* @param mimeType The resource response's MIME type
|
||||
*/
|
||||
public void setMimeType(String mimeType) {
|
||||
checkImmutable();
|
||||
mMimeType = mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Gets the resource response's MIME type.
|
||||
*
|
||||
* @return The resource response's MIME type
|
||||
*/
|
||||
@Override
|
||||
public String getMimeType() {
|
||||
return mMimeType;
|
||||
}
|
||||
@@ -98,13 +103,15 @@ public class WebResourceResponse extends WebResourceResponseBase {
|
||||
* @param encoding The resource response's encoding
|
||||
*/
|
||||
public void setEncoding(String encoding) {
|
||||
checkImmutable();
|
||||
mEncoding = encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Gets the resource response's encoding.
|
||||
*
|
||||
* @return The resource response's encoding
|
||||
*/
|
||||
@Override
|
||||
public String getEncoding() {
|
||||
return mEncoding;
|
||||
}
|
||||
@@ -118,6 +125,7 @@ public class WebResourceResponse extends WebResourceResponseBase {
|
||||
* and not empty.
|
||||
*/
|
||||
public void setStatusCodeAndReasonPhrase(int statusCode, String reasonPhrase) {
|
||||
checkImmutable();
|
||||
if (statusCode < 100)
|
||||
throw new IllegalArgumentException("statusCode can't be less than 100.");
|
||||
if (statusCode > 599)
|
||||
@@ -140,17 +148,19 @@ public class WebResourceResponse extends WebResourceResponseBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Gets the resource response's status code.
|
||||
*
|
||||
* @return The resource response's status code.
|
||||
*/
|
||||
@Override
|
||||
public int getStatusCode() {
|
||||
return mStatusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Gets the description of the resource response's status code.
|
||||
*
|
||||
* @return The description of the resource response's status code.
|
||||
*/
|
||||
@Override
|
||||
public String getReasonPhrase() {
|
||||
return mReasonPhrase;
|
||||
}
|
||||
@@ -161,13 +171,15 @@ public class WebResourceResponse extends WebResourceResponseBase {
|
||||
* @param headers Mapping of header name -> header value.
|
||||
*/
|
||||
public void setResponseHeaders(Map<String, String> headers) {
|
||||
checkImmutable();
|
||||
mResponseHeaders = headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Gets the headers for the resource response.
|
||||
*
|
||||
* @return The headers for the resource response.
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getResponseHeaders() {
|
||||
return mResponseHeaders;
|
||||
}
|
||||
@@ -180,6 +192,7 @@ public class WebResourceResponse extends WebResourceResponseBase {
|
||||
* StringBufferInputStream.
|
||||
*/
|
||||
public void setData(InputStream data) {
|
||||
checkImmutable();
|
||||
// If data is (or is a subclass of) StringBufferInputStream
|
||||
if (data != null && StringBufferInputStream.class.isAssignableFrom(data.getClass())) {
|
||||
throw new IllegalArgumentException("StringBufferInputStream is deprecated and must " +
|
||||
@@ -189,10 +202,32 @@ public class WebResourceResponse extends WebResourceResponseBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Gets the input stream that provides the resource response's data.
|
||||
*
|
||||
* @return The input stream that provides the resource response's data
|
||||
*/
|
||||
@Override
|
||||
public InputStream getData() {
|
||||
return mInputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* The internal version of the constructor that doesn't perform arguments checks.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public WebResourceResponse(boolean immutable, String mimeType, String encoding, int statusCode,
|
||||
String reasonPhrase, Map<String, String> responseHeaders, InputStream data) {
|
||||
mImmutable = immutable;
|
||||
mMimeType = mimeType;
|
||||
mEncoding = encoding;
|
||||
mStatusCode = statusCode;
|
||||
mReasonPhrase = reasonPhrase;
|
||||
mResponseHeaders = responseHeaders;
|
||||
mInputStream = data;
|
||||
}
|
||||
|
||||
private void checkImmutable() {
|
||||
if (mImmutable)
|
||||
throw new IllegalStateException("This WebResourceResponse instance is immutable");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,53 +16,9 @@
|
||||
|
||||
package android.webkit;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Encapsulates a resource response received from the server.
|
||||
* This is an abstract class used by WebView callbacks.
|
||||
* This class will be deleted after updated WebView.apk will be submitted
|
||||
* into the Android tree.
|
||||
*/
|
||||
public abstract class WebResourceResponseBase {
|
||||
/**
|
||||
* Gets the resource response's MIME type.
|
||||
*
|
||||
* @return The resource response's MIME type
|
||||
*/
|
||||
public abstract String getMimeType();
|
||||
|
||||
/**
|
||||
* Gets the resource response's encoding.
|
||||
*
|
||||
* @return The resource response's encoding
|
||||
*/
|
||||
public abstract String getEncoding();
|
||||
|
||||
/**
|
||||
* Gets the resource response's status code.
|
||||
*
|
||||
* @return The resource response's status code.
|
||||
*/
|
||||
public abstract int getStatusCode();
|
||||
|
||||
/**
|
||||
* Gets the description of the resource response's status code.
|
||||
*
|
||||
* @return The description of the resource response's status code.
|
||||
*/
|
||||
public abstract String getReasonPhrase();
|
||||
|
||||
/**
|
||||
* Gets the headers for the resource response.
|
||||
*
|
||||
* @return The headers for the resource response.
|
||||
*/
|
||||
public abstract Map<String, String> getResponseHeaders();
|
||||
|
||||
/**
|
||||
* Gets the input stream that provides the resource response's data.
|
||||
*
|
||||
* @return The input stream that provides the resource response's data
|
||||
*/
|
||||
public abstract InputStream getData();
|
||||
}
|
||||
|
||||
@@ -233,10 +233,19 @@ public class WebViewClient {
|
||||
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
||||
if (request.isForMainFrame()) {
|
||||
onReceivedError(view,
|
||||
error.getErrorCode(), error.getDescription(), request.getUrl().toString());
|
||||
error.getErrorCode(), error.getDescription().toString(),
|
||||
request.getUrl().toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be deleted after updated WebView.apk will be submitted
|
||||
* into the Android tree.
|
||||
*/
|
||||
public void onReceivedHttpError(
|
||||
WebView view, WebResourceRequest request, WebResourceResponseBase errorResponse) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the host application that an HTTP error has been received from the server while
|
||||
* loading a resource. HTTP errors have status codes >= 400. This callback will be called
|
||||
@@ -248,7 +257,7 @@ public class WebViewClient {
|
||||
* @param errorResponse Information about the error occured.
|
||||
*/
|
||||
public void onReceivedHttpError(
|
||||
WebView view, WebResourceRequest request, WebResourceResponseBase errorResponse) {
|
||||
WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user