cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [07/13] git commit: CB-4788: Modified the onJsPrompt to warn against Cordova calls
Date Thu, 26 Sep 2013 22:27:01 GMT
CB-4788: Modified the onJsPrompt to warn against Cordova calls


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/2dcfafb6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/2dcfafb6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/2dcfafb6

Branch: refs/heads/master
Commit: 2dcfafb60e2ba51678d6fdd4305e5d82bbfaa22f
Parents: 6735207
Author: Joe Bowser <bowserj@apache.org>
Authored: Tue Sep 24 14:33:44 2013 -0700
Committer: Joe Bowser <bowserj@apache.org>
Committed: Tue Sep 24 14:33:54 2013 -0700

----------------------------------------------------------------------
 src/android/InAppChromeClient.java | 35 +++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/2dcfafb6/src/android/InAppChromeClient.java
----------------------------------------------------------------------
diff --git a/src/android/InAppChromeClient.java b/src/android/InAppChromeClient.java
index 2db73ab..2c240c6 100644
--- a/src/android/InAppChromeClient.java
+++ b/src/android/InAppChromeClient.java
@@ -95,21 +95,30 @@ public class InAppChromeClient extends WebChromeClient {
     @Override
     public boolean onJsPrompt(WebView view, String url, String message, String defaultValue,
JsPromptResult result) {
         // See if the prompt string uses the 'gap-iab' protocol. If so, the remainder should
be the id of a callback to execute.
-        if (defaultValue != null && defaultValue.startsWith("gap-iab://")) {
-            PluginResult scriptResult;
-            String scriptCallbackId = defaultValue.substring(10);
-            if (scriptCallbackId.startsWith("InAppBrowser")) {
-                if(message == null || message.length() == 0) {
-                    scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray());
-                } else {
-                    try {
-                        scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray(message));
-                    } catch(JSONException e) {
-                        scriptResult = new PluginResult(PluginResult.Status.JSON_EXCEPTION,
e.getMessage());
+        if (defaultValue != null && defaultValue.startsWith("gap")) {
+            if(defaultValue.startsWith("gap-iab://")) {
+                PluginResult scriptResult;
+                String scriptCallbackId = defaultValue.substring(10);
+                if (scriptCallbackId.startsWith("InAppBrowser")) {
+                    if(message == null || message.length() == 0) {
+                        scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray());
+                    } else {
+                        try {
+                            scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray(message));
+                        } catch(JSONException e) {
+                            scriptResult = new PluginResult(PluginResult.Status.JSON_EXCEPTION,
e.getMessage());
+                        }
                     }
+                    this.webView.sendPluginResult(scriptResult, scriptCallbackId);
+                    result.confirm("");
+                    return true;
                 }
-                this.webView.sendPluginResult(scriptResult, scriptCallbackId);
-                result.confirm("");
+            }
+            else
+            {
+                // Anything else with a gap: prefix should get this message
+                LOG.w(LOG_TAG, "InAppBrowser does not support Cordova API calls: " + url
+ " " + defaultValue); 
+                result.cancel();
                 return true;
             }
         }


Mime
View raw message