Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Handling ReportBrokenSiteShown message #1167

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" : "3f58e008d4e9d1b56ab12dbb95bd891045cf2758",
"version" : "8.0.0"
"branch" : "pr-releases/pr-302",
"revision" : "05d04de7505117b32949b2007e5a56ba2d39469b"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ let package = Package(
.package(url: "https://github.com/duckduckgo/sync_crypto", exact: "0.4.0"),
.package(url: "https://github.com/gumob/PunycodeSwift.git", exact: "3.0.0"),
.package(url: "https://github.com/duckduckgo/content-scope-scripts", exact: "7.5.0"),
.package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "8.0.0"),
.package(url: "https://github.com/duckduckgo/privacy-dashboard", branch: "pr-releases/pr-302"),
.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"),
.package(url: "https://github.com/1024jp/GzipSwift.git", exact: "6.0.1"),
Expand Down
9 changes: 7 additions & 2 deletions Sources/PrivacyDashboard/PrivacyDashboardController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -368,18 +368,23 @@ extension PrivacyDashboardController: PrivacyDashboardUserScriptDelegate {
}

func userScriptDidRequestShowReportBrokenSite(_ userScript: PrivacyDashboardUserScript) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a legacy message that will isn’t currently being fired and is likely to be removed in the future.

eventMapping.fire(.showReportBrokenSite)
}

func userScriptDidRequestReportBrokenSiteShown(_ userScript: PrivacyDashboardUserScript) {
eventMapping.fire(.reportBrokenSiteShown, parameters: [
PrivacyDashboardEvents.Parameters.source: source.rawValue
])
eventMapping.fire(.showReportBrokenSite)
}

func userScript(_ userScript: PrivacyDashboardUserScript, setHeight height: Int) {
delegate?.privacyDashboardController(self, didSetHeight: height)
}

func userScript(_ userScript: PrivacyDashboardUserScript, didRequestSubmitBrokenSiteReportWithCategory category: String, description: String) {
eventMapping.fire(.reportBrokenSiteSent)
eventMapping.fire(.reportBrokenSiteSent, parameters: [
PrivacyDashboardEvents.Parameters.source: source.rawValue
])
delegate?.privacyDashboardController(self, didRequestSubmitBrokenSiteReportWithCategory: category, description: description)
}

Expand Down
8 changes: 8 additions & 0 deletions Sources/PrivacyDashboard/PrivacyDashboardUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ protocol PrivacyDashboardUserScriptDelegate: AnyObject {
func userScript(_ userScript: PrivacyDashboardUserScript, setHeight height: Int)
func userScriptDidRequestClose(_ userScript: PrivacyDashboardUserScript)
func userScriptDidRequestShowReportBrokenSite(_ userScript: PrivacyDashboardUserScript)
func userScriptDidRequestReportBrokenSiteShown(_ userScript: PrivacyDashboardUserScript)
func userScript(_ userScript: PrivacyDashboardUserScript, didRequestSubmitBrokenSiteReportWithCategory category: String, description: String)
func userScript(_ userScript: PrivacyDashboardUserScript, didRequestOpenUrlInNewTab: URL)
func userScript(_ userScript: PrivacyDashboardUserScript, didRequestOpenSettings: String)
Expand Down Expand Up @@ -107,6 +108,7 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript {
case privacyDashboardSetSize
case privacyDashboardClose
case privacyDashboardShowReportBrokenSite
case privacyDashboardReportBrokenSiteShown
case privacyDashboardSubmitBrokenSiteReport
case privacyDashboardOpenUrlInNewTab
case privacyDashboardOpenSettings
Expand Down Expand Up @@ -143,6 +145,8 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript {
handleClose()
case .privacyDashboardShowReportBrokenSite:
handleShowReportBrokenSite()
case .privacyDashboardReportBrokenSiteShown:
handleReportBrokenSiteShown()
case .privacyDashboardSubmitBrokenSiteReport:
handleSubmitBrokenSiteReport(message: message)
case .privacyDashboardOpenUrlInNewTab:
Expand Down Expand Up @@ -196,6 +200,10 @@ final class PrivacyDashboardUserScript: NSObject, StaticUserScript {
delegate?.userScriptDidRequestShowReportBrokenSite(self)
}

private func handleReportBrokenSiteShown() {
delegate?.userScriptDidRequestReportBrokenSiteShown(self)
}

private func handleSubmitBrokenSiteReport(message: WKScriptMessage) {
guard let dict = message.body as? [String: Any],
let category = dict["category"] as? String,
Expand Down
Loading