diff --git a/BrowserKit/Sources/WebEngine/EngineSession.swift b/BrowserKit/Sources/WebEngine/EngineSession.swift index 500ceed6620b..3e711d847d6a 100644 --- a/BrowserKit/Sources/WebEngine/EngineSession.swift +++ b/BrowserKit/Sources/WebEngine/EngineSession.swift @@ -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() diff --git a/BrowserKit/Sources/WebEngine/WKWebview/WKEngineSession.swift b/BrowserKit/Sources/WebEngine/WKWebview/WKEngineSession.swift index d7efbbb50303..d6fd7c7f9eca 100644 --- a/BrowserKit/Sources/WebEngine/WKWebview/WKEngineSession.swift +++ b/BrowserKit/Sources/WebEngine/WKWebview/WKEngineSession.swift @@ -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) diff --git a/SampleBrowser/SampleBrowser/UI/Browser/BrowserViewController.swift b/SampleBrowser/SampleBrowser/UI/Browser/BrowserViewController.swift index 655c9ecac3a6..53c61b0f272b 100644 --- a/SampleBrowser/SampleBrowser/UI/Browser/BrowserViewController.swift +++ b/SampleBrowser/SampleBrowser/UI/Browser/BrowserViewController.swift @@ -122,6 +122,10 @@ class BrowserViewController: UIViewController, engineSession.switchToStrictTrackingProtection() } + func disableTrackingProtection() { + engineSession.disableTrackingProtection() + } + func toggleNoImageMode() { engineSession.toggleNoImageMode() } diff --git a/SampleBrowser/SampleBrowser/UI/RootViewController.swift b/SampleBrowser/SampleBrowser/UI/RootViewController.swift index 2033de8c4fbf..fd8a839e01d9 100644 --- a/SampleBrowser/SampleBrowser/UI/RootViewController.swift +++ b/SampleBrowser/SampleBrowser/UI/RootViewController.swift @@ -211,6 +211,10 @@ class RootViewController: UIViewController, browserVC.switchToStandardTrackingProtection() } + func disableTrackingProtection() { + browserVC.disableTrackingProtection() + } + func toggleNoImageMode() { browserVC.toggleNoImageMode() } diff --git a/SampleBrowser/SampleBrowser/UI/Settings/SettingsDataSource.swift b/SampleBrowser/SampleBrowser/UI/Settings/SettingsDataSource.swift index 2facd515d669..b3a49beca4f9 100644 --- a/SampleBrowser/SampleBrowser/UI/Settings/SettingsDataSource.swift +++ b/SampleBrowser/SampleBrowser/UI/Settings/SettingsDataSource.swift @@ -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, diff --git a/SampleBrowser/SampleBrowser/UI/Settings/SettingsDelegate.swift b/SampleBrowser/SampleBrowser/UI/Settings/SettingsDelegate.swift index f847b4404a05..c1713b701251 100644 --- a/SampleBrowser/SampleBrowser/UI/Settings/SettingsDelegate.swift +++ b/SampleBrowser/SampleBrowser/UI/Settings/SettingsDelegate.swift @@ -9,6 +9,7 @@ protocol SettingsDelegate: AnyObject { func showFindInPage() func switchToStrictTrackingProtection() func switchToStandardTrackingProtection() + func disableTrackingProtection() func toggleNoImageMode() func increaseZoom() func decreaseZoom() diff --git a/SampleBrowser/SampleBrowser/UI/Settings/SettingsType.swift b/SampleBrowser/SampleBrowser/UI/Settings/SettingsType.swift index 3791682bf863..8f042e949cb9 100644 --- a/SampleBrowser/SampleBrowser/UI/Settings/SettingsType.swift +++ b/SampleBrowser/SampleBrowser/UI/Settings/SettingsType.swift @@ -8,6 +8,7 @@ import Foundation public enum SettingsType: String { case standardContentBlocking case strictContentBlocking + case disableContentBlocking case noImageMode case findInPage case scrollingToTop diff --git a/SampleBrowser/SampleBrowser/UI/Settings/SettingsViewController.swift b/SampleBrowser/SampleBrowser/UI/Settings/SettingsViewController.swift index fcc53520092e..2e76772292a5 100644 --- a/SampleBrowser/SampleBrowser/UI/Settings/SettingsViewController.swift +++ b/SampleBrowser/SampleBrowser/UI/Settings/SettingsViewController.swift @@ -85,6 +85,8 @@ class SettingsViewController: UIViewController, UITableViewDelegate { delegate?.switchToStandardTrackingProtection() case .strictContentBlocking: delegate?.switchToStrictTrackingProtection() + case .disableContentBlocking: + delegate?.disableTrackingProtection() case .noImageMode: delegate?.toggleNoImageMode() case .findInPage: