You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2015/03/16 17:42:41 UTC

cordova-plugin-inappbrowser git commit: CB-8659 - Update InAppBrowser to support both cordova-ios 4.0.x and 3.x (closes #93)

Repository: cordova-plugin-inappbrowser
Updated Branches:
  refs/heads/master 4c8f58d87 -> ed1227f61


CB-8659 - Update InAppBrowser to support both cordova-ios 4.0.x and 3.x (closes #93)


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/ed1227f6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/ed1227f6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/ed1227f6

Branch: refs/heads/master
Commit: ed1227f61ac24c712558600002d11e2691754b65
Parents: 4c8f58d
Author: Shazron Abdullah <sh...@gmail.com>
Authored: Fri Mar 13 20:29:55 2015 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Mon Mar 16 09:42:16 2015 -0700

----------------------------------------------------------------------
 src/ios/CDVInAppBrowser.h | 13 ++++++++++++-
 src/ios/CDVInAppBrowser.m | 24 ++++++++++++++++--------
 2 files changed, 28 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/ed1227f6/src/ios/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h
index c92d9b7..1ccc7b1 100644
--- a/src/ios/CDVInAppBrowser.h
+++ b/src/ios/CDVInAppBrowser.h
@@ -20,7 +20,12 @@
 #import <Cordova/CDVPlugin.h>
 #import <Cordova/CDVInvokedUrlCommand.h>
 #import <Cordova/CDVScreenOrientationDelegate.h>
-#import <Cordova/CDVWebViewDelegate.h>
+
+#ifdef __CORDOVA_4_0_0
+    #import <Cordova/CDVUIWebViewDelegate.h>
+#else
+    #import <Cordova/CDVWebViewDelegate.h>
+#endif
 
 @class CDVInAppBrowserViewController;
 
@@ -69,7 +74,13 @@
     NSString* _prevUserAgent;
     NSInteger _userAgentLockToken;
     CDVInAppBrowserOptions *_browserOptions;
+    
+#ifdef __CORDOVA_4_0_0
+    CDVUIWebViewDelegate* _webViewDelegate;
+#else
     CDVWebViewDelegate* _webViewDelegate;
+#endif
+    
 }
 
 @property (nonatomic, strong) IBOutlet UIWebView* webView;

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/ed1227f6/src/ios/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m
index 71e214e..6d141d3 100644
--- a/src/ios/CDVInAppBrowser.m
+++ b/src/ios/CDVInAppBrowser.m
@@ -41,15 +41,10 @@
 
 @implementation CDVInAppBrowser
 
-- (CDVInAppBrowser*)initWithWebView:(UIWebView*)theWebView
+- (void)pluginInitialize
 {
-    self = [super initWithWebView:theWebView];
-    if (self != nil) {
-        _previousStatusBarStyle = -1;
-        _callbackIdPattern = nil;
-    }
-
-    return self;
+    _previousStatusBarStyle = -1;
+    _callbackIdPattern = nil;
 }
 
 - (void)onReset
@@ -87,7 +82,11 @@
     self.callbackId = command.callbackId;
 
     if (url != nil) {
+#ifdef __CORDOVA_4_0_0
+        NSURL* baseUrl = [self.webViewEngine URL];
+#else
         NSURL* baseUrl = [self.webView.request URL];
+#endif
         NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
 
         if ([self isSystemUrl:absoluteUrl]) {
@@ -231,7 +230,11 @@
 {
     if ([self.commandDelegate URLIsWhitelisted:url]) {
         NSURLRequest* request = [NSURLRequest requestWithURL:url];
+#ifdef __CORDOVA_4_0_0
+        [self.webViewEngine loadRequest:request];
+#else
         [self.webView loadRequest:request];
+#endif
     } else { // this assumes the InAppBrowser can be excepted from the white-list
         [self openInInAppBrowser:url withOptions:options];
     }
@@ -462,7 +465,12 @@
         _userAgent = userAgent;
         _prevUserAgent = prevUserAgent;
         _browserOptions = browserOptions;
+#ifdef __CORDOVA_4_0_0
+        _webViewDelegate = [[CDVUIWebViewDelegate alloc] initWithDelegate:self];
+#else
         _webViewDelegate = [[CDVWebViewDelegate alloc] initWithDelegate:self];
+#endif
+        
         [self createViews];
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org