Skip to content

Commit

Permalink
Bug 1051513 - Fix update of webapp activity registration. r=fabrice
Browse files Browse the repository at this point in the history
Remove all old activities for a given manifest before re-registering new ones.
  • Loading branch information
Cwiiis committed Aug 11, 2014
1 parent 589ed1e commit db6f22f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions dom/activities/src/ActivitiesService.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -166,6 +180,7 @@ let Activities = {

"Activities:Register",
"Activities:Unregister",
"Activities:UnregisterAll",
"Activities:GetContentTypes",

"child-process-shutdown"
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions dom/apps/src/Webapps.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit db6f22f

Please sign in to comment.