Bug 926736 - Update mozapps callers for new return type of get directory methods in DownloadIntegration.jsm r=paolo
authorRaymond Lee <raymond@raysquare.com>
Mon, 21 Oct 2013 13:04:59 +0800
changeset 166846 776a19e7928cc75ebd1d2b36b62e7d36a4733902
parent 166845 eafedd45d99ed98859a5f148d9c4deb4adc8c5c7
child 166847 1e970a11c5767551a6b9a4bfa808f17a81156fe4
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs926736
milestone27.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 926736 - Update mozapps callers for new return type of get directory methods in DownloadIntegration.jsm r=paolo
toolkit/mozapps/downloads/nsHelperAppDlg.js
--- a/toolkit/mozapps/downloads/nsHelperAppDlg.js
+++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js
@@ -98,16 +98,17 @@ const PREF_BD_USEDOWNLOADDIR = "browser.
 const nsITimer = Components.interfaces.nsITimer;
 
 let downloadModule = {};
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
 Components.utils.import("resource://gre/modules/DownloadPaths.jsm");
 Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
 Components.utils.import("resource://gre/modules/Downloads.jsm");
+Components.utils.import("resource://gre/modules/FileUtils.jsm");
 Components.utils.import("resource://gre/modules/Task.jsm");
 
 /* ctor
  */
 function nsUnknownContentTypeDialog() {
   // Initialize data properties.
   this.mLauncher = null;
   this.mContext  = null;
@@ -211,17 +212,18 @@ nsUnknownContentTypeDialog.prototype = {
         // folder without prompting. Note that preference might not be set.
         let autodownload = false;
         try {
           autodownload = prefs.getBoolPref(PREF_BD_USEDOWNLOADDIR);
         } catch (e) { }
 
         if (autodownload) {
           // Retrieve the user's default download directory
-          let defaultFolder = yield Downloads.getPreferredDownloadsDirectory();
+          let preferredDir = yield Downloads.getPreferredDownloadsDirectory();
+          let defaultFolder = new FileUtils.File(preferredDir);
 
           try {
             result = this.validateLeafName(defaultFolder, aDefaultFile, aSuggestedFileExtension);
           }
           catch (ex) {
             if (ex.result == Components.results.NS_ERROR_FILE_ACCESS_DENIED) {
               let prompter = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
                                         getService(Components.interfaces.nsIPromptService);
@@ -269,19 +271,20 @@ nsUnknownContentTypeDialog.prototype = {
       if (aSuggestedFileExtension) {
         wildCardExtension += aSuggestedFileExtension;
         picker.appendFilter(this.mLauncher.MIMEInfo.description, wildCardExtension);
       }
 
       picker.appendFilters( nsIFilePicker.filterAll );
 
       // Default to lastDir if it is valid, otherwise use the user's default
-      // downloads directory.  userDownloadsDirectory should always return a
-      // valid directory, so we can safely default to it.
-      picker.displayDirectory = yield Downloads.getPreferredDownloadsDirectory();
+      // downloads directory.  getPreferredDownloadsDirectory should always 
+      // return a valid directory path, so we can safely default to it.
+      let preferredDir = yield Downloads.getPreferredDownloadsDirectory();
+      picker.displayDirectory = new FileUtils.File(preferredDir);
 
       gDownloadLastDir.getFileAsync(aLauncher.source, function LastDirCallback(lastDir) {
         if (lastDir && isUsableDirectory(lastDir))
           picker.displayDirectory = lastDir;
 
         if (picker.show() == nsIFilePicker.returnCancel) {
           // null result means user cancelled.
           aLauncher.saveDestinationAvailable(null);