Skip to content

Commit

Permalink
uaoijepfaeoija
Browse files Browse the repository at this point in the history
  • Loading branch information
bparrishMines committed Dec 19, 2024
1 parent 0fccbdc commit fc57cbf
Showing 1 changed file with 54 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,59 +112,60 @@ extension NavigationDelegateImpl {
}
}
}
// public func webView(
// _ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse,
// decisionHandler: @escaping @MainActor (WKNavigationResponsePolicy) -> Void
// ) {
// registrar.dispatchOnMainThread { onFailure in
// self.api.decidePolicyForNavigationResponse(
// pigeonInstance: self, webView: webView, navigationResponse: navigationResponse
// ) { @MainActor result in
// switch result {
// case .success(let policy):
// switch policy {
// case .allow:
// decisionHandler(.allow)
// case .cancel:
// decisionHandler(.cancel)
// case .download:
// if #available(iOS 14.5, macOS 11.3, *) {
// decisionHandler(.download)
// } else {
// decisionHandler(.cancel)
// assertionFailure(
// self.registrar.createUnsupportedVersionMessage(
// "WKNavigationResponsePolicy.download", versionRequirements: "iOS 14.5, macOS 11.3"
// ))
// }
// }
// case .failure(let error):
// decisionHandler(.cancel)
// onFailure("WKNavigationDelegate.decidePolicyForNavigationResponse", error)
// }
// }
// }
// }
//
// public func webView(
// _ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge,
// completionHandler: @escaping @MainActor (URLSession.AuthChallengeDisposition, URLCredential?) ->
// Void
// ) {
// registrar.dispatchOnMainThread { onFailure in
// self.api.didReceiveAuthenticationChallenge(
// pigeonInstance: self, webView: webView, challenge: challenge
// ) { @MainActor result in
// switch result {
// case .success(let response):
// completionHandler(response.disposition, response.credential)
// case .failure(let error):
// completionHandler(.cancelAuthenticationChallenge, nil)
// onFailure("WKNavigationDelegate.didReceiveAuthenticationChallenge", error)
// }
// }
// }
// }

public func webView(
_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse,
decisionHandler: @escaping @MainActor (WKNavigationResponsePolicy) -> Void
) {
registrar.dispatchOnMainThread { onFailure in
self.api.decidePolicyForNavigationResponse(
pigeonInstance: self, webView: webView, navigationResponse: navigationResponse
) { @MainActor result in
switch result {
case .success(let policy):
switch policy {
case .allow:
decisionHandler(.allow)
case .cancel:
decisionHandler(.cancel)
case .download:
if #available(iOS 14.5, macOS 11.3, *) {
decisionHandler(.download)
} else {
decisionHandler(.cancel)
assertionFailure(
self.registrar.createUnsupportedVersionMessage(
"WKNavigationResponsePolicy.download", versionRequirements: "iOS 14.5, macOS 11.3"
))
}
}
case .failure(let error):
decisionHandler(.cancel)
onFailure("WKNavigationDelegate.decidePolicyForNavigationResponse", error)
}
}
}
}

public func webView(
_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping @MainActor (URLSession.AuthChallengeDisposition, URLCredential?) ->
Void
) {
registrar.dispatchOnMainThread { onFailure in
self.api.didReceiveAuthenticationChallenge(
pigeonInstance: self, webView: webView, challenge: challenge
) { @MainActor result in
switch result {
case .success(let response):
completionHandler(response.disposition, response.credential)
case .failure(let error):
completionHandler(.cancelAuthenticationChallenge, nil)
onFailure("WKNavigationDelegate.didReceiveAuthenticationChallenge", error)
}
}
}
}
}

/// ProxyApi implementation for `WKNavigationDelegate`.
Expand Down

0 comments on commit fc57cbf

Please sign in to comment.