cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject android commit: [CB-2305] Add InAppBrowser injectSriptCode command to support InAppBrowser.executeScript and InAppBrowser.insertCSS APIs
Date Sat, 23 Mar 2013 17:13:47 GMT
Updated Branches:
  refs/heads/master b028ad360 -> f60d54eae


[CB-2305] Add InAppBrowser injectSriptCode command to support InAppBrowser.executeScript and
InAppBrowser.insertCSS APIs


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/f60d54ea
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/f60d54ea
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/f60d54ea

Branch: refs/heads/master
Commit: f60d54eae4a6af0ab55fa8fa1323b5ebacf8db85
Parents: b028ad3
Author: Ian Clelland <iclelland@chromium.org>
Authored: Mon Mar 18 10:16:24 2013 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Sat Mar 23 13:13:21 2013 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/InAppBrowser.java |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/f60d54ea/framework/src/org/apache/cordova/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/InAppBrowser.java b/framework/src/org/apache/cordova/InAppBrowser.java
index 48e27c6..02aa002 100644
--- a/framework/src/org/apache/cordova/InAppBrowser.java
+++ b/framework/src/org/apache/cordova/InAppBrowser.java
@@ -151,6 +151,21 @@ public class InAppBrowser extends CordovaPlugin {
                 pluginResult.setKeepCallback(false);
                 this.callbackContext.sendPluginResult(pluginResult);
             }
+            else if (action.equals("injectScriptCode")) {
+                String source = args.getString(0);
+
+                org.json.JSONArray jsonEsc = new org.json.JSONArray();
+                jsonEsc.put(source);
+                String jsonRepr = jsonEsc.toString();
+                String jsonSourceString = jsonRepr.substring(1, jsonRepr.length()-1);
+                String scriptEnclosure = "(function(d){var c=d.createElement('script');c.type='text/javascript';c.innerText="
+                                       + jsonSourceString
+                                       + ";d.getElementsByTagName('head')[0].appendChild(c);})(document)";
+                this.inAppWebView.loadUrl("javascript:" + scriptEnclosure);
+
+                PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
+                this.callbackContext.sendPluginResult(pluginResult);
+            }
             else {
                 status = PluginResult.Status.INVALID_ACTION;
             }


Mime
View raw message