Bug 1114594 - Remove promptForSaveToFile in favor of promptForSaveToFileAsync. r=paolo

This commit is contained in:
Ganesh Sahukari 2015-01-20 10:11:00 +00:00
parent 94a946b262
commit a4f09b67d8
10 changed files with 9 additions and 92 deletions

View File

@ -33,14 +33,6 @@ HelperAppLauncherDialog.prototype = {
aLauncher.saveToDisk(null, false);
},
promptForSaveToFile: function(aLauncher,
aContext,
aDefaultFile,
aSuggestedFileExt,
aForcePrompt) {
throw Cr.NS_ERROR_NOT_AVAILABLE;
},
promptForSaveToFileAsync: function(aLauncher,
aContext,
aDefaultFile,

View File

@ -138,10 +138,6 @@ HelperAppLauncherDialog.prototype = {
messageContainer.appendChild(fragment);
},
promptForSaveToFile: function hald_promptForSaveToFile(aLauncher, aContext, aDefaultFile, aSuggestedFileExt, aForcePrompt) {
throw new Components.Exception("Async version must be used", Cr.NS_ERROR_NOT_AVAILABLE);
},
promptForSaveToFileAsync: function hald_promptForSaveToFileAsync(aLauncher, aContext, aDefaultFile, aSuggestedFileExt, aForcePrompt) {
let file = null;
let prefs = Services.prefs;

View File

@ -236,11 +236,6 @@ HelperAppLauncherDialog.prototype = {
Services.prefs.clearUserPref(this._getPrefName(mime));
},
promptForSaveToFile: function () {
throw new Components.Exception("Async version must be used",
Cr.NS_ERROR_NOT_AVAILABLE);
},
promptForSaveToFileAsync: function (aLauncher, aContext, aDefaultFile,
aSuggestedFileExt, aForcePrompt) {
Task.spawn(function* () {

View File

@ -15,9 +15,7 @@ HelperAppDlg.prototype = {
show: function (launcher, ctx, reason) {
launcher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.saveToDisk;
launcher.launchWithApplication(null, false);
},
promptForSaveToFile: function (launcher, ctx, defaultFile, suggestedExtension, forcePrompt) { }
}
}

View File

@ -793,15 +793,6 @@ add_task(function test_common_initialize()
createInstance: function (aOuter, aIid) {
return {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIHelperAppLauncherDialog]),
promptForSaveToFile: function (aLauncher, aWindowContext,
aDefaultFileName,
aSuggestedFileExtension,
aForcePrompt)
{
throw new Components.Exception(
"Synchronous promptForSaveToFile not implemented.",
Cr.NS_ERROR_NOT_AVAILABLE);
},
promptForSaveToFileAsync: function (aLauncher, aWindowContext,
aDefaultFileName,
aSuggestedFileExtension,

View File

@ -195,22 +195,6 @@ nsUnknownContentTypeDialog.prototype = {
bundle.GetStringFromName("badPermissions"));
},
// promptForSaveToFile: Display file picker dialog and return selected file.
// This is called by the External Helper App Service
// after the ucth dialog calls |saveToDisk| with a null
// target filename (no target, therefore user must pick).
//
// Alternatively, if the user has selected to have all
// files download to a specific location, return that
// location and don't ask via the dialog.
//
// Note - this function is called without a dialog, so it cannot access any part
// of the dialog XUL as other functions on this object do.
promptForSaveToFile: function(aLauncher, aContext, aDefaultFile, aSuggestedFileExtension, aForcePrompt) {
throw new Components.Exception("Async version must be used", Components.results.NS_ERROR_NOT_AVAILABLE);
},
promptForSaveToFileAsync: function(aLauncher, aContext, aDefaultFile, aSuggestedFileExtension, aForcePrompt) {
var result = null;

View File

@ -2237,24 +2237,16 @@ void nsExternalAppHandler::RequestSaveDestination(const nsAFlatString &aDefaultF
// picker is up would cause Cancel() to be called, and the dialog would be
// released, which would release this object too, which would crash.
// See Bug 249143
nsIFile* fileToUse;
nsRefPtr<nsExternalAppHandler> kungFuDeathGrip(this);
nsCOMPtr<nsIHelperAppLauncherDialog> dlg(mDialog);
rv = mDialog->PromptForSaveToFile(this,
GetDialogParent(),
aDefaultFile.get(),
aFileExtension.get(),
mForceSave, &fileToUse);
if (rv == NS_ERROR_NOT_AVAILABLE) {
// we need to use the async version -> nsIHelperAppLauncherDialog.promptForSaveToFileAsync.
rv = mDialog->PromptForSaveToFileAsync(this,
GetDialogParent(),
aDefaultFile.get(),
aFileExtension.get(),
mForceSave);
} else {
SaveDestinationAvailable(rv == NS_OK ? fileToUse : nullptr);
rv = mDialog->PromptForSaveToFileAsync(this,
GetDialogParent(),
aDefaultFile.get(),
aFileExtension.get(),
mForceSave);
if (NS_FAILED(rv)) {
Cancel(NS_BINDING_ABORTED);
}
}

View File

@ -57,32 +57,6 @@ interface nsIHelperAppLauncherDialog : nsISupports {
in nsISupports aWindowContext,
in unsigned long aReason);
/**
* Invoke a save-to-file dialog instead of the full fledged helper app dialog.
* Returns the a nsIFile for the file name/location selected.
*
* @param aLauncher
* A nsIHelperAppLauncher to be invoked when a file is selected.
* @param aWindowContext
* Window associated with action.
* @param aDefaultFileName
* Default file name to provide (can be null)
* @param aSuggestedFileExtension
* Sugested file extension
* @param aForcePrompt
* Set to true to force prompting the user for thet file
* name/location, otherwise perferences may control if the user is
* prompted.
*
* @throws NS_ERROR_NOT_AVAILABLE if the async version of this function
* should be used.
*/
nsIFile promptForSaveToFile(in nsIHelperAppLauncher aLauncher,
in nsISupports aWindowContext,
in wstring aDefaultFileName,
in wstring aSuggestedFileExtension,
in boolean aForcePrompt);
/**
* Async invoke a save-to-file dialog instead of the full fledged helper app
* dialog. When the file is chosen (or the dialog is closed), the callback

View File

@ -84,9 +84,6 @@ function load() {
"The filename should be correctly sanitized");
gCallback();
},
promptForSaveToFile: function(aLauncher, aWindowContext, aDefaultFileName, aSuggestedFileExtension, aForcePrompt) {
return null;
},
QueryInterface: function(aIID) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (aIID.equals(SpecialPowers.Ci.nsISupports) ||

View File

@ -61,9 +61,7 @@ HelperAppDlg.prototype = {
show: function (launcher, ctx, reason, usePrivateUI) {
launcher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.saveToFile;
launcher.launchWithApplication(null, false);
},
promptForSaveToFile: function (launcher, ctx, defaultFile, suggestedExtension, forcePrompt) { }
}
}
// Stolen from XPCOMUtils, since this handy function is not public there