Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Unified Diff: android_webview/native/aw_contents.cc

Issue 12091111: Implement Webviewclient.onReceivedSslError (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address code review Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/native/aw_contents.cc
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index f170e4927ac7041ee9ce4006daaf45e2d441da1d..c46118299e19b16ad2bebdf4e70add2990700772 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -917,4 +917,36 @@ void AwContents::OnPictureUpdated(int process_id, int render_view_id) {
Invalidate();
}
+void AwContents::AllowCertificateError(
+ int cert_error,
+ net::X509Certificate* cert,
+ const GURL& request_url,
+ const base::Callback<void(bool)>& callback,
+ bool* cancel_request) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ JNIEnv* env = AttachCurrentThread();
+
+ std::string der_string;
+ net::X509Certificate::GetDEREncoded(cert->os_cert_handle(),&der_string);
+ ScopedJavaLocalRef<jbyteArray> jcert = base::android::ToJavaByteArray(env,
+ reinterpret_cast<const uint8*>(der_string.data()), der_string.length());
+ ScopedJavaLocalRef<jstring> jurl(ConvertUTF8ToJavaString(
+ env, request_url.spec()));
+ ssl_error_callback_ = callback;
+ *cancel_request = Java_AwContents_cancelCertificateError(env,
boliu 2013/02/01 23:07:13 Would the old name but with a negation here be bet
sgurun-gerrit only 2013/02/02 01:01:10 I think the name is very clear. Why make it compli
boliu 2013/02/02 01:10:42 There is a convention to match the method name all
+ java_ref_.get(env).obj(), reinterpret_cast<jint>(cert_error), jcert.obj(),
+ jurl.obj());
+}
+
+void AwContents::ProceedSslError(JNIEnv* env, jobject obj, jboolean proceed) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (ssl_error_callback_.is_null()) {
+ LOG(WARNING) << "Ignoring unexpected ssl error proceed callback";
+ return;
+ }
+ ssl_error_callback_.Run(proceed);
+ ssl_error_callback_.Reset();
+}
+
+
} // namespace android_webview

Powered by Google App Engine
This is Rietveld 408576698