Skip to content

Commit

Permalink
(ios) add compile-time decision for disabling UIWebView (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maik Hummel authored and NiklasMerz committed Jan 4, 2020
1 parent 785fc4c commit 82bbe29
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 47 deletions.
130 changes: 84 additions & 46 deletions src/ios/CDVInAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Licensed to the Apache Software Foundation (ASF) under one

#import "CDVInAppBrowser.h"
#import "CDVInAppBrowserOptions.h"
#if !WK_WEB_VIEW_ONLY
#import "CDVUIInAppBrowser.h"
#endif
#import "CDVWKInAppBrowser.h"
#import <Cordova/CDVPluginResult.h>

Expand Down Expand Up @@ -49,86 +51,122 @@ - (void)open:(CDVInvokedUrlCommand*)command
return;
}
self.usewkwebview = browserOptions.usewkwebview;
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] open:command];
}else{
[[CDVUIInAppBrowser getInstance] open:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] open:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] open:command];
}else{
[[CDVUIInAppBrowser getInstance] open:command];
}
#endif
}

- (void)close:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] close:command];
}else{
[[CDVUIInAppBrowser getInstance] close:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] close:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] close:command];
}else{
[[CDVUIInAppBrowser getInstance] close:command];
}
#endif
}


- (void)show:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] show:command];
}else{
[[CDVUIInAppBrowser getInstance] show:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] show:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] show:command];
}else{
[[CDVUIInAppBrowser getInstance] show:command];
}
#endif
}

- (void)hide:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] hide:command];
}else{
[[CDVUIInAppBrowser getInstance] hide:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] hide:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] hide:command];
}else{
[[CDVUIInAppBrowser getInstance] hide:command];
}
#endif
}


- (void)injectScriptCode:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectScriptCode:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectScriptCode:command];
}
#endif
}

- (void)injectScriptFile:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptFile:command];
}else{
[[CDVUIInAppBrowser getInstance] injectScriptFile:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectScriptCode:command];
}
#endif
}

- (void)injectStyleCode:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectStyleCode:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectStyleCode:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectStyleCode:command];
}
#endif
}

- (void)injectStyleFile:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleFile:command];
}else{
[[CDVUIInAppBrowser getInstance] injectStyleFile:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] injectStyleFile:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleFile:command];
}else{
[[CDVUIInAppBrowser getInstance] injectStyleFile:command];
}
#endif
}

- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
}else{
[[CDVUIInAppBrowser getInstance] loadAfterBeforeload:command];
}
#if WK_WEB_VIEW_ONLY
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
#else
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
}else{
[[CDVUIInAppBrowser getInstance] loadAfterBeforeload:command];
}
#endif
}


@end
@end
4 changes: 4 additions & 0 deletions src/ios/CDVUIInAppBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
under the License.
*/

#if !WK_WEB_VIEW_ONLY

#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVInvokedUrlCommand.h>
#import <Cordova/CDVScreenOrientationDelegate.h>
Expand Down Expand Up @@ -89,3 +91,5 @@
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;

@end

#endif
4 changes: 3 additions & 1 deletion src/ios/CDVUIInAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Licensed to the Apache Software Foundation (ASF) under one
under the License.
*/

#if !WK_WEB_VIEW_ONLY

#import "CDVUIInAppBrowser.h"
#import <Cordova/CDVPluginResult.h>
#import <Cordova/CDVUserAgentUtil.h>
Expand Down Expand Up @@ -1126,4 +1128,4 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface

@end


#endif

0 comments on commit 82bbe29

Please sign in to comment.