mirror of
https://github.com/bitwarden/browser
synced 2025-12-22 03:03:43 +00:00
download file via content script
This commit is contained in:
@@ -173,6 +173,21 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
||||
let pasteboard = NSPasteboard.general
|
||||
m?.responseData = pasteboard.pasteboardItems?.first?.string(forType: .string)
|
||||
replyMessage(message: m!)
|
||||
} else if command == "downloadFile" {
|
||||
SFSafariApplication.getActiveWindow { win in
|
||||
win?.getActiveTab(completionHandler: { tab in
|
||||
tab?.getActivePage { activePage in
|
||||
activePage?.dispatchMessageToScript(withName: "bitwarden", userInfo: ["msg": m!.data])
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if command == "getAppPath" {
|
||||
SFSafariExtension.getBaseURI(completionHandler: { uri in
|
||||
if uri != nil {
|
||||
m!.responseData = uri!.absoluteString
|
||||
self.replyMessage(message: m!)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,3 +341,9 @@ class TabMessage: Decodable, Encodable {
|
||||
class TabMessageOptions: Decodable, Encodable {
|
||||
var frameId: Int?
|
||||
}
|
||||
|
||||
class DownloadFileMessage: Decodable, Encodable {
|
||||
var fileName: String
|
||||
var data: String?
|
||||
var type: String?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user