diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java index c8e53d74..438dab8b 100755 --- a/framework/src/org/apache/cordova/CordovaWebViewClient.java +++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java @@ -161,6 +161,34 @@ public void onReceivedLoadError(XWalkView view, int errorCode, String descriptio public boolean shouldOverrideUrlLoading(XWalkView view, String url) { return helper.shouldOverrideUrlLoading(view, url); } + + /** + * Notify the host application that an SSL error occurred while loading a + * resource. The host application must call either callback.onReceiveValue(true) + * or callback.onReceiveValue(false). Note that the decision may be + * retained for use in response to future SSL errors. The default behavior + * is to pop up a dialog. + */ + public void onReceivedSslError(XWalkView view, ValueCallback callback, SslError error) { + final String packageName = this.cordova.getActivity().getPackageName(); + final PackageManager pm = this.cordova.getActivity().getPackageManager(); + + ApplicationInfo appInfo; + try { + appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); + if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { + // debug = true + callback.onReceiveValue(true); + return; + } else { + // debug = false + callback.onReceiveValue(false); + } + } catch (NameNotFoundException e) { + // When it doubt, lock it out! + callback.onReceiveValue(false); + } + } /** * Sets the authentication token.