You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2014/08/14 23:21:14 UTC
[06/10] android commit: Handle unsupported protocol errors in webview
better
Handle unsupported protocol errors in webview better
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/993d7376
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/993d7376
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/993d7376
Branch: refs/heads/4.0.x
Commit: 993d73762caaf02e2d5045fb9e60345e2a8bf6ac
Parents: 48b51c4
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Jul 21 09:20:49 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Wed Aug 6 09:55:03 2014 -0400
----------------------------------------------------------------------
.../src/org/apache/cordova/CordovaWebViewClient.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/993d7376/framework/src/org/apache/cordova/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java
index a2cf0be..f65a976 100755
--- a/framework/src/org/apache/cordova/CordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java
@@ -231,7 +231,19 @@ public class CordovaWebViewClient extends WebViewClient {
// Clear timeout flag
this.appView.loadUrlTimeout++;
- // Handle error
+ // If this is a "Protocol Not Supported" error, then revert to the previous
+ // page. If there was no previous page, then punt. The application's config
+ // is likely incorrect (start page set to sms: or something like that)
+ if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
+ if (view.canGoBack()) {
+ view.goBack();
+ return;
+ } else {
+ super.onReceivedError(view, errorCode, description, failingUrl);
+ }
+ }
+
+ // Handle other errors by passing them to the webview in JS
JSONObject data = new JSONObject();
try {
data.put("errorCode", errorCode);