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
Родитель ae38c7ba8a
Коммит 27ef62b0d3
10 изменённых файлов: 9 добавлений и 92 удалений

Просмотреть файл

@ -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,

Просмотреть файл

@ -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;

Просмотреть файл

@ -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* () {

Просмотреть файл

@ -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) { }
}
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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) ||

Просмотреть файл

@ -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