From d754acd863674ed3481f3f86e246ea2f75772b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Mon, 20 Oct 2025 20:51:32 +0200 Subject: [PATCH] Adhere to style guides --- .../CredentialProviderViewController.swift | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift b/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift index 3d0603ec52a..3de9468c8ab 100644 --- a/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift +++ b/apps/desktop/macos/autofill-extension/CredentialProviderViewController.swift @@ -8,16 +8,20 @@ import AuthenticationServices import os - class CredentialProviderViewController: ASCredentialProviderViewController { let logger: Logger @IBOutlet weak var statusLabel: NSTextField! @IBOutlet weak var logoImageView: NSImageView! + // The IPC client to communicate with the Bitwarden desktop app private var client: MacOsProviderClient? - // We made the the getclient method async + // Timer for checking connection status + private var connectionMonitorTimer: Timer? + private var lastConnectionStatus: ConnectionStatus = .disconnected + + // We changed the getClient method to be async, here's why: // This is so that we can check if the app is running, and launch it, without blocking the main thread // Blocking the main thread caused MacOS layouting to 'fail' or at least be very delayed, which caused our getWindowPositioning code to sent 0,0. // We also properly retry the IPC connection which sometimes would take some time to be up and running, depending on CPU load, phase of jupiters moon, etc. @@ -83,11 +87,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController { self.client = newClient return newClient! - } - - // Timer for checking connection status - private var connectionMonitorTimer: Timer? - private var lastConnectionStatus: ConnectionStatus = .disconnected + } // Setup the connection monitoring timer private func setupConnectionMonitoring() { @@ -321,8 +321,7 @@ class CredentialProviderViewController: ASCredentialProviderViewController { logger.log("[autofill-extension] provideCredentialWithoutUserInteraction2 called wrong") self.extensionContext.cancelRequest(withError: BitwardenError.Internal("Invalid authentication request")) } - - + private func createTimer() -> DispatchWorkItem { // Create a timer for 600 second timeout let timeoutTimer = DispatchWorkItem { [weak self] in