Skip to content

Commit

Permalink
Add FXIOS-8088 [v125] WebEngine API: disable tracking protection
Browse files Browse the repository at this point in the history
  • Loading branch information
mattreaganmozilla authored Mar 5, 2024
1 parent 8acdc03 commit 76d8d26
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions BrowserKit/Sources/WebEngine/EngineSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public protocol EngineSession {
/// Switch to strict tracking protection mode.
func switchToStrictTrackingProtection()

/// Disable all tracking protection.
func disableTrackingProtection()

/// Toggle image blocking mode.
func toggleNoImageMode()

Expand Down
7 changes: 7 additions & 0 deletions BrowserKit/Sources/WebEngine/WKWebview/WKEngineSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ class WKEngineSession: NSObject,
metadataFetcher.delegate = nil
}

func disableTrackingProtection() {
var settings = contentBlockingSettings
settings.remove(.strict)
settings.remove(.standard)
contentBlockingSettings = settings
}

func switchToStandardTrackingProtection() {
var settings = contentBlockingSettings
settings.remove(.strict)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ class BrowserViewController: UIViewController,
engineSession.switchToStrictTrackingProtection()
}

func disableTrackingProtection() {
engineSession.disableTrackingProtection()
}

func toggleNoImageMode() {
engineSession.toggleNoImageMode()
}
Expand Down
4 changes: 4 additions & 0 deletions SampleBrowser/SampleBrowser/UI/RootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ class RootViewController: UIViewController,
browserVC.switchToStandardTrackingProtection()
}

func disableTrackingProtection() {
browserVC.disableTrackingProtection()
}

func toggleNoImageMode() {
browserVC.toggleNoImageMode()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class SettingsDataSource: NSObject, UITableViewDataSource {
title: "Trigger standard content blocking"),
SettingsCellViewModel(settingType: .strictContentBlocking,
title: "Trigger strict content blocking"),
SettingsCellViewModel(settingType: .disableContentBlocking,
title: "Disable content blocking"),
SettingsCellViewModel(settingType: .noImageMode,
title: "Trigger No Images"),
SettingsCellViewModel(settingType: .zoomIncrease,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ protocol SettingsDelegate: AnyObject {
func showFindInPage()
func switchToStrictTrackingProtection()
func switchToStandardTrackingProtection()
func disableTrackingProtection()
func toggleNoImageMode()
func increaseZoom()
func decreaseZoom()
Expand Down
1 change: 1 addition & 0 deletions SampleBrowser/SampleBrowser/UI/Settings/SettingsType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Foundation
public enum SettingsType: String {
case standardContentBlocking
case strictContentBlocking
case disableContentBlocking
case noImageMode
case findInPage
case scrollingToTop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class SettingsViewController: UIViewController, UITableViewDelegate {
delegate?.switchToStandardTrackingProtection()
case .strictContentBlocking:
delegate?.switchToStrictTrackingProtection()
case .disableContentBlocking:
delegate?.disableTrackingProtection()
case .noImageMode:
delegate?.toggleNoImageMode()
case .findInPage:
Expand Down

0 comments on commit 76d8d26

Please sign in to comment.