Skip to content

Commit

Permalink
Populate credential store if user has enabled before launching app
Browse files Browse the repository at this point in the history
  • Loading branch information
amddg44 committed Dec 18, 2024
1 parent 1e4ecf0 commit c59c6cb
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions DuckDuckGo/AutofillUsageMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,34 @@

import Core
import AuthenticationServices
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,
tld: AppDependencyProvider.shared.storageCache.tld)
}()

init() {
NotificationCenter.default.addObserver(self, selector: #selector(didReceiveSaveEvent), name: .autofillSaveEvent, object: nil)

ASCredentialIdentityStore.shared.getState({ state in
ASCredentialIdentityStore.shared.getState({ [weak self] state in
if state.isEnabled {
self.autofillExtensionEnabled = true
if self?.autofillExtensionEnabled == nil {
Task {
await self?.credentialIdentityStoreManager?.populateCredentialStore()
}
}
self?.autofillExtensionEnabled = true
} else {
if self.autofillExtensionEnabled != nil {
if self?.autofillExtensionEnabled != nil {
Pixel.fire(pixel: .autofillExtensionDisabled)
self.autofillExtensionEnabled = false
self?.autofillExtensionEnabled = false
}
}
})
Expand Down

0 comments on commit c59c6cb

Please sign in to comment.