You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by na...@apache.org on 2014/08/28 21:03:30 UTC
[16/50] git 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-amazon-fireos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/commit/48ba0036
Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/48ba0036
Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/48ba0036
Branch: refs/heads/master
Commit: 48ba0036315bea01730e771ee3600e0dc5b6e65b
Parents: 5843c7e
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Jul 21 09:20:49 2014 -0400
Committer: Archana Naik <na...@lab126.com>
Committed: Mon Aug 18 12:30:52 2014 -0700
----------------------------------------------------------------------
.../src/org/apache/cordova/CordovaWebViewClient.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/48ba0036/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 082ea25..0af891a 100755
--- a/framework/src/org/apache/cordova/CordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java
@@ -232,7 +232,19 @@ public class CordovaWebViewClient extends AmazonWebViewClient {
// 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);