OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_CLIENT_BRIDGE_H_ |
| 6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_CLIENT_BRIDGE_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 |
| 10 #include "android_webview/browser/aw_contents_client_bridge_base.h" |
| 11 #include "base/android/jni_helper.h" |
| 12 #include "base/android/scoped_java_ref.h" |
| 13 #include "base/callback.h" |
| 14 #include "base/id_map.h" |
| 15 |
| 16 namespace net { |
| 17 class X509Certificate; |
| 18 } |
| 19 |
| 20 namespace android_webview { |
| 21 |
| 22 // A class that handles the Java<->Native communication for the |
| 23 // AwContentsClient. AwContentsClientBridge is created and owned by |
| 24 // native AwContents class and it only has a weak reference to the |
| 25 // its Java peer. Since the Java AwContentsClientBridge can have |
| 26 // indirect refs from the Application (via callbacks) and so can outlive |
| 27 // webview, this class notifies it before being destroyed and to nullify |
| 28 // any references. |
| 29 class AwContentsClientBridge : public AwContentsClientBridgeBase { |
| 30 public: |
| 31 |
| 32 AwContentsClientBridge(JNIEnv* env, jobject obj); |
| 33 virtual ~AwContentsClientBridge(); |
| 34 |
| 35 // AwContentsClientBridgeBase implementation |
| 36 virtual void AllowCertificateError(int cert_error, |
| 37 net::X509Certificate* cert, |
| 38 const GURL& request_url, |
| 39 const base::Callback<void(bool)>& callback, |
| 40 bool* cancel_request) OVERRIDE; |
| 41 |
| 42 // Methods called from Java. |
| 43 void ProceedSslError(JNIEnv* env, jobject obj, jboolean proceed, jint id); |
| 44 |
| 45 private: |
| 46 JavaObjectWeakGlobalRef java_ref_; |
| 47 |
| 48 typedef const base::Callback<void(bool)> CertErrorCallback; |
| 49 IDMap<CertErrorCallback, IDMapOwnPointer> pending_cert_error_callbacks_; |
| 50 }; |
| 51 |
| 52 bool RegisterAwContentsClientBridge(JNIEnv* env); |
| 53 |
| 54 } // namespace android_webview |
| 55 |
| 56 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_CLIENT_BRIDGE_H_ |
OLD | NEW |