| 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 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_CLIENT_BRIDGE_H_ | 5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_CLIENT_BRIDGE_H_ |
| 6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_CLIENT_BRIDGE_H_ | 6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_CLIENT_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_contents_client_bridge_base.h" | 10 #include "android_webview/browser/aw_contents_client_bridge_base.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // A class that handles the Java<->Native communication for the | 23 // A class that handles the Java<->Native communication for the |
| 24 // AwContentsClient. AwContentsClientBridge is created and owned by | 24 // AwContentsClient. AwContentsClientBridge is created and owned by |
| 25 // native AwContents class and it only has a weak reference to the | 25 // native AwContents class and it only has a weak reference to the |
| 26 // its Java peer. Since the Java AwContentsClientBridge can have | 26 // its Java peer. Since the Java AwContentsClientBridge can have |
| 27 // indirect refs from the Application (via callbacks) and so can outlive | 27 // indirect refs from the Application (via callbacks) and so can outlive |
| 28 // webview, this class notifies it before being destroyed and to nullify | 28 // webview, this class notifies it before being destroyed and to nullify |
| 29 // any references. | 29 // any references. |
| 30 class AwContentsClientBridge : public AwContentsClientBridgeBase { | 30 class AwContentsClientBridge : public AwContentsClientBridgeBase { |
| 31 public: | 31 public: |
| 32 typedef base::Callback<void(net::X509Certificate*)> SelectCertificateCallback; |
| 32 | 33 |
| 33 AwContentsClientBridge(JNIEnv* env, jobject obj); | 34 AwContentsClientBridge(JNIEnv* env, jobject obj); |
| 34 virtual ~AwContentsClientBridge(); | 35 virtual ~AwContentsClientBridge(); |
| 35 | 36 |
| 36 // AwContentsClientBridgeBase implementation | 37 // AwContentsClientBridgeBase implementation |
| 37 virtual void AllowCertificateError(int cert_error, | 38 virtual void AllowCertificateError(int cert_error, |
| 38 net::X509Certificate* cert, | 39 net::X509Certificate* cert, |
| 39 const GURL& request_url, | 40 const GURL& request_url, |
| 40 const base::Callback<void(bool)>& callback, | 41 const base::Callback<void(bool)>& callback, |
| 41 bool* cancel_request) OVERRIDE; | 42 bool* cancel_request) OVERRIDE; |
| 43 virtual void SelectClientCertificate( |
| 44 net::SSLCertRequestInfo* cert_request_info, |
| 45 const SelectCertificateCallback& callback) OVERRIDE; |
| 42 | 46 |
| 43 virtual void RunJavaScriptDialog( | 47 virtual void RunJavaScriptDialog( |
| 44 content::JavaScriptMessageType message_type, | 48 content::JavaScriptMessageType message_type, |
| 45 const GURL& origin_url, | 49 const GURL& origin_url, |
| 46 const base::string16& message_text, | 50 const base::string16& message_text, |
| 47 const base::string16& default_prompt_text, | 51 const base::string16& default_prompt_text, |
| 48 const content::JavaScriptDialogManager::DialogClosedCallback& callback) | 52 const content::JavaScriptDialogManager::DialogClosedCallback& callback) |
| 49 OVERRIDE; | 53 OVERRIDE; |
| 50 virtual void RunBeforeUnloadDialog( | 54 virtual void RunBeforeUnloadDialog( |
| 51 const GURL& origin_url, | 55 const GURL& origin_url, |
| 52 const base::string16& message_text, | 56 const base::string16& message_text, |
| 53 const content::JavaScriptDialogManager::DialogClosedCallback& callback) | 57 const content::JavaScriptDialogManager::DialogClosedCallback& callback) |
| 54 OVERRIDE; | 58 OVERRIDE; |
| 55 virtual bool ShouldOverrideUrlLoading(const base::string16& url) OVERRIDE; | 59 virtual bool ShouldOverrideUrlLoading(const base::string16& url) OVERRIDE; |
| 56 | 60 |
| 57 // Methods called from Java. | 61 // Methods called from Java. |
| 58 void ProceedSslError(JNIEnv* env, jobject obj, jboolean proceed, jint id); | 62 void ProceedSslError(JNIEnv* env, jobject obj, jboolean proceed, jint id); |
| 63 void ProvideClientCertificateResponse(JNIEnv* env, jobject object, |
| 64 jlong request_id, jobjectArray encoded_chain_ref, |
| 65 jobject private_key_ref); |
| 59 void ConfirmJsResult(JNIEnv*, jobject, int id, jstring prompt); | 66 void ConfirmJsResult(JNIEnv*, jobject, int id, jstring prompt); |
| 60 void CancelJsResult(JNIEnv*, jobject, int id); | 67 void CancelJsResult(JNIEnv*, jobject, int id); |
| 61 | 68 |
| 62 private: | 69 private: |
| 63 JavaObjectWeakGlobalRef java_ref_; | 70 JavaObjectWeakGlobalRef java_ref_; |
| 64 | 71 |
| 65 typedef const base::Callback<void(bool)> CertErrorCallback; | 72 typedef const base::Callback<void(bool)> CertErrorCallback; |
| 66 IDMap<CertErrorCallback, IDMapOwnPointer> pending_cert_error_callbacks_; | 73 IDMap<CertErrorCallback, IDMapOwnPointer> pending_cert_error_callbacks_; |
| 67 IDMap<content::JavaScriptDialogManager::DialogClosedCallback, IDMapOwnPointer> | 74 IDMap<content::JavaScriptDialogManager::DialogClosedCallback, IDMapOwnPointer> |
| 68 pending_js_dialog_callbacks_; | 75 pending_js_dialog_callbacks_; |
| 69 }; | 76 }; |
| 70 | 77 |
| 71 bool RegisterAwContentsClientBridge(JNIEnv* env); | 78 bool RegisterAwContentsClientBridge(JNIEnv* env); |
| 72 | 79 |
| 73 } // namespace android_webview | 80 } // namespace android_webview |
| 74 | 81 |
| 75 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_CLIENT_BRIDGE_H_ | 82 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_CLIENT_BRIDGE_H_ |
| OLD | NEW |