[Pkg-mozext-commits] [requestpolicy] 22/100: automatically repopulate table in "Your Policy"
David Prévot
taffit at moszumanska.debian.org
Fri Dec 12 22:56:49 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit cdf571352f2e1c112d93b9eef9e38fb67a4b487d
Author: myrdd <myrdd at users.noreply.github.com>
Date: Sat Sep 13 22:28:41 2014 +0200
automatically repopulate table in "Your Policy"
resolves #471
---
src/content/settings/yourpolicy.js | 29 ++++++++++++++++++++++++++++-
src/modules/PolicyManager.jsm | 23 +++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/src/content/settings/yourpolicy.js b/src/content/settings/yourpolicy.js
index 580eb6e..ad0f48d 100644
--- a/src/content/settings/yourpolicy.js
+++ b/src/content/settings/yourpolicy.js
@@ -32,6 +32,8 @@ const SEARCH_DELAY = 100;
var searchTimeoutId = null;
+var rulesChangedObserver = null;
+
function populateRuleTable(filter) {
searchTimeoutId = null;
@@ -147,7 +149,8 @@ function addRule() {
return;
}
var search = document.getElementById('rulesearch');
- populateRuleTable(search.value);
+
+ // the table is repopulated through the RulesChangedObserver
}
function addRuleHelper() {
@@ -206,6 +209,25 @@ function addRuleHelper() {
}
}
+function RulesChangedObserver()
+{
+ this.register();
+}
+RulesChangedObserver.prototype.observe = function(subject, topic, data) {
+ var search = document.getElementById('rulesearch');
+ populateRuleTable(search.value);
+};
+RulesChangedObserver.prototype.register = function() {
+ var observerService = Components.classes["@mozilla.org/observer-service;1"].
+ getService(Components.interfaces.nsIObserverService);
+ observerService.addObserver(this, "requestpolicy-rules-changed", false);
+};
+RulesChangedObserver.prototype.unregister = function() {
+ var observerService = Components.classes["@mozilla.org/observer-service;1"].
+ getService(Components.interfaces.nsIObserverService);
+ observerService.removeObserver(this, "requestpolicy-rules-changed");
+};
+
function onload() {
var search = document.getElementById('rulesearch');
search.addEventListener('keyup', function (event) {
@@ -220,4 +242,9 @@ function onload() {
if (rpService.oldRulesExist()) {
$('#oldrulesexist').show();
}
+ rulesChangedObserver = new RulesChangedObserver();
+}
+
+function onunload() {
+ rulesChangedObserver.unregister();
}
diff --git a/src/modules/PolicyManager.jsm b/src/modules/PolicyManager.jsm
index 4adb670..235ac2f 100644
--- a/src/modules/PolicyManager.jsm
+++ b/src/modules/PolicyManager.jsm
@@ -22,6 +22,7 @@
var EXPORTED_SYMBOLS = [
"PolicyManager",
+ "RULES_CHANGED_TOPIC",
"RequestResult",
"Destination",
"REQUEST_TYPE_NORMAL",
@@ -45,6 +46,8 @@ var EXPORTED_SYMBOLS = [
const CI = Components.interfaces;
const CC = Components.classes;
+const RULES_CHANGED_TOPIC = "requestpolicy-rules-changed";
+
if (!requestpolicy) {
var requestpolicy = {
mod : {}
@@ -71,6 +74,12 @@ function warn(msg) {
requestpolicy.mod.Logger.warning(requestpolicy.mod.Logger.TYPE_POLICY, msg);
}
+function notifyRulesChanged() {
+ var observerService = Components.classes["@mozilla.org/observer-service;1"].
+ getService(Components.interfaces.nsIObserverService);
+ observerService.notifyObservers(null, RULES_CHANGED_TOPIC, null);
+}
+
// XXX: Subscriptions need an option to be "blacklist-only" so that users
// can subscribe to one as blacklist-only and know that a malicious or
@@ -305,6 +314,8 @@ PolicyManager.prototype = {
this._userPolicies["user"].policy.print();
// Temporary rules. These are never stored.
this.resetTemporaryPolicy();
+
+ notifyRulesChanged();
},
loadSubscriptionPolicies : function(subscriptionInfo) {
@@ -340,6 +351,8 @@ PolicyManager.prototype = {
}
}
+ notifyRulesChanged();
+
return failures;
},
@@ -363,6 +376,8 @@ PolicyManager.prototype = {
}
}
+ notifyRulesChanged();
+
return failures;
},
@@ -412,6 +427,8 @@ PolicyManager.prototype = {
}
//this._userPolicies["user"].policy.print();
+
+ notifyRulesChanged();
},
storeRules : function() {
@@ -430,6 +447,8 @@ PolicyManager.prototype = {
this._userPolicies["temp"].policy);
//this._userPolicies["temp"].policy.print();
+
+ notifyRulesChanged();
},
removeRule : function(ruleType, ruleData, noStore) {
@@ -458,6 +477,8 @@ PolicyManager.prototype = {
//this._userPolicies["user"].policy.print();
//this._userPolicies["temp"].policy.print();
+
+ notifyRulesChanged();
},
temporaryRulesExist : function() {
@@ -472,6 +493,8 @@ PolicyManager.prototype = {
"policy" : rawPolicy.toPolicy("temp")
};
this._userPolicies["temp"]["policy"].userPolicy = true;
+
+ notifyRulesChanged();
},
checkRequestAgainstUserPolicies : function(origin, dest) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list