1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 09:13:33 +00:00

Revert "Safari Web Extension Port from App Extension"

This commit is contained in:
Chad Scharf
2021-01-13 17:08:33 -05:00
committed by GitHub
parent ebd2439edd
commit 336f8f3117
47 changed files with 1950 additions and 664 deletions

View File

@@ -1,44 +1,14 @@
import Cocoa
import SafariServices.SFSafariApplication
import SafariServices.SFSafariExtensionManager
let appName = "desktop"
let extensionBundleIdentifier = "com.bitwarden.desktop.Extension"
class ViewController: NSViewController {
@IBOutlet var appNameLabel: NSTextField!
override func viewDidLoad() {
super.viewDidLoad()
self.appNameLabel.stringValue = appName
SFSafariExtensionManager.getStateOfSafariExtension(withIdentifier: extensionBundleIdentifier) { (state, error) in
guard let state = state, error == nil else {
// Insert code to inform the user that something went wrong.
return
}
DispatchQueue.main.async {
if (state.isEnabled) {
self.appNameLabel.stringValue = "\(appName)'s extension is currently on."
} else {
self.appNameLabel.stringValue = "\(appName)'s extension is currently off. You can turn it on in Safari Extensions preferences."
}
}
}
}
@IBAction func openSafariExtensionPreferences(_ sender: AnyObject?) {
SFSafariApplication.showPreferencesForExtension(withIdentifier: extensionBundleIdentifier) { error in
guard error == nil else {
// Insert code to inform the user that something went wrong.
return
}
DispatchQueue.main.async {
NSApplication.shared.terminate(nil)
}
}
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}