parent
47827e3626
commit
e62348adc7
|
@ -5,6 +5,7 @@
|
||||||
- Merged "Fix ios multiple flutter presenting error" [#1736](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1736) (thanks to [AlexT84](https://github.com/AlexT84))
|
- Merged "Fix ios multiple flutter presenting error" [#1736](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1736) (thanks to [AlexT84](https://github.com/AlexT84))
|
||||||
- Merged "fix cert parsing for ios 12" [#1822](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1822) (thanks to [darkang3lz92](https://github.com/darkang3lz92))
|
- Merged "fix cert parsing for ios 12" [#1822](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1822) (thanks to [darkang3lz92](https://github.com/darkang3lz92))
|
||||||
- Merged "Fix iOS and macOS Forced unwrap null value HTTPCookie for CookieManager.setCookie" [#1677](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1677) (thanks to [maxmitz](https://github.com/maxmitz))
|
- Merged "Fix iOS and macOS Forced unwrap null value HTTPCookie for CookieManager.setCookie" [#1677](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1677) (thanks to [maxmitz](https://github.com/maxmitz))
|
||||||
|
- Fixed "iOS about:blank popup not loading page" [#1500](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1500)
|
||||||
|
|
||||||
## 6.0.0-beta.25
|
## 6.0.0-beta.25
|
||||||
|
|
||||||
|
|
|
@ -145,9 +145,9 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let wId = windowId, let webViewTransport = plugin?.inAppWebViewManager?.windowWebViews[wId] {
|
if let wId = windowId {
|
||||||
webView?.load(webViewTransport.request)
|
|
||||||
channelDelegate?.onBrowserCreated()
|
channelDelegate?.onBrowserCreated()
|
||||||
|
webView?.runWindowBeforeCreatedCallbacks()
|
||||||
} else {
|
} else {
|
||||||
if #available(iOS 11.0, *) {
|
if #available(iOS 11.0, *) {
|
||||||
if let contentBlockers = webView?.settings?.contentBlockers, contentBlockers.count > 0 {
|
if let contentBlockers = webView?.settings?.contentBlockers, contentBlockers.count > 0 {
|
||||||
|
|
|
@ -138,8 +138,8 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable
|
||||||
}
|
}
|
||||||
load(initialUrlRequest: initialUrlRequest, initialFile: initialFile, initialData: initialData)
|
load(initialUrlRequest: initialUrlRequest, initialFile: initialFile, initialData: initialData)
|
||||||
}
|
}
|
||||||
else if let wId = windowId, let webViewTransport = webView.plugin?.inAppWebViewManager?.windowWebViews[wId] {
|
else if let wId = windowId {
|
||||||
webView.load(webViewTransport.request)
|
webView.runWindowBeforeCreatedCallbacks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
var plugin: SwiftFlutterPlugin?
|
var plugin: SwiftFlutterPlugin?
|
||||||
var windowId: Int64?
|
var windowId: Int64?
|
||||||
var windowCreated = false
|
var windowCreated = false
|
||||||
|
var windowBeforeCreatedCallbacks: [() -> ()] = []
|
||||||
var inAppBrowserDelegate: InAppBrowserDelegate?
|
var inAppBrowserDelegate: InAppBrowserDelegate?
|
||||||
var channelDelegate: WebViewChannelDelegate?
|
var channelDelegate: WebViewChannelDelegate?
|
||||||
var settings: InAppWebViewSettings?
|
var settings: InAppWebViewSettings?
|
||||||
|
@ -1774,12 +1775,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
public func webView(_ webView: WKWebView,
|
public func webView(_ webView: WKWebView,
|
||||||
decidePolicyFor navigationAction: WKNavigationAction,
|
decidePolicyFor navigationAction: WKNavigationAction,
|
||||||
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||||
|
|
||||||
if windowId != nil, !windowCreated {
|
|
||||||
decisionHandler(.cancel)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var decisionHandlerCalled = false
|
var decisionHandlerCalled = false
|
||||||
let callback = WebViewChannelDelegate.ShouldOverrideUrlLoadingCallback()
|
let callback = WebViewChannelDelegate.ShouldOverrideUrlLoadingCallback()
|
||||||
callback.nonNullSuccess = { (response: WKNavigationActionPolicy) in
|
callback.nonNullSuccess = { (response: WKNavigationActionPolicy) in
|
||||||
|
@ -1798,13 +1793,21 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
callback?.defaultBehaviour(nil)
|
callback?.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let useShouldOverrideUrlLoading = settings?.useShouldOverrideUrlLoading, useShouldOverrideUrlLoading, let channelDelegate = channelDelegate {
|
let runCallback = {
|
||||||
|
if let useShouldOverrideUrlLoading = self.settings?.useShouldOverrideUrlLoading, useShouldOverrideUrlLoading, let channelDelegate = self.channelDelegate {
|
||||||
channelDelegate.shouldOverrideUrlLoading(navigationAction: navigationAction, callback: callback)
|
channelDelegate.shouldOverrideUrlLoading(navigationAction: navigationAction, callback: callback)
|
||||||
} else {
|
} else {
|
||||||
callback.defaultBehaviour(nil)
|
callback.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if windowId != nil, !windowCreated {
|
||||||
|
windowBeforeCreatedCallbacks.append(runCallback)
|
||||||
|
} else {
|
||||||
|
runCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func webView(_ webView: WKWebView,
|
public func webView(_ webView: WKWebView,
|
||||||
decidePolicyFor navigationResponse: WKNavigationResponse,
|
decidePolicyFor navigationResponse: WKNavigationResponse,
|
||||||
decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
||||||
|
@ -1946,12 +1949,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
}
|
}
|
||||||
|
|
||||||
public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||||
|
|
||||||
if windowId != nil, !windowCreated {
|
|
||||||
completionHandler(.cancelAuthenticationChallenge, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var completionHandlerCalled = false
|
var completionHandlerCalled = false
|
||||||
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodHTTPBasic ||
|
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodHTTPBasic ||
|
||||||
challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodDefault ||
|
challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodDefault ||
|
||||||
|
@ -2025,12 +2022,20 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
callback?.defaultBehaviour(nil)
|
callback?.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let channelDelegate = channelDelegate {
|
let runCallback = {
|
||||||
|
if let channelDelegate = self.channelDelegate {
|
||||||
channelDelegate.onReceivedHttpAuthRequest(challenge: HttpAuthenticationChallenge(fromChallenge: challenge), callback: callback)
|
channelDelegate.onReceivedHttpAuthRequest(challenge: HttpAuthenticationChallenge(fromChallenge: challenge), callback: callback)
|
||||||
} else {
|
} else {
|
||||||
callback.defaultBehaviour(nil)
|
callback.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if windowId != nil, !windowCreated {
|
||||||
|
windowBeforeCreatedCallbacks.append(runCallback)
|
||||||
|
} else {
|
||||||
|
runCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
|
else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
|
||||||
guard let serverTrust = challenge.protectionSpace.serverTrust else {
|
guard let serverTrust = challenge.protectionSpace.serverTrust else {
|
||||||
completionHandler(.performDefaultHandling, nil)
|
completionHandler(.performDefaultHandling, nil)
|
||||||
|
@ -2076,12 +2081,20 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
callback?.defaultBehaviour(nil)
|
callback?.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let channelDelegate = channelDelegate {
|
let runCallback = {
|
||||||
|
if let channelDelegate = self.channelDelegate {
|
||||||
channelDelegate.onReceivedServerTrustAuthRequest(challenge: ServerTrustChallenge(fromChallenge: challenge), callback: callback)
|
channelDelegate.onReceivedServerTrustAuthRequest(challenge: ServerTrustChallenge(fromChallenge: challenge), callback: callback)
|
||||||
} else {
|
} else {
|
||||||
callback.defaultBehaviour(nil)
|
callback.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if windowId != nil, !windowCreated {
|
||||||
|
windowBeforeCreatedCallbacks.append(runCallback)
|
||||||
|
} else {
|
||||||
|
runCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodClientCertificate {
|
else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodClientCertificate {
|
||||||
let callback = WebViewChannelDelegate.ReceivedClientCertRequestCallback()
|
let callback = WebViewChannelDelegate.ReceivedClientCertRequestCallback()
|
||||||
callback.nonNullSuccess = { (response: ClientCertResponse) in
|
callback.nonNullSuccess = { (response: ClientCertResponse) in
|
||||||
|
@ -2135,12 +2148,20 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
callback?.defaultBehaviour(nil)
|
callback?.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let channelDelegate = channelDelegate {
|
let runCallback = {
|
||||||
|
if let channelDelegate = self.channelDelegate {
|
||||||
channelDelegate.onReceivedClientCertRequest(challenge: ClientCertChallenge(fromChallenge: challenge), callback: callback)
|
channelDelegate.onReceivedClientCertRequest(challenge: ClientCertChallenge(fromChallenge: challenge), callback: callback)
|
||||||
} else {
|
} else {
|
||||||
callback.defaultBehaviour(nil)
|
callback.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if windowId != nil, !windowCreated {
|
||||||
|
windowBeforeCreatedCallbacks.append(runCallback)
|
||||||
|
} else {
|
||||||
|
runCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
completionHandler(.performDefaultHandling, nil)
|
completionHandler(.performDefaultHandling, nil)
|
||||||
}
|
}
|
||||||
|
@ -2471,6 +2492,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
createWebViewWith configuration: WKWebViewConfiguration,
|
createWebViewWith configuration: WKWebViewConfiguration,
|
||||||
for navigationAction: WKNavigationAction,
|
for navigationAction: WKNavigationAction,
|
||||||
windowFeatures: WKWindowFeatures) -> WKWebView? {
|
windowFeatures: WKWindowFeatures) -> WKWebView? {
|
||||||
|
|
||||||
var windowId: Int64 = 0
|
var windowId: Int64 = 0
|
||||||
let inAppWebViewManager = plugin?.inAppWebViewManager
|
let inAppWebViewManager = plugin?.inAppWebViewManager
|
||||||
if let inAppWebViewManager = inAppWebViewManager {
|
if let inAppWebViewManager = inAppWebViewManager {
|
||||||
|
@ -2478,7 +2500,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
windowId = inAppWebViewManager.windowAutoincrementId
|
windowId = inAppWebViewManager.windowAutoincrementId
|
||||||
}
|
}
|
||||||
|
|
||||||
let windowWebView = InAppWebView(id: nil, plugin: nil, frame: CGRect.zero, configuration: configuration, contextMenu: nil)
|
let windowWebView = InAppWebView(id: nil, plugin: nil, frame: self.bounds, configuration: configuration, contextMenu: nil)
|
||||||
windowWebView.windowId = windowId
|
windowWebView.windowId = windowId
|
||||||
|
|
||||||
let webViewTransport = WebViewTransport(
|
let webViewTransport = WebViewTransport(
|
||||||
|
@ -2487,7 +2509,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
)
|
)
|
||||||
|
|
||||||
inAppWebViewManager?.windowWebViews[windowId] = webViewTransport
|
inAppWebViewManager?.windowWebViews[windowId] = webViewTransport
|
||||||
windowWebView.stopLoading()
|
|
||||||
|
|
||||||
let createWindowAction = CreateWindowAction(navigationAction: navigationAction, windowId: windowId, windowFeatures: windowFeatures, isDialog: nil)
|
let createWindowAction = CreateWindowAction(navigationAction: navigationAction, windowId: windowId, windowFeatures: windowFeatures, isDialog: nil)
|
||||||
|
|
||||||
|
@ -2518,11 +2539,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
public func webView(_ webView: WKWebView,
|
public func webView(_ webView: WKWebView,
|
||||||
authenticationChallenge challenge: URLAuthenticationChallenge,
|
authenticationChallenge challenge: URLAuthenticationChallenge,
|
||||||
shouldAllowDeprecatedTLS decisionHandler: @escaping (Bool) -> Void) {
|
shouldAllowDeprecatedTLS decisionHandler: @escaping (Bool) -> Void) {
|
||||||
if windowId != nil, !windowCreated {
|
|
||||||
decisionHandler(false)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var decisionHandlerCalled = false
|
var decisionHandlerCalled = false
|
||||||
let callback = WebViewChannelDelegate.ShouldAllowDeprecatedTLSCallback()
|
let callback = WebViewChannelDelegate.ShouldAllowDeprecatedTLSCallback()
|
||||||
callback.nonNullSuccess = { (action: Bool) in
|
callback.nonNullSuccess = { (action: Bool) in
|
||||||
|
@ -2541,13 +2557,21 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
||||||
callback?.defaultBehaviour(nil)
|
callback?.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let channelDelegate = channelDelegate {
|
let runCallback = {
|
||||||
|
if let channelDelegate = self.channelDelegate {
|
||||||
channelDelegate.shouldAllowDeprecatedTLS(challenge: challenge, callback: callback)
|
channelDelegate.shouldAllowDeprecatedTLS(challenge: challenge, callback: callback)
|
||||||
} else {
|
} else {
|
||||||
callback.defaultBehaviour(nil)
|
callback.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if windowId != nil, !windowCreated {
|
||||||
|
windowBeforeCreatedCallbacks.append(runCallback)
|
||||||
|
} else {
|
||||||
|
runCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func webViewDidClose(_ webView: WKWebView) {
|
public func webViewDidClose(_ webView: WKWebView) {
|
||||||
channelDelegate?.onCloseWindow()
|
channelDelegate?.onCloseWindow()
|
||||||
}
|
}
|
||||||
|
@ -3194,9 +3218,18 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
|
||||||
return settings?.disableInputAccessoryView ?? false ? nil : super.inputAccessoryView
|
return settings?.disableInputAccessoryView ?? false ? nil : super.inputAccessoryView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func runWindowBeforeCreatedCallbacks() {
|
||||||
|
let callbacks = windowBeforeCreatedCallbacks
|
||||||
|
callbacks.forEach { (callback) in
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
windowBeforeCreatedCallbacks.removeAll()
|
||||||
|
}
|
||||||
|
|
||||||
public func dispose() {
|
public func dispose() {
|
||||||
channelDelegate?.dispose()
|
channelDelegate?.dispose()
|
||||||
channelDelegate = nil
|
channelDelegate = nil
|
||||||
|
runWindowBeforeCreatedCallbacks()
|
||||||
removeObserver(self, forKeyPath: #keyPath(WKWebView.estimatedProgress))
|
removeObserver(self, forKeyPath: #keyPath(WKWebView.estimatedProgress))
|
||||||
removeObserver(self, forKeyPath: #keyPath(WKWebView.url))
|
removeObserver(self, forKeyPath: #keyPath(WKWebView.url))
|
||||||
removeObserver(self, forKeyPath: #keyPath(WKWebView.title))
|
removeObserver(self, forKeyPath: #keyPath(WKWebView.title))
|
||||||
|
|
|
@ -100,9 +100,9 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega
|
||||||
progressBar.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 0.0).isActive = true
|
progressBar.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 0.0).isActive = true
|
||||||
progressBar.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: 0.0).isActive = true
|
progressBar.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: 0.0).isActive = true
|
||||||
|
|
||||||
if let wId = windowId, let webViewTransport = plugin?.inAppWebViewManager?.windowWebViews[wId] {
|
if let wId = windowId {
|
||||||
webView?.load(webViewTransport.request)
|
|
||||||
channelDelegate?.onBrowserCreated()
|
channelDelegate?.onBrowserCreated()
|
||||||
|
webView?.runWindowBeforeCreatedCallbacks()
|
||||||
} else {
|
} else {
|
||||||
if #available(macOS 10.13, *) {
|
if #available(macOS 10.13, *) {
|
||||||
if let contentBlockers = webView?.settings?.contentBlockers, contentBlockers.count > 0 {
|
if let contentBlockers = webView?.settings?.contentBlockers, contentBlockers.count > 0 {
|
||||||
|
|
|
@ -127,8 +127,8 @@ public class FlutterWebViewController: NSObject, /*FlutterPlatformView,*/ Dispos
|
||||||
}
|
}
|
||||||
load(initialUrlRequest: initialUrlRequest, initialFile: initialFile, initialData: initialData)
|
load(initialUrlRequest: initialUrlRequest, initialFile: initialFile, initialData: initialData)
|
||||||
}
|
}
|
||||||
else if let wId = windowId, let webViewTransport = webView.plugin?.inAppWebViewManager?.windowWebViews[wId] {
|
else if let wId = windowId {
|
||||||
webView.load(webViewTransport.request)
|
webView.runWindowBeforeCreatedCallbacks()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
var plugin: InAppWebViewFlutterPlugin?
|
var plugin: InAppWebViewFlutterPlugin?
|
||||||
var windowId: Int64?
|
var windowId: Int64?
|
||||||
var windowCreated = false
|
var windowCreated = false
|
||||||
|
var windowBeforeCreatedCallbacks: [() -> ()] = []
|
||||||
var inAppBrowserDelegate: InAppBrowserDelegate?
|
var inAppBrowserDelegate: InAppBrowserDelegate?
|
||||||
var channelDelegate: WebViewChannelDelegate?
|
var channelDelegate: WebViewChannelDelegate?
|
||||||
var settings: InAppWebViewSettings?
|
var settings: InAppWebViewSettings?
|
||||||
|
@ -1165,12 +1166,6 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
public func webView(_ webView: WKWebView,
|
public func webView(_ webView: WKWebView,
|
||||||
decidePolicyFor navigationAction: WKNavigationAction,
|
decidePolicyFor navigationAction: WKNavigationAction,
|
||||||
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||||
|
|
||||||
if windowId != nil, !windowCreated {
|
|
||||||
decisionHandler(.cancel)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var decisionHandlerCalled = false
|
var decisionHandlerCalled = false
|
||||||
let callback = WebViewChannelDelegate.ShouldOverrideUrlLoadingCallback()
|
let callback = WebViewChannelDelegate.ShouldOverrideUrlLoadingCallback()
|
||||||
callback.nonNullSuccess = { (response: WKNavigationActionPolicy) in
|
callback.nonNullSuccess = { (response: WKNavigationActionPolicy) in
|
||||||
|
@ -1189,13 +1184,21 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
callback?.defaultBehaviour(nil)
|
callback?.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let useShouldOverrideUrlLoading = settings?.useShouldOverrideUrlLoading, useShouldOverrideUrlLoading, let channelDelegate = channelDelegate {
|
let runCallback = {
|
||||||
|
if let useShouldOverrideUrlLoading = self.settings?.useShouldOverrideUrlLoading, useShouldOverrideUrlLoading, let channelDelegate = self.channelDelegate {
|
||||||
channelDelegate.shouldOverrideUrlLoading(navigationAction: navigationAction, callback: callback)
|
channelDelegate.shouldOverrideUrlLoading(navigationAction: navigationAction, callback: callback)
|
||||||
} else {
|
} else {
|
||||||
callback.defaultBehaviour(nil)
|
callback.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if windowId != nil, !windowCreated {
|
||||||
|
windowBeforeCreatedCallbacks.append(runCallback)
|
||||||
|
} else {
|
||||||
|
runCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func webView(_ webView: WKWebView,
|
public func webView(_ webView: WKWebView,
|
||||||
decidePolicyFor navigationResponse: WKNavigationResponse,
|
decidePolicyFor navigationResponse: WKNavigationResponse,
|
||||||
decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) {
|
||||||
|
@ -1328,12 +1331,6 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
}
|
}
|
||||||
|
|
||||||
public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||||
|
|
||||||
if windowId != nil, !windowCreated {
|
|
||||||
completionHandler(.cancelAuthenticationChallenge, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var completionHandlerCalled = false
|
var completionHandlerCalled = false
|
||||||
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodHTTPBasic ||
|
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodHTTPBasic ||
|
||||||
challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodDefault ||
|
challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodDefault ||
|
||||||
|
@ -1407,12 +1404,20 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
callback?.defaultBehaviour(nil)
|
callback?.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let channelDelegate = channelDelegate {
|
let runCallback = {
|
||||||
|
if let channelDelegate = self.channelDelegate {
|
||||||
channelDelegate.onReceivedHttpAuthRequest(challenge: HttpAuthenticationChallenge(fromChallenge: challenge), callback: callback)
|
channelDelegate.onReceivedHttpAuthRequest(challenge: HttpAuthenticationChallenge(fromChallenge: challenge), callback: callback)
|
||||||
} else {
|
} else {
|
||||||
callback.defaultBehaviour(nil)
|
callback.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if windowId != nil, !windowCreated {
|
||||||
|
windowBeforeCreatedCallbacks.append(runCallback)
|
||||||
|
} else {
|
||||||
|
runCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
|
else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust {
|
||||||
guard let serverTrust = challenge.protectionSpace.serverTrust else {
|
guard let serverTrust = challenge.protectionSpace.serverTrust else {
|
||||||
completionHandler(.performDefaultHandling, nil)
|
completionHandler(.performDefaultHandling, nil)
|
||||||
|
@ -1458,12 +1463,20 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
callback?.defaultBehaviour(nil)
|
callback?.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let channelDelegate = channelDelegate {
|
let runCallback = {
|
||||||
|
if let channelDelegate = self.channelDelegate {
|
||||||
channelDelegate.onReceivedServerTrustAuthRequest(challenge: ServerTrustChallenge(fromChallenge: challenge), callback: callback)
|
channelDelegate.onReceivedServerTrustAuthRequest(challenge: ServerTrustChallenge(fromChallenge: challenge), callback: callback)
|
||||||
} else {
|
} else {
|
||||||
callback.defaultBehaviour(nil)
|
callback.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if windowId != nil, !windowCreated {
|
||||||
|
windowBeforeCreatedCallbacks.append(runCallback)
|
||||||
|
} else {
|
||||||
|
runCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodClientCertificate {
|
else if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodClientCertificate {
|
||||||
let callback = WebViewChannelDelegate.ReceivedClientCertRequestCallback()
|
let callback = WebViewChannelDelegate.ReceivedClientCertRequestCallback()
|
||||||
callback.nonNullSuccess = { (response: ClientCertResponse) in
|
callback.nonNullSuccess = { (response: ClientCertResponse) in
|
||||||
|
@ -1515,12 +1528,20 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
callback?.defaultBehaviour(nil)
|
callback?.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let channelDelegate = channelDelegate {
|
let runCallback = {
|
||||||
|
if let channelDelegate = self.channelDelegate {
|
||||||
channelDelegate.onReceivedClientCertRequest(challenge: ClientCertChallenge(fromChallenge: challenge), callback: callback)
|
channelDelegate.onReceivedClientCertRequest(challenge: ClientCertChallenge(fromChallenge: challenge), callback: callback)
|
||||||
} else {
|
} else {
|
||||||
callback.defaultBehaviour(nil)
|
callback.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if windowId != nil, !windowCreated {
|
||||||
|
windowBeforeCreatedCallbacks.append(runCallback)
|
||||||
|
} else {
|
||||||
|
runCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
completionHandler(.performDefaultHandling, nil)
|
completionHandler(.performDefaultHandling, nil)
|
||||||
}
|
}
|
||||||
|
@ -1832,11 +1853,6 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
public func webView(_ webView: WKWebView,
|
public func webView(_ webView: WKWebView,
|
||||||
authenticationChallenge challenge: URLAuthenticationChallenge,
|
authenticationChallenge challenge: URLAuthenticationChallenge,
|
||||||
shouldAllowDeprecatedTLS decisionHandler: @escaping (Bool) -> Void) {
|
shouldAllowDeprecatedTLS decisionHandler: @escaping (Bool) -> Void) {
|
||||||
if windowId != nil, !windowCreated {
|
|
||||||
decisionHandler(false)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var decisionHandlerCalled = false
|
var decisionHandlerCalled = false
|
||||||
let callback = WebViewChannelDelegate.ShouldAllowDeprecatedTLSCallback()
|
let callback = WebViewChannelDelegate.ShouldAllowDeprecatedTLSCallback()
|
||||||
callback.nonNullSuccess = { (action: Bool) in
|
callback.nonNullSuccess = { (action: Bool) in
|
||||||
|
@ -1855,13 +1871,21 @@ public class InAppWebView: WKWebView, WKUIDelegate,
|
||||||
callback?.defaultBehaviour(nil)
|
callback?.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let channelDelegate = channelDelegate {
|
let runCallback = {
|
||||||
|
if let channelDelegate = self.channelDelegate {
|
||||||
channelDelegate.shouldAllowDeprecatedTLS(challenge: challenge, callback: callback)
|
channelDelegate.shouldAllowDeprecatedTLS(challenge: challenge, callback: callback)
|
||||||
} else {
|
} else {
|
||||||
callback.defaultBehaviour(nil)
|
callback.defaultBehaviour(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if windowId != nil, !windowCreated {
|
||||||
|
windowBeforeCreatedCallbacks.append(runCallback)
|
||||||
|
} else {
|
||||||
|
runCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func webViewDidClose(_ webView: WKWebView) {
|
public func webViewDidClose(_ webView: WKWebView) {
|
||||||
channelDelegate?.onCloseWindow()
|
channelDelegate?.onCloseWindow()
|
||||||
}
|
}
|
||||||
|
@ -2534,9 +2558,18 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func runWindowBeforeCreatedCallbacks() {
|
||||||
|
let callbacks = windowBeforeCreatedCallbacks
|
||||||
|
callbacks.forEach { (callback) in
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
windowBeforeCreatedCallbacks.removeAll()
|
||||||
|
}
|
||||||
|
|
||||||
public func dispose() {
|
public func dispose() {
|
||||||
channelDelegate?.dispose()
|
channelDelegate?.dispose()
|
||||||
channelDelegate = nil
|
channelDelegate = nil
|
||||||
|
runWindowBeforeCreatedCallbacks()
|
||||||
currentOpenPanel?.cancel(self)
|
currentOpenPanel?.cancel(self)
|
||||||
currentOpenPanel?.close()
|
currentOpenPanel?.close()
|
||||||
currentOpenPanel = nil
|
currentOpenPanel = nil
|
||||||
|
|
Loading…
Reference in New Issue