diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index a5983ad947..eab0e54705 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -28,9 +28,9 @@ 1D01A3DA2B88DF8B00FE8150 /* PreferencesSyncView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D01A3D72B88DF8B00FE8150 /* PreferencesSyncView.swift */; }; 1D02633628D8A9A9005CBB41 /* BWEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D02633528D8A9A9005CBB41 /* BWEncryption.m */; settings = {COMPILER_FLAGS = "-Wno-deprecated -Wno-strict-prototypes"; }; }; 1D074B272909A433006E4AC3 /* PasswordManagerCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D074B262909A433006E4AC3 /* PasswordManagerCoordinator.swift */; }; - 1D0E4F562BB419ED00670CFE /* BurnOnQuitHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E4F552BB419ED00670CFE /* BurnOnQuitHandler.swift */; }; - 1D0E4F572BB419ED00670CFE /* BurnOnQuitHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E4F552BB419ED00670CFE /* BurnOnQuitHandler.swift */; }; - 1D0E4F582BB419ED00670CFE /* BurnOnQuitHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E4F552BB419ED00670CFE /* BurnOnQuitHandler.swift */; }; + 1D0E4F562BB419ED00670CFE /* AutoClearHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E4F552BB419ED00670CFE /* AutoClearHandler.swift */; }; + 1D0E4F572BB419ED00670CFE /* AutoClearHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E4F552BB419ED00670CFE /* AutoClearHandler.swift */; }; + 1D0E4F582BB419ED00670CFE /* AutoClearHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E4F552BB419ED00670CFE /* AutoClearHandler.swift */; }; 1D12F2E2298BC660009A65FD /* InternalUserDeciderStoreMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D12F2E1298BC660009A65FD /* InternalUserDeciderStoreMock.swift */; }; 1D1A33492A6FEB170080ACED /* BurnerMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1A33482A6FEB170080ACED /* BurnerMode.swift */; }; 1D1A334A2A6FEB170080ACED /* BurnerMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1A33482A6FEB170080ACED /* BurnerMode.swift */; }; @@ -72,8 +72,8 @@ 1D43EB38292B636E0065E5D6 /* BWCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D43EB37292B636E0065E5D6 /* BWCommand.swift */; }; 1D43EB3A292B63B00065E5D6 /* BWRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D43EB39292B63B00065E5D6 /* BWRequest.swift */; }; 1D43EB3C292B664A0065E5D6 /* BWMessageIdGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D43EB3B292B664A0065E5D6 /* BWMessageIdGenerator.swift */; }; - 1D5FADA22BC7E734005D6EB1 /* BurnOnQuitHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D5FADA12BC7E734005D6EB1 /* BurnOnQuitHandlerTests.swift */; }; - 1D5FADA32BC7E734005D6EB1 /* BurnOnQuitHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D5FADA12BC7E734005D6EB1 /* BurnOnQuitHandlerTests.swift */; }; + 1D5FADA22BC7E734005D6EB1 /* AutoClearHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D5FADA12BC7E734005D6EB1 /* AutoClearHandlerTests.swift */; }; + 1D5FADA32BC7E734005D6EB1 /* AutoClearHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D5FADA12BC7E734005D6EB1 /* AutoClearHandlerTests.swift */; }; 1D6216B229069BBF00386B2C /* BWKeyStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6216B129069BBF00386B2C /* BWKeyStorage.swift */; }; 1D69C553291302F200B75945 /* BWVault.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D69C552291302F200B75945 /* BWVault.swift */; }; 1D6A492029CF7A490011DF74 /* NSPopoverExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6A491F29CF7A490011DF74 /* NSPopoverExtension.swift */; }; @@ -3573,7 +3573,7 @@ 1D02633428D8A9A9005CBB41 /* BWEncryption.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BWEncryption.h; sourceTree = ""; }; 1D02633528D8A9A9005CBB41 /* BWEncryption.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BWEncryption.m; sourceTree = ""; }; 1D074B262909A433006E4AC3 /* PasswordManagerCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordManagerCoordinator.swift; sourceTree = ""; }; - 1D0E4F552BB419ED00670CFE /* BurnOnQuitHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BurnOnQuitHandler.swift; sourceTree = ""; }; + 1D0E4F552BB419ED00670CFE /* AutoClearHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoClearHandler.swift; sourceTree = ""; }; 1D12F2E1298BC660009A65FD /* InternalUserDeciderStoreMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternalUserDeciderStoreMock.swift; sourceTree = ""; }; 1D1A33482A6FEB170080ACED /* BurnerMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BurnerMode.swift; sourceTree = ""; }; 1D1C36E229FAE8DA001FA40C /* FaviconManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaviconManagerTests.swift; sourceTree = ""; }; @@ -3597,7 +3597,7 @@ 1D43EB37292B636E0065E5D6 /* BWCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BWCommand.swift; sourceTree = ""; }; 1D43EB39292B63B00065E5D6 /* BWRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BWRequest.swift; sourceTree = ""; }; 1D43EB3B292B664A0065E5D6 /* BWMessageIdGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BWMessageIdGenerator.swift; sourceTree = ""; }; - 1D5FADA12BC7E734005D6EB1 /* BurnOnQuitHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BurnOnQuitHandlerTests.swift; sourceTree = ""; }; + 1D5FADA12BC7E734005D6EB1 /* AutoClearHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutoClearHandlerTests.swift; sourceTree = ""; }; 1D6216B129069BBF00386B2C /* BWKeyStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BWKeyStorage.swift; sourceTree = ""; }; 1D69C552291302F200B75945 /* BWVault.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BWVault.swift; sourceTree = ""; }; 1D6A491F29CF7A490011DF74 /* NSPopoverExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSPopoverExtension.swift; sourceTree = ""; }; @@ -6975,7 +6975,7 @@ isa = PBXGroup; children = ( 85F1B0C825EF9759004792B6 /* URLEventHandlerTests.swift */, - 1D5FADA12BC7E734005D6EB1 /* BurnOnQuitHandlerTests.swift */, + 1D5FADA12BC7E734005D6EB1 /* AutoClearHandlerTests.swift */, 0289041E2A7B23CE0028369C /* AppConfigurationURLProviderTests.swift */, ); path = AppDelegate; @@ -7179,7 +7179,7 @@ 858A798226A8B75F00A75A42 /* CopyHandler.swift */, 1D36E65A298ACD2900AA485D /* AppIconChanger.swift */, CB24F70B29A3D9CB006DCC58 /* AppConfigurationURLProvider.swift */, - 1D0E4F552BB419ED00670CFE /* BurnOnQuitHandler.swift */, + 1D0E4F552BB419ED00670CFE /* AutoClearHandler.swift */, ); path = Application; sourceTree = ""; @@ -10949,7 +10949,7 @@ 3706FC52293F65D500E42796 /* MouseOverAnimationButton.swift in Sources */, B60293E72BA19ECD0033186B /* NetPPopoverManagerMock.swift in Sources */, 3706FC53293F65D500E42796 /* TabBarScrollView.swift in Sources */, - 1D0E4F572BB419ED00670CFE /* BurnOnQuitHandler.swift in Sources */, + 1D0E4F572BB419ED00670CFE /* AutoClearHandler.swift in Sources */, B6104E9C2BA9C173008636B2 /* DownloadResumeData.swift in Sources */, 3706FC54293F65D500E42796 /* BookmarkListTreeControllerDataSource.swift in Sources */, 3706FC55293F65D500E42796 /* AddressBarViewController.swift in Sources */, @@ -11223,7 +11223,7 @@ 3706FE46293F661700E42796 /* EncryptedValueTransformerTests.swift in Sources */, 9F3910632B68C35600CB5112 /* DownloadsTabExtensionTests.swift in Sources */, 3706FE47293F661700E42796 /* URLExtensionTests.swift in Sources */, - 1D5FADA32BC7E734005D6EB1 /* BurnOnQuitHandlerTests.swift in Sources */, + 1D5FADA32BC7E734005D6EB1 /* AutoClearHandlerTests.swift in Sources */, 1DB9617B29F1D06D00CF5568 /* InternalUserDeciderMock.swift in Sources */, 317295D52AF058D3002C3206 /* MockWaitlistFeatureSetupHandler.swift in Sources */, 3706FE48293F661700E42796 /* PixelTests.swift in Sources */, @@ -12043,7 +12043,7 @@ 4B957AF12AC7AE700062CA31 /* AppStateRestorationManager.swift in Sources */, 4B957AF22AC7AE700062CA31 /* DailyPixel.swift in Sources */, 9FDA6C232B79A59D00E099A9 /* BookmarkFavoriteView.swift in Sources */, - 1D0E4F582BB419ED00670CFE /* BurnOnQuitHandler.swift in Sources */, + 1D0E4F582BB419ED00670CFE /* AutoClearHandler.swift in Sources */, 4B957AF32AC7AE700062CA31 /* NavigationHotkeyHandler.swift in Sources */, B6CC266E2BAD9CD800F53F8D /* FileProgressPresenter.swift in Sources */, 4B957AF42AC7AE700062CA31 /* ClickToLoadUserScript.swift in Sources */, @@ -12471,7 +12471,7 @@ B6A9E48426146AAB0067D1B9 /* PixelParameters.swift in Sources */, AA5FA697275F90C400DCE9C9 /* FaviconImageCache.swift in Sources */, 1430DFF524D0580F00B8978C /* TabBarViewController.swift in Sources */, - 1D0E4F562BB419ED00670CFE /* BurnOnQuitHandler.swift in Sources */, + 1D0E4F562BB419ED00670CFE /* AutoClearHandler.swift in Sources */, B62B483E2ADE48DE000DECE5 /* ArrayBuilder.swift in Sources */, 4B92929B26670D2A00AD2C21 /* BookmarkOutlineViewDataSource.swift in Sources */, 56D145EB29E6C99B00E3488A /* DataImportStatusProviding.swift in Sources */, @@ -13334,7 +13334,7 @@ 85F487B5276A8F2E003CE668 /* OnboardingTests.swift in Sources */, B626A7642992506A00053070 /* SerpHeadersNavigationResponderTests.swift in Sources */, AA652CCE25DD9071009059CC /* BookmarkListTests.swift in Sources */, - 1D5FADA22BC7E734005D6EB1 /* BurnOnQuitHandlerTests.swift in Sources */, + 1D5FADA22BC7E734005D6EB1 /* AutoClearHandlerTests.swift in Sources */, 859E7D6D274548F2009C2B69 /* BookmarksExporterTests.swift in Sources */, B6A5A2A825BAA35500AA7ADA /* WindowManagerStateRestorationTests.swift in Sources */, B6AE39F129373AF200C37AA4 /* EmptyAttributionRulesProver.swift in Sources */, diff --git a/DuckDuckGo/Application/AppDelegate.swift b/DuckDuckGo/Application/AppDelegate.swift index 7405cffd25..eada31b66d 100644 --- a/DuckDuckGo/Application/AppDelegate.swift +++ b/DuckDuckGo/Application/AppDelegate.swift @@ -70,7 +70,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { let internalUserDecider: InternalUserDecider let featureFlagger: FeatureFlagger private var appIconChanger: AppIconChanger! - private var burnOnQuitHandler: BurnOnQuitHandler! + private var autoClearHandler: AutoClearHandler! private(set) var syncDataProviders: SyncDataProviders! private(set) var syncService: DDGSyncing? @@ -313,7 +313,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { #endif - setUpBurnOnQuitHandler() + setUpAutoClearHandler() } func applicationDidBecomeActive(_ notification: Notification) { @@ -352,7 +352,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { stateRestorationManager?.applicationWillTerminate() // Handling of "Burn on quit" - if let terminationReply = burnOnQuitHandler.handleAppTermination() { + if let terminationReply = autoClearHandler.handleAppTermination() { return terminationReply } @@ -556,11 +556,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } } - private func setUpBurnOnQuitHandler() { - burnOnQuitHandler = BurnOnQuitHandler(preferences: .shared, fireViewModel: FireCoordinator.fireViewModel) - burnOnQuitHandler.burnOnStartIfNeeded() - burnOnQuitHandler.resetTheFlag() - burnOnQuitHandler.onBurnOnQuitCompleted = { + private func setUpAutoClearHandler() { + autoClearHandler = AutoClearHandler(preferences: .shared, fireViewModel: FireCoordinator.fireViewModel) + autoClearHandler.burnOnStartIfNeeded() + autoClearHandler.resetTheFlag() + autoClearHandler.onAutoClearCompleted = { NSApplication.shared.reply(toApplicationShouldTerminate: true) } } diff --git a/DuckDuckGo/Application/BurnOnQuitHandler.swift b/DuckDuckGo/Application/AutoClearHandler.swift similarity index 76% rename from DuckDuckGo/Application/BurnOnQuitHandler.swift rename to DuckDuckGo/Application/AutoClearHandler.swift index f3c5416b04..1ed2bf4837 100644 --- a/DuckDuckGo/Application/BurnOnQuitHandler.swift +++ b/DuckDuckGo/Application/AutoClearHandler.swift @@ -1,5 +1,5 @@ // -// BurnOnQuitHandler.swift +// AutoClearHandler.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -19,7 +19,7 @@ import Foundation import Combine -final class BurnOnQuitHandler { +final class AutoClearHandler { private let preferences: DataClearingPreferences private let fireViewModel: FireViewModel @@ -29,17 +29,17 @@ final class BurnOnQuitHandler { self.fireViewModel = fireViewModel } - var onBurnOnQuitCompleted: (() -> Void)? + var onAutoClearCompleted: (() -> Void)? @MainActor func handleAppTermination() -> NSApplication.TerminateReply? { - guard preferences.isBurnDataOnQuitEnabled else { return nil } + guard preferences.isAutoClearEnabled else { return nil } - if preferences.isWarnBeforeClearingEnabled, !confirmBurnOnQuit() { + if preferences.isWarnBeforeClearingEnabled, !confirmAutoClear() { return .terminateCancel } - performBurnOnQuit() + performAutoClear() return .terminateLater } @@ -49,17 +49,17 @@ final class BurnOnQuitHandler { // MARK: - Private - private func confirmBurnOnQuit() -> Bool { - let alert = NSAlert.burnOnQuitAlert() + private func confirmAutoClear() -> Bool { + let alert = NSAlert.autoClearAlert() let response = alert.runModal() return response == .alertFirstButtonReturn } @MainActor - private func performBurnOnQuit() { + private func performAutoClear() { fireViewModel.fire.burnAll { [weak self] in self?.appTerminationHandledCorrectly = true - self?.onBurnOnQuitCompleted?() + self?.onAutoClearCompleted?() } } @@ -72,7 +72,7 @@ final class BurnOnQuitHandler { @MainActor @discardableResult func burnOnStartIfNeeded() -> Bool { - let shouldBurnOnStart = preferences.isBurnDataOnQuitEnabled && !appTerminationHandledCorrectly + let shouldBurnOnStart = preferences.isAutoClearEnabled && !appTerminationHandledCorrectly guard shouldBurnOnStart else { return false } fireViewModel.fire.burnAll() diff --git a/DuckDuckGo/Common/Extensions/NSAlertExtension.swift b/DuckDuckGo/Common/Extensions/NSAlertExtension.swift index 0f7246d89d..4576a98515 100644 --- a/DuckDuckGo/Common/Extensions/NSAlertExtension.swift +++ b/DuckDuckGo/Common/Extensions/NSAlertExtension.swift @@ -215,10 +215,10 @@ extension NSAlert { return alert } - static func burnOnQuitAlert() -> NSAlert { + static func autoClearAlert() -> NSAlert { let alert = NSAlert() alert.messageText = UserText.warnBeforeQuitDialogHeader - alert.informativeText = UserText.warnBeforeQuitDialogMessage + //TODO checkbox alert.alertStyle = .warning alert.icon = .burnAlert alert.addButton(withTitle: UserText.clear) diff --git a/DuckDuckGo/Common/Localizables/UserText.swift b/DuckDuckGo/Common/Localizables/UserText.swift index 7e5714381d..787ab1d4cc 100644 --- a/DuckDuckGo/Common/Localizables/UserText.swift +++ b/DuckDuckGo/Common/Localizables/UserText.swift @@ -1045,18 +1045,17 @@ struct UserText { static let fireproofCheckboxTitle = NSLocalizedString("fireproof.checkbox.title", value: "Ask to Fireproof websites when signing in", comment: "Fireproof settings checkbox title") static let fireproofExplanation = NSLocalizedString("fireproof.explanation", value: "When you Fireproof a site, cookies won't be erased and you'll stay signed in, even after using the Fire Button.", comment: "Fireproofing mechanism explanation") static let manageFireproofSites = NSLocalizedString("fireproof.manage-sites", value: "Manage Fireproof Sites…", comment: "Fireproof settings button caption") - static let automaticallyClearData = NSLocalizedString("automatically.clear.data", value: "Automatically Clear", comment: "Header of a section in Settings. The setting configures clearing data automatically after quitting the app.") - static let burnDataOnQuit = NSLocalizedString("burn.data.on.quit", value: "Clear Data upon Quitting", comment: "Label after the checkbox in Settings which configures clearing data automatically after quitting the app.") - static let burnDataOnQuitExplanation = NSLocalizedString("burn.data.on.quit.explanation", value: "Data from \"Fireproofed\" sites won't be cleared, keeping your essential logins and preferences intact.", comment: "Explanation of a setting which configures clearing data automatically after quitting the app.") - static let warnBeforeQuit = NSLocalizedString("warn.before.quit", value: "Warn before Quit", comment: "Label after the checkbox in Settings which configures a warning before clearing data on the application termination.") - static let warnBeforeQuitDialogHeader = NSLocalizedString("warn.before.quit.dialog.header", value: "Quit the application and \nclear all data?", comment: "A header of warning before clearing data on the application termination.") - static let warnBeforeQuitDialogMessage = NSLocalizedString("warn.before.quit.dialog.message", value: "Cookies and site data for all sites will be cleared, unless the site is Fireproof.", comment: "A warning before clearing data on the application termination.") - - static func disableBurnOnQuitToEnableSessionRestore() -> String { - let localized = NSLocalizedString("disable.burn.on.quit.to.enable.session.restore", + static let autoClear = NSLocalizedString("auto.clear", value: "Auto-Clear", comment: "Header of a section in Settings. The setting configures clearing data automatically after quitting the app.") + static let automaticallyClearData = NSLocalizedString("automatically.clear.data", value: "Automatically clear browsing data when DuckDuckGo quits", comment: "Label after the checkbox in Settings which configures clearing data automatically after quitting the app.") + static let warnBeforeQuit = NSLocalizedString("warn.before.quit", value: "Warn me that data will be cleared when quitting", comment: "Label after the checkbox in Settings which configures a warning before clearing data on the application termination.") + static let warnBeforeQuitDialogHeader = NSLocalizedString("warn.before.quit.dialog.header", value: "Clear browsing data and quit\nDuckDuckGo?", comment: "A header of warning before clearing data on the application termination.") + static let warnBeforeQuitDialogCheckboxMessage = NSLocalizedString("warn.before.quit.dialog.checkbox.message", value: "Warn me every time", comment: "A label after checkbox to configure the warning before clearing data on the application termination.") + + static func disableAutoClearToEnableSessionRestore() -> String { + let localized = NSLocalizedString("disable.auto.clear.to.enable.session.restore", value: "Disable the %@ setting to enable session restore on startup.", comment: "Information label in Settings. It tells user that to enable session restoration setting they have to disable burn on quit") - return String(format: localized, automaticallyClearData) + return String(format: localized, autoClear) } static func showDataClearingSettings() -> String { let localized = NSLocalizedString("show.data.clearing.settings", diff --git a/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift b/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift index 39930f8a76..f5efea63d8 100644 --- a/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift +++ b/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift @@ -55,7 +55,7 @@ public struct UserDefaultsWrapper { case grammarCheckEnabledOnce = "grammar.check.enabled.once" case loginDetectionEnabled = "fireproofing.login-detection-enabled" - case burnDataOnQuitEnabled = "preferences.burn-data-on-quit-enabled" + case autoClearEnabled = "preferences.auto-clear-enabled" case warnBeforeClearingEnabled = "preferences.warn-before-clearing-enabled" case clearDataAfter = "preferences.clear-data-after" case gpcEnabled = "preferences.gpc-enabled" diff --git a/DuckDuckGo/Localizable.xcstrings b/DuckDuckGo/Localizable.xcstrings index ee449728e3..22779b61f8 100644 --- a/DuckDuckGo/Localizable.xcstrings +++ b/DuckDuckGo/Localizable.xcstrings @@ -2359,6 +2359,18 @@ } } }, + "auto.clear" : { + "comment" : "Header of a section in Settings. The setting configures clearing data automatically after quitting the app.", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Auto-Clear" + } + } + } + }, "autoconsent.checkbox.title" : { "comment" : "Autoconsent settings checkbox title", "extractionState" : "extracted_with_value", @@ -5600,13 +5612,13 @@ } }, "automatically.clear.data" : { - "comment" : "Header of a section in Settings. The setting configures clearing data automatically after quitting the app.", + "comment" : "Label after the checkbox in Settings which configures clearing data automatically after quitting the app.", "extractionState" : "extracted_with_value", "localizations" : { "en" : { "stringUnit" : { "state" : "new", - "value" : "Automatically Clear" + "value" : "Automatically clear browsing data when DuckDuckGo quits" } } } @@ -9880,30 +9892,6 @@ } } }, - "burn.data.on.quit" : { - "comment" : "Label after the checkbox in Settings which configures clearing data automatically after quitting the app.", - "extractionState" : "extracted_with_value", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "new", - "value" : "Clear Data upon Quitting" - } - } - } - }, - "burn.data.on.quit.explanation" : { - "comment" : "Explanation of a setting which configures clearing data automatically after quitting the app.", - "extractionState" : "extracted_with_value", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "new", - "value" : "Data from \"Fireproofed\" sites won't be cleared, keeping your essential logins and preferences intact." - } - } - } - }, "burner.homepage.description.1" : { "comment" : "Descriptions of features Fire page. Provides information about browsing functionalities such as browsing without saving local history, signing in to a site with a different account, and troubleshooting websites.", "extractionState" : "extracted_with_value", @@ -12848,7 +12836,7 @@ } } }, - "disable.burn.on.quit.to.enable.session.restore" : { + "disable.auto.clear.to.enable.session.restore" : { "comment" : "Information label in Settings. It tells user that to enable session restoration setting they have to disable burn on quit", "extractionState" : "extracted_with_value", "localizations" : { @@ -51713,31 +51701,31 @@ "en" : { "stringUnit" : { "state" : "new", - "value" : "Warn before Quit" + "value" : "Warn me that data will be cleared when quitting" } } } }, - "warn.before.quit.dialog.header" : { - "comment" : "A header of warning before clearing data on the application termination.", + "warn.before.quit.dialog.checkbox.message" : { + "comment" : "A label after checkbox to configure the warning before clearing data on the application termination.", "extractionState" : "extracted_with_value", "localizations" : { "en" : { "stringUnit" : { "state" : "new", - "value" : "Quit the application and \nclear all data?" + "value" : "Warn me every time" } } } }, - "warn.before.quit.dialog.message" : { - "comment" : "A warning before clearing data on the application termination.", + "warn.before.quit.dialog.header" : { + "comment" : "A header of warning before clearing data on the application termination.", "extractionState" : "extracted_with_value", "localizations" : { "en" : { "stringUnit" : { "state" : "new", - "value" : "Cookies and site data for all sites will be cleared, unless the site is Fireproof." + "value" : "Clear browsing data and quit\nDuckDuckGo?" } } } diff --git a/DuckDuckGo/Preferences/Model/DataClearingPreferences.swift b/DuckDuckGo/Preferences/Model/DataClearingPreferences.swift index 3c405140a5..0e7d7a59b1 100644 --- a/DuckDuckGo/Preferences/Model/DataClearingPreferences.swift +++ b/DuckDuckGo/Preferences/Model/DataClearingPreferences.swift @@ -20,7 +20,6 @@ import Foundation final class DataClearingPreferences: ObservableObject, PreferencesTabOpening { - static let burnOnQuitNotificationKey = "isBurnDataOnQuitEnabled" static let shared = DataClearingPreferences() @Published @@ -31,10 +30,10 @@ final class DataClearingPreferences: ObservableObject, PreferencesTabOpening { } @Published - var isBurnDataOnQuitEnabled: Bool { + var isAutoClearEnabled: Bool { didSet { - persistor.burnDataOnQuitEnabled = isBurnDataOnQuitEnabled - NotificationCenter.default.post(name: .burnDataOnQuitDidChange, + persistor.autoClearEnabled = isAutoClearEnabled + NotificationCenter.default.post(name: .autoClearDidChange, object: nil, userInfo: nil) } @@ -64,7 +63,7 @@ final class DataClearingPreferences: ObservableObject, PreferencesTabOpening { init(persistor: FireButtonPreferencesPersistor = FireButtonPreferencesUserDefaultsPersistor()) { self.persistor = persistor isLoginDetectionEnabled = persistor.loginDetectionEnabled - isBurnDataOnQuitEnabled = persistor.burnDataOnQuitEnabled + isAutoClearEnabled = persistor.autoClearEnabled isWarnBeforeClearingEnabled = persistor.warnBeforeClearingEnabled } @@ -73,7 +72,7 @@ final class DataClearingPreferences: ObservableObject, PreferencesTabOpening { protocol FireButtonPreferencesPersistor { var loginDetectionEnabled: Bool { get set } - var burnDataOnQuitEnabled: Bool { get set } + var autoClearEnabled: Bool { get set } var warnBeforeClearingEnabled: Bool { get set } } @@ -82,8 +81,8 @@ struct FireButtonPreferencesUserDefaultsPersistor: FireButtonPreferencesPersisto @UserDefaultsWrapper(key: .loginDetectionEnabled, defaultValue: false) var loginDetectionEnabled: Bool - @UserDefaultsWrapper(key: .burnDataOnQuitEnabled, defaultValue: false) - var burnDataOnQuitEnabled: Bool + @UserDefaultsWrapper(key: .autoClearEnabled, defaultValue: false) + var autoClearEnabled: Bool @UserDefaultsWrapper(key: .warnBeforeClearingEnabled, defaultValue: false) var warnBeforeClearingEnabled: Bool @@ -91,5 +90,5 @@ struct FireButtonPreferencesUserDefaultsPersistor: FireButtonPreferencesPersisto } extension Notification.Name { - static let burnDataOnQuitDidChange = Notification.Name("burnDataOnQuitDidChange") + static let autoClearDidChange = Notification.Name("autoClearDidChange") } diff --git a/DuckDuckGo/Preferences/Model/StartupPreferences.swift b/DuckDuckGo/Preferences/Model/StartupPreferences.swift index 11ab60e384..9bdafbacf3 100644 --- a/DuckDuckGo/Preferences/Model/StartupPreferences.swift +++ b/DuckDuckGo/Preferences/Model/StartupPreferences.swift @@ -136,13 +136,13 @@ final class StartupPreferences: ObservableObject, PreferencesTabOpening { } private func checkDataClearingStatus() { - if dataClearingPreferences.isBurnDataOnQuitEnabled { + if dataClearingPreferences.isAutoClearEnabled { restorePreviousSession = false } } private func listenToDataClearingPreferencesNotifications() { - dataClearingPreferencesNotificationCancellable = NotificationCenter.default.publisher(for: .burnDataOnQuitDidChange).sink { [weak self] _ in + dataClearingPreferencesNotificationCancellable = NotificationCenter.default.publisher(for: .autoClearDidChange).sink { [weak self] _ in guard let self = self else { return } diff --git a/DuckDuckGo/Preferences/View/PreferencesDataClearingView.swift b/DuckDuckGo/Preferences/View/PreferencesDataClearingView.swift index 0fb1e94feb..1680fb2e69 100644 --- a/DuckDuckGo/Preferences/View/PreferencesDataClearingView.swift +++ b/DuckDuckGo/Preferences/View/PreferencesDataClearingView.swift @@ -29,16 +29,13 @@ extension Preferences { PreferencePane(UserText.dataClearing) { // SECTION 1: Automatically Clear Data - PreferencePaneSection(UserText.automaticallyClearData) { + PreferencePaneSection(UserText.autoClear) { PreferencePaneSubSection { - ToggleMenuItem(UserText.burnDataOnQuit, isOn: $model.isBurnDataOnQuitEnabled) - VStack(alignment: .leading, spacing: 1) { - TextMenuItemCaption(UserText.burnDataOnQuitExplanation) - } + ToggleMenuItem(UserText.automaticallyClearData, isOn: $model.isAutoClearEnabled) ToggleMenuItem(UserText.warnBeforeQuit, isOn: $model.isWarnBeforeClearingEnabled) - .disabled(!model.isBurnDataOnQuitEnabled) + .disabled(!model.isAutoClearEnabled) .padding(.leading, 16) } diff --git a/DuckDuckGo/Preferences/View/PreferencesGeneralView.swift b/DuckDuckGo/Preferences/View/PreferencesGeneralView.swift index 5bf36add6f..528e920fc2 100644 --- a/DuckDuckGo/Preferences/View/PreferencesGeneralView.swift +++ b/DuckDuckGo/Preferences/View/PreferencesGeneralView.swift @@ -45,12 +45,12 @@ extension Preferences { .accessibilityIdentifier("PreferencesGeneralView.stateRestorePicker.reopenAllWindowsFromLastSession") }, label: {}) .pickerStyle(.radioGroup) - .disabled(dataClearingModel.isBurnDataOnQuitEnabled) + .disabled(dataClearingModel.isAutoClearEnabled) .offset(x: PreferencesViews.Const.pickerHorizontalOffset) .accessibilityIdentifier("PreferencesGeneralView.stateRestorePicker") - if dataClearingModel.isBurnDataOnQuitEnabled { + if dataClearingModel.isAutoClearEnabled { VStack(alignment: .leading, spacing: 1) { - TextMenuItemCaption(UserText.disableBurnOnQuitToEnableSessionRestore()) + TextMenuItemCaption(UserText.disableAutoClearToEnableSessionRestore()) TextButton(UserText.showDataClearingSettings()) { startupModel.show(url: .settingsPane(.dataClearing)) } diff --git a/UnitTests/AppDelegate/BurnOnQuitHandlerTests.swift b/UnitTests/AppDelegate/AutoClearHandlerTests.swift similarity index 82% rename from UnitTests/AppDelegate/BurnOnQuitHandlerTests.swift rename to UnitTests/AppDelegate/AutoClearHandlerTests.swift index 9a06bd3f0d..40545f1d3e 100644 --- a/UnitTests/AppDelegate/BurnOnQuitHandlerTests.swift +++ b/UnitTests/AppDelegate/AutoClearHandlerTests.swift @@ -1,5 +1,5 @@ // -// BurnOnQuitHandlerTests.swift +// AutoClearHandlerTests.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -22,9 +22,9 @@ import XCTest @testable import DuckDuckGo_Privacy_Browser @MainActor -class BurnOnQuitHandlerTests: XCTestCase { +class AutoClearHandlerTests: XCTestCase { - var handler: BurnOnQuitHandler! + var handler: AutoClearHandler! var preferences: DataClearingPreferences! var fireViewModel: FireViewModel! @@ -33,7 +33,7 @@ class BurnOnQuitHandlerTests: XCTestCase { let persistor = MockFireButtonPreferencesPersistor() preferences = DataClearingPreferences(persistor: persistor) fireViewModel = FireViewModel(fire: Fire(tld: ContentBlocking.shared.tld)) - handler = BurnOnQuitHandler(preferences: preferences, fireViewModel: fireViewModel) + handler = AutoClearHandler(preferences: preferences, fireViewModel: fireViewModel) } override func tearDown() { @@ -44,7 +44,7 @@ class BurnOnQuitHandlerTests: XCTestCase { } func testWhenBurningEnabledAndNoWarningRequiredThenTerminateLaterIsReturned() { - preferences.isBurnDataOnQuitEnabled = true + preferences.isAutoClearEnabled = true preferences.isWarnBeforeClearingEnabled = false let response = handler.handleAppTermination() @@ -53,7 +53,7 @@ class BurnOnQuitHandlerTests: XCTestCase { } func testWhenBurningDisabledThenNoTerminationResponse() { - preferences.isBurnDataOnQuitEnabled = false + preferences.isAutoClearEnabled = false let response = handler.handleAppTermination() @@ -61,14 +61,14 @@ class BurnOnQuitHandlerTests: XCTestCase { } func testWhenBurningEnabledAndFlagFalseThenBurnOnStartTriggered() { - preferences.isBurnDataOnQuitEnabled = true + preferences.isAutoClearEnabled = true handler.resetTheFlag() XCTAssertTrue(handler.burnOnStartIfNeeded()) } func testWhenBurningDisabledThenBurnOnStartNotTriggered() { - preferences.isBurnDataOnQuitEnabled = false + preferences.isAutoClearEnabled = false handler.resetTheFlag() XCTAssertFalse(handler.burnOnStartIfNeeded()) diff --git a/UnitTests/Preferences/DataClearingPreferencesTests.swift b/UnitTests/Preferences/DataClearingPreferencesTests.swift index 3fb71b91d6..1c0b6675e4 100644 --- a/UnitTests/Preferences/DataClearingPreferencesTests.swift +++ b/UnitTests/Preferences/DataClearingPreferencesTests.swift @@ -21,7 +21,7 @@ import XCTest class MockFireButtonPreferencesPersistor: FireButtonPreferencesPersistor { - var burnDataOnQuitEnabled: Bool = false + var autoClearEnabled: Bool = false var warnBeforeClearingEnabled: Bool = false var loginDetectionEnabled: Bool = false