1
0
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:
Kyle Spearrin
2019-08-21 21:10:38 -04:00
parent 2e609331f3
commit 8dd574bf9a
3 changed files with 39 additions and 6 deletions

View File

@@ -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?
}