mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 04:35:33 +00:00
Bug 223895 - Completed downloads should include size and TLD instead of "Done". r=sdwilsh, r=dwitte, b-ff3=beltzner, a1.9=beltzner
This commit is contained in:
parent
39be0419a4
commit
6b11207a93
@ -1,7 +1,6 @@
|
||||
<!ENTITY window.width "400">
|
||||
<!ENTITY window.height "300">
|
||||
|
||||
<!ENTITY done.label "Done">
|
||||
<!ENTITY canceled.label "Canceled">
|
||||
|
||||
<!ENTITY starting.label "Starting...">
|
||||
|
@ -50,6 +50,14 @@ timeSecondsLeft=#1 seconds left
|
||||
timeFewSeconds=A few seconds left
|
||||
timeUnknown=Unknown time left
|
||||
|
||||
# LOCALIZATION NOTE (doneStatus): — is the "em dash" (long dash)
|
||||
# #1 download size for FINISHED or download state; #2 host (e.g., eTLD + 1, IP)
|
||||
# examples: 1.1 MB — website2.com; Canceled — 222.net
|
||||
doneStatus=#1 — #2
|
||||
# LOCALIZATION NOTE (doneSize): #1 size number; #2 size unit
|
||||
doneSize=#1 #2
|
||||
doneSizeUnknown=Unknown size
|
||||
|
||||
fileDoesNotExistOpenTitle=Cannot Open %S
|
||||
fileDoesNotExistShowTitle=Cannot Show %S
|
||||
fileDoesNotExistError=%S does not exist. It may have been renamed, moved, or deleted since it was downloaded.
|
||||
|
@ -199,7 +199,8 @@
|
||||
<xul:label xbl:inherits="value=target,tooltiptext=target"
|
||||
crop="center" class="name"/>
|
||||
<xul:spacer flex="1"/>
|
||||
<xul:label value="&done.label;" class="status"/>
|
||||
<xul:label xbl:inherits="value=status,tooltiptext=status" flex="1"
|
||||
crop="right" class="status"/>
|
||||
</xul:vbox>
|
||||
<xul:vbox pack="center">
|
||||
<xul:hbox>
|
||||
|
@ -83,6 +83,10 @@ let gStr = {
|
||||
timeSecondsLeft: "timeSecondsLeft",
|
||||
timeFewSeconds: "timeFewSeconds",
|
||||
timeUnknown: "timeUnknown",
|
||||
doneStatus: "doneStatus",
|
||||
doneSize: "doneSize",
|
||||
doneSizeUnknown: "doneSizeUnknown",
|
||||
|
||||
units: ["bytes", "kilobyte", "megabyte", "gigabyte"],
|
||||
|
||||
fileExecutableSecurityWarningTitle: "fileExecutableSecurityWarningTitle",
|
||||
@ -159,6 +163,8 @@ function downloadCompleted(aDownload)
|
||||
|
||||
// Update attributes now that we've finished
|
||||
dl.setAttribute("startTime", Math.round(aDownload.startTime / 1000));
|
||||
dl.setAttribute("currBytes", aDownload.amountTransferred);
|
||||
dl.setAttribute("maxBytes", aDownload.size);
|
||||
|
||||
// If we are displaying search results, we do not want to add it to the list
|
||||
// of completed downloads
|
||||
@ -809,6 +815,53 @@ function updateStatus(aItem, aDownload) {
|
||||
status = replaceInsert(status, 4, remain);
|
||||
}
|
||||
|
||||
break;
|
||||
case nsIDM.DOWNLOAD_FINISHED:
|
||||
let (stateSize = {}) {
|
||||
stateSize[nsIDM.DOWNLOAD_FINISHED] = function() {
|
||||
// Display the file size, but show "Unknown" for negative sizes
|
||||
let fileSize = Number(aItem.getAttribute("maxBytes"));
|
||||
let sizeText = gStr.doneSizeUnknown;
|
||||
if (fileSize >= 0) {
|
||||
let [size, unit] = convertByteUnits(fileSize);
|
||||
sizeText = replaceInsert(gStr.doneSize, 1, size);
|
||||
sizeText = replaceInsert(sizeText, 2, unit);
|
||||
}
|
||||
return sizeText;
|
||||
};
|
||||
|
||||
// Insert 1 is the download size or download state
|
||||
status = replaceInsert(gStr.doneStatus, 1, stateSize[state]());
|
||||
}
|
||||
|
||||
let (displayHost,
|
||||
ioService = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService),
|
||||
eTLDService = Cc["@mozilla.org/network/effective-tld-service;1"].
|
||||
getService(Ci.nsIEffectiveTLDService)) {
|
||||
// Get a URI that knows about its components
|
||||
let uri = ioService.newURI(getReferrerOrSource(aItem), null, null);
|
||||
|
||||
try {
|
||||
// This might fail if it's an IP address or doesn't have >1 parts
|
||||
displayHost = eTLDService.getBaseDomain(uri);
|
||||
} catch (e) {
|
||||
// Default to the host name
|
||||
displayHost = uri.host;
|
||||
}
|
||||
|
||||
// Ahh! we have nothing :( Let's give the full spec (e.g., about:blank)
|
||||
if (displayHost.length == 0)
|
||||
displayHost = uri.spec;
|
||||
|
||||
// Tack on the port if it's not the default port
|
||||
else if (uri.port != -1)
|
||||
displayHost += ":" + uri.port;
|
||||
|
||||
// Insert 2 is the eTLD + 1 or other variations of the host
|
||||
status = replaceInsert(status, 2, displayHost);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user