Skip to content

Commit

Permalink
Merge pull request #3116 from dizzymonkey/timob-11227
Browse files Browse the repository at this point in the history
TIMOB-11227 fix to support new ignoreSslError property on web view
  • Loading branch information
billdawson committed Oct 5, 2012
2 parents 3bd9708 + 459f960 commit 96e5544
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
TiC.PROPERTY_DATA,
TiC.PROPERTY_ON_CREATE_WINDOW,
TiC.PROPERTY_SCALES_PAGE_TO_FIT,
TiC.PROPERTY_URL
TiC.PROPERTY_URL,
TiC.PROPERTY_WEBVIEW_IGNORE_SSL_ERROR
})
public class WebViewProxy extends ViewProxy
implements Handler.Callback, OnLifecycleEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
package ti.modules.titanium.ui.widget.webview;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiC;

import ti.modules.titanium.media.TiVideoActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.webkit.HttpAuthHandler;
import android.webkit.MimeTypeMap;
import android.webkit.SslErrorHandler;
import android.webkit.URLUtil;
import android.webkit.WebView;
import android.webkit.WebViewClient;
Expand Down Expand Up @@ -150,4 +153,31 @@ public void setBasicAuthentication(String username, String password)
this.username = username;
this.password = password;
}

@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
{
/*
* in theory this should be checked to make sure it's not null but if there is some failure
* in the association then usage of webViewProxy should trigger a NPE to make sure the issue
* is not ignored
*/
KrollProxy webViewProxy = this.webView.getProxy();

boolean ignoreSslError = false;
try {
ignoreSslError = webViewProxy.getProperties().optBoolean(TiC.PROPERTY_WEBVIEW_IGNORE_SSL_ERROR, false);

} catch(IllegalArgumentException e) {
Log.e(TAG, TiC.PROPERTY_WEBVIEW_IGNORE_SSL_ERROR + " property does not contain a boolean value, ignoring");
}

if (ignoreSslError == true) {
Log.w(TAG, "ran into SSL error but ignoring...");
handler.proceed();

} else {
Log.e(TAG, "SSL error occurred: " + error.toString());
}
}
}
5 changes: 5 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,11 @@ public class TiC
*/
public static final String PROPERTY_VOLUME = "volume";

/**
* @module.api
*/
public static final String PROPERTY_WEBVIEW_IGNORE_SSL_ERROR = "ignoreSslError";

/**
* @module.api
*/
Expand Down

0 comments on commit 96e5544

Please sign in to comment.