Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malicious Site Protection - Pixels #3779

Open
wants to merge 1 commit into
base: alessandro/malicious-site-protection-settings
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Foundation
import Combine
import Core
import SwiftUI
import PixelKit
import MaliciousSiteProtection

final class MaliciousSiteProtectionSettingsViewModel: ObservableObject {
Expand Down Expand Up @@ -51,4 +52,8 @@ final class MaliciousSiteProtectionSettingsViewModel: ObservableObject {
urlOpener.open(URL.maliciousSiteProtectionLearnMore)
}

private func updateMaliciousSiteProtection(enabled isEnabled: Bool) {
isMaliciousSiteProtectionOn = isEnabled
PixelKit.fire(MaliciousSiteProtection.Event.settingToggled(to: isEnabled))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Core
import SpecialErrorPages
import WebKit
import MaliciousSiteProtection
import PixelKit

enum MaliciousSiteProtectionNavigationResult: Equatable {
case navigationHandled(NavigationType)
Expand Down Expand Up @@ -109,6 +110,7 @@ extension MaliciousSiteProtectionNavigationHandler: MaliciousSiteProtectionNavig
let response = MaliciousSiteDetectionNavigationResponse(navigationAction: navigationAction, errorData: errorData)
return .navigationHandled(.mainFrame(response))
} else {
PixelKit.fire(MaliciousSiteProtection.Event.iframeLoaded(category: threatKind))
// Extract the URL of the source frame (the iframe) that initiated the navigation action
let iFrameTopURL = navigationAction.sourceFrame.safeRequest?.url ?? url
let errorData = SpecialErrorData.maliciousSite(kind: threatKind, url: iFrameTopURL)
Expand Down Expand Up @@ -137,19 +139,19 @@ extension MaliciousSiteProtectionNavigationHandler: MaliciousSiteProtectionNavig
extension MaliciousSiteProtectionNavigationHandler: SpecialErrorPageActionHandler {

func visitSite(url: URL, errorData: SpecialErrorData) {
maliciousURLExemptions[url] = errorData.threatKind
bypassedMaliciousSiteThreatKind = errorData.threatKind
guard let threatKind = errorData.threatKind else {
assertionFailure("Error Data should have a threat kind")
return
}
maliciousURLExemptions[url] = threatKind
bypassedMaliciousSiteThreatKind = threatKind

// Fire Pixel
PixelKit.fire(MaliciousSiteProtection.Event.visitSite(category: threatKind))
}

func leaveSite() {
// Fire Pixel
}
func leaveSite() { }
Copy link
Contributor

Choose a reason for hiding this comment

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

Double checking: No pixel and not implemented yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don’t fire any pixels when the user taps “Leave site” button. Implementation is in its parent which is generic special error handler. It calls leaveSite on its children in case we need to do custom actions. But it’s not the case as we’re not sending pixels.


func advancedInfoPresented() {
// Fire Pixel
}
func advancedInfoPresented() { }
Copy link
Contributor

Choose a reason for hiding this comment

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

Just double checking: No pixel to send?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As Above


}

Expand Down
Loading