0
Fork 0
mirror of https://codeberg.org/librewolf/source.git synced 2024-12-22 05:33:03 -05:00

Add toggle to allow_cookies_for_site.patch

This commit is contained in:
Malte Jürgens 2023-12-05 23:22:30 +01:00
parent feb2835b3f
commit 1c8a036435
No known key found for this signature in database
GPG key ID: D29FBD5F93C0CFC3
2 changed files with 44 additions and 36 deletions

View file

@ -1,68 +1,76 @@
diff --git a/browser/base/content/browser-siteIdentity.js b/browser/base/content/browser-siteIdentity.js
index 4efbba2324..a35021b0c6 100644
index 4efbba2..1bc6b5b 100644
--- a/browser/base/content/browser-siteIdentity.js
+++ b/browser/base/content/browser-siteIdentity.js
@@ -414,6 +414,35 @@ var gIdentityHandler = {
@@ -414,6 +414,33 @@ var gIdentityHandler = {
event.stopPropagation();
},
+ /**
+ * Handles clicks on the "ALLOW Cookies and Site Data" button.
+ */
+ async allowSiteData(event) {
+ // Hide the popup before showing the removal prompt, to
+ // avoid a pretty ugly transition. Also hide it even
+ // if the update resulted in no site data, to keep the
+ // illusion that clicking the button had an effect.
+ let hidden = new Promise(c => {
+ this._identityPopup.addEventListener("popuphidden", c, { once: true });
+ });
+ PanelMultiView.hidePopup(this._identityPopup);
+ await hidden;
+ async refreshSiteData() {
+ document.getElementById("identity-popup-allow-sitedata-toggle").setAttribute(
+ "pressed",
+ Services.perms.testExactPermissionFromPrincipal(
+ gBrowser.contentPrincipal,
+ "cookie"
+ ) === Services.perms.ALLOW_ACTION
+ );
+ },
+
+ // Get base domain
+ if (!this._uriHasHost) { return }
+ let baseDomain = SiteDataManager.getBaseDomainFromHost(this._uri.host);
+ async toggleSiteData() {
+ const pressed = document.getElementById("identity-popup-allow-sitedata-toggle").toggleAttribute(
+ "pressed"
+ );
+
+ // Set variables and call addFromPrincipal()
+ const type = 'cookie';
+ const capability = Ci.nsIPermissionManager.ALLOW_ACTION;
+ let uri = Services.io.newURI('https://' + baseDomain);
+ let principal = Services.scriptSecurityManager.createContentPrincipal(uri,{});
+ Services.perms.addFromPrincipal(principal, type, capability);
+
+ // Stop propagating the event and exit.
+ event.stopPropagation();
+ 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.
@@ -1151,6 +1178,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 8bc64faa1e..0768ff1520 100644
index 8bc64fa..4a4a1af 100644
--- a/browser/components/controlcenter/content/identityPanel.inc.xhtml
+++ b/browser/components/controlcenter/content/identityPanel.inc.xhtml
@@ -96,6 +96,10 @@
@@ -96,6 +96,12 @@
data-l10n-id="identity-clear-site-data"
class="subviewbutton"
oncommand="gIdentityHandler.clearSiteData(event);"/>
+ <toolbarbutton id="identity-popup-allow-sitedata-button"
+ data-l10n-id="identity-allow-site-data"
+ class="subviewbutton"
+ oncommand="gIdentityHandler.allowSiteData(event);"/>
+ oncommand="gIdentityHandler.toggleSiteData();">
+ <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/locales/en-US/browser/browser.ftl b/browser/locales/en-US/browser/browser.ftl
index 0dbdc78eda..3ced42d39f 100644
index 0dbdc78..e183f1a 100644
--- a/browser/locales/en-US/browser/browser.ftl
+++ b/browser/locales/en-US/browser/browser.ftl
@@ -402,6 +402,8 @@ identity-permissions-storage-access-learn-more = Learn more
@@ -402,6 +402,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 =
+ .label = LibreWolf: Always store cookies/data for this site
+identity-allow-site-data = LibreWolf: 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:

@ -1 +1 @@
Subproject commit 9dac02778ebed3e2614da52c36b7cede45f4f602
Subproject commit b587388bdbe63511c478cb8b5f82c2e80040414c