From 25757cfdd7a09f37b0f86f50adf00e49322a1760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20J=C3=BCrgens?= Date: Thu, 28 Sep 2023 20:42:57 +0200 Subject: [PATCH] experimental identity pane --- assets/patches.txt | 1 + patches/ui-patches/identity-pane.patch | 345 +++++++++++++++++++++++++ 2 files changed, 346 insertions(+) create mode 100644 patches/ui-patches/identity-pane.patch diff --git a/assets/patches.txt b/assets/patches.txt index 1077388..28bd084 100644 --- a/assets/patches.txt +++ b/assets/patches.txt @@ -18,6 +18,7 @@ patches/sed-patches/stop-undesired-requests.patch patches/ui-patches/firefox-view.patch patches/ui-patches/handlers.patch patches/ui-patches/hide-default-browser.patch +patches/ui-patches/identity-pane.patch patches/ui-patches/lw-logo-devtools.patch patches/ui-patches/pref-naming.patch patches/ui-patches/privacy-preferences.patch diff --git a/patches/ui-patches/identity-pane.patch b/patches/ui-patches/identity-pane.patch new file mode 100644 index 0000000..0345a03 --- /dev/null +++ b/patches/ui-patches/identity-pane.patch @@ -0,0 +1,345 @@ +diff --git a/browser/base/content/browser-siteProtections.js b/browser/base/content/browser-siteProtections.js +--- a/browser/base/content/browser-siteProtections.js ++++ b/browser/base/content/browser-siteProtections.js +@@ -415,6 +415,10 @@ let TrackingProtection = + this.prefEmailTrackingProtectionEnabledInPrivateWindows, + this + ); ++ Services.prefs.addObserver( ++ "privacy.resistFingerprinting.exemptedDomains", ++ this ++ ); + } + + uninit() { +@@ -428,6 +432,10 @@ let TrackingProtection = + this.prefEmailTrackingProtectionEnabledInPrivateWindows, + this + ); ++ Services.prefs.removeObserver( ++ "privacy.resistFingerprinting.exemptedDomains", ++ this ++ ); + } + + observe() { +@@ -1402,6 +1396,19 @@ var gProtectionsHandler = { + "protections-popup-tp-switch" + )); + }, ++ get _protectionsPopupRFPSwitch() { ++ delete this._protectionsPopupRFPSwitch; ++ return (this._protectionsPopupRFPSwitch = document.getElementById( ++ "protections-popup-rfp-switch" ++ )); ++ }, ++ ++ get _protectionsPopupCookieSwitch() { ++ delete this._protectionsPopupCookieSwitch; ++ return (this._protectionsPopupCookieSwitch = document.getElementById( ++ "protections-popup-cookie-switch" ++ )); ++ }, + get _protectionsPopupBlockingHeader() { + delete this._protectionsPopupBlockingHeader; + return (this._protectionsPopupBlockingHeader = document.getElementById( +@@ -1774,6 +1781,11 @@ var gProtectionsHandler = { + if (event.target == this._protectionsPopup) { + window.removeEventListener("focus", this, true); + } ++ if (this._shouldReloadNextHide) { ++ this._shouldReloadNextHide = false; ++ BrowserReload(); ++ setTimeout(BrowserReload, 500); ++ } + }, + + onHeaderClicked(event) { +@@ -2094,6 +2106,23 @@ var gProtectionsHandler = { + tpSwitch.toggleAttribute("enabled", currentlyEnabled); + } + ++ this._protectionsPopupRFPSwitch.toggleAttribute( ++ "enabled", ++ !Services.prefs ++ .getStringPref("privacy.resistFingerprinting.exemptedDomains") ++ .split(",") ++ .map(x => x.trim()) ++ .includes(host) ++ ); ++ ++ this._protectionsPopupCookieSwitch.toggleAttribute( ++ "enabled", ++ !Services.perms.testPermissionFromPrincipal( ++ gBrowser.contentPrincipal, ++ "cookie" ++ ) == Services.perms.ALLOW_ACTION ++ ); ++ + this._notBlockingWhyLink.setAttribute( + "tooltip", + currentlyEnabled +@@ -2256,9 +2285,9 @@ var gProtectionsHandler = { + // Indicating that we need to show a toast after refreshing the page. + // And caching the current URI and window ID in order to only show the mini + // panel if it's still on the same page. +- this._showToastAfterRefresh = true; + this._previousURI = gBrowser.currentURI.spec; + this._previousOuterWindowID = gBrowser.selectedBrowser.outerWindowID; ++ this._shouldReloadNextHide = true; + + if (newExceptionState) { + this.disableForCurrentPage(false); +@@ -2268,22 +2297,52 @@ var gProtectionsHandler = { + this.recordClick("etp_toggle_on"); + } + +- // We need to flush the TP state change immediately without waiting the +- // 500ms delay if the Tab get switched out. +- let targetTab = gBrowser.selectedTab; +- let onTabSelectHandler; +- let tabSelectPromise = new Promise(resolve => { +- onTabSelectHandler = () => resolve(); +- gBrowser.tabContainer.addEventListener("TabSelect", onTabSelectHandler); +- }); +- let timeoutPromise = new Promise(resolve => setTimeout(resolve, 500)); ++ delete this._TPSwitchCommanding; ++ }, ++ ++ async onRFPSwitchCommand(event) { ++ const enabled = this._protectionsPopupRFPSwitch.toggleAttribute("enabled"); + +- await Promise.race([tabSelectPromise, timeoutPromise]); +- gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelectHandler); +- PanelMultiView.hidePopup(this._protectionsPopup); +- gBrowser.reloadTab(targetTab); ++ if (enabled) { ++ Services.prefs.setStringPref( ++ "privacy.resistFingerprinting.exemptedDomains", ++ Services.prefs ++ .getStringPref("privacy.resistFingerprinting.exemptedDomains") ++ .split(",") ++ .filter(x => x.trim() != gBrowser.currentURI.host) ++ .join(",") ++ ); ++ } else { ++ Services.prefs.setStringPref( ++ "privacy.resistFingerprinting.exemptedDomains", ++ Services.prefs.getStringPref( ++ "privacy.resistFingerprinting.exemptedDomains" ++ ) + ++ "," + ++ gBrowser.currentURI.host ++ ); ++ } + +- delete this._TPSwitchCommanding; ++ this._shouldReloadNextHide = true; ++ }, ++ ++ async onCookieSwitchCommand(event) { ++ const enabled = this._protectionsPopupCookieSwitch.toggleAttribute( ++ "enabled" ++ ); ++ ++ if (enabled) { ++ Services.perms.removeFromPrincipal(gBrowser.contentPrincipal, "cookie"); ++ } else { ++ Services.perms.addFromPrincipal( ++ gBrowser.contentPrincipal, ++ "cookie", ++ Services.perms.ALLOW_ACTION, ++ Services.perms.EXPIRE_NEVER ++ ); ++ } ++ ++ this._shouldReloadNextHide = true; + }, + + onCookieBannerToggleCommand() { +diff --git a/browser/components/controlcenter/content/protectionsPanel.inc.xhtml b/browser/components/controlcenter/content/protectionsPanel.inc.xhtml +--- a/browser/components/controlcenter/content/protectionsPanel.inc.xhtml ++++ b/browser/components/controlcenter/content/protectionsPanel.inc.xhtml +@@ -45,22 +45,45 @@ + + + +- +- +- ++ ++ + +- ++ + ++ class="protections-popup-switch" ++ enabled="false" ++ oncommand="gProtectionsHandler.onTPSwitchCommand();" /> + + +- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + +- +- ++ + + +- +- ++