Files
lbmk/config/firefox/default/patches/0037-ui-patches-allow_cookies_for_site.patch.patch
T
Leah Rowe 2b34aeea5d WIP: convert to lwmk
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-08 06:44:40 +01:00

174 lines
6.6 KiB
Diff

From 0eaea882ee730683f16d3e9bde8cc52a4ce8f4cc Mon Sep 17 00:00:00 2001
From: LibreWolf Developers <noreply@librewolf.net>
Date: Sun, 6 Sep 2026 10:11:42 +0100
Subject: [PATCH 37/52] ui-patches/allow_cookies_for_site.patch
---
browser/base/content/browser-siteIdentity.js | 32 +++++++++++++++++
browser/base/content/browser-trustPanel.js | 35 +++++++++++++++++++
.../content/identityPanel.inc.xhtml | 5 +++
.../content/trustPanel.inc.xhtml | 7 ++++
4 files changed, 79 insertions(+)
diff --git a/browser/base/content/browser-siteIdentity.js b/browser/base/content/browser-siteIdentity.js
index 16b222280f85..2d0ba31d5ff8 100644
--- a/browser/base/content/browser-siteIdentity.js
+++ b/browser/base/content/browser-siteIdentity.js
@@ -231,6 +231,9 @@ var gIdentityHandler = {
"identity-popup-clear-sitedata-button": event => {
this.clearSiteData(event);
},
+ "identity-popup-allow-sitedata-button": () => {
+ this.toggleSiteData();
+ },
"identity-popup-remove-cert-exception": () => {
this.removeCertException();
},
@@ -483,6 +486,33 @@ var gIdentityHandler = {
event.stopPropagation();
},
+ async refreshSiteData() {
+ document.getElementById("identity-popup-allow-sitedata-toggle").toggleAttribute(
+ "pressed",
+ Services.perms.testExactPermissionFromPrincipal(
+ gBrowser.contentPrincipal,
+ "persist-data-on-shutdown"
+ ) === Services.perms.ALLOW_ACTION
+ );
+ },
+
+ async toggleSiteData() {
+ const pressed = document.getElementById("identity-popup-allow-sitedata-toggle").toggleAttribute(
+ "pressed"
+ );
+
+ if (pressed) {
+ Services.perms.addFromPrincipal(
+ gBrowser.contentPrincipal,
+ "persist-data-on-shutdown",
+ Services.perms.ALLOW_ACTION,
+ Services.perms.EXPIRE_NEVER
+ );
+ } else {
+ Services.perms.removeFromPrincipal(gBrowser.contentPrincipal, "persist-data-on-shutdown");
+ }
+ },
+
/**
* Handler for mouseclicks on the "More Information" button in the
* "identity-popup" panel.
@@ -1234,6 +1264,8 @@ var gIdentityHandler = {
this._identityPopupContentOwner.textContent = owner;
this._identityPopupContentSupp.textContent = supplemental;
this._identityPopupContentVerif.textContent = verifier;
+
+ this.refreshSiteData();
},
setURI(uri) {
diff --git a/browser/base/content/browser-trustPanel.js b/browser/base/content/browser-trustPanel.js
index a749cead9842..f607b960c9e5 100644
--- a/browser/base/content/browser-trustPanel.js
+++ b/browser/base/content/browser-trustPanel.js
@@ -341,6 +341,9 @@ class TrustPanel {
document
.getElementById("trustpanel-toggle")
.addEventListener("click", () => this.#toggleTrackingProtection());
+ document
+ .getElementById("identity-popup-allow-sitedata-button")
+ .addEventListener("click", () => this.#toggleCookiesAllowed());
document
.getElementById("identity-popup-remove-cert-exception")
.addEventListener("click", () => this.#removeCertException());
@@ -353,6 +356,30 @@ class TrustPanel {
}
}
+ #toggleCookiesAllowed() {
+ const pressed = document.getElementById("identity-popup-allow-sitedata-toggle").toggleAttribute(
+ "pressed"
+ );
+
+ if (pressed) {
+ Services.perms.addFromPrincipal(
+ gBrowser.contentPrincipal,
+ "persist-data-on-shutdown",
+ Services.perms.ALLOW_ACTION,
+ Services.perms.EXPIRE_NEVER
+ );
+ } else {
+ Services.perms.removeFromPrincipal(gBrowser.contentPrincipal, "persist-data-on-shutdown");
+ }
+ }
+
+ #areCookiesAllowed() {
+ return Services.perms.testExactPermissionFromPrincipal(
+ gBrowser.contentPrincipal,
+ "persist-data-on-shutdown"
+ ) === Services.perms.ALLOW_ACTION;
+ }
+
async showPopup(opts = {}) {
this.#initializePopup();
@@ -742,6 +769,9 @@ class TrustPanel {
{ host: this.#displayHost }
);
+ let toggleCookies = document.getElementById("identity-popup-allow-sitedata-toggle");
+ toggleCookies.toggleAttribute("pressed", this.#areCookiesAllowed());
+
let hostElement = document.getElementById("trustpanel-popup-host");
hostElement.setAttribute("value", this.#displayHost);
hostElement.setAttribute("tooltiptext", this.#displayHost);
@@ -781,6 +811,11 @@ class TrustPanel {
"hidden",
isPrivate
);
+ this.#updateAttribute(
+ document.getElementById("trustpanel-allow-cookies-footer"),
+ "hidden",
+ isPrivate
+ );
if (!isPrivate) {
try {
let baseDomain = SiteDataManager.getBaseDomainFromHost(this.#uri.host);
diff --git a/browser/components/controlcenter/content/identityPanel.inc.xhtml b/browser/components/controlcenter/content/identityPanel.inc.xhtml
index d7f214f471f7..088662a045a3 100644
--- a/browser/components/controlcenter/content/identityPanel.inc.xhtml
+++ b/browser/components/controlcenter/content/identityPanel.inc.xhtml
@@ -98,6 +98,11 @@
<toolbarbutton id="identity-popup-clear-sitedata-button"
data-l10n-id="identity-clear-site-data"
class="subviewbutton"/>
+ <toolbarbutton id="identity-popup-allow-sitedata-button"
+ class="subviewbutton">
+ <label data-l10n-id="identity-allow-site-data" flex="1"></label>
+ <html:moz-toggle id="identity-popup-allow-sitedata-toggle" style="pointer-events: none;"></html:moz-toggle>
+ </toolbarbutton>
</vbox>
</panelview>
diff --git a/browser/components/controlcenter/content/trustPanel.inc.xhtml b/browser/components/controlcenter/content/trustPanel.inc.xhtml
index 65f8089b0a5f..51794158610c 100644
--- a/browser/components/controlcenter/content/trustPanel.inc.xhtml
+++ b/browser/components/controlcenter/content/trustPanel.inc.xhtml
@@ -75,6 +75,13 @@
<toolbarbutton data-l10n-id="trustpanel-clear-cookies-button" id="trustpanel-clear-cookies-button" class="subviewbutton subviewbutton-nav"></toolbarbutton>
</vbox>
+ <vbox id="trustpanel-allow-cookies-footer">
+ <toolbarbutton id="identity-popup-allow-sitedata-button" class="subviewbutton">
+ <label data-l10n-id="identity-allow-site-data" flex="1"></label>
+ <html:moz-toggle id="identity-popup-allow-sitedata-toggle" style="pointer-events: none;"></html:moz-toggle>
+ </toolbarbutton>
+ </vbox>
+
<toolbarseparator></toolbarseparator>
<toolbarbutton id="trustpanel-privacy-link" data-l10n-id="trustpanel-privacy-link" class="subviewbutton"></toolbarbutton>
</vbox>
--
2.47.3