From 8329e75aa0a0fd4881f02c00102abee858eaffc2 Mon Sep 17 00:00:00 2001 From: bwaresiak Date: Tue, 9 Jan 2024 15:32:44 +0100 Subject: [PATCH] Add API to obtain reason why given feature is disabled (#2030) Task/Issue URL: https://app.asana.com/0/0/1206213106333866/f Tech Design URL: CC: **Description**: Add API to obtain reason why given feature is disabled - needed for sync dialogs. --- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- .../Mocks/MockPrivacyConfiguration.swift | 14 ++++++++++++++ LocalPackages/DataBrokerProtection/Package.swift | 2 +- .../Tests/DataBrokerProtectionTests/Mocks.swift | 8 ++++++++ LocalPackages/LoginItems/Package.swift | 2 +- LocalPackages/NetworkProtectionMac/Package.swift | 2 +- LocalPackages/PixelKit/Package.swift | 2 +- LocalPackages/Subscription/Package.swift | 2 +- LocalPackages/SwiftUIExtensions/Package.swift | 2 +- LocalPackages/SyncUI/Package.swift | 2 +- LocalPackages/SystemExtensionManager/Package.swift | 2 +- LocalPackages/XPCHelper/Package.swift | 2 +- 13 files changed, 34 insertions(+), 12 deletions(-) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index e6a9c9864a..c232561852 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -13066,7 +13066,7 @@ repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 100.0.3; + version = 101.0.0; }; }; AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 42bb2e232c..be2424dba3 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { - "revision" : "f2b6a76e4ed0ce3147cdf0cba94cf0d1b928d687", - "version" : "100.0.3" + "revision" : "71f65c35de0ae291a1b012ff17c91b9dcd6618fb", + "version" : "101.0.0" } }, { diff --git a/DuckDuckGo/ContentBlocker/Mocks/MockPrivacyConfiguration.swift b/DuckDuckGo/ContentBlocker/Mocks/MockPrivacyConfiguration.swift index f8dc30a6ae..1078823ed8 100644 --- a/DuckDuckGo/ContentBlocker/Mocks/MockPrivacyConfiguration.swift +++ b/DuckDuckGo/ContentBlocker/Mocks/MockPrivacyConfiguration.swift @@ -28,6 +28,13 @@ final class MockPrivacyConfiguration: PrivacyConfiguration { isSubfeatureKeyEnabled?(subfeature, versionProvider) ?? false } + func stateFor(_ subfeature: any PrivacySubfeature, versionProvider: AppVersionProvider, randomizer: (Range) -> Double) -> PrivacyConfigurationFeatureState { + if isSubfeatureKeyEnabled?(subfeature, versionProvider) == true { + return .enabled + } + return .disabled(.disabledInConfig) + } + var identifier: String = "MockPrivacyConfiguration" var userUnprotectedDomains: [String] = [] var tempUnprotectedDomains: [String] = [] @@ -41,6 +48,13 @@ final class MockPrivacyConfiguration: PrivacyConfiguration { func isEnabled(featureKey: PrivacyFeature, versionProvider: AppVersionProvider) -> Bool { isFeatureKeyEnabled?(featureKey, versionProvider) ?? true } + func stateFor(featureKey: PrivacyFeature, versionProvider: AppVersionProvider) -> PrivacyConfigurationFeatureState { + if isFeatureKeyEnabled?(featureKey, versionProvider) == true { + return .enabled + } + return .disabled(.disabledInConfig) + } + func isFeature(_ feature: PrivacyFeature, enabledForDomain: String?) -> Bool { true } func isProtected(domain: String?) -> Bool { true } func isUserUnprotected(domain: String?) -> Bool { false } diff --git a/LocalPackages/DataBrokerProtection/Package.swift b/LocalPackages/DataBrokerProtection/Package.swift index dc62b7fe77..009dc880e8 100644 --- a/LocalPackages/DataBrokerProtection/Package.swift +++ b/LocalPackages/DataBrokerProtection/Package.swift @@ -29,7 +29,7 @@ let package = Package( targets: ["DataBrokerProtection"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "100.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "101.0.0"), .package(path: "../PixelKit"), .package(path: "../SwiftUIExtensions"), .package(path: "../XPCHelper") diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift index b9699bd4e2..c414674201 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift @@ -89,10 +89,18 @@ final class PrivacyConfigurationMock: PrivacyConfiguration { false } + func stateFor(featureKey: BrowserServicesKit.PrivacyFeature, versionProvider: BrowserServicesKit.AppVersionProvider) -> BrowserServicesKit.PrivacyConfigurationFeatureState { + .disabled(.disabledInConfig) + } + func isSubfeatureEnabled(_ subfeature: any PrivacySubfeature, versionProvider: BrowserServicesKit.AppVersionProvider) -> Bool { false } + func stateFor(_ subfeature: any PrivacySubfeature, versionProvider: BrowserServicesKit.AppVersionProvider, randomizer: (Range) -> Double) -> BrowserServicesKit.PrivacyConfigurationFeatureState { + .disabled(.disabledInConfig) + } + func exceptionsList(forFeature featureKey: BrowserServicesKit.PrivacyFeature) -> [String] { [String]() } diff --git a/LocalPackages/LoginItems/Package.swift b/LocalPackages/LoginItems/Package.swift index 0534feddb2..ec28dc4085 100644 --- a/LocalPackages/LoginItems/Package.swift +++ b/LocalPackages/LoginItems/Package.swift @@ -13,7 +13,7 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "100.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "101.0.0"), ], targets: [ .target( diff --git a/LocalPackages/NetworkProtectionMac/Package.swift b/LocalPackages/NetworkProtectionMac/Package.swift index 4bb5f956e6..16d5877845 100644 --- a/LocalPackages/NetworkProtectionMac/Package.swift +++ b/LocalPackages/NetworkProtectionMac/Package.swift @@ -30,7 +30,7 @@ let package = Package( .library(name: "NetworkProtectionUI", targets: ["NetworkProtectionUI"]) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "100.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "101.0.0"), .package(path: "../XPCHelper"), .package(path: "../SwiftUIExtensions") ], diff --git a/LocalPackages/PixelKit/Package.swift b/LocalPackages/PixelKit/Package.swift index 49e4c51291..82f57cf3e4 100644 --- a/LocalPackages/PixelKit/Package.swift +++ b/LocalPackages/PixelKit/Package.swift @@ -20,7 +20,7 @@ let package = Package( ) ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "100.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "101.0.0"), ], targets: [ .target( diff --git a/LocalPackages/Subscription/Package.swift b/LocalPackages/Subscription/Package.swift index 7a8f30693b..4d87c5690d 100644 --- a/LocalPackages/Subscription/Package.swift +++ b/LocalPackages/Subscription/Package.swift @@ -12,7 +12,7 @@ let package = Package( targets: ["Subscription"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "100.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "101.0.0"), ], targets: [ .target( diff --git a/LocalPackages/SwiftUIExtensions/Package.swift b/LocalPackages/SwiftUIExtensions/Package.swift index c6ad0c761c..20666f5e42 100644 --- a/LocalPackages/SwiftUIExtensions/Package.swift +++ b/LocalPackages/SwiftUIExtensions/Package.swift @@ -13,7 +13,7 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "100.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "101.0.0"), ], targets: [ .target( diff --git a/LocalPackages/SyncUI/Package.swift b/LocalPackages/SyncUI/Package.swift index e259aac8fe..b86fef94d6 100644 --- a/LocalPackages/SyncUI/Package.swift +++ b/LocalPackages/SyncUI/Package.swift @@ -13,7 +13,7 @@ let package = Package( ], dependencies: [ .package(path: "../SwiftUIExtensions"), - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "100.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "101.0.0"), ], targets: [ .target( diff --git a/LocalPackages/SystemExtensionManager/Package.swift b/LocalPackages/SystemExtensionManager/Package.swift index b714d03314..b2fd514046 100644 --- a/LocalPackages/SystemExtensionManager/Package.swift +++ b/LocalPackages/SystemExtensionManager/Package.swift @@ -16,7 +16,7 @@ let package = Package( ), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "100.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "101.0.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. diff --git a/LocalPackages/XPCHelper/Package.swift b/LocalPackages/XPCHelper/Package.swift index c032f8e6a5..d2400584b6 100644 --- a/LocalPackages/XPCHelper/Package.swift +++ b/LocalPackages/XPCHelper/Package.swift @@ -30,7 +30,7 @@ let package = Package( .library(name: "XPCHelper", targets: ["XPCHelper"]), ], dependencies: [ - .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "100.0.3"), + .package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "101.0.0"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite.