mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 908999 - Update Registered/Allowed Connections for Inter-App Communication API When App Gets Uninstalled. r=gene
This commit is contained in:
parent
282bce7af4
commit
f9ce9b9149
@ -52,6 +52,7 @@ const kMessages =["Webapps:Connect",
|
|||||||
this.InterAppCommService = {
|
this.InterAppCommService = {
|
||||||
init: function() {
|
init: function() {
|
||||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||||
|
Services.obs.addObserver(this, "webapps-clear-data", false);
|
||||||
|
|
||||||
kMessages.forEach(function(aMsg) {
|
kMessages.forEach(function(aMsg) {
|
||||||
ppmm.addMessageListener(aMsg, this);
|
ppmm.addMessageListener(aMsg, this);
|
||||||
@ -932,11 +933,80 @@ this.InterAppCommService = {
|
|||||||
switch (aTopic) {
|
switch (aTopic) {
|
||||||
case "xpcom-shutdown":
|
case "xpcom-shutdown":
|
||||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||||
|
Services.obs.removeObserver(this, "webapps-clear-data");
|
||||||
kMessages.forEach(function(aMsg) {
|
kMessages.forEach(function(aMsg) {
|
||||||
ppmm.removeMessageListener(aMsg, this);
|
ppmm.removeMessageListener(aMsg, this);
|
||||||
}, this);
|
}, this);
|
||||||
ppmm = null;
|
ppmm = null;
|
||||||
break;
|
break;
|
||||||
|
case "webapps-clear-data":
|
||||||
|
let params =
|
||||||
|
aSubject.QueryInterface(Ci.mozIApplicationClearPrivateDataParams);
|
||||||
|
if (!params) {
|
||||||
|
if (DEBUG) {
|
||||||
|
debug("Error updating registered/allowed connections for an " +
|
||||||
|
"uninstalled app.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only update registered/allowed connections for apps.
|
||||||
|
if (params.browserOnly) {
|
||||||
|
if (DEBUG) {
|
||||||
|
debug("Only update registered/allowed connections for apps.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let manifestURL = appsService.getManifestURLByLocalId(params.appId);
|
||||||
|
if (!manifestURL) {
|
||||||
|
if (DEBUG) {
|
||||||
|
debug("Error updating registered/allowed connections for an " +
|
||||||
|
"uninstalled app.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update registered connections.
|
||||||
|
for (let keyword in this._registeredConnections) {
|
||||||
|
let subAppManifestURLs = this._registeredConnections[keyword];
|
||||||
|
if (subAppManifestURLs[manifestURL]) {
|
||||||
|
delete subAppManifestURLs[manifestURL];
|
||||||
|
if (DEBUG) {
|
||||||
|
debug("Remove " + manifestURL + " from registered connections " +
|
||||||
|
"due to app uninstallation.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update allowed connections.
|
||||||
|
for (let keyword in this._allowedConnections) {
|
||||||
|
let allowedPubAppManifestURLs = this._allowedConnections[keyword];
|
||||||
|
if (allowedPubAppManifestURLs[manifestURL]) {
|
||||||
|
delete allowedPubAppManifestURLs[manifestURL];
|
||||||
|
if (DEBUG) {
|
||||||
|
debug("Remove " + manifestURL + " (as a pub app) from allowed " +
|
||||||
|
"connections due to app uninstallation.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let pubAppManifestURL in allowedPubAppManifestURLs) {
|
||||||
|
let subAppManifestURLs = allowedPubAppManifestURLs[pubAppManifestURL];
|
||||||
|
for (let i = subAppManifestURLs.length - 1; i >= 0; i--) {
|
||||||
|
if (subAppManifestURLs[i] === manifestURL) {
|
||||||
|
subAppManifestURLs.splice(i, 1);
|
||||||
|
if (DEBUG) {
|
||||||
|
debug("Remove " + manifestURL + " (as a sub app to pub " +
|
||||||
|
pubAppManifestURL + ") from allowed connections " +
|
||||||
|
"due to app uninstallation.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
debug("Finish updating registered/allowed connections for an " +
|
||||||
|
"uninstalled app.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user