summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni/WebCoreFrameBridge.cpp
diff options
context:
space:
mode:
authorHuahui Wu <hwu@google.com>2010-12-08 15:22:43 -0800
committerHuahui Wu <hwu@google.com>2010-12-15 09:36:28 -0800
commit1f9212cd9a5e957562b12e8c3294b7f357fa1f85 (patch)
treed3ad74023aa22e8a3edbec1c8a1089126e06428e /WebKit/android/jni/WebCoreFrameBridge.cpp
parent0d7cec732e3f00f89749d4946fd22168d8d4111c (diff)
downloadexternal_webkit-1f9212cd9a5e957562b12e8c3294b7f357fa1f85.zip
external_webkit-1f9212cd9a5e957562b12e8c3294b7f357fa1f85.tar.gz
external_webkit-1f9212cd9a5e957562b12e8c3294b7f357fa1f85.tar.bz2
b/2864818 Prompt SSL cert error dialog to user and proceed or cancel the request. Java side CL: https://android-git.corp.google.com/g/#change,84530
Change-Id: I2a16be691ba3846f3ecb1fd533905d7b6ac374fc
Diffstat (limited to 'WebKit/android/jni/WebCoreFrameBridge.cpp')
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index 5fa5dfb..4fac42d 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -215,6 +215,7 @@ struct WebFrame::JavaBrowserFrame
jmethodID mGetFileSize;
jmethodID mGetFile;
jmethodID mDidReceiveAuthenticationChallenge;
+ jmethodID mReportSslCertError;
jmethodID mDownloadStart;
AutoJObject frame(JNIEnv* env) {
return getRealObject(env, mObj);
@@ -281,6 +282,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
mJavaFrame->mGetFile = env->GetMethodID(clazz, "getFile", "(Ljava/lang/String;[BII)I");
mJavaFrame->mDidReceiveAuthenticationChallenge = env->GetMethodID(clazz, "didReceiveAuthenticationChallenge",
"(ILjava/lang/String;Ljava/lang/String;Z)V");
+ mJavaFrame->mReportSslCertError = env->GetMethodID(clazz, "reportSslCertError", "(II[B)V");
mJavaFrame->mDownloadStart = env->GetMethodID(clazz, "downloadStart",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;J)V");
env->DeleteLocalRef(clazz);
@@ -308,6 +310,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
LOG_ASSERT(mJavaFrame->mGetFileSize, "Could not find method getFileSize");
LOG_ASSERT(mJavaFrame->mGetFile, "Could not find method getFile");
LOG_ASSERT(mJavaFrame->mDidReceiveAuthenticationChallenge, "Could not find method didReceiveAuthenticationChallenge");
+ LOG_ASSERT(mJavaFrame->mReportSslCertError, "Could not find method reportSslCertError");
LOG_ASSERT(mJavaFrame->mDownloadStart, "Could not find method downloadStart");
mUserAgent = WTF::String();
@@ -863,6 +866,26 @@ WebFrame::didReceiveAuthenticationChallenge(WebUrlLoaderClient* client, const st
}
void
+WebFrame::reportSslCertError(WebUrlLoaderClient* client, int cert_error, const std::string& cert)
+{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::JavaCallbackTimeCounter);
+#endif
+ JNIEnv* env = getJNIEnv();
+ int jHandle = reinterpret_cast<int>(client);
+
+ int len = cert.length();
+ jbyteArray jCert = env->NewByteArray(len);
+ jbyte* bytes = env->GetByteArrayElements(jCert, NULL);
+ cert.copy(reinterpret_cast<char*>(bytes), len);
+
+ env->CallVoidMethod(mJavaFrame->frame(env).get(),
+ mJavaFrame->mReportSslCertError, jHandle, cert_error, jCert);
+ env->DeleteLocalRef(jCert);
+ checkException(env);
+}
+
+void
WebFrame::downloadStart(const std::string& url, const std::string& userAgent, const std::string& contentDisposition, const std::string& mimetype, long long contentLength)
{
#ifdef ANDROID_INSTRUMENT
@@ -1876,6 +1899,18 @@ static void AuthenticationCancel(JNIEnv *env, jobject obj, int handle)
client->cancelAuth();
}
+static void SslCertErrorProceed(JNIEnv *env, jobject obj, int handle)
+{
+ WebUrlLoaderClient* client = reinterpret_cast<WebUrlLoaderClient*>(handle);
+ client->proceedSslCertError();
+}
+
+static void SslCertErrorCancel(JNIEnv *env, jobject obj, int handle, int cert_error)
+{
+ WebUrlLoaderClient* client = reinterpret_cast<WebUrlLoaderClient*>(handle);
+ client->cancelSslCertError(cert_error);
+}
+
#else
static void AuthenticationProceed(JNIEnv *env, jobject obj, int handle, jstring jUsername, jstring jPassword)
@@ -1888,6 +1923,16 @@ static void AuthenticationCancel(JNIEnv *env, jobject obj, int handle)
LOGW("Chromium authentication API called, but libchromium is not available");
}
+static void SslCertErrorProceed(JNIEnv *env, jobject obj, int handle)
+{
+ LOGW("Chromium SSL API called, but libchromium is not available");
+}
+
+static void SslCertErrorCancel(JNIEnv *env, jobject obj, int handle, int cert_error)
+{
+ LOGW("Chromium SSL API called, but libchromium is not available");
+}
+
#endif // USE(CHROME_NETWORK_STACK)
// ----------------------------------------------------------------------------
@@ -1950,6 +1995,10 @@ static JNINativeMethod gBrowserFrameNativeMethods[] = {
(void*) AuthenticationProceed },
{ "nativeAuthenticationCancel", "(I)V",
(void*) AuthenticationCancel },
+ { "nativeSslCertErrorProceed", "(I)V",
+ (void*) SslCertErrorProceed },
+ { "nativeSslCertErrorCancel", "(II)V",
+ (void*) SslCertErrorCancel },
};
int registerWebFrame(JNIEnv* env)