summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Policy.js15
-rw-r--r--src/ui/popup.js2
-rw-r--r--src/ui/ui.js19
3 files changed, 27 insertions, 9 deletions
diff --git a/src/common/Policy.js b/src/common/Policy.js
index 4fbc4ec..c61596d 100644
--- a/src/common/Policy.js
+++ b/src/common/Policy.js
@@ -238,7 +238,20 @@ var {Permissions, Policy, Sites} = (() => {
}
return enabled;
}
-
+ sameAs(otherPerms) {
+ let otherCaps = new Set(otherPerms.capabilities);
+ let theseCaps = this.capabilities;
+ for (let c of theseCaps) {
+ if (!otherCaps.delete(c)) return false;
+ }
+ for (let c of otherCaps) {
+ if (!theseCaps.has(c)) return false;
+ }
+ return true;
+ }
+ clone() {
+ return new Permissions(this.capabilities, this.temp, this.context);
+ }
get tempTwin() {
return this._tempTwin || (this._tempTwin = new Permissions(this.capabilities, true, this.contextual));
}
diff --git a/src/ui/popup.js b/src/ui/popup.js
index 310ecac..c29b94d 100644
--- a/src/ui/popup.js
+++ b/src/ui/popup.js
@@ -164,7 +164,7 @@ addEventListener("unload", e => {
sitesUI = new UI.Sites(document.getElementById("sites"));
sitesUI.onChange = (row) => {
- pendingReload(!row.temp2perm);
+ pendingReload(sitesUI.anyPermissionsChanged());
if (optionsClosed) return;
browser.tabs.query({
url: browser.extension.getURL(
diff --git a/src/ui/ui.js b/src/ui/ui.js
index c2e12b0..a387d6e 100644
--- a/src/ui/ui.js
+++ b/src/ui/ui.js
@@ -346,6 +346,11 @@ var UI = (() => {
allSiteRows() {
return this.table.querySelectorAll("tr.site");
}
+
+ anyPermissionsChanged() {
+ return Array.from(this.allSiteRows()).some(row => row.permissionsChanged);
+ }
+
clear() {
debug("Clearing list", this.table);
@@ -399,17 +404,16 @@ var UI = (() => {
let tempToggle = preset.parentNode.querySelector("input.temp");
if (ev.type === "change") {
- row.temp2perm = false;
+ row.permissionsChanged = false;
+ if (!row._originalPerms) {
+ row._originalPerms = row.perms.clone();
+ }
let policy = UI.policy;
let presetValue = preset.value;
let policyPreset = presetValue.startsWith("T_") ? policy[presetValue.substring(2)].tempTwin : policy[presetValue];
- if (policyPreset) {
- if (row.perms !== policyPreset) {
- row.temp2perm = row.perms &&
- (policyPreset.tempTwin === row.perms || policyPreset === row.perms._tempTwin);
- row.perms = policyPreset;
- }
+ if (policyPreset && row.perms !== policyPreset) {
+ row.perms = policyPreset;
}
if (preset.checked) {
row.dataset.preset = preset.value;
@@ -443,6 +447,7 @@ var UI = (() => {
this.customize(perms, preset, row);
}
}
+ row.permissionsChanged = !row.perms.sameAs(row._originalPerms);
fireOnChange(this, row);
} else if (!(isCap || isTemp) && ev.type === "click") {
this.customize(row.perms, preset, row);