This source file includes following definitions.
- JNINamespace
- setNativeContentsClientBridge
- allowCertificateError
- proceedSslError
- handleJsAlert
- handleJsConfirm
- handleJsPrompt
- handleJsBeforeUnload
- shouldOverrideUrlLoading
- confirmJsResult
- cancelJsResult
- nativeProceedSslError
- nativeConfirmJsResult
- nativeCancelJsResult
package org.chromium.android_webview;
import android.net.http.SslCertificate;
import android.net.http.SslError;
import android.webkit.ValueCallback;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
@JNINamespace("android_webview")
public class AwContentsClientBridge {
private AwContentsClient mClient;
private long mNativeContentsClientBridge;
public AwContentsClientBridge(AwContentsClient client) {
assert client != null;
mClient = client;
}
@CalledByNative
private void setNativeContentsClientBridge(long nativeContentsClientBridge) {
mNativeContentsClientBridge = nativeContentsClientBridge;
}
@CalledByNative
private boolean allowCertificateError(int certError, byte[] derBytes, final String url,
final int id) {
final SslCertificate cert = SslUtil.getCertificateFromDerBytes(derBytes);
if (cert == null) {
return false;
}
final SslError sslError = SslUtil.sslErrorFromNetErrorCode(certError, cert, url);
ValueCallback<Boolean> callback = new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean value) {
proceedSslError(value.booleanValue(), id);
}
};
mClient.onReceivedSslError(callback, sslError);
return true;
}
private void proceedSslError(boolean proceed, int id) {
if (mNativeContentsClientBridge == 0) return;
nativeProceedSslError(mNativeContentsClientBridge, proceed, id);
}
@CalledByNative
private void handleJsAlert(String url, String message, int id) {
JsResultHandler handler = new JsResultHandler(this, id);
mClient.handleJsAlert(url, message, handler);
}
@CalledByNative
private void handleJsConfirm(String url, String message, int id) {
JsResultHandler handler = new JsResultHandler(this, id);
mClient.handleJsConfirm(url, message, handler);
}
@CalledByNative
private void handleJsPrompt(String url, String message, String defaultValue, int id) {
JsResultHandler handler = new JsResultHandler(this, id);
mClient.handleJsPrompt(url, message, defaultValue, handler);
}
@CalledByNative
private void handleJsBeforeUnload(String url, String message, int id) {
JsResultHandler handler = new JsResultHandler(this, id);
mClient.handleJsBeforeUnload(url, message, handler);
}
@CalledByNative
private boolean shouldOverrideUrlLoading(String url) {
return mClient.shouldOverrideUrlLoading(url);
}
void confirmJsResult(int id, String prompt) {
if (mNativeContentsClientBridge == 0) return;
nativeConfirmJsResult(mNativeContentsClientBridge, id, prompt);
}
void cancelJsResult(int id) {
if (mNativeContentsClientBridge == 0) return;
nativeCancelJsResult(mNativeContentsClientBridge, id);
}
private native void nativeProceedSslError(long nativeAwContentsClientBridge, boolean proceed,
int id);
private native void nativeConfirmJsResult(long nativeAwContentsClientBridge, int id,
String prompt);
private native void nativeCancelJsResult(long nativeAwContentsClientBridge, int id);
}