-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autofill never save for site (#1991)
Task/Issue URL: https://app.asana.com/0/1201645688934642/1205190244970075/f Tech Design URL: CC: Description: Adds the functionality to allow users to choose to "Never Save for this Site" from the autofill save password prompt, with the option to reset this list from the Settings screen.
- Loading branch information
Showing
20 changed files
with
274 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
DuckDuckGo/SecureVault/Model/AutofillNeverPromptWebsitesManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// | ||
// AutofillNeverPromptWebsitesManager.swift | ||
// | ||
// Copyright © 2023 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
import BrowserServicesKit | ||
|
||
final class AutofillNeverPromptWebsitesManager { | ||
|
||
static let shared = AutofillNeverPromptWebsitesManager() | ||
|
||
public private(set) var neverPromptWebsites: [SecureVaultModels.NeverPromptWebsites] = [] | ||
|
||
private let secureVault: (any AutofillSecureVault)? | ||
|
||
public init(secureVault: (any AutofillSecureVault)? = try? AutofillSecureVaultFactory.makeVault(errorReporter: SecureVaultErrorReporter.shared)) { | ||
self.secureVault = secureVault | ||
|
||
fetchNeverPromptWebsites() | ||
} | ||
|
||
public func hasNeverPromptWebsitesFor(domain: String) -> Bool { | ||
return neverPromptWebsites.contains { $0.domain == domain } | ||
} | ||
|
||
public func saveNeverPromptWebsite(_ domain: String) throws -> Int64? { | ||
guard let secureVault = secureVault else { | ||
return nil | ||
} | ||
|
||
do { | ||
let id = try secureVault.storeNeverPromptWebsites(SecureVaultModels.NeverPromptWebsites(domain: domain)) | ||
|
||
fetchNeverPromptWebsites() | ||
return id | ||
} catch { | ||
Pixel.fire(.debug(event: .secureVaultError, error: error)) | ||
throw error | ||
} | ||
} | ||
|
||
public func deleteAllNeverPromptWebsites() -> Bool { | ||
guard let secureVault = secureVault else { | ||
return false | ||
} | ||
|
||
do { | ||
try secureVault.deleteAllNeverPromptWebsites() | ||
|
||
fetchNeverPromptWebsites() | ||
return true | ||
} catch { | ||
Pixel.fire(.debug(event: .secureVaultError, error: error)) | ||
return false | ||
} | ||
} | ||
|
||
private func fetchNeverPromptWebsites() { | ||
guard let secureVault = secureVault else { | ||
return | ||
} | ||
|
||
do { | ||
neverPromptWebsites = try secureVault.neverPromptWebsites() | ||
} catch { | ||
Pixel.fire(.debug(event: .secureVaultError, error: error)) | ||
neverPromptWebsites = [] | ||
} | ||
} | ||
} |
Oops, something went wrong.