1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-18 11:05:41 +01:00

WKUIDelegate for file open panel

This commit is contained in:
Kyle Spearrin 2019-08-22 23:11:05 -04:00
parent 615e7583bb
commit 6fd71f9ebf

View File

@ -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([])