diff --git a/framework/src/org/apache/cordova/InAppBrowser.java b/framework/src/org/apache/cordova/InAppBrowser.java index 48e27c60..0d5d4965 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; } @@ -445,7 +460,7 @@ public class InAppBrowser extends CordovaPlugin { //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); - boolean enableDatabase = appSettings.getBoolean("InAppBrowserStorageEnabled", true); + boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); if(enableDatabase) { String databasePath = cordova.getActivity().getApplicationContext().getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath(); diff --git a/framework/src/org/apache/cordova/api/PluginManager.java b/framework/src/org/apache/cordova/api/PluginManager.java index 337ef129..774b21c3 100755 --- a/framework/src/org/apache/cordova/api/PluginManager.java +++ b/framework/src/org/apache/cordova/api/PluginManager.java @@ -30,6 +30,7 @@ import org.xmlpull.v1.XmlPullParserException; import android.content.Intent; import android.content.res.XmlResourceParser; +import android.util.Log; import android.webkit.WebResourceResponse; /** @@ -213,6 +214,7 @@ public class PluginManager { public boolean exec(String service, String action, String callbackId, String rawArgs) { CordovaPlugin plugin = this.getPlugin(service); if (plugin == null) { + Log.d(TAG, "exec() call to unknown plugin: " + service); PluginResult cr = new PluginResult(PluginResult.Status.CLASS_NOT_FOUND_EXCEPTION); app.sendPluginResult(cr, callbackId); return true;