diff options
Diffstat (limited to 'WebKit')
| -rw-r--r-- | WebKit/Android.mk | 4 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/ChromiumLogging.cpp | 68 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/ChromiumLogging.h | 38 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebRequest.cpp | 12 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebRequest.h | 3 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebRequestContext.cpp | 4 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebResourceRequest.cpp | 33 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebResourceRequest.h | 11 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebResponse.cpp | 10 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebResponse.h | 2 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp | 55 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebViewClientError.cpp | 117 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/WebViewClientError.h | 72 | ||||
| -rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 12 | ||||
| -rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.h | 2 |
15 files changed, 376 insertions, 67 deletions
diff --git a/WebKit/Android.mk b/WebKit/Android.mk index 7906da3..b9bc5a8 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -32,13 +32,15 @@ LOCAL_SRC_FILES := \ ifeq ($(HTTP_STACK),chrome) LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ + android/WebCoreSupport/ChromiumLogging.cpp \ android/WebCoreSupport/WebCache.cpp \ android/WebCoreSupport/WebUrlLoader.cpp \ android/WebCoreSupport/WebUrlLoaderClient.cpp \ 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/ChromiumLogging.cpp b/WebKit/android/WebCoreSupport/ChromiumLogging.cpp new file mode 100644 index 0000000..07fbeb8 --- /dev/null +++ b/WebKit/android/WebCoreSupport/ChromiumLogging.cpp @@ -0,0 +1,68 @@ +/* + * 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 "ChromiumLogging.h" + +#include "ChromiumIncludes.h" + +#include <cutils/log.h> +#include <string> + +namespace android { + +bool logMessageHandler(int severity, const std::string& str) { + int androidSeverity = ANDROID_LOG_VERBOSE; + switch(severity) { + case logging::LOG_FATAL: + androidSeverity = ANDROID_LOG_FATAL; + break; + case logging::LOG_ERROR_REPORT: + case logging::LOG_ERROR: + androidSeverity = ANDROID_LOG_ERROR; + break; + case logging::LOG_WARNING: + androidSeverity = ANDROID_LOG_WARN; + break; + default: + androidSeverity = ANDROID_LOG_VERBOSE; + break; + } + android_printLog(androidSeverity, "chromium", "%s", str.c_str()); + return false; +} + +void initChromiumLogging() +{ + static Lock loggingLock; + AutoLock aLock(loggingLock); + static bool loggingStarted = false; + if (!loggingStarted) { + logging::SetLogMessageHandler(logMessageHandler); + loggingStarted = true; + } +} + +} // namespace android diff --git a/WebKit/android/WebCoreSupport/ChromiumLogging.h b/WebKit/android/WebCoreSupport/ChromiumLogging.h new file mode 100644 index 0000000..74b71b4 --- /dev/null +++ b/WebKit/android/WebCoreSupport/ChromiumLogging.h @@ -0,0 +1,38 @@ +/* + * 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 ChromiumLogging_h +#define ChromiumLogging_h + +namespace android { + +// Sends chromium logs to logcat +// +// This only calls into chromium once, but can be called multiple times. +// It should be called before any other calls into external/chromium. +void initChromiumLogging(); +} + +#endif diff --git a/WebKit/android/WebCoreSupport/WebRequest.cpp b/WebKit/android/WebCoreSupport/WebRequest.cpp index ef09ff7..f21c1a2 100644 --- a/WebKit/android/WebCoreSupport/WebRequest.cpp +++ b/WebKit/android/WebCoreSupport/WebRequest.cpp @@ -130,10 +130,18 @@ void WebRequest::finish(bool success) m_urlLoader = 0; } -void WebRequest::AppendBytesToUpload(WTF::Vector<char>* data) +void WebRequest::appendFileToUpload(std::string filename) +{ + // AppendFileToUpload is only valid before calling start + ASSERT(m_loadState == Created, "appendFileToUpload called on a WebRequest not in CREATED state: (%s)", m_url.c_str()); + FilePath filePath(filename); + m_request->AppendFileToUpload(filePath); +} + +void WebRequest::appendBytesToUpload(WTF::Vector<char>* data) { // AppendBytesToUpload is only valid before calling start - ASSERT(m_loadState == Created, "Start called on a WebRequest not in CREATED state: (%s)", m_url.c_str()); + ASSERT(m_loadState == Created, "appendBytesToUpload called on a WebRequest not in CREATED state: (%s)", m_url.c_str()); m_request->AppendBytesToUpload(data->data(), data->size()); delete data; } diff --git a/WebKit/android/WebCoreSupport/WebRequest.h b/WebKit/android/WebCoreSupport/WebRequest.h index 1f73d2a..c82096e 100644 --- a/WebKit/android/WebCoreSupport/WebRequest.h +++ b/WebKit/android/WebCoreSupport/WebRequest.h @@ -60,7 +60,8 @@ public: WebRequest(WebUrlLoaderClient*, const WebResourceRequest&, int inputStream); // Optional, but if used has to be called before start - void AppendBytesToUpload(Vector<char>* data); + void appendBytesToUpload(Vector<char>* data); + void appendFileToUpload(std::string filename); void start(bool isPrivateBrowsing); void cancel(); diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/WebKit/android/WebCoreSupport/WebRequestContext.cpp index d7fa6b8..4b29f10 100644 --- a/WebKit/android/WebCoreSupport/WebRequestContext.cpp +++ b/WebKit/android/WebCoreSupport/WebRequestContext.cpp @@ -27,6 +27,7 @@ #include "WebRequestContext.h" #include "ChromiumIncludes.h" +#include "ChromiumLogging.h" #include "JNIUtility.h" #include "WebCoreJni.h" #include "WebUrlLoaderClient.h" @@ -193,6 +194,9 @@ WebRequestContext* WebRequestContext::getPrivateBrowsingContext() WebRequestContext* WebRequestContext::get(bool isPrivateBrowsing) { + // Initialize chromium logging, needs to be done before any chromium code is called + initChromiumLogging(); + return isPrivateBrowsing ? getPrivateBrowsingContext() : getRegularContext(); } diff --git a/WebKit/android/WebCoreSupport/WebResourceRequest.cpp b/WebKit/android/WebCoreSupport/WebResourceRequest.cpp index 8954887..e8fb520 100644 --- a/WebKit/android/WebCoreSupport/WebResourceRequest.cpp +++ b/WebKit/android/WebCoreSupport/WebResourceRequest.cpp @@ -30,17 +30,6 @@ #include <wtf/text/CString.h> -namespace { -const std::string android_asset("file:///android_asset/"); -const std::string android_res("file:///android_res/"); -const std::string android_content("content:"); - -// Matched in BrowserFrame.java -const int RESOURCE = 1; -const int ASSET = 2; -const int CONTENT = 3; -} - namespace android { WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceRequest) @@ -77,28 +66,6 @@ WebResourceRequest::WebResourceRequest(const WebCore::ResourceRequest& resourceR m_userAgent = resourceRequest.httpUserAgent().utf8().data(); m_url = resourceRequest.url().string().utf8().data(); - - // Android has special file urls, resolve these - m_specialAndroidFileType = 0; - std::string::size_type loc = m_url.find(android_asset); - if (loc != std::string::npos && loc == 0) { - m_url = m_url.erase(0, android_asset.length()); - m_specialAndroidFileType = ASSET; - return; - } - - loc = m_url.find(android_res); - if (loc != std::string::npos && loc == 0) { - m_url = m_url.erase(0, android_res.length()); - m_specialAndroidFileType = RESOURCE; - return; - } - - loc = m_url.find(android_content); - if (loc != std::string::npos && loc == 0) { - m_specialAndroidFileType = CONTENT; - return; - } } } // namespace android diff --git a/WebKit/android/WebCoreSupport/WebResourceRequest.h b/WebKit/android/WebCoreSupport/WebResourceRequest.h index 6274624..d0c7f90 100644 --- a/WebKit/android/WebCoreSupport/WebResourceRequest.h +++ b/WebKit/android/WebCoreSupport/WebResourceRequest.h @@ -66,22 +66,11 @@ public: return m_url; } - bool isAndroidUrl() const - { - return m_specialAndroidFileType != 0; - } - - int androidFileType() const - { - return m_specialAndroidFileType; - } - private: std::string m_method; std::string m_referrer; std::string m_userAgent; net::HttpRequestHeaders m_requestHeaders; - int m_specialAndroidFileType; std::string m_url; }; 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/WebUrlLoaderClient.cpp b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp index 8925fbc..6d8e192 100644 --- a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp +++ b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp @@ -37,6 +37,31 @@ #include "WebRequest.h" #include "WebResourceRequest.h" +#include <wtf/text/CString.h> + +namespace { +const char* androidAsset = "file:///android_asset/"; +const char* androidResource = "file:///android_res/"; +const char* androidContent = "content:"; +const int androidAssetLen = strlen(androidAsset); +const int androidResourceLen = strlen(androidResource); +const int androidContentLen = strlen(androidContent); + +bool isAndroidUrl(const std::string& url) +{ + if (!url.compare(0, androidAssetLen, androidAsset)) + return true; + + if (!url.compare(0, androidResourceLen, androidResource)) + return true; + + if (!url.compare(0, androidContentLen, androidContent)) + return true; + + return false; +} +} + namespace android { base::Thread* WebUrlLoaderClient::ioThread() @@ -93,8 +118,8 @@ WebUrlLoaderClient::WebUrlLoaderClient(WebFrame* webFrame, WebCore::ResourceHand , m_finished(false) { WebResourceRequest webResourceRequest(resourceRequest); - if (webResourceRequest.isAndroidUrl()) { - int inputStream = webFrame->inputStreamForAndroidResource(webResourceRequest.url().c_str(), webResourceRequest.androidFileType()); + if (isAndroidUrl(webResourceRequest.url())) { + int inputStream = webFrame->inputStreamForAndroidResource(webResourceRequest.url().c_str()); m_request = new WebRequest(this, webResourceRequest, inputStream); return; } @@ -107,6 +132,7 @@ WebUrlLoaderClient::WebUrlLoaderClient(WebFrame* webFrame, WebCore::ResourceHand Vector<FormDataElement> elements = resourceRequest.httpBody()->elements(); for (iter = elements.begin(); iter != elements.end(); iter++) { FormDataElement element = *iter; + switch (element.m_type) { case FormDataElement::data: if (!element.m_data.isEmpty()) { @@ -115,22 +141,29 @@ WebUrlLoaderClient::WebUrlLoaderClient(WebFrame* webFrame, WebCore::ResourceHand base::Thread* thread = ioThread(); if (thread) { Vector<char>* data = new Vector<char>(element.m_data); - thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::AppendBytesToUpload, data)); + thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::appendBytesToUpload, data)); } } break; -#if ENABLE(BLOB) case FormDataElement::encodedFile: - if (element.m_fileLength == -1) - continue; // TODO: Not supporting directories yet - else { - // TODO: Add fileuploads after Google log-in is fixed. - // Chrome code is here: webkit/glue/weburlloader_impl.cc:391 + { + // Chromium check if it is a directory by checking + // element.m_fileLength, that doesn't work in Android + std::string filename = element.m_filename.utf8().data(); + if (filename.size() > 0) { + base::Thread* thread = ioThread(); + if (thread) + thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::appendFileToUpload, filename)); + } } break; -#endif +#if ENABLE(BLOB) + case FormDataElement::encodedBlob: + LOG_ASSERT(false, "Unexpected use of FormDataElement::encodedBlob"); + break; +#endif // ENABLE(BLOB) default: - // TODO: Add a warning/DCHECK/assert here, should never happen + LOG_ASSERT(false, "Unexpected default case in WebUrlLoaderClient.cpp"); break; } } 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 diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 9cd5c79..04db4a9 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -33,6 +33,7 @@ #include "Cache.h" #include "Chrome.h" #include "ChromeClientAndroid.h" +#include "ChromiumLogging.h" #include "ContextMenuClientAndroid.h" #include "DeviceMotionClientAndroid.h" #include "DeviceOrientationClientAndroid.h" @@ -234,7 +235,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page* mJavaFrame = new JavaBrowserFrame; mJavaFrame->mObj = env->NewWeakGlobalRef(obj); mJavaFrame->mHistoryList = env->NewWeakGlobalRef(historyList); - mJavaFrame->mInputStreamForAndroidResource = env->GetMethodID(clazz, "inputStreamForAndroidResource", "(Ljava/lang/String;I)Ljava/io/InputStream;"); + mJavaFrame->mInputStreamForAndroidResource = env->GetMethodID(clazz, "inputStreamForAndroidResource", "(Ljava/lang/String;)Ljava/io/InputStream;"); mJavaFrame->mStartLoadingResource = env->GetMethodID(clazz, "startLoadingResource", "(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BJIZZZLjava/lang/String;Ljava/lang/String;)Landroid/webkit/LoadListener;"); mJavaFrame->mLoadStarted = env->GetMethodID(clazz, "loadStarted", @@ -382,13 +383,13 @@ private: int m_size; }; -int WebFrame::inputStreamForAndroidResource(const char* url, int type) +int WebFrame::inputStreamForAndroidResource(const char* url) { JNIEnv* env = getJNIEnv(); AutoJObject obj = mJavaFrame->frame(env); jstring jUrlStr = env->NewStringUTF(url); - jobject jInputStream = env->CallObjectMethod(obj.get(), mJavaFrame->mInputStreamForAndroidResource, jUrlStr, type); + jobject jInputStream = env->CallObjectMethod(obj.get(), mJavaFrame->mInputStreamForAndroidResource, jUrlStr); env->DeleteLocalRef(jUrlStr); return (int)jInputStream; @@ -960,6 +961,11 @@ static void CreateFrame(JNIEnv* env, jobject obj, jobject javaview, jobject jAss { ScriptController::initializeThreading(); +#if USE(CHROME_NETWORK_STACK) + // Initialize chromium logging, needs to be done before any chromium code is called + initChromiumLogging(); +#endif + #ifdef ANDROID_INSTRUMENT #if USE(V8) V8Counters::initCounters(); diff --git a/WebKit/android/jni/WebCoreFrameBridge.h b/WebKit/android/jni/WebCoreFrameBridge.h index 9e3b5db..2d2b571 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.h +++ b/WebKit/android/jni/WebCoreFrameBridge.h @@ -60,7 +60,7 @@ class WebFrame : public WebCoreRefObject { // helper function static WebFrame* getWebFrame(const WebCore::Frame* frame); - int inputStreamForAndroidResource(const char* url, int type); + int inputStreamForAndroidResource(const char* url); virtual PassRefPtr<WebCore::ResourceLoaderAndroid> startLoadingResource(WebCore::ResourceHandle*, const WebCore::ResourceRequest& request, bool mainResource, |
