mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-07 09:31:31 +01:00
is popover open check from safari app
This commit is contained in:
parent
5c47b33967
commit
0f3cef7762
@ -43,11 +43,16 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
}
|
||||
|
||||
override func popoverWillShow(in _: SFSafariWindow) {
|
||||
SafariExtensionViewController.shared.popoverOpenCount += 1
|
||||
DispatchQueue.main.async {
|
||||
self.sendMessage(msg: ["command": "reloadPopup"], sender: nil)
|
||||
}
|
||||
}
|
||||
|
||||
override func popoverDidClose(in _: SFSafariWindow) {
|
||||
SafariExtensionViewController.shared.popoverOpenCount -= 1
|
||||
}
|
||||
|
||||
func sendMessage(msg: [String: Any]?, sender: Tab? = nil) {
|
||||
if SafariExtensionViewController.shared.webView == nil {
|
||||
return
|
||||
|
@ -12,6 +12,7 @@ import WebKit
|
||||
class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMessageHandler, WKNavigationDelegate {
|
||||
var webView: WKWebView!
|
||||
var initedWebView: Bool = false
|
||||
var popoverOpenCount: Int = 0
|
||||
|
||||
static let shared: SafariExtensionViewController = {
|
||||
let shared = SafariExtensionViewController()
|
||||
@ -148,7 +149,7 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
||||
})
|
||||
}
|
||||
} else if command == "isPopoverOpen" {
|
||||
m!.responseData = "true";
|
||||
m!.responseData = popoverOpenCount > 0 ? "true" : "false";
|
||||
replyMessage(message: m!)
|
||||
} else if command == "reloadExtension" {
|
||||
webView?.reload()
|
||||
|
Loading…
Reference in New Issue
Block a user