Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Source/Turbo/Navigator/Navigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ extension Navigator: SessionDelegate {
}

public func session(_ session: Session, didReceiveAuthenticationChallenge challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
delegate?.didReceiveAuthenticationChallenge(challenge, completionHandler: completionHandler)
guard let delegate else {
completionHandler(.performDefaultHandling, nil)
return
}
delegate.didReceiveAuthenticationChallenge(challenge, completionHandler: completionHandler)
}

public func sessionDidFinishRequest(_ session: Session) {
Expand Down
12 changes: 10 additions & 2 deletions Source/Turbo/Navigator/WKUIController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,29 @@ open class WKUIController: NSObject, WKUIDelegate {
}

open func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
guard let delegate else {
completionHandler()
return
}
let alert = UIAlertController(title: message, message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Close", style: .default) { _ in
completionHandler()
})
delegate?.present(alert, animated: true)
delegate.present(alert, animated: true)
}

open func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
guard let delegate else {
completionHandler(false)
return
}
let alert = UIAlertController(title: message, message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default) { _ in
completionHandler(true)
})
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel) { _ in
completionHandler(false)
})
delegate?.present(alert, animated: true)
delegate.present(alert, animated: true)
}
}
6 changes: 5 additions & 1 deletion Source/Turbo/Session/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ extension Session: VisitDelegate {
}

func visit(_ visit: Visit, didReceiveAuthenticationChallenge challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
delegate?.session(self, didReceiveAuthenticationChallenge: challenge, completionHandler: completionHandler)
guard let delegate else {
completionHandler(.performDefaultHandling, nil)
return
}
delegate.session(self, didReceiveAuthenticationChallenge: challenge, completionHandler: completionHandler)
}

func visitDidProposeVisitToLocation(_ location: URL) {
Expand Down
6 changes: 5 additions & 1 deletion Source/Turbo/Visit/ColdBootVisit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ extension ColdBootVisit: WKNavigationDelegate {
}

func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
delegate?.visit(self, didReceiveAuthenticationChallenge: challenge, completionHandler: completionHandler)
guard let delegate else {
completionHandler(.performDefaultHandling, nil)
return
}
delegate.visit(self, didReceiveAuthenticationChallenge: challenge, completionHandler: completionHandler)
}
}

Expand Down
Loading