breaking(ios): remove UIWebView (#635)
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
#import <Cordova/CDVInvokedUrlCommand.h>
|
||||
|
||||
@interface CDVInAppBrowser : CDVPlugin {}
|
||||
|
||||
@property (nonatomic, assign) BOOL wkwebviewavailable;
|
||||
@property (nonatomic, assign) BOOL usewkwebview;
|
||||
|
||||
- (void)open:(CDVInvokedUrlCommand*)command;
|
||||
- (void)close:(CDVInvokedUrlCommand*)command;
|
||||
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command;
|
||||
- (void)show:(CDVInvokedUrlCommand*)command;
|
||||
- (void)hide:(CDVInvokedUrlCommand*)command;
|
||||
- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import "CDVInAppBrowser.h"
|
||||
#import "CDVInAppBrowserOptions.h"
|
||||
#if !WK_WEB_VIEW_ONLY
|
||||
#import "CDVUIInAppBrowser.h"
|
||||
#endif
|
||||
#import "CDVWKInAppBrowser.h"
|
||||
#import <Cordova/CDVPluginResult.h>
|
||||
|
||||
|
||||
#pragma mark CDVInAppBrowser
|
||||
|
||||
@implementation CDVInAppBrowser
|
||||
|
||||
- (void)pluginInitialize
|
||||
{
|
||||
// default values
|
||||
self.usewkwebview = NO;
|
||||
|
||||
#if __has_include("CDVWKWebViewEngine.h")
|
||||
self.wkwebviewavailable = YES;
|
||||
#else
|
||||
self.wkwebviewavailable = NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)open:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
NSString* options = [command argumentAtIndex:2 withDefault:@"" andClass:[NSString class]];
|
||||
CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
|
||||
if(browserOptions.usewkwebview && !self.wkwebviewavailable){
|
||||
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:@{@"type":@"loaderror", @"message": @"usewkwebview option specified but but no plugin that supplies a WKWebView engine is present"}] callbackId:command.callbackId];
|
||||
return;
|
||||
}
|
||||
self.usewkwebview = browserOptions.usewkwebview;
|
||||
#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 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 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 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 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 WK_WEB_VIEW_ONLY
|
||||
[[CDVWKInAppBrowser getInstance] injectScriptFile:command];
|
||||
#else
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] injectScriptFile:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] injectScriptFile:command];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)injectStyleCode:(CDVInvokedUrlCommand*)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 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 WK_WEB_VIEW_ONLY
|
||||
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
|
||||
#else
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] loadAfterBeforeload:command];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
@interface CDVInAppBrowserOptions : NSObject {}
|
||||
|
||||
@property (nonatomic, assign) BOOL usewkwebview;
|
||||
@property (nonatomic, assign) BOOL location;
|
||||
@property (nonatomic, assign) BOOL toolbar;
|
||||
@property (nonatomic, copy) NSString* closebuttoncaption;
|
||||
@@ -42,8 +41,6 @@
|
||||
@property (nonatomic, assign) BOOL enableviewportscale;
|
||||
@property (nonatomic, assign) BOOL mediaplaybackrequiresuseraction;
|
||||
@property (nonatomic, assign) BOOL allowinlinemediaplayback;
|
||||
@property (nonatomic, assign) BOOL keyboarddisplayrequiresuseraction;
|
||||
@property (nonatomic, assign) BOOL suppressesincrementalrendering;
|
||||
@property (nonatomic, assign) BOOL hidden;
|
||||
@property (nonatomic, assign) BOOL disallowoverscroll;
|
||||
@property (nonatomic, copy) NSString* beforeload;
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
{
|
||||
if (self = [super init]) {
|
||||
// default values
|
||||
self.usewkwebview = NO;
|
||||
self.location = YES;
|
||||
self.toolbar = YES;
|
||||
self.closebuttoncaption = nil;
|
||||
@@ -38,8 +37,6 @@
|
||||
self.enableviewportscale = NO;
|
||||
self.mediaplaybackrequiresuseraction = NO;
|
||||
self.allowinlinemediaplayback = NO;
|
||||
self.keyboarddisplayrequiresuseraction = YES;
|
||||
self.suppressesincrementalrendering = NO;
|
||||
self.hidden = NO;
|
||||
self.disallowoverscroll = NO;
|
||||
self.hidenavigationbuttons = NO;
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#if !WK_WEB_VIEW_ONLY
|
||||
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
#import <Cordova/CDVInvokedUrlCommand.h>
|
||||
#import <Cordova/CDVScreenOrientationDelegate.h>
|
||||
#import "CDVInAppBrowserOptions.h"
|
||||
#import "CDVInAppBrowserNavigationController.h"
|
||||
|
||||
#ifdef __CORDOVA_4_0_0
|
||||
#import <Cordova/CDVUIWebViewDelegate.h>
|
||||
#else
|
||||
#import <Cordova/CDVWebViewDelegate.h>
|
||||
#endif
|
||||
|
||||
@class CDVUIInAppBrowserViewController;
|
||||
|
||||
@interface CDVUIInAppBrowser : CDVPlugin {
|
||||
UIWindow * tmpWindow;
|
||||
|
||||
@private
|
||||
NSString* _beforeload;
|
||||
BOOL _waitForBeforeload;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) CDVUIInAppBrowserViewController* inAppBrowserViewController;
|
||||
@property (nonatomic, copy) NSString* callbackId;
|
||||
@property (nonatomic, copy) NSRegularExpression *callbackIdPattern;
|
||||
|
||||
+ (id) getInstance;
|
||||
- (void)open:(CDVInvokedUrlCommand*)command;
|
||||
- (void)close:(CDVInvokedUrlCommand*)command;
|
||||
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command;
|
||||
- (void)show:(CDVInvokedUrlCommand*)command;
|
||||
- (void)hide:(CDVInvokedUrlCommand*)command;
|
||||
- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
|
||||
@interface CDVUIInAppBrowserViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{
|
||||
@private
|
||||
NSString* _userAgent;
|
||||
NSString* _prevUserAgent;
|
||||
NSInteger _userAgentLockToken;
|
||||
CDVInAppBrowserOptions *_browserOptions;
|
||||
|
||||
#ifdef __CORDOVA_4_0_0
|
||||
CDVUIWebViewDelegate* _webViewDelegate;
|
||||
#else
|
||||
CDVWebViewDelegate* _webViewDelegate;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) IBOutlet UIWebView* webView;
|
||||
@property (nonatomic, strong) IBOutlet UIBarButtonItem* closeButton;
|
||||
@property (nonatomic, strong) IBOutlet UILabel* addressLabel;
|
||||
@property (nonatomic, strong) IBOutlet UIBarButtonItem* backButton;
|
||||
@property (nonatomic, strong) IBOutlet UIBarButtonItem* forwardButton;
|
||||
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView* spinner;
|
||||
@property (nonatomic, strong) IBOutlet UIToolbar* toolbar;
|
||||
|
||||
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
|
||||
@property (nonatomic, weak) CDVUIInAppBrowser* navigationDelegate;
|
||||
@property (nonatomic) NSURL* currentURL;
|
||||
|
||||
- (void)close;
|
||||
- (void)navigateTo:(NSURL*)url;
|
||||
- (void)showLocationBar:(BOOL)show;
|
||||
- (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition;
|
||||
- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString : (int) buttonIndex;
|
||||
|
||||
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,10 +51,8 @@
|
||||
|
||||
@interface CDVWKInAppBrowserViewController : UIViewController <CDVScreenOrientationDelegate,WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler>{
|
||||
@private
|
||||
NSString* _userAgent;
|
||||
NSString* _prevUserAgent;
|
||||
NSInteger _userAgentLockToken;
|
||||
CDVInAppBrowserOptions *_browserOptions;
|
||||
NSDictionary *_settings;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) IBOutlet WKWebView* webView;
|
||||
@@ -77,6 +75,6 @@
|
||||
- (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition;
|
||||
- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString : (int) buttonIndex;
|
||||
|
||||
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;
|
||||
- (id)initWithBrowserOptions: (CDVInAppBrowserOptions*) browserOptions andSettings:(NSDictionary*) settings;
|
||||
|
||||
@end
|
||||
|
||||
+21
-62
@@ -24,7 +24,6 @@
|
||||
#endif
|
||||
|
||||
#import <Cordova/CDVPluginResult.h>
|
||||
#import <Cordova/CDVUserAgentUtil.h>
|
||||
|
||||
#define kInAppBrowserTargetSelf @"_self"
|
||||
#define kInAppBrowserTargetSystem @"_system"
|
||||
@@ -64,11 +63,6 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
_waitForBeforeload = NO;
|
||||
}
|
||||
|
||||
- (id)settingForKey:(NSString*)key
|
||||
{
|
||||
return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
|
||||
}
|
||||
|
||||
- (void)onReset
|
||||
{
|
||||
[self close:nil];
|
||||
@@ -105,11 +99,7 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
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]) {
|
||||
@@ -209,16 +199,7 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
}
|
||||
|
||||
if (self.inAppBrowserViewController == nil) {
|
||||
NSString* userAgent = [CDVUserAgentUtil originalUserAgent];
|
||||
NSString* overrideUserAgent = [self settingForKey:@"OverrideUserAgent"];
|
||||
NSString* appendUserAgent = [self settingForKey:@"AppendUserAgent"];
|
||||
if(overrideUserAgent){
|
||||
userAgent = overrideUserAgent;
|
||||
}
|
||||
if(appendUserAgent){
|
||||
userAgent = [userAgent stringByAppendingString: appendUserAgent];
|
||||
}
|
||||
self.inAppBrowserViewController = [[CDVWKInAppBrowserViewController alloc] initWithUserAgent:userAgent prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions];
|
||||
self.inAppBrowserViewController = [[CDVWKInAppBrowserViewController alloc] initWithBrowserOptions: browserOptions andSettings:self.commandDelegate.settings];
|
||||
self.inAppBrowserViewController.navigationDelegate = self;
|
||||
|
||||
if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) {
|
||||
@@ -369,18 +350,9 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
|
||||
{
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||
|
||||
#ifdef __CORDOVA_4_0_0
|
||||
// the webview engine itself will filter for this according to <allow-navigation> policy
|
||||
// in config.xml for cordova-ios-4.0
|
||||
[self.webViewEngine loadRequest:request];
|
||||
#else
|
||||
if ([self.commandDelegate URLIsWhitelisted:url]) {
|
||||
[self.webView loadRequest:request];
|
||||
} else { // this assumes the InAppBrowser can be excepted from the white-list
|
||||
[self openInInAppBrowser:url withOptions:options];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)openInSystem:(NSURL*)url
|
||||
@@ -725,13 +697,12 @@ static CDVWKInAppBrowser* instance = nil;
|
||||
BOOL viewRenderedAtLeastOnce = FALSE;
|
||||
BOOL isExiting = FALSE;
|
||||
|
||||
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions
|
||||
- (id)initWithBrowserOptions: (CDVInAppBrowserOptions*) browserOptions andSettings:(NSDictionary *)settings
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_userAgent = userAgent;
|
||||
_prevUserAgent = prevUserAgent;
|
||||
_browserOptions = browserOptions;
|
||||
_settings = settings;
|
||||
self.webViewUIDelegate = [[CDVWKInAppBrowserUIDelegate alloc] initWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]];
|
||||
[self.webViewUIDelegate setViewController:self];
|
||||
|
||||
@@ -755,6 +726,15 @@ BOOL isExiting = FALSE;
|
||||
WKUserContentController* userContentController = [[WKUserContentController alloc] init];
|
||||
|
||||
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
|
||||
|
||||
NSString *userAgent = configuration.applicationNameForUserAgent;
|
||||
if (
|
||||
[self settingForKey:@"OverrideUserAgent"] == nil &&
|
||||
[self settingForKey:@"AppendUserAgent"] != nil
|
||||
) {
|
||||
userAgent = [NSString stringWithFormat:@"%@ %@", userAgent, [self settingForKey:@"AppendUserAgent"]];
|
||||
}
|
||||
configuration.applicationNameForUserAgent = userAgent;
|
||||
configuration.userContentController = userContentController;
|
||||
#if __has_include("CDVWKProcessPoolFactory.h")
|
||||
configuration.processPool = [[CDVWKProcessPoolFactory sharedFactory] sharedProcessPool];
|
||||
@@ -785,6 +765,9 @@ BOOL isExiting = FALSE;
|
||||
self.webView.navigationDelegate = self;
|
||||
self.webView.UIDelegate = self.webViewUIDelegate;
|
||||
self.webView.backgroundColor = [UIColor whiteColor];
|
||||
if ([self settingForKey:@"OverrideUserAgent"] != nil) {
|
||||
self.webView.customUserAgent = [self settingForKey:@"OverrideUserAgent"];
|
||||
}
|
||||
|
||||
self.webView.clearsContextBeforeDrawing = YES;
|
||||
self.webView.clipsToBounds = YES;
|
||||
@@ -915,6 +898,11 @@ BOOL isExiting = FALSE;
|
||||
[self.view addSubview:self.spinner];
|
||||
}
|
||||
|
||||
- (id)settingForKey:(NSString*)key
|
||||
{
|
||||
return [_settings objectForKey:[key lowercaseString]];
|
||||
}
|
||||
|
||||
- (void) setWebViewFrame : (CGRect) frame {
|
||||
NSLog(@"Setting the WebView's frame to %@", NSStringFromCGRect(frame));
|
||||
[self.webView setFrame:frame];
|
||||
@@ -1074,7 +1062,6 @@ BOOL isExiting = FALSE;
|
||||
|
||||
- (void)close
|
||||
{
|
||||
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
|
||||
self.currentURL = nil;
|
||||
|
||||
__weak UIViewController* weakSelf = self;
|
||||
@@ -1093,17 +1080,7 @@ BOOL isExiting = FALSE;
|
||||
- (void)navigateTo:(NSURL*)url
|
||||
{
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||
|
||||
if (_userAgentLockToken != 0) {
|
||||
[self.webView loadRequest:request];
|
||||
} else {
|
||||
__weak CDVWKInAppBrowserViewController* weakSelf = self;
|
||||
[CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
|
||||
_userAgentLockToken = lockToken;
|
||||
[CDVUserAgentUtil setUserAgent:_userAgent lockToken:lockToken];
|
||||
[weakSelf.webView loadRequest:request];
|
||||
}];
|
||||
}
|
||||
[self.webView loadRequest:request];
|
||||
}
|
||||
|
||||
- (void)goBack:(id)sender
|
||||
@@ -1203,24 +1180,6 @@ BOOL isExiting = FALSE;
|
||||
|
||||
[self.spinner stopAnimating];
|
||||
|
||||
// Work around a bug where the first time a PDF is opened, all UIWebViews
|
||||
// reload their User-Agent from NSUserDefaults.
|
||||
// This work-around makes the following assumptions:
|
||||
// 1. The app has only a single Cordova Webview. If not, then the app should
|
||||
// take it upon themselves to load a PDF in the background as a part of
|
||||
// their start-up flow.
|
||||
// 2. That the PDF does not require any additional network requests. We change
|
||||
// the user-agent here back to that of the CDVViewController, so requests
|
||||
// from it must pass through its white-list. This *does* break PDFs that
|
||||
// contain links to other remote PDF/websites.
|
||||
// More info at https://issues.apache.org/jira/browse/CB-2225
|
||||
BOOL isPDF = NO;
|
||||
//TODO webview class
|
||||
//BOOL isPDF = [@"true" isEqualToString :[theWebView evaluateJavaScript:@"document.body==null"]];
|
||||
if (isPDF) {
|
||||
[CDVUserAgentUtil setUserAgent:_prevUserAgent lockToken:_userAgentLockToken];
|
||||
}
|
||||
|
||||
[self.navigationDelegate didFinishNavigation:theWebView];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user