diff --git a/src/safari/safari/SafariExtensionHandler.swift b/src/safari/safari/SafariExtensionHandler.swift index dc221838e8..bc6ff2e8af 100644 --- a/src/safari/safari/SafariExtensionHandler.swift +++ b/src/safari/safari/SafariExtensionHandler.swift @@ -1,11 +1,3 @@ -// -// SafariExtensionHandler.swift -// safari -// -// Created by Kyle Spearrin on 8/1/19. -// Copyright © 2019 8bit Solutions LLC. All rights reserved. -// - import SafariServices class SafariExtensionHandler: SFSafariExtensionHandler { @@ -15,10 +7,10 @@ class SafariExtensionHandler: SFSafariExtensionHandler { } 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" { page.getPropertiesWithCompletionHandler { properties in - // NSLog("The extension received a message (\(messageName)) from a script injected into (\(String(describing: properties?.url))) with userInfo (\(userInfo ?? [:]))") DispatchQueue.main.async { makeSenderTabObject(page: page, props: properties, complete: { senderTab in self.sendMessage(msg: userInfo, sender: senderTab) @@ -30,11 +22,11 @@ class SafariExtensionHandler: SFSafariExtensionHandler { override func toolbarItemClicked(in _: SFSafariWindow) { // This method will be called when your toolbar item is clicked. - // NSLog("The extension's toolbar item was clicked") } override func validateToolbarItem(in _: SFSafariWindow, validationHandler: @escaping ((Bool, String) -> Void)) { - // This is called when Safari's state changed in some way that would require the extension's toolbar item to be validated again. + // This is called when Safari's state changed in some way that would require the extension's + // toolbar item to be validated again. validationHandler(true, "") } diff --git a/src/safari/safari/SafariExtensionViewController.swift b/src/safari/safari/SafariExtensionViewController.swift index 3509d1a66e..1234de6554 100644 --- a/src/safari/safari/SafariExtensionViewController.swift +++ b/src/safari/safari/SafariExtensionViewController.swift @@ -1,11 +1,3 @@ -// -// SafariExtensionViewController.swift -// safari -// -// Created by Kyle Spearrin on 8/1/19. -// Copyright © 2019 8bit Solutions LLC. All rights reserved. -// - import SafariServices import WebKit @@ -35,7 +27,8 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe webViewConfig.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs") webViewConfig.preferences.setValue(true, forKey: "developerExtrasEnabled") webViewConfig.userContentController.add(self, name: "bitwardenApp") - webView = WKWebView(frame: CGRect(x: 0, y: 0, width: parentWidth, height: parentHeight), configuration: webViewConfig) + webView = WKWebView(frame: CGRect(x: 0, y: 0, width: parentWidth, height: parentHeight), + configuration: webViewConfig) webView.navigationDelegate = self webView.allowsLinkPreview = false webView.loadFileURL(url!, allowingReadAccessTo: bundleURL) @@ -65,7 +58,6 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe // print(messageBody) let m: AppMessage? = jsonDeserialize(json: messageBody) if m == nil { - // print("m is nil") return } let command = m!.command @@ -216,7 +208,8 @@ func processWindowsForTabs(wins: [SFSafariWindow], options: TabQueryOptions?, co if activeTab != nil && activeTab == tab { let windowIndex = wins.firstIndex(of: win) ?? -100 let tabIndex = allTabs.firstIndex(of: tab) ?? -1 - makeTabObject(tab: tab, activeTab: activeTab, windowIndex: windowIndex, tabIndex: tabIndex, complete: { t in + makeTabObject(tab: tab, activeTab: activeTab, windowIndex: windowIndex, + tabIndex: tabIndex, complete: { t in newTabs.append(t) tabGroup.leave() }) @@ -226,7 +219,8 @@ func processWindowsForTabs(wins: [SFSafariWindow], options: TabQueryOptions?, co } else { let windowIndex = wins.firstIndex(of: win) ?? -100 let tabIndex = allTabs.firstIndex(of: tab) ?? -1 - makeTabObject(tab: tab, activeTab: activeTab, windowIndex: windowIndex, tabIndex: tabIndex, complete: { t in + makeTabObject(tab: tab, activeTab: activeTab, windowIndex: windowIndex, + tabIndex: tabIndex, complete: { t in newTabs.append(t) tabGroup.leave() }) @@ -243,7 +237,8 @@ func processWindowsForTabs(wins: [SFSafariWindow], options: TabQueryOptions?, co } } -func makeTabObject(tab: SFSafariTab, activeTab: SFSafariTab?, windowIndex: Int, tabIndex: Int, complete: @escaping (Tab) -> Void) { +func makeTabObject(tab: SFSafariTab, activeTab: SFSafariTab?, windowIndex: Int, tabIndex: Int, + complete: @escaping (Tab) -> Void) { let t = Tab() t.active = activeTab != nil && tab == activeTab t.windowId = windowIndex