You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/03/25 15:29:25 UTC
ios commit: [CB-2653] Simplify InAppBrowser.injectScriptCode.
Updated Branches:
refs/heads/master 40c98b8b7 -> 9a6a68948
[CB-2653] Simplify InAppBrowser.injectScriptCode.
The previous commit was an outdated pull request. This one is the
correct one (whoops).
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/9a6a6894
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/9a6a6894
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/9a6a6894
Branch: refs/heads/master
Commit: 9a6a6894835f8035fcc189a068c59a1c96fdff6c
Parents: 40c98b8
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Mar 25 10:27:57 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Mar 25 10:27:57 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVInAppBrowser.m | 18 ++----------------
1 files changed, 2 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9a6a6894/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
index dcbb2f4..ef0acb3 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.m
+++ b/CordovaLib/Classes/CDVInAppBrowser.m
@@ -162,25 +162,11 @@
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command
{
NSString* source = [command argumentAtIndex:0];
- // NSString* position = [command argumentAtIndex:1];
CDVPluginResult* pluginResult;
- self.callbackId = command.callbackId;
-
- NSError* jsonErr;
- NSData* jsonEsc = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:&jsonErr];
-
- if (jsonErr == nil) {
- NSString* jsonRepr = [[NSString alloc] initWithData:jsonEsc encoding:NSUTF8StringEncoding];
- NSString* jsonSourceString = [jsonRepr substringWithRange:(NSRange) {1, [jsonRepr length] - 2}];
- NSString* scriptEnclosure = [NSString stringWithFormat:@"(function(d) { var c = d.createElement('script'); c.type='text/javascript'; c.innerText = %@; d.getElementsByTagName('head')[0].appendChild(c); })(document)", jsonSourceString];
- [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:scriptEnclosure];
+ [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:source];
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"unable to serialize script code"];
- }
- [pluginResult setKeepCallback:[NSNumber numberWithBool:NO]];
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
}