mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Bug 875731 - Replace callers of nsIDownloadManager.usersDownloadsDirectory with Downloads.getUserDownloadsDirectory mobile/andriod/. r=mfinkle
This commit is contained in:
parent
6037be2b03
commit
14924f9c42
@ -13,6 +13,11 @@ const URI_GENERIC_ICON_DOWNLOAD = "drawable://alert_download";
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
|
||||
"resource://gre/modules/Downloads.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// HelperApp Launcher Dialog
|
||||
// -----------------------------------------------------------------------
|
||||
@ -30,15 +35,16 @@ HelperAppLauncherDialog.prototype = {
|
||||
},
|
||||
|
||||
promptForSaveToFile: function hald_promptForSaveToFile(aLauncher, aContext, aDefaultFile, aSuggestedFileExt, aForcePrompt) {
|
||||
// Retrieve the user's default download directory
|
||||
let dnldMgr = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
|
||||
let defaultFolder = dnldMgr.userDownloadsDirectory;
|
||||
return Task.spawn(function() {
|
||||
// Retrieve the user's default download directory
|
||||
let defaultFolder = yield Downloads.getPreferredDownloadsDirectory();
|
||||
|
||||
try {
|
||||
file = this.validateLeafName(defaultFolder, aDefaultFile, aSuggestedFileExt);
|
||||
} catch (e) { }
|
||||
try {
|
||||
file = this.validateLeafName(defaultFolder, aDefaultFile, aSuggestedFileExt);
|
||||
} catch (e) { }
|
||||
|
||||
return file;
|
||||
throw new Task.Result(file);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
validateLeafName: function hald_validateLeafName(aLocalFile, aLeafName, aFileExt) {
|
||||
|
Loading…
Reference in New Issue
Block a user