mirror of
https://github.com/bitwarden/browser
synced 2025-01-04 14:22:50 +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) {
|
override func popoverWillShow(in _: SFSafariWindow) {
|
||||||
|
SafariExtensionViewController.shared.popoverOpenCount += 1
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.sendMessage(msg: ["command": "reloadPopup"], sender: nil)
|
self.sendMessage(msg: ["command": "reloadPopup"], sender: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func popoverDidClose(in _: SFSafariWindow) {
|
||||||
|
SafariExtensionViewController.shared.popoverOpenCount -= 1
|
||||||
|
}
|
||||||
|
|
||||||
func sendMessage(msg: [String: Any]?, sender: Tab? = nil) {
|
func sendMessage(msg: [String: Any]?, sender: Tab? = nil) {
|
||||||
if SafariExtensionViewController.shared.webView == nil {
|
if SafariExtensionViewController.shared.webView == nil {
|
||||||
return
|
return
|
||||||
|
@ -12,6 +12,7 @@ import WebKit
|
|||||||
class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMessageHandler, WKNavigationDelegate {
|
class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMessageHandler, WKNavigationDelegate {
|
||||||
var webView: WKWebView!
|
var webView: WKWebView!
|
||||||
var initedWebView: Bool = false
|
var initedWebView: Bool = false
|
||||||
|
var popoverOpenCount: Int = 0
|
||||||
|
|
||||||
static let shared: SafariExtensionViewController = {
|
static let shared: SafariExtensionViewController = {
|
||||||
let shared = SafariExtensionViewController()
|
let shared = SafariExtensionViewController()
|
||||||
@ -148,7 +149,7 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if command == "isPopoverOpen" {
|
} else if command == "isPopoverOpen" {
|
||||||
m!.responseData = "true";
|
m!.responseData = popoverOpenCount > 0 ? "true" : "false";
|
||||||
replyMessage(message: m!)
|
replyMessage(message: m!)
|
||||||
} else if command == "reloadExtension" {
|
} else if command == "reloadExtension" {
|
||||||
webView?.reload()
|
webView?.reload()
|
||||||
|
Loading…
Reference in New Issue
Block a user