[Pkg-mozext-commits] [requestpolicy] 109/280: [refact] put all constants into *one object*
David Prévot
taffit at moszumanska.debian.org
Sat May 2 20:30:07 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit f57029c49f9e91a63d72e04f5566e36d481e22e6
Author: Martin Kimmerle <dev at 256k.de>
Date: Tue Jan 6 01:19:47 2015 +0100
[refact] put all constants into *one object*
---
src/content/lib/constants.jsm | 51 ++++++++---------------
src/content/lib/content-policy.jsm | 4 +-
src/content/lib/gui-location.jsm | 4 +-
src/content/lib/policy-manager.alias-functions.js | 12 +++---
src/content/lib/policy-manager.jsm | 2 +-
src/content/lib/ruleset.jsm | 44 +++++++++----------
src/content/lib/utils.jsm | 4 +-
src/content/main/requestpolicy-service.jsm | 2 +-
src/content/ui/frame.blocked-content.js | 4 +-
src/content/ui/frame.dom-content-loaded.js | 12 +++---
src/content/ui/frame.js | 12 +++---
src/content/ui/menu.js | 38 ++++++++---------
src/content/ui/overlay.js | 20 ++++-----
13 files changed, 94 insertions(+), 115 deletions(-)
diff --git a/src/content/lib/constants.jsm b/src/content/lib/constants.jsm
index e16dbb3..b9b6486 100644
--- a/src/content/lib/constants.jsm
+++ b/src/content/lib/constants.jsm
@@ -25,45 +25,28 @@ const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
-let EXPORTED_SYMBOLS = [
- "EXTENSION_ID",
- "FIREFOX_ID",
- "MMID",
+let EXPORTED_SYMBOLS = ["C"];
- "APP_STARTUP",
- "APP_SHUTDOWN",
- "ADDON_ENABLE",
- "ADDON_DISABLE",
- "ADDON_INSTALL",
- "ADDON_UNINSTALL",
- "ADDON_UPGRADE",
- "ADDON_DOWNGRADE",
+let C = {};
- "CP_OK",
- "CP_REJECT",
-
- "RULE_ACTION_ALLOW",
- "RULE_ACTION_DENY"
-];
-
-const EXTENSION_ID = "requestpolicy at requestpolicy.com";
-const FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
-const MMID = EXTENSION_ID; // message manager ID
+C.EXTENSION_ID = "requestpolicy at requestpolicy.com";
+C.FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
+C.MMID = C.EXTENSION_ID; // message manager ID
// reason constants for startup(), shutdown(), install() and uninstall()
// see https://developer.mozilla.org/en-US/Add-ons/Bootstrapped_extensions#Reason_constants
-const APP_STARTUP = 1; // The application is starting up.
-const APP_SHUTDOWN = 2; // The application is shutting down.
-const ADDON_ENABLE = 3; // The add-on is being enabled.
-const ADDON_DISABLE = 4; // The add-on is being disabled. (Also sent during uninstallation)
-const ADDON_INSTALL = 5; // The add-on is being installed.
-const ADDON_UNINSTALL = 6; // The add-on is being uninstalled.
-const ADDON_UPGRADE = 7; // The add-on is being upgraded.
-const ADDON_DOWNGRADE = 8; // The add-on is being downgraded.
+C.APP_STARTUP = 1; // The application is starting up.
+C.APP_SHUTDOWN = 2; // The application is shutting down.
+C.ADDON_ENABLE = 3; // The add-on is being enabled.
+C.ADDON_DISABLE = 4; // The add-on is being disabled. (Also sent during uninstallation)
+C.ADDON_INSTALL = 5; // The add-on is being installed.
+C.ADDON_UNINSTALL = 6; // The add-on is being uninstalled.
+C.ADDON_UPGRADE = 7; // The add-on is being upgraded.
+C.ADDON_DOWNGRADE = 8; // The add-on is being downgraded.
// content policy
-const CP_OK = Ci.nsIContentPolicy.ACCEPT;
-const CP_REJECT = Ci.nsIContentPolicy.REJECT_SERVER;
+C.CP_OK = Ci.nsIContentPolicy.ACCEPT;
+C.CP_REJECT = Ci.nsIContentPolicy.REJECT_SERVER;
-const RULE_ACTION_ALLOW = 1;
-const RULE_ACTION_DENY = 2;
+C.RULE_ACTION_ALLOW = 1;
+C.RULE_ACTION_DENY = 2;
diff --git a/src/content/lib/content-policy.jsm b/src/content/lib/content-policy.jsm
index 03fc62a..98e2afb 100644
--- a/src/content/lib/content-policy.jsm
+++ b/src/content/lib/content-policy.jsm
@@ -34,7 +34,7 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("chrome://requestpolicy/content/lib/script-loader.jsm");
ScriptLoader.importModules([
- "lib/constants", // e.g. CP_OK
+ "lib/constants",
"lib/logger",
"lib/request",
"lib/utils",
@@ -117,7 +117,7 @@ let PolicyImplementation = (function() {
// aContext, aMimeTypeGuess, aExtra, aRequestPrincipal);
};
- self.shouldProcess = (() => CP_OK);
+ self.shouldProcess = (() => C.CP_OK);
//
// nsIFactory interface implementation
diff --git a/src/content/lib/gui-location.jsm b/src/content/lib/gui-location.jsm
index fd57be4..6381684 100644
--- a/src/content/lib/gui-location.jsm
+++ b/src/content/lib/gui-location.jsm
@@ -215,11 +215,11 @@ GUILocationProperties.prototype.accumulate = function (requests, ruleAction) {
}
switch (ruleAction) {
- case RULE_ACTION_ALLOW:
+ case C.RULE_ACTION_ALLOW:
this.numAllowedRequests += ruleActionCounter;
break;
- case RULE_ACTION_DENY:
+ case C.RULE_ACTION_DENY:
this.numBlockedRequests += ruleActionCounter;
break;
diff --git a/src/content/lib/policy-manager.alias-functions.js b/src/content/lib/policy-manager.alias-functions.js
index 0c1f6b3..99de8cf 100644
--- a/src/content/lib/policy-manager.alias-functions.js
+++ b/src/content/lib/policy-manager.alias-functions.js
@@ -24,14 +24,14 @@
let PolicyManager = (function(self) {
- self.addAllowRule = self.addRule.bind(this, RULE_ACTION_ALLOW);
+ self.addAllowRule = self.addRule.bind(this, C.RULE_ACTION_ALLOW);
self.addTemporaryAllowRule = self.addTemporaryRule.bind(this,
- RULE_ACTION_ALLOW);
- self.removeAllowRule = self.removeRule.bind(this, RULE_ACTION_ALLOW);
- self.addDenyRule = self.addRule.bind(this, RULE_ACTION_DENY);
+ C.RULE_ACTION_ALLOW);
+ self.removeAllowRule = self.removeRule.bind(this, C.RULE_ACTION_ALLOW);
+ self.addDenyRule = self.addRule.bind(this, C.RULE_ACTION_DENY);
self.addTemporaryDenyRule = self.addTemporaryRule.bind(this,
- RULE_ACTION_DENY);
- self.removeDenyRule = self.removeRule.bind(this, RULE_ACTION_DENY);
+ C.RULE_ACTION_DENY);
+ self.removeDenyRule = self.removeRule.bind(this, C.RULE_ACTION_DENY);
function getRuleData(aOrigin, aDest) {
diff --git a/src/content/lib/policy-manager.jsm b/src/content/lib/policy-manager.jsm
index b93fbf9..3ad9dcb 100644
--- a/src/content/lib/policy-manager.jsm
+++ b/src/content/lib/policy-manager.jsm
@@ -188,7 +188,7 @@ let PolicyManager = (function(self) {
};
function assertRuleAction(ruleAction) {
- if (ruleAction != RULE_ACTION_ALLOW && ruleAction != RULE_ACTION_DENY) {
+ if (ruleAction != C.RULE_ACTION_ALLOW && ruleAction != C.RULE_ACTION_DENY) {
throw "Invalid rule type: " + ruleAction;
}
}
diff --git a/src/content/lib/ruleset.jsm b/src/content/lib/ruleset.jsm
index 69151a0..2de427a 100644
--- a/src/content/lib/ruleset.jsm
+++ b/src/content/lib/ruleset.jsm
@@ -162,7 +162,7 @@ RawRuleset.prototype = {
r.initDestinations();
[rules, r] = this._addEntryHelper(d, r.destinations);
//r.destinationRuleAction = ruleAction;
- if (ruleAction == RULE_ACTION_ALLOW) {
+ if (ruleAction == C.RULE_ACTION_ALLOW) {
r.allowDestination = true;
} else {
r.denyDestination = true;
@@ -171,7 +171,7 @@ RawRuleset.prototype = {
} else if (o && !d) {
[rules, r] = this._addEntryHelper(o, policy);
//r.originRuleAction = ruleAction;
- if (ruleAction == RULE_ACTION_ALLOW) {
+ if (ruleAction == C.RULE_ACTION_ALLOW) {
r.allowOrigin = true;
} else {
r.denyOrigin = true;
@@ -180,7 +180,7 @@ RawRuleset.prototype = {
} else if (!o && d) {
[rules, r] = this._addEntryHelper(d, policy);
//r.destinationRuleAction = ruleAction;
- if (ruleAction == RULE_ACTION_ALLOW) {
+ if (ruleAction == C.RULE_ACTION_ALLOW) {
r.allowDestination = true;
} else {
r.denyDestination = true;
@@ -193,8 +193,8 @@ RawRuleset.prototype = {
},
ruleExists : function(ruleAction, ruleData) {
- var actionStr = ruleAction == RULE_ACTION_ALLOW ? "allow" :
- ruleAction == RULE_ACTION_DENY ? "deny" : "";
+ var actionStr = ruleAction == C.RULE_ACTION_ALLOW ? "allow" :
+ ruleAction == C.RULE_ACTION_DENY ? "deny" : "";
if (!actionStr) {
throw "Invalid ruleAction: " + ruleAction;
}
@@ -220,8 +220,8 @@ RawRuleset.prototype = {
addRule : function(ruleAction, ruleData, policy) {
// XXX: remove loggings
//dprint("addRule: adding entry");
- var actionStr = ruleAction == RULE_ACTION_ALLOW ? "allow" :
- ruleAction == RULE_ACTION_DENY ? "deny" : "";
+ var actionStr = ruleAction == C.RULE_ACTION_ALLOW ? "allow" :
+ ruleAction == C.RULE_ACTION_DENY ? "deny" : "";
if (!actionStr) {
throw "Invalid ruleAction: " + ruleAction;
}
@@ -291,9 +291,9 @@ RawRuleset.prototype = {
// r.destinationRuleAction = null;
// }
//dprint("_removeEntryFromRuleset: got rule to alter: " + r.toString());
- if (ruleAction == RULE_ACTION_ALLOW) {
+ if (ruleAction == C.RULE_ACTION_ALLOW) {
r.allowDestination = null;
- } else if (ruleAction == RULE_ACTION_DENY) {
+ } else if (ruleAction == C.RULE_ACTION_DENY) {
r.denyDestination = null;
} else {
throw "Invalid rule type: " + ruleAction;
@@ -317,9 +317,9 @@ RawRuleset.prototype = {
// if (r.originRuleAction == ruleAction) {
// r.originRuleAction = null;
// }
- if (ruleAction == RULE_ACTION_ALLOW) {
+ if (ruleAction == C.RULE_ACTION_ALLOW) {
r.allowOrigin = null;
- } else if (ruleAction == RULE_ACTION_DENY) {
+ } else if (ruleAction == C.RULE_ACTION_DENY) {
r.denyOrigin = null;
} else {
throw "Invalid rule type: " + ruleAction;
@@ -343,9 +343,9 @@ RawRuleset.prototype = {
// if (r.destinationRuleAction == ruleAction) {
// r.destinationRuleAction = null;
// }
- if (ruleAction == RULE_ACTION_ALLOW) {
+ if (ruleAction == C.RULE_ACTION_ALLOW) {
r.allowDestination = null;
- } else if (ruleAction == RULE_ACTION_DENY) {
+ } else if (ruleAction == C.RULE_ACTION_DENY) {
r.denyDestination = null;
} else {
throw "Invalid rule type: " + ruleAction;
@@ -367,8 +367,8 @@ RawRuleset.prototype = {
removeRule : function(ruleAction, ruleData, policy) {
// XXX: remove loggings
//dprint("removeRule: removing entry");
- var actionStr = ruleAction == RULE_ACTION_ALLOW ? "allow" :
- ruleAction == RULE_ACTION_DENY ? "deny" : "";
+ var actionStr = ruleAction == C.RULE_ACTION_ALLOW ? "allow" :
+ ruleAction == C.RULE_ACTION_DENY ? "deny" : "";
if (!actionStr) {
throw "Invalid ruleAction: " + ruleAction;
}
@@ -412,7 +412,7 @@ RawRuleset.prototype = {
dwarn("Invalid entry type: " + actionStr);
continue;
}
- var ruleAction = actionStr == "allow" ? RULE_ACTION_ALLOW : RULE_ACTION_DENY;
+ var ruleAction = actionStr == "allow" ? C.RULE_ACTION_ALLOW : C.RULE_ACTION_DENY;
var entryArray = this._entries[actionStr];
for (var i in entryArray) {
//dprint("toRuleset: adding entry");
@@ -915,13 +915,13 @@ Ruleset.prototype = {
matchedDenyRules.push(["origin", entry, rule]);
}
// switch(rule.originRuleAction) {
- // case RULE_ACTION_ALLOW:
+ // case C.RULE_ACTION_ALLOW:
// if (ruleMatchedOrigin) {
// dprint("ALLOW origin by rule " + entry + " " + rule);
// matchedAllowRules.push(["origin", entry, rule]);
// }
// break;
- // case RULE_ACTION_DENY:
+ // case C.RULE_ACTION_DENY:
// if (ruleMatchedOrigin) {
// dprint("DENY origin by rule " + entry + " " + rule);
// matchedDenyRules.push(["origin", entry, rule]);
@@ -948,13 +948,13 @@ Ruleset.prototype = {
}
// switch(destRule.destinationRuleAction) {
- // case RULE_ACTION_ALLOW:
+ // case C.RULE_ACTION_ALLOW:
// if (destRule.isMatch(dest)) {
// dprint("ALLOW origin-to-dest by rule origin " + entry + " " + rule + " to dest " + destEntry + " " + destRule);
// matchedAllowRules.push(["origin-to-dest", entry, rule, destEntry, destRule]);
// }
// break;
- // case RULE_ACTION_DENY:
+ // case C.RULE_ACTION_DENY:
// if (destRule.isMatch(dest)) {
// dprint("DENY origin-to-dest by rule origin " + entry + " " + rule + " to dest " + destEntry + " " + destRule);
// matchedDenyRules.push(["origin-to-dest", entry, rule, destEntry, destRule]);
@@ -985,13 +985,13 @@ Ruleset.prototype = {
matchedDenyRules.push(["dest", entry, rule]);
}
// switch(rule.destinationRuleAction) {
- // case RULE_ACTION_ALLOW:
+ // case C.RULE_ACTION_ALLOW:
// if (rule.isMatch(dest)) {
// dprint("ALLOW dest by rule " + entry + " " + rule);
// matchedAllowRules.push(["dest", entry, rule]);
// }
// break;
- // case RULE_ACTION_DENY:
+ // case C.RULE_ACTION_DENY:
// if (rule.isMatch(dest)) {
// dprint("DENY dest by rule " + entry + " " + rule);
// matchedDenyRules.push(["dest", entry, rule]);
diff --git a/src/content/lib/utils.jsm b/src/content/lib/utils.jsm
index 4b98908..f0a5999 100644
--- a/src/content/lib/utils.jsm
+++ b/src/content/lib/utils.jsm
@@ -79,7 +79,7 @@ let Utils = (function() {
self.info.curRPVersion = "0.0";
// curRPVersion needs to be set asynchronously
- AddonManager.getAddonByID(EXTENSION_ID, function(addon) {
+ AddonManager.getAddonByID(C.EXTENSION_ID, function(addon) {
rpPrefBranch.setCharPref("lastVersion", addon.version);
self.info.curRPVersion = addon.version;
if (self.info.lastRPVersion != self.info.curRPVersion) {
@@ -101,7 +101,7 @@ let Utils = (function() {
}
}
- self.info.isFirefox = Services.appinfo.ID == FIREFOX_ID;
+ self.info.isFirefox = Services.appinfo.ID == C.FIREFOX_ID;
self.info.isAustralis = self.info.isFirefox &&
Services.vc.compare(Services.appinfo.platformVersion, '29') >= 0;
diff --git a/src/content/main/requestpolicy-service.jsm b/src/content/main/requestpolicy-service.jsm
index b78919c..ec8ecde 100644
--- a/src/content/main/requestpolicy-service.jsm
+++ b/src/content/main/requestpolicy-service.jsm
@@ -448,7 +448,7 @@ let rpService = (function() {
});
ProcessEnvironment.pushShutdownFunction(function(data, reason) {
- if (reason == ADDON_DISABLE || reason == ADDON_UNINSTALL) {
+ if (reason == C.ADDON_DISABLE || reason == C.ADDON_UNINSTALL) {
handleUninstallOrDisable();
}
unregister();
diff --git a/src/content/ui/frame.blocked-content.js b/src/content/ui/frame.blocked-content.js
index 47d2aae..2b523ce 100644
--- a/src/content/ui/frame.blocked-content.js
+++ b/src/content/ui/frame.blocked-content.js
@@ -20,8 +20,6 @@
* ***** END LICENSE BLOCK *****
*/
-var MMID = "requestpolicy at requestpolicy.com";
-
let ManagerForBlockedContent = (function() {
let self = {};
@@ -94,7 +92,7 @@ let ManagerForBlockedContent = (function() {
}
}
- addMessageListener(MMID + ":indicateBlockedVisibleObjects",
+ addMessageListener(C.MMID + ":indicateBlockedVisibleObjects",
indicateBlockedVisibleObjects);
return self;
diff --git a/src/content/ui/frame.dom-content-loaded.js b/src/content/ui/frame.dom-content-loaded.js
index c48acf9..3e1c91d 100644
--- a/src/content/ui/frame.dom-content-loaded.js
+++ b/src/content/ui/frame.dom-content-loaded.js
@@ -20,8 +20,6 @@
* ***** END LICENSE BLOCK *****
*/
-var MMID = "requestpolicy at requestpolicy.com";
-
let ManagerForDOMContentLoaded = (function() {
let self = {};
@@ -44,7 +42,7 @@ let ManagerForDOMContentLoaded = (function() {
// Notify the main thread that a link has been clicked.
// Note: The <a> element is `currentTarget`! See:
// https://developer.mozilla.org/en-US/docs/Web/API/Event.currentTarget
- sendSyncMessage(MMID + ":notifyLinkClicked",
+ sendSyncMessage(C.MMID + ":notifyLinkClicked",
{origin: event.currentTarget.ownerDocument.URL,
dest: event.currentTarget.href});
}
@@ -79,12 +77,12 @@ let ManagerForDOMContentLoaded = (function() {
onDocumentLoaded(doc);
let docID = DocManager.generateDocID(doc);
- sendAsyncMessage(MMID + ":notifyDocumentLoaded",
+ sendAsyncMessage(C.MMID + ":notifyDocumentLoaded",
{docID: docID, documentURI: doc.documentURI});
if (isActiveTopLevelDocument(doc)) {
- sendAsyncMessage(MMID + ":notifyTopLevelDocumentLoaded");
+ sendAsyncMessage(C.MMID + ":notifyTopLevelDocumentLoaded");
}
}
@@ -110,7 +108,7 @@ let ManagerForDOMContentLoaded = (function() {
// other origins every time an iframe is loaded. Maybe, then, this should
// use a timeout like observerBlockedRequests does.
if (isActiveTopLevelDocument(iframe.ownerDocument)) {
- sendAsyncMessage(MMID + ":notifyDOMFrameContentLoaded");
+ sendAsyncMessage(C.MMID + ":notifyDOMFrameContentLoaded");
/*
// This has an advantage over just relying on the
// observeBlockedRequest() call in that this will clear a blocked
@@ -174,7 +172,7 @@ let ManagerForDOMContentLoaded = (function() {
"Another extension disabled docShell.allowMetaRedirects.");
}
- sendAsyncMessage(MMID + ":handleMetaRefreshes",
+ sendAsyncMessage(C.MMID + ":handleMetaRefreshes",
{documentURI: documentURI, metaRefreshes: metaRefreshes});
}
diff --git a/src/content/ui/frame.js b/src/content/ui/frame.js
index a5196e3..8911ddc 100644
--- a/src/content/ui/frame.js
+++ b/src/content/ui/frame.js
@@ -20,11 +20,11 @@
* ***** END LICENSE BLOCK *****
*/
-var MMID = "requestpolicy at requestpolicy.com";
-
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("chrome://requestpolicy/content/lib/script-loader.jsm");
+ScriptLoader.importModule("lib/constants", this);
+
/**
@@ -91,7 +91,7 @@ var WinEnv = (function getWindowEnvironment() {
// I believe an empty href always gets filled in with the current URL so
// it will never actually be empty. However, I don't know this for certain.
if (event.target.nodeName.toLowerCase() == "a" && event.target.href) {
- sendSyncMessage(MMID + ":notifyLinkClicked",
+ sendSyncMessage(C.MMID + ":notifyLinkClicked",
{origin: event.target.ownerDocument.URL,
dest: event.target.href});
return;
@@ -102,7 +102,7 @@ var WinEnv = (function getWindowEnvironment() {
if (event.target.nodeName.toLowerCase() == "input" &&
event.target.type.toLowerCase() == "submit" &&
event.target.form && event.target.form.action) {
- sendSyncMessage(MMID + ":registerFormSubmitted",
+ sendSyncMessage(C.MMID + ":registerFormSubmitted",
{origin: event.target.ownerDocument.URL,
dest: event.target.form.action});
return;
@@ -110,11 +110,11 @@ var WinEnv = (function getWindowEnvironment() {
}, true);*/
WinEnv.enqueueStartupFunction(function() {
- addMessageListener(MMID + ":reload", function() {
+ addMessageListener(C.MMID + ":reload", function() {
content.document.location.reload(false);
});
- addMessageListener(MMID + ":setLocation", function(message) {
+ addMessageListener(C.MMID + ":setLocation", function(message) {
content.document.location.href = message.data.uri;
});
});
diff --git a/src/content/ui/menu.js b/src/content/ui/menu.js
index c9bdabb..0db1eb4 100644
--- a/src/content/ui/menu.js
+++ b/src/content/ui/menu.js
@@ -48,7 +48,7 @@ requestpolicy.menu = (function() {
let {StringUtils} = iMod("lib/utils/strings");
let {DOMUtils} = iMod("lib/utils/dom");
let {rpService} = iMod("main/requestpolicy-service");
- let {RULE_ACTION_ALLOW, RULE_ACTION_DENY} = iMod("lib/constants");
+ let {C} = iMod("lib/constants");
let initialized = false;
@@ -373,13 +373,13 @@ requestpolicy.menu = (function() {
};
//if (Prefs.isDefaultAllow()) {
if (self._isCurrentlySelectedDestAllowed ||
- (!PolicyManager.ruleExists(RULE_ACTION_DENY, ruleData) &&
- !PolicyManager.ruleExists(RULE_ACTION_DENY, destOnlyRuleData))) {
+ (!PolicyManager.ruleExists(C.RULE_ACTION_DENY, ruleData) &&
+ !PolicyManager.ruleExists(C.RULE_ACTION_DENY, destOnlyRuleData))) {
// show "Block requests" if the destination was allowed
// OR if there's no blocking rule (i.e. the request was blocked "by default")
// -- this enables support for blacklisting.
- if (!PolicyManager.ruleExists(RULE_ACTION_ALLOW, ruleData) &&
- !PolicyManager.ruleExists(RULE_ACTION_DENY, ruleData)) {
+ if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, ruleData) &&
+ !PolicyManager.ruleExists(C.RULE_ACTION_DENY, ruleData)) {
if (!self._privateBrowsingEnabled) {
var item = self._addMenuItemDenyOriginToDest(
self._addRulesList, ruleData);
@@ -388,8 +388,8 @@ requestpolicy.menu = (function() {
self._addRulesList, ruleData);
}
- if (!PolicyManager.ruleExists(RULE_ACTION_ALLOW, destOnlyRuleData) &&
- !PolicyManager.ruleExists(RULE_ACTION_DENY, destOnlyRuleData)) {
+ if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, destOnlyRuleData) &&
+ !PolicyManager.ruleExists(C.RULE_ACTION_DENY, destOnlyRuleData)) {
if (!self._privateBrowsingEnabled) {
var item = self._addMenuItemDenyDest(
self._addRulesList, destOnlyRuleData);
@@ -399,13 +399,13 @@ requestpolicy.menu = (function() {
}
}
if (self._isCurrentlySelectedDestBlocked ||
- (!PolicyManager.ruleExists(RULE_ACTION_ALLOW, ruleData) &&
- !PolicyManager.ruleExists(RULE_ACTION_ALLOW, destOnlyRuleData))) {
+ (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, ruleData) &&
+ !PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, destOnlyRuleData))) {
// show "Allow requests" if the destination was blocked
// OR if there's no allow-rule (i.e. the request was allowed "by default")
// -- this enables support for whitelisting.
- if (!PolicyManager.ruleExists(RULE_ACTION_ALLOW, ruleData) &&
- !PolicyManager.ruleExists(RULE_ACTION_DENY, ruleData)) {
+ if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, ruleData) &&
+ !PolicyManager.ruleExists(C.RULE_ACTION_DENY, ruleData)) {
if (!self._privateBrowsingEnabled) {
var item = self._addMenuItemAllowOriginToDest(
self._addRulesList, ruleData);
@@ -414,8 +414,8 @@ requestpolicy.menu = (function() {
self._addRulesList, ruleData);
}
- if (!PolicyManager.ruleExists(RULE_ACTION_ALLOW, destOnlyRuleData) &&
- !PolicyManager.ruleExists(RULE_ACTION_DENY, destOnlyRuleData)) {
+ if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, destOnlyRuleData) &&
+ !PolicyManager.ruleExists(C.RULE_ACTION_DENY, destOnlyRuleData)) {
if (!self._privateBrowsingEnabled) {
var item = self._addMenuItemAllowDest(
self._addRulesList, destOnlyRuleData);
@@ -663,7 +663,7 @@ requestpolicy.menu = (function() {
var result = [];
for (var destBase in requests) {
var properties = new GUILocationProperties();
- properties.accumulate(requests[destBase], RULE_ACTION_DENY);
+ properties.accumulate(requests[destBase], C.RULE_ACTION_DENY);
result.push(new GUIDestination(destBase, properties));
}
return result;
@@ -686,7 +686,7 @@ requestpolicy.menu = (function() {
}
var properties = new GUILocationProperties();
- properties.accumulate(requests[destBase], RULE_ACTION_ALLOW);
+ properties.accumulate(requests[destBase], C.RULE_ACTION_ALLOW);
result.push(new GUIDestination(destBase, properties));
}
return result;
@@ -1179,8 +1179,8 @@ requestpolicy.menu = (function() {
'h': destHost
}
};
- if (!PolicyManager.ruleExists(RULE_ACTION_ALLOW, ruleData) &&
- !PolicyManager.ruleExists(RULE_ACTION_DENY, ruleData)) {
+ if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, ruleData) &&
+ !PolicyManager.ruleExists(C.RULE_ACTION_DENY, ruleData)) {
if (!self._privateBrowsingEnabled) {
var item = self._addMenuItemAllowOriginToDest(list, ruleData);
}
@@ -1192,8 +1192,8 @@ requestpolicy.menu = (function() {
'h': destHost
}
};
- if (!PolicyManager.ruleExists(RULE_ACTION_ALLOW, destOnlyRuleData) &&
- !PolicyManager.ruleExists(RULE_ACTION_DENY, destOnlyRuleData)) {
+ if (!PolicyManager.ruleExists(C.RULE_ACTION_ALLOW, destOnlyRuleData) &&
+ !PolicyManager.ruleExists(C.RULE_ACTION_DENY, destOnlyRuleData)) {
if (!self._privateBrowsingEnabled) {
var item = self._addMenuItemAllowDest(list, destOnlyRuleData);
}
diff --git a/src/content/ui/overlay.js b/src/content/ui/overlay.js
index 3736731..1d78a80 100644
--- a/src/content/ui/overlay.js
+++ b/src/content/ui/overlay.js
@@ -50,7 +50,7 @@ requestpolicy.overlay = (function() {
let {StringUtils} = iMod("lib/utils/strings");
let {DOMUtils} = iMod("lib/utils/dom");
let {rpService} = iMod("main/requestpolicy-service");
- let {MMID} = iMod("lib/constants");
+ let {C} = iMod("lib/constants");
let $ = function(id) {
return document.getElementById(id);
@@ -182,7 +182,7 @@ requestpolicy.overlay = (function() {
messageManager.addMessageListener(
- MMID + ":notifyDocumentLoaded",
+ C.MMID + ":notifyDocumentLoaded",
function(message) {
dump("notifyDocumentLoaded\n\n");
let {docID, documentURI} = message.data;
@@ -221,7 +221,7 @@ requestpolicy.overlay = (function() {
}
}
message.target.messageManager.sendAsyncMessage(
- MMID + ":indicateBlockedVisibleObjects",
+ C.MMID + ":indicateBlockedVisibleObjects",
{blockedURIs: blockedURIs, docID: docID});
}
@@ -239,7 +239,7 @@ requestpolicy.overlay = (function() {
});
messageManager.addMessageListener(
- MMID + ":notifyTopLevelDocumentLoaded",
+ C.MMID + ":notifyTopLevelDocumentLoaded",
function (message) {
// Clear any notifications that may have been present.
self._setContentBlockedState(false);
@@ -258,7 +258,7 @@ requestpolicy.overlay = (function() {
});
messageManager.addMessageListener(
- MMID + ":notifyDOMFrameContentLoaded",
+ C.MMID + ":notifyDOMFrameContentLoaded",
function (message) {
// This has an advantage over just relying on the
// observeBlockedRequest() call in that this will clear a blocked
@@ -270,17 +270,17 @@ requestpolicy.overlay = (function() {
self._updateBlockedContentState(message.target);
});
- messageManager.addMessageListener(MMID + ":handleMetaRefreshes",
+ messageManager.addMessageListener(C.MMID + ":handleMetaRefreshes",
self.handleMetaRefreshes);
messageManager.addMessageListener(
- MMID + ":notifyLinkClicked", function (message) {
+ C.MMID + ":notifyLinkClicked", function (message) {
RequestProcessor.registerLinkClicked(message.data.origin,
message.data.dest);
});
messageManager.addMessageListener(
- MMID + ":notifyFormSubmitted", function (message) {
+ C.MMID + ":notifyFormSubmitted", function (message) {
RequestProcessor.registerFormSubmitted(message.data.origin,
message.data.dest);
});
@@ -530,7 +530,7 @@ requestpolicy.overlay = (function() {
RequestProcessor.registerAllowedRedirect(
browser.documentURI.specIgnoringRef, redirectTargetUri);
- browser.messageManager.sendAsyncMessage(MMID + ":setLocation",
+ browser.messageManager.sendAsyncMessage(C.MMID + ":setLocation",
{uri: redirectTargetUri});
}
},
@@ -994,7 +994,7 @@ requestpolicy.overlay = (function() {
if (rulesChanged || self._needsReloadOnMenuClose) {
if (rpPrefBranch.getBoolPref("autoReload")) {
let mm = gBrowser.selectedBrowser.messageManager;
- mm.sendAsyncMessage(MMID + ":reload");
+ mm.sendAsyncMessage(C.MMID + ":reload");
}
}
self._needsReloadOnMenuClose = false;
--
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