Bug 1129040 - Forward blocklist update notifications to the content process. r=Mossop

This commit is contained in:
Jim Mathies 2015-04-29 06:33:09 -05:00
Родитель 0cdf242407
Коммит e4180f41c7
2 изменённых файлов: 47 добавлений и 12 удалений

Просмотреть файл

@ -298,7 +298,7 @@ function Blocklist() {
gPref.addObserver(PREF_EM_LOGGING_ENABLED, this, false);
this.wrappedJSObject = this;
// requests from child processes come in here, see receiveMessage.
Services.ppmm.addMessageListener("Blocklist::getPluginBlocklistState", this);
Services.ppmm.addMessageListener("Blocklist:getPluginBlocklistState", this);
}
Blocklist.prototype = {
@ -322,7 +322,7 @@ Blocklist.prototype = {
shutdown: function () {
Services.obs.removeObserver(this, "xpcom-shutdown");
Services.ppmm.removeMessageListener("Blocklist::getPluginBlocklistState", this);
Services.ppmm.removeMessageListener("Blocklist:getPluginBlocklistState", this);
gPref.removeObserver("extensions.blocklist.", this);
gPref.removeObserver(PREF_EM_LOGGING_ENABLED, this);
},
@ -359,7 +359,7 @@ Blocklist.prototype = {
// Message manager message handlers
receiveMessage: function (aMsg) {
switch (aMsg.name) {
case "Blocklist::getPluginBlocklistState":
case "Blocklist:getPluginBlocklistState":
return this.getPluginBlocklistState(aMsg.data.addonData,
aMsg.data.appVersion,
aMsg.data.toolkitVersion);
@ -1192,6 +1192,11 @@ Blocklist.prototype = {
return blockEntry.infoURL;
},
_notifyObserversBlocklistUpdated: function () {
Services.obs.notifyObservers(this, "blocklist-updated", "");
Services.ppmm.broadcastAsyncMessage("Blocklist:blocklistInvalidated", {});
},
_blocklistUpdated: function Blocklist_blocklistUpdated(oldAddonEntries, oldPluginEntries) {
var addonList = [];
@ -1296,7 +1301,7 @@ Blocklist.prototype = {
}
if (addonList.length == 0) {
Services.obs.notifyObservers(self, "blocklist-updated", "");
self._notifyObserversBlocklistUpdated();
return;
}
@ -1308,7 +1313,7 @@ Blocklist.prototype = {
} catch (e) {
LOG(e);
}
Services.obs.notifyObservers(self, "blocklist-updated", "");
self._notifyObserversBlocklistUpdated();
return;
}
@ -1342,7 +1347,7 @@ Blocklist.prototype = {
if (args.restart)
restartApp();
Services.obs.notifyObservers(self, "blocklist-updated", "");
self._notifyObserversBlocklistUpdated();
Services.obs.removeObserver(applyBlocklistChanges, "addon-blocklist-closed");
}

Просмотреть файл

@ -21,6 +21,7 @@ const kMissingAPIMessage = "Unsupported blocklist call in the child process."
*/
function Blocklist() {
this.init();
}
Blocklist.prototype = {
@ -28,12 +29,41 @@ Blocklist.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIBlocklistService]),
init: function () {
Services.cpmm.addMessageListener("Blocklist:blocklistInvalidated", this);
Services.obs.addObserver(this, "xpcom-shutdown", false);
},
uninit: function () {
Services.cpmm.removeMessageListener("Blocklist:blocklistInvalidated", this);
Services.obs.removeObserver(this, "xpcom-shutdown", false);
},
observe: function (aSubject, aTopic, aData) {
switch (aTopic) {
case "xpcom-shutdown":
this.uninit();
break;
}
},
// Message manager message handlers
receiveMessage: function (aMsg) {
switch (aMsg.name) {
case "Blocklist:blocklistInvalidated":
Services.obs.notifyObservers(null, "blocklist-updated", null);
break;
default:
throw new Error("Unknown blocklist message received from content: " + aMsg.name);
}
},
/*
* A helper that queries key data from a plugin or addon object
* and generates a simple data wrapper suitable for ipc. We hand
* these directly to the nsBlockListService in the parent which
* doesn't query for much.. allowing us to get away with this.
*/
* A helper that queries key data from a plugin or addon object
* and generates a simple data wrapper suitable for ipc. We hand
* these directly to the nsBlockListService in the parent which
* doesn't query for much.. allowing us to get away with this.
*/
flattenObject: function (aTag) {
// Based on debugging the nsBlocklistService, these are the props the
// parent side will check on our objects.
@ -57,7 +87,7 @@ Blocklist.prototype = {
},
getPluginBlocklistState: function (aPluginTag, aAppVersion, aToolkitVersion) {
return Services.cpmm.sendSyncMessage("Blocklist::getPluginBlocklistState", {
return Services.cpmm.sendSyncMessage("Blocklist:getPluginBlocklistState", {
addonData: this.flattenObject(aPluginTag),
appVersion: aAppVersion,
toolkitVersion: aToolkitVersion