Bug 777639 - Part 4: Listen for removed downloads in about:downloads. r=wesj

--HG--
extra : rebase_source : c1f83dc5708f7b930e33e0644a19dffb86aa9be8
This commit is contained in:
Brian Nicholson 2013-02-05 16:08:10 -08:00
parent 7c1b9edcf4
commit b7ebfb9f60

View File

@ -139,6 +139,7 @@ let Downloads = {
this._dlmgr.addPrivacyAwareListener(this);
Services.obs.addObserver(this, "last-pb-context-exited", false);
Services.obs.addObserver(this, "download-manager-remove-download-guid", false);
// If we have private downloads, show them all immediately. If we were to
// add them asynchronously, there's a small chance we could get a
@ -165,6 +166,7 @@ let Downloads = {
this._dlmgr.removeListener(this);
Services.obs.removeObserver(this, "last-pb-context-exited");
Services.obs.removeObserver(this, "download-manager-remove-download-guid");
},
onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress,
@ -194,9 +196,17 @@ let Downloads = {
onStateChange: function(aWebProgress, aRequest, aState, aStatus, aDownload) { },
onSecurityChange: function(aWebProgress, aRequest, aState, aDownload) { },
// Called when last private window is closed
observe: function (aSubject, aTopic, aData) {
this._privateList.innerHTML = "";
switch (aTopic) {
case "last-pb-context-exited":
this._privateList.innerHTML = "";
break;
case "download-manager-remove-download-guid": {
let guid = aSubject.QueryInterface(Ci.nsISupportsCString).data;
this._removeItem(this._getElementForDownload(guid));
break;
}
}
},
_moveDownloadAfterActive: function dl_moveDownloadAfterActive(aItem) {
@ -459,7 +469,6 @@ let Downloads = {
this.logError("removeDownload() " + ex, aDownload);
}
}.bind(this));
aItem.parentNode.removeChild(aItem);
},
removeAll: function dl_removeAll() {