Bug 1051513 - Fix update of webapp activity registration. r=fabrice

Remove all old activities for a given manifest before re-registering new ones.
This commit is contained in:
Chris Lord 2014-08-11 23:21:44 +01:00
parent 63a5782589
commit bf797a46b8
2 changed files with 22 additions and 0 deletions

View File

@ -122,6 +122,20 @@ ActivitiesDb.prototype = {
}.bind(this), function() {}, function() {});
},
// Remove all activities associated with the given |aManifest| URL.
removeAll: function actdb_removeAll(aManifest) {
this.newTxn("readwrite", STORE_NAME, function (txn, store) {
let index = store.index("manifest");
let request = index.mozGetAll(aManifest);
request.onsuccess = function manifestActivities(aEvent) {
aEvent.target.result.forEach(function(result) {
debug('Removing activity: ' + JSON.stringify(result));
store.delete(result.id);
});
};
});
},
find: function actdb_find(aObject, aSuccess, aError, aMatch) {
debug("Looking for " + aObject.options.name);
@ -166,6 +180,7 @@ let Activities = {
"Activities:Register",
"Activities:Unregister",
"Activities:UnregisterAll",
"Activities:GetContentTypes",
"child-process-shutdown"
@ -394,6 +409,9 @@ let Activities = {
case "Activities:Unregister":
this.db.remove(msg);
break;
case "Activities:UnregisterAll":
this.db.removeAll(msg);
break;
case "child-process-shutdown":
for (let id in this.callers) {
if (this.callers[id].childMM == mm) {

View File

@ -883,6 +883,10 @@ this.DOMApplicationRegistry = {
activitiesToRegister.push.apply(activitiesToRegister,
this._createActivitiesToRegister(manifest, app, null, aRunUpdate));
if (aRunUpdate) {
cpmm.sendAsyncMessage("Activities:UnregisterAll", app.manifestURL);
}
if (!manifest.entry_points) {
return;
}