diff --git a/src/safari/safari/SafariExtensionViewController.swift b/src/safari/safari/SafariExtensionViewController.swift index 2f1cc6d5d2..11e41e0d7f 100644 --- a/src/safari/safari/SafariExtensionViewController.swift +++ b/src/safari/safari/SafariExtensionViewController.swift @@ -190,6 +190,20 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe } } +extension SafariExtensionViewController: WKUIDelegate { + func webView(_ webView: WKWebView, runOpenPanelWith parameters: WKOpenPanelParameters, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping ([URL]?) -> Void) { + let openPanel = NSOpenPanel() + openPanel.canChooseFiles = true + openPanel.begin { result in + if result == NSApplication.ModalResponse.OK && openPanel.url != nil { + completionHandler([openPanel.url!]) + } else { + completionHandler(nil) + } + } + } +} + func processWindowsForTabs(wins: [SFSafariWindow], options: TabQueryOptions?, complete: @escaping ([Tab]) -> Void) { if wins.count == 0 { complete([])