cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [09/13] git commit: CB-4788: Modified the onJsPrompt to warn against Cordova calls
Date Thu, 26 Sep 2013 22:27:03 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/de4fd41f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/de4fd41f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/de4fd41f

Branch: refs/heads/master
Commit: de4fd41f8efdcd05c05afe056c593e7df0fc7db5
Parents: 1ce5dca
Author: Joe Bowser <bowserj@apache.org>
Authored: Tue Sep 24 14:33:44 2013 -0700
Committer: Anis Kadri <anis@apache.org>
Committed: Wed Sep 25 16:49:16 2013 +0200

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


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/de4fd41f/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