From 332ca401ebf32e9ffbadef9c3d13a2c3b5deab1a Mon Sep 17 00:00:00 2001 From: Kailas Date: Mon, 15 Aug 2011 12:53:03 -0700 Subject: [PATCH] Bug 595888 - Show file size when attempting to download a file. r=sdwilsh, r=dolske, ui-r=faaborg --- .../downloads/unknownContentType.properties | 3 +++ toolkit/mozapps/downloads/nsHelperAppDlg.js | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties b/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties index 93fcb45a069b..6dc7b82938bc 100644 --- a/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties +++ b/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties @@ -22,6 +22,7 @@ # Contributor(s): # Ben Goodger # Rich Walsh +# Kailas Patil # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -49,6 +50,8 @@ selectDownloadDir=Select Download Folder unknownAccept.label=Save File unknownCancel.label=Cancel fileType=%S file +# LOCALIZATION NOTE (fileSizeWithType): first %S is type, second %S is size, and third %S is unit +fileSizeWithType=%1S (%2S %3S) # LOCALIZATION NOTE (wpsDefaultOS2): OS/2 only, WPS refers to the Workplace Shell and should probably not be translated wpsDefaultOS2=WPS Default diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.js b/toolkit/mozapps/downloads/nsHelperAppDlg.js index 816d8c1326e2..dee0af3d06ab 100644 --- a/toolkit/mozapps/downloads/nsHelperAppDlg.js +++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js @@ -29,6 +29,7 @@ # Dan Mosedale # Jim Mathies # Ehsan Akhgari +# Kailas Patil # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -139,6 +140,7 @@ const nsITimer = Components.interfaces.nsITimer; Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/DownloadLastDir.jsm"); Components.utils.import("resource://gre/modules/DownloadPaths.jsm"); +Components.utils.import("resource://gre/modules/DownloadUtils.jsm"); /* ctor */ @@ -609,8 +611,16 @@ nsUnknownContentTypeDialog.prototype = { else typeString = mimeInfo.MIMEType; } - - type.value = typeString; + if (this.mLauncher.contentLength) { + let [size, unit] = DownloadUtils. + convertByteUnits(this.mLauncher.contentLength); + type.value = this.dialogElement("strings") + .getFormattedString("fileSizeWithType", + [typeString, size, unit]); + } + else { + type.value = typeString; + } }, _blurred: false,