Skip to content

Commit

Permalink
Add API to obtain reason why given feature is disabled (#2030)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bwaresiak authored Jan 9, 2024
1 parent c23d403 commit 8329e75
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13066,7 +13066,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 100.0.3;
version = 101.0.0;
};
};
AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
14 changes: 14 additions & 0 deletions DuckDuckGo/ContentBlocker/Mocks/MockPrivacyConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ final class MockPrivacyConfiguration: PrivacyConfiguration {
isSubfeatureKeyEnabled?(subfeature, versionProvider) ?? false
}

func stateFor(_ subfeature: any PrivacySubfeature, versionProvider: AppVersionProvider, randomizer: (Range<Double>) -> Double) -> PrivacyConfigurationFeatureState {
if isSubfeatureKeyEnabled?(subfeature, versionProvider) == true {
return .enabled
}
return .disabled(.disabledInConfig)
}

var identifier: String = "MockPrivacyConfiguration"
var userUnprotectedDomains: [String] = []
var tempUnprotectedDomains: [String] = []
Expand All @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>) -> Double) -> BrowserServicesKit.PrivacyConfigurationFeatureState {
.disabled(.disabledInConfig)
}

func exceptionsList(forFeature featureKey: BrowserServicesKit.PrivacyFeature) -> [String] {
[String]()
}
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/LoginItems/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
],
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/PixelKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/Subscription/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SwiftUIExtensions/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SyncUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SystemExtensionManager/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/XPCHelper/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8329e75

Please sign in to comment.