diff options
-rw-r--r-- | WebKit/Android.mk | 3 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebResponse.cpp | 10 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebResponse.h | 2 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebViewClientError.cpp | 117 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/WebViewClientError.h | 72 |
5 files changed, 199 insertions, 5 deletions
diff --git a/WebKit/Android.mk b/WebKit/Android.mk index 038e3dc..b9bc5a8 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -39,7 +39,8 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ android/WebCoreSupport/WebRequest.cpp \ android/WebCoreSupport/WebRequestContext.cpp \ android/WebCoreSupport/WebResourceRequest.cpp \ - android/WebCoreSupport/WebResponse.cpp + android/WebCoreSupport/WebResponse.cpp \ + android/WebCoreSupport/WebViewClientError.cpp else LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ android/WebCoreSupport/ResourceLoaderAndroid.cpp diff --git a/WebKit/android/WebCoreSupport/WebResponse.cpp b/WebKit/android/WebCoreSupport/WebResponse.cpp index 5c9b79b..bad733c 100644 --- a/WebKit/android/WebCoreSupport/WebResponse.cpp +++ b/WebKit/android/WebCoreSupport/WebResponse.cpp @@ -36,6 +36,9 @@ namespace android { WebResponse::WebResponse(URLRequest* request) : m_httpStatusCode(0) { + // The misleadingly-named os_error() is actually a net::Error enum constant. + m_error = net::Error(request->status().os_error()); + m_url = request->url().spec(); m_host = request->url().HostNoBrackets(); request->GetMimeType(&m_mime); @@ -57,9 +60,9 @@ WebResponse::WebResponse(URLRequest* request) } WebResponse::WebResponse(const string &url, const string &mimeType, long long expectedSize, const string &encoding, int httpStatusCode) - : m_encoding(encoding) + : m_error(net::OK) + , m_encoding(encoding) , m_httpStatusCode(httpStatusCode) - , m_httpStatusText("") , m_expectedSize(expectedSize) , m_mime(mimeType) , m_url(url) @@ -81,8 +84,7 @@ WebCore::ResourceResponse WebResponse::createResourceResponse() WebCore::ResourceError WebResponse::createResourceError() { - // TODO: Last parameter is a localized string, get the correct one from android - WebCore::ResourceError error(m_host.c_str(), m_httpStatusCode, m_url.c_str(), m_httpStatusText.c_str()); + WebCore::ResourceError error(m_host.c_str(), ToWebViewClientError(m_error), m_url.c_str(), net::ErrorToString(m_error)); return error; } diff --git a/WebKit/android/WebCoreSupport/WebResponse.h b/WebKit/android/WebCoreSupport/WebResponse.h index eafc4e3..3c7c601 100644 --- a/WebKit/android/WebCoreSupport/WebResponse.h +++ b/WebKit/android/WebCoreSupport/WebResponse.h @@ -28,6 +28,7 @@ #include "ChromiumIncludes.h" #include "KURL.h" +#include "WebViewClientError.h" #include <map> #include <string> @@ -61,6 +62,7 @@ public: WebCore::ResourceError createResourceError(); private: + net::Error m_error; std::string m_encoding; int m_httpStatusCode; std::string m_host; diff --git a/WebKit/android/WebCoreSupport/WebViewClientError.cpp b/WebKit/android/WebCoreSupport/WebViewClientError.cpp new file mode 100644 index 0000000..8e50cfe --- /dev/null +++ b/WebKit/android/WebCoreSupport/WebViewClientError.cpp @@ -0,0 +1,117 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebViewClientError.h" + +using namespace net; + +namespace android { + +WebViewClientError ToWebViewClientError(net::Error error) { + // Note: many net::Error constants don't have an obvious mapping. + // These will be handled by the default case, ERROR_UNKNOWN. + switch(error) { + case ERR_UNSUPPORTED_AUTH_SCHEME: + return ERROR_UNSUPPORTED_AUTH_SCHEME; + + case ERR_INVALID_AUTH_CREDENTIALS: + case ERR_MISSING_AUTH_CREDENTIALS: + case ERR_MISCONFIGURED_AUTH_ENVIRONMENT: + return ERROR_AUTHENTICATION; + + case ERR_TOO_MANY_REDIRECTS: + return ERROR_REDIRECT_LOOP; + + case ERR_UPLOAD_FILE_CHANGED: + return ERROR_FILE_NOT_FOUND; + + case ERR_INVALID_URL: + return ERROR_BAD_URL; + + case ERR_DISALLOWED_URL_SCHEME: + case ERR_UNKNOWN_URL_SCHEME: + return ERROR_UNSUPPORTED_SCHEME; + + case ERR_IO_PENDING: + case ERR_NETWORK_IO_SUSPENDED: + return ERROR_IO; + + case ERR_CONNECTION_TIMED_OUT: + case ERR_TIMED_OUT: + return ERROR_TIMEOUT; + + case ERR_FILE_TOO_BIG: + return ERROR_FILE; + + case ERR_HOST_RESOLVER_QUEUE_TOO_LARGE: + case ERR_INSUFFICIENT_RESOURCES: + case ERR_OUT_OF_MEMORY: + return ERROR_TOO_MANY_REQUESTS; + + case ERR_CONNECTION_CLOSED: + case ERR_CONNECTION_RESET: + case ERR_CONNECTION_REFUSED: + case ERR_CONNECTION_ABORTED: + case ERR_CONNECTION_FAILED: + case ERR_SOCKET_NOT_CONNECTED: + return ERROR_CONNECT; + + case ERR_ADDRESS_INVALID: + case ERR_ADDRESS_UNREACHABLE: + case ERR_NAME_NOT_RESOLVED: + case ERR_NAME_RESOLUTION_FAILED: + return ERROR_HOST_LOOKUP; + + case ERR_SSL_PROTOCOL_ERROR: + case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: + case ERR_TUNNEL_CONNECTION_FAILED: + case ERR_NO_SSL_VERSIONS_ENABLED: + case ERR_SSL_VERSION_OR_CIPHER_MISMATCH: + case ERR_SSL_RENEGOTIATION_REQUESTED: + case ERR_CERT_ERROR_IN_SSL_RENEGOTIATION: + case ERR_BAD_SSL_CLIENT_AUTH_CERT: + case ERR_SSL_NO_RENEGOTIATION: + case ERR_SSL_DECOMPRESSION_FAILURE_ALERT: + case ERR_SSL_BAD_RECORD_MAC_ALERT: + case ERR_SSL_UNSAFE_NEGOTIATION: + case ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY: + case ERR_SSL_SNAP_START_NPN_MISPREDICTION: + case ERR_SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED: + case ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY: + return ERROR_FAILED_SSL_HANDSHAKE; + + case ERR_PROXY_AUTH_UNSUPPORTED: + case ERR_PROXY_AUTH_REQUESTED: + case ERR_PROXY_CONNECTION_FAILED: + case ERR_UNEXPECTED_PROXY_AUTH: + return ERROR_PROXY_AUTHENTICATION; + + default: + return ERROR_UNKNOWN; + } +} + +} diff --git a/WebKit/android/WebCoreSupport/WebViewClientError.h b/WebKit/android/WebCoreSupport/WebViewClientError.h new file mode 100644 index 0000000..847fb01 --- /dev/null +++ b/WebKit/android/WebCoreSupport/WebViewClientError.h @@ -0,0 +1,72 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebViewClientError_h +#define WebViewClientError_h + +#include "ChromiumIncludes.h" + +namespace android { + +// This enum must be kept in sync with WebViewClient.java +enum WebViewClientError { + /** Generic error */ + ERROR_UNKNOWN = -1, + /** Server or proxy hostname lookup failed */ + ERROR_HOST_LOOKUP = -2, + /** Unsupported authentication scheme (not basic or digest) */ + ERROR_UNSUPPORTED_AUTH_SCHEME = -3, + /** User authentication failed on server */ + ERROR_AUTHENTICATION = -4, + /** User authentication failed on proxy */ + ERROR_PROXY_AUTHENTICATION = -5, + /** Failed to connect to the server */ + ERROR_CONNECT = -6, + /** Failed to read or write to the server */ + ERROR_IO = -7, + /** Connection timed out */ + ERROR_TIMEOUT = -8, + /** Too many redirects */ + ERROR_REDIRECT_LOOP = -9, + /** Unsupported URI scheme */ + ERROR_UNSUPPORTED_SCHEME = -10, + /** Failed to perform SSL handshake */ + ERROR_FAILED_SSL_HANDSHAKE = -11, + /** Malformed URL */ + ERROR_BAD_URL = -12, + /** Generic file error */ + ERROR_FILE = -13, + /** File not found */ + ERROR_FILE_NOT_FOUND = -14, + /** Too many requests during this load */ + ERROR_TOO_MANY_REQUESTS = -15, +}; + +// Get the closest WebViewClient match to the given Chrome error code. +WebViewClientError ToWebViewClientError(net::Error); + +} // namespace android + +#endif // WebViewClientError_h |