1
0
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:
Kyle Spearrin 2019-08-19 21:04:03 -04:00
parent 41be76a107
commit 8dbdfe96b1
2 changed files with 10 additions and 0 deletions

View File

@ -9,6 +9,11 @@
import SafariServices
class SafariExtensionHandler: SFSafariExtensionHandler {
override init() {
super.init()
SafariExtensionViewController.shared.initWebView()
}
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").
if messageName == "bitwarden" {

View File

@ -11,6 +11,7 @@ import WebKit
class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMessageHandler, WKNavigationDelegate {
var webView: WKWebView!
var initedWebView: Bool = false
static let shared: SafariExtensionViewController = {
let shared = SafariExtensionViewController()
@ -19,6 +20,10 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
}()
func initWebView() {
if initedWebView {
return
}
initedWebView = true
let parentHeight = SafariExtensionViewController.shared.preferredContentSize.height
let parentWidth = SafariExtensionViewController.shared.preferredContentSize.width
let webViewConfig = WKWebViewConfiguration()