From 9d83f0531c0228d8210a3ada3073d11eb37076db Mon Sep 17 00:00:00 2001 From: Defelo Date: Wed, 20 May 2026 16:13:33 +0200 Subject: [PATCH] feat: add cookie exception control to site identity popup Based on https://codeberg.org/librewolf/source/src/commit/9e8bf19710707440704242cf61aa6fb6da186210/patches/ui-patches/allow_cookies_for_site.patch --- browser/base/content/browser-siteIdentity.js | 32 +++++++++++++++++++ .../content/identityPanel.inc.xhtml | 5 +++ browser/locales/en-US/browser/browser.ftl | 1 + 3 files changed, 38 insertions(+) diff --git a/browser/base/content/browser-siteIdentity.js b/browser/base/content/browser-siteIdentity.js index 77b6c61b76fc1..58de5e31b7088 100644 --- a/browser/base/content/browser-siteIdentity.js +++ b/browser/base/content/browser-siteIdentity.js @@ -216,6 +216,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(); }, @@ -463,6 +466,33 @@ var gIdentityHandler = { event.stopPropagation(); }, + async refreshSiteData() { + document.getElementById("identity-popup-allow-sitedata-toggle").toggleAttribute( + "pressed", + Services.perms.testExactPermissionFromPrincipal( + gBrowser.contentPrincipal, + "cookie" + ) === Services.perms.ALLOW_ACTION + ); + }, + + async toggleSiteData() { + const pressed = document.getElementById("identity-popup-allow-sitedata-toggle").toggleAttribute( + "pressed" + ); + + if (pressed) { + Services.perms.addFromPrincipal( + gBrowser.contentPrincipal, + "cookie", + Services.perms.ALLOW_ACTION, + Services.perms.EXPIRE_NEVER + ); + } else { + Services.perms.removeFromPrincipal(gBrowser.contentPrincipal, "cookie"); + } + }, + /** * Handler for mouseclicks on the "More Information" button in the * "identity-popup" panel. @@ -1190,6 +1220,8 @@ var gIdentityHandler = { this._identityPopupContentOwner.textContent = owner; this._identityPopupContentSupp.textContent = supplemental; this._identityPopupContentVerif.textContent = verifier; + + this.refreshSiteData(); }, setURI(uri) { diff --git a/browser/components/controlcenter/content/identityPanel.inc.xhtml b/browser/components/controlcenter/content/identityPanel.inc.xhtml index 225340c698f77..f51c49ae7f7ed 100644 --- a/browser/components/controlcenter/content/identityPanel.inc.xhtml +++ b/browser/components/controlcenter/content/identityPanel.inc.xhtml @@ -98,6 +98,11 @@ + + + + diff --git a/browser/locales/en-US/browser/browser.ftl b/browser/locales/en-US/browser/browser.ftl index 17c4840157cd9..faed0aaa5d981 100644 --- a/browser/locales/en-US/browser/browser.ftl +++ b/browser/locales/en-US/browser/browser.ftl @@ -461,6 +461,7 @@ identity-permissions-storage-access-learn-more = Learn more identity-permissions-reload-hint = You may need to reload the page for changes to apply. identity-clear-site-data = .label = Clear cookies and site data… +identity-allow-site-data = Always store cookies/data for this site identity-connection-not-secure-security-view = You are not securely connected to this site. identity-connection-verified = You are securely connected to this site. identity-ev-owner-label = Certificate issued to: