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 2013/09/24 23:34:04 UTC

git commit: CB-4788: Modified the onJsPrompt to warn against Cordova calls

Updated Branches:
  refs/heads/dev 673520793 -> 2dcfafb60


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/dev
Commit: 2dcfafb60e2ba51678d6fdd4305e5d82bbfaa22f
Parents: 6735207
Author: Joe Bowser <bo...@apache.org>
Authored: Tue Sep 24 14:33:44 2013 -0700
Committer: Joe Bowser <bo...@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;
             }
         }