| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/native/aw_contents_client_bridge.h" | 5 #include "android_webview/native/aw_contents_client_bridge.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "jni/AwContentsClientBridge_jni.h" | 12 #include "jni/AwContentsClientBridge_jni.h" |
| 13 #include "net/cert/x509_certificate.h" | 13 #include "net/cert/x509_certificate.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 using base::android::AttachCurrentThread; | 16 using base::android::AttachCurrentThread; |
| 17 using base::android::ConvertJavaStringToUTF16; | 17 using base::android::ConvertJavaStringToUTF16; |
| 18 using base::android::ConvertUTF8ToJavaString; | 18 using base::android::ConvertUTF8ToJavaString; |
| 19 using base::android::ConvertUTF16ToJavaString; | 19 using base::android::ConvertUTF16ToJavaString; |
| 20 using base::android::GetApplicationContext; |
| 20 using base::android::JavaRef; | 21 using base::android::JavaRef; |
| 21 using base::android::ScopedJavaLocalRef; | 22 using base::android::ScopedJavaLocalRef; |
| 22 using content::BrowserThread; | 23 using content::BrowserThread; |
| 23 | 24 |
| 24 namespace android_webview { | 25 namespace android_webview { |
| 25 | 26 |
| 26 AwContentsClientBridge::AwContentsClientBridge(JNIEnv* env, jobject obj) | 27 AwContentsClientBridge::AwContentsClientBridge(JNIEnv* env, jobject obj) |
| 27 : java_ref_(env, obj) { | 28 : java_ref_(env, obj) { |
| 28 DCHECK(obj); | 29 DCHECK(obj); |
| 29 Java_AwContentsClientBridge_setNativeContentsClientBridge( | 30 Java_AwContentsClientBridge_setNativeContentsClientBridge( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 env, | 62 env, |
| 62 reinterpret_cast<const uint8*>(der_string.data()), | 63 reinterpret_cast<const uint8*>(der_string.data()), |
| 63 der_string.length()); | 64 der_string.length()); |
| 64 ScopedJavaLocalRef<jstring> jurl(ConvertUTF8ToJavaString( | 65 ScopedJavaLocalRef<jstring> jurl(ConvertUTF8ToJavaString( |
| 65 env, request_url.spec())); | 66 env, request_url.spec())); |
| 66 // We need to add the callback before making the call to java side, | 67 // We need to add the callback before making the call to java side, |
| 67 // as it may do a synchronous callback prior to returning. | 68 // as it may do a synchronous callback prior to returning. |
| 68 int request_id = pending_cert_error_callbacks_.Add( | 69 int request_id = pending_cert_error_callbacks_.Add( |
| 69 new CertErrorCallback(callback)); | 70 new CertErrorCallback(callback)); |
| 70 *cancel_request = !Java_AwContentsClientBridge_allowCertificateError( | 71 *cancel_request = !Java_AwContentsClientBridge_allowCertificateError( |
| 71 env, obj.obj(), cert_error, jcert.obj(), jurl.obj(), request_id); | 72 env, |
| 73 obj.obj(), |
| 74 GetApplicationContext(), |
| 75 cert_error, |
| 76 jcert.obj(), |
| 77 jurl.obj(), |
| 78 request_id); |
| 72 // if the request is cancelled, then cancel the stored callback | 79 // if the request is cancelled, then cancel the stored callback |
| 73 if (*cancel_request) { | 80 if (*cancel_request) { |
| 74 pending_cert_error_callbacks_.Remove(request_id); | 81 pending_cert_error_callbacks_.Remove(request_id); |
| 75 } | 82 } |
| 76 } | 83 } |
| 77 | 84 |
| 78 void AwContentsClientBridge::ProceedSslError(JNIEnv* env, jobject obj, | 85 void AwContentsClientBridge::ProceedSslError(JNIEnv* env, jobject obj, |
| 79 jboolean proceed, jint id) { | 86 jboolean proceed, jint id) { |
| 80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 81 CertErrorCallback* callback = pending_cert_error_callbacks_.Lookup(id); | 88 CertErrorCallback* callback = pending_cert_error_callbacks_.Lookup(id); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 190 } |
| 184 callback->Run(false, string16()); | 191 callback->Run(false, string16()); |
| 185 pending_js_dialog_callbacks_.Remove(id); | 192 pending_js_dialog_callbacks_.Remove(id); |
| 186 } | 193 } |
| 187 | 194 |
| 188 bool RegisterAwContentsClientBridge(JNIEnv* env) { | 195 bool RegisterAwContentsClientBridge(JNIEnv* env) { |
| 189 return RegisterNativesImpl(env) >= 0; | 196 return RegisterNativesImpl(env) >= 0; |
| 190 } | 197 } |
| 191 | 198 |
| 192 } // namespace android_webview | 199 } // namespace android_webview |
| OLD | NEW |