Skip to content

Commit

Permalink
Support new privacy dashboard source (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaceklyp committed May 14, 2024
1 parent 72be4e7 commit c1ce2cb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/privacy-dashboard",
"state" : {
"revision" : "14b13d0c3db38f471ce4ba1ecb502ee1986c84d7",
"version" : "3.5.0"
"revision" : "25b8903191a40b21b09525085fe325ae3386092e",
"version" : "3.6.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let package = Package(
.package(url: "https://github.com/duckduckgo/TrackerRadarKit", exact: "2.0.0"),
.package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.2.0"),
.package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "2.1.0"),
.package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "3.5.0"),
.package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "3.6.0"),
.package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "5.12.0"),
.package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"),
.package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,28 @@ public struct BrokenSiteReport {

}

public enum Source: String {
public enum Source {

/// From the app menu's "Report Broken Site"
case appMenu = "menu"
case appMenu
/// From the privacy dashboard's "Website not working?"
case dashboard
/// From the app menu's "Disable Privacy Protection"
case onProtectionsOffMenu = "on_protections_off_menu"
case onProtectionsOffMenu
/// From the privacy dashboard's on protections toggle off
case onProtectionsOffDashboard = "on_protections_off_dashboard_main"
case onProtectionsOffDashboard
/// From the 'Site Not Working?' prompt that appears on various events
case prompt(String)

public var rawValue: String {
switch self {
case .appMenu: return "menu"
case .dashboard: return "dashboard"
case .onProtectionsOffMenu: return "on_protections_off_menu"
case .onProtectionsOffDashboard: return "on_protections_off_dashboard_main"
case .prompt(let event): return event
}
}

}

Expand Down
5 changes: 3 additions & 2 deletions Sources/PrivacyDashboard/PrivacyDashboardController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate {
privacyDashboardDelegate?.privacyDashboardController(self, didChangeProtectionSwitch: protectionState, didSendReport: didSendReport)
case .breakageForm:
privacyDashboardReportBrokenSiteDelegate?.privacyDashboardController(self, reportBrokenSiteDidChangeProtectionSwitch: protectionState)
case .toggleReport:
assertionFailure("Simple Breakage report screen doesn't have toggling capability")
case .toggleReport, .promptBreakageForm:
assertionFailure("These screen don't have toggling capability")
}
}

Expand Down Expand Up @@ -485,6 +485,7 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate {
case .report: source = .appMenu
case .dashboard: source = .dashboard
case .toggleReport: source = .onProtectionsOffMenu
case .prompt(let event): source = .prompt(event)
}
if protectionStateToSubmitOnToggleReportDismiss != nil {
source = .onProtectionsOffDashboard
Expand Down
4 changes: 3 additions & 1 deletion Sources/PrivacyDashboard/PrivacyDashboardMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ public enum PrivacyDashboardMode: Equatable {

case dashboard
case report
case prompt(String)
case toggleReport(completionHandler: (Bool) -> Void)

var screen: PrivacyDashboard.Screen {
switch self {
case .dashboard: return .primaryScreen
case .report: return .breakageForm
case .prompt: return .promptBreakageForm
case .toggleReport: return .toggleReport
}
}

public static func == (lhs: PrivacyDashboardMode, rhs: PrivacyDashboardMode) -> Bool {
switch (lhs, rhs) {
case (.dashboard, .dashboard), (.report, .report), (.toggleReport, .toggleReport):
case (.dashboard, .dashboard), (.report, .report), (.toggleReport, .toggleReport), (.prompt, .prompt):
return true
default:
return false
Expand Down
1 change: 1 addition & 0 deletions Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public enum Screen: String, Decodable {
case primaryScreen
case breakageForm
case toggleReport
case promptBreakageForm

}

Expand Down

0 comments on commit c1ce2cb

Please sign in to comment.