mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-02 08:40:08 +01:00
init vc and web view on app init
This commit is contained in:
parent
41be76a107
commit
8dbdfe96b1
@ -9,6 +9,11 @@
|
|||||||
import SafariServices
|
import SafariServices
|
||||||
|
|
||||||
class SafariExtensionHandler: SFSafariExtensionHandler {
|
class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||||
|
override init() {
|
||||||
|
super.init()
|
||||||
|
SafariExtensionViewController.shared.initWebView()
|
||||||
|
}
|
||||||
|
|
||||||
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String: Any]?) {
|
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String: Any]?) {
|
||||||
// This method will be called when a content script provided by your extension calls safari.extension.dispatchMessage("message").
|
// This method will be called when a content script provided by your extension calls safari.extension.dispatchMessage("message").
|
||||||
if messageName == "bitwarden" {
|
if messageName == "bitwarden" {
|
||||||
|
@ -11,6 +11,7 @@ import WebKit
|
|||||||
|
|
||||||
class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMessageHandler, WKNavigationDelegate {
|
class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMessageHandler, WKNavigationDelegate {
|
||||||
var webView: WKWebView!
|
var webView: WKWebView!
|
||||||
|
var initedWebView: Bool = false
|
||||||
|
|
||||||
static let shared: SafariExtensionViewController = {
|
static let shared: SafariExtensionViewController = {
|
||||||
let shared = SafariExtensionViewController()
|
let shared = SafariExtensionViewController()
|
||||||
@ -19,6 +20,10 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
func initWebView() {
|
func initWebView() {
|
||||||
|
if initedWebView {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
initedWebView = true
|
||||||
let parentHeight = SafariExtensionViewController.shared.preferredContentSize.height
|
let parentHeight = SafariExtensionViewController.shared.preferredContentSize.height
|
||||||
let parentWidth = SafariExtensionViewController.shared.preferredContentSize.width
|
let parentWidth = SafariExtensionViewController.shared.preferredContentSize.width
|
||||||
let webViewConfig = WKWebViewConfiguration()
|
let webViewConfig = WKWebViewConfiguration()
|
||||||
|
Loading…
Reference in New Issue
Block a user