Skip to content

Commit

Permalink
Update calls to AutofillCredentialIdentityStoreManager to optionally …
Browse files Browse the repository at this point in the history
…provide a vault (and always provide SecureVaultReporter() since AutofillCredentialIdentityStoreManager can now init the vault lazily)
  • Loading branch information
amddg44 committed Jan 3, 2025
1 parent b84cea1 commit f8d2dc8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ class CredentialProviderViewController: ASCredentialProviderViewController {
private lazy var authenticator = UserAuthenticator(reason: UserText.credentialProviderListAuthenticationReason,
cancelTitle: UserText.credentialProviderListAuthenticationCancelButton)

private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManaging = AutofillCredentialIdentityStoreManager(credentialStore: ASCredentialIdentityStore.shared,
vault: secureVault,
tld: tld)
private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManaging = AutofillCredentialIdentityStoreManager(
credentialStore: ASCredentialIdentityStore.shared,
vault: secureVault,
reporter: SecureVaultReporter(),
tld: tld)

private lazy var secureVault: (any AutofillSecureVault)? = {
if findKeychainItemsWithV4() {
Expand Down
3 changes: 1 addition & 2 deletions Core/SyncCredentialsAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public final class SyncCredentialsAdapter {
secureVaultErrorReporter: secureVaultErrorReporter,
errorEvents: CredentialsCleanupErrorHandling()
)
credentialIdentityStoreManager = AutofillCredentialIdentityStoreManager(
vault: try? secureVaultFactory.makeVault(reporter: secureVaultErrorReporter), tld: tld)
credentialIdentityStoreManager = AutofillCredentialIdentityStoreManager(reporter: secureVaultErrorReporter, tld: tld)
}

public func cleanUpDatabaseAndUpdateSchedule(shouldEnable: Bool) {
Expand Down
4 changes: 3 additions & 1 deletion DuckDuckGo/AutofillLoginListViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ final class AutofillLoginListViewModel: ObservableObject {
return settings["monitorIntervalDays"] as? Int ?? 42
}()

private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManaging = AutofillCredentialIdentityStoreManager(vault: secureVault, tld: tld)
private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManaging = AutofillCredentialIdentityStoreManager(vault: secureVault,
reporter: SecureVaultReporter(),
tld: tld)

private lazy var syncPromoManager: SyncPromoManaging = SyncPromoManager(syncService: syncService)

Expand Down
10 changes: 3 additions & 7 deletions DuckDuckGo/AutofillUsageMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ import BrowserServicesKit

final class AutofillUsageMonitor {

private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManager? = {
guard let vault = try? AutofillSecureVaultFactory.makeVault(reporter: SecureVaultReporter()) else {
return nil
}

return AutofillCredentialIdentityStoreManager(vault: vault,
private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManager = {
return AutofillCredentialIdentityStoreManager(reporter: SecureVaultReporter(),
tld: AppDependencyProvider.shared.storageCache.tld)
}()

Expand All @@ -39,7 +35,7 @@ final class AutofillUsageMonitor {
if state.isEnabled {
if self?.autofillExtensionEnabled == nil {
Task {
await self?.credentialIdentityStoreManager?.populateCredentialStore()
await self?.credentialIdentityStoreManager.populateCredentialStore()
}
}
self?.autofillExtensionEnabled = true
Expand Down
12 changes: 4 additions & 8 deletions DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,8 @@ class TabViewController: UIViewController {
return manager
}()

private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManager? = {
guard let vault = try? AutofillSecureVaultFactory.makeVault(reporter: SecureVaultReporter()) else {
return nil
}

return AutofillCredentialIdentityStoreManager(vault: vault,
private lazy var credentialIdentityStoreManager: AutofillCredentialIdentityStoreManager = {
return AutofillCredentialIdentityStoreManager(reporter: SecureVaultReporter(),
tld: AppDependencyProvider.shared.storageCache.tld)
}()

Expand Down Expand Up @@ -2851,7 +2847,7 @@ extension TabViewController: SecureVaultManagerDelegate {

guard let domain = account?.domain else { return }
Task {
await self?.credentialIdentityStoreManager?.updateCredentialStore(for: domain)
await self?.credentialIdentityStoreManager.updateCredentialStore(for: domain)
}
} completionHandler: { account in
if account != nil {
Expand Down Expand Up @@ -3049,7 +3045,7 @@ extension TabViewController: SaveLoginViewControllerDelegate {

guard let domain = newCredential.account.domain else { return }
Task {
await credentialIdentityStoreManager?.updateCredentialStore(for: domain)
await credentialIdentityStoreManager.updateCredentialStore(for: domain)
}
}
} catch {
Expand Down

0 comments on commit f8d2dc8

Please sign in to comment.