Bug 904702 - Toggle download-progress notifications. r=mbrubeck

This commit is contained in:
Marina Samuel 2013-09-19 13:55:54 -04:00
parent 9869943464
commit c65775caf0
4 changed files with 20 additions and 19 deletions

View File

@ -88,12 +88,6 @@ var Appbar = {
this._updateStarButton();
},
onDownloadButton: function() {
let notificationBox = Browser.getNotificationBox();
notificationBox.notificationsHidden = !notificationBox.notificationsHidden;
ContextUI.dismiss();
},
onPinButton: function() {
if (this.pinButton.checked) {
Browser.pinSite();

View File

@ -254,7 +254,7 @@
<observes element="bcast_urlbarState" attribute="*"/>
<hbox id="toolbar-context-page" pack="end">
<circularprogressindicator id="download-progress"
oncommand="Appbar.onDownloadButton()"/>
oncommand="Downloads.onDownloadButton()"/>
<toolbarbutton id="star-button" class="appbar-primary"
type="checkbox"
oncommand="Appbar.onStarButton()"/>

View File

@ -88,7 +88,7 @@ var Downloads = {
case 0: // Downloading
case 5: // Queued
this.watchDownload(dl);
this.updateInfobar(dl);
this.updateInfobar();
break;
}
}
@ -194,7 +194,6 @@ var Downloads = {
},
showNotification: function dh_showNotification(title, msg, buttons, priority) {
this._notificationBox.notificationsHidden = false;
let notification = this._notificationBox.appendNotification(msg,
title,
URI_GENERIC_ICON_DOWNLOAD,
@ -335,9 +334,10 @@ var Downloads = {
this._downloadProgressIndicator.updateProgress(percentComplete);
},
_computeDownloadProgressString: function dv_computeDownloadProgressString(aDownload) {
_computeDownloadProgressString: function dv_computeDownloadProgressString() {
let totTransferred = 0, totSize = 0, totSecondsLeft = 0;
for (let [guid, info] of this._progressNotificationInfo) {
let guid, info;
for ([guid, info] of this._progressNotificationInfo) {
let size = info.download.size;
let amountTransferred = info.download.amountTransferred;
let speed = info.download.speed;
@ -358,7 +358,7 @@ var Downloads = {
if (this._downloadCount == 1) {
return Strings.browser.GetStringFromName("alertDownloadsStart2")
.replace("#1", aDownload.displayName)
.replace("#1", info.download.displayName)
.replace("#2", progress)
.replace("#3", timeLeft)
}
@ -380,12 +380,20 @@ var Downloads = {
this._progressNotificationInfo.set(aDownload.guid, infoObj);
},
updateInfobar: function dv_updateInfobar(aDownload) {
let message = this._computeDownloadProgressString(aDownload);
this._updateCircularProgressMeter();
onDownloadButton: function dv_onDownloadButton() {
if (this._progressNotification) {
let progressBar = this._notificationBox.getNotificationWithValue("download-progress");
if (progressBar) {
this._notificationBox.removeNotification(progressBar);
} else {
this.updateInfobar();
}
}
},
if (this._notificationBox && this._notificationBox.notificationsHidden)
this._notificationBox.notificationsHidden = false;
updateInfobar: function dv_updateInfobar() {
let message = this._computeDownloadProgressString();
this._updateCircularProgressMeter();
if (this._progressNotification == null ||
!this._notificationBox.getNotificationWithValue("download-progress")) {
@ -457,7 +465,7 @@ var Downloads = {
case "dl-start":
let download = aSubject.QueryInterface(Ci.nsIDownload);
this.watchDownload(download);
this.updateInfobar(download);
this.updateInfobar();
break;
case "dl-done":
this._downloadsInProgress--;

View File

@ -124,7 +124,6 @@ HelperAppLauncherDialog.prototype = {
className: "download-host-text"
}
);
notificationBox.notificationsHidden = false;
let newBar = notificationBox.appendNotification("",
"save-download",
URI_GENERIC_ICON_DOWNLOAD,