Bug 595888 - Show file size when attempting to download a file. r=sdwilsh, r=dolske, ui-r=faaborg
authorKailas <patilkr24@gmail.com>
Mon, 15 Aug 2011 12:53:03 -0700
changeset 75382 5ff103433c3b46a811b18e7043bc5f70f5af9c26
parent 75381 bdbc65fca5ff366c35841120c53128bde7a6a205
child 75383 e68b6ce72fc32ead1ff716e8c21cd46a86627ac2
push id21011
push userrcampbell@mozilla.com
push dateTue, 16 Aug 2011 15:35:10 +0000
treeherdermozilla-central@e765c8f565c6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssdwilsh, dolske, faaborg
bugs595888
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 595888 - Show file size when attempting to download a file. r=sdwilsh, r=dolske, ui-r=faaborg
toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties
toolkit/mozapps/downloads/nsHelperAppDlg.js
--- a/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties
+++ b/toolkit/locales/en-US/chrome/mozapps/downloads/unknownContentType.properties
@@ -17,16 +17,17 @@
 # The Initial Developer of the Original Code is
 # Doron Rosenberg.
 # Portions created by the Initial Developer are Copyright (C) 2001
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Ben Goodger <ben@bengoodger.com>
 #   Rich Walsh <dragtext@e-vertise.com>
+#   Kailas Patil <patilkr24@gmail.com>
 #
 # 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
 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 # in which case the provisions of the GPL or the LGPL are applicable instead
 # of those above. If you wish to allow use of your version of this file only
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
@@ -44,16 +45,18 @@ chooseAppFilePickerTitle=Choose Helper A
 badApp=The application you chose ("%S") could not be found.  Check the file name or choose another application.
 badApp.title=Application not found
 badPermissions=The file could not be saved because you do not have the proper permissions.  Choose another save directory.
 badPermissions.title=Invalid Save Permissions
 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
 # LOCALIZATION NOTE (classViewerOS2): OS/2 only
 classViewerOS2=Viewer for Class %S
 # LOCALIZATION NOTE (mmImageViewerOS2): OS/2 only, default operation of image files with OS/2 multimedia support installed
 mmImageViewerOS2=Image Viewer
 # LOCALIZATION NOTE (mmAudioPlayerOS2): OS/2 only, default operation of audio files with OS/2 multimedia support installed
--- a/toolkit/mozapps/downloads/nsHelperAppDlg.js
+++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js
@@ -24,16 +24,17 @@
 # Contributor(s):
 #   Bill Law <law@netscape.com>
 #   Scott MacGregor <mscott@netscape.com>
 #   Ben Goodger <ben@bengoodger.com> (2.0)
 #   Fredrik Holmqvist <thesuckiestemail@yahoo.se>
 #   Dan Mosedale <dmose@mozilla.org>
 #   Jim Mathies <jmathies@mozilla.com>
 #   Ehsan Akhgari <ehsan.akhgari@gmail.com>
+#   Kailas Patil <patilkr24@gmail.com>
 #
 # 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
 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 # in which case the provisions of the GPL or the LGPL are applicable instead
 # of those above. If you wish to allow use of your version of this file only
 # under the terms of either the GPL or the LGPL, and not to allow others to
 # use your version of this file under the terms of the MPL, indicate your
@@ -134,16 +135,17 @@ nsUnkownContentTypeDialogProgressListene
  */
 
 const PREF_BD_USEDOWNLOADDIR = "browser.download.useDownloadDir";
 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
  */
 function nsUnknownContentTypeDialog() {
   // Initialize data properties.
   this.mLauncher = null;
   this.mContext  = null;
   this.mSourcePath = null;
@@ -604,18 +606,26 @@ nsUnknownContentTypeDialog.prototype = {
       catch (ex) {
       }
       if (primaryExtension != "")
         typeString = this.dialogElement("strings").getFormattedString("fileType", [primaryExtension.toUpperCase()]);
       // 3. If we can't even do that, just give up and show the MIME type.
       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,
   _delayExpired: false,
   onBlur: function(aEvent) {
     this._blurred = true;
     this.mDialog.document.documentElement.getButton("accept").disabled = true;
   },