зеркало из https://github.com/mozilla/gecko-dev.git
Bug #47799 --> push prompt for file name over to ucth handler code so we don't bring
UI up from the uriloader. This allows us to properly use a string bundle for text in the dialog. this is prep work for the real fix for this bug. r=law
This commit is contained in:
Родитель
e059927594
Коммит
823a02d85d
|
@ -24,6 +24,7 @@
|
|||
#include "domstubs.idl"
|
||||
|
||||
interface nsIHelperAppLauncher;
|
||||
interface nsILocalFile;
|
||||
|
||||
// nsIHelperAppLauncherDialog
|
||||
// ==========================
|
||||
|
@ -36,6 +37,12 @@ interface nsIHelperAppLauncherDialog : nsISupports {
|
|||
// Show confirmation dialog for launching application (or "save to
|
||||
// disk") for content specified by aLauncher.
|
||||
void show( in nsIHelperAppLauncher aLauncher, in nsISupports aContext );
|
||||
|
||||
// invoke a save to file dialog instead of the full fledged helper app dialog.
|
||||
// aDefaultFileName --> default file name to provide (can be null)
|
||||
// aSuggestedFileExtension --> sugested file extension
|
||||
// aFileLocation --> return value for the file location
|
||||
void promptForSaveToFile(in nsISupports aWindowContext, in wstring aDefaultFile, in wstring aSuggestedFileExtension, out nsILocalFile aFileLocation);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
chooseAppFilePickerTitle=Choose Viewer
|
||||
chooseFileFilePickerTitle=Choose File
|
||||
saveDialogTitle=Enter name of file to save to...
|
||||
|
|
|
@ -35,6 +35,11 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIExternalHelperAppService.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIFilePicker.h"
|
||||
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
#define HELPERAPP_DIALOG_URL "chrome://global/locale/helperAppLauncher.properties"
|
||||
|
||||
// {42770B50-03E9-11d3-8068-00600811A9C3}
|
||||
#define NS_UNKNOWNCONTENTTYPEHANDLER_CID \
|
||||
|
@ -219,6 +224,42 @@ nsUnknownContentTypeHandler::Show( nsIHelperAppLauncher *aLauncher, nsISupports
|
|||
return rv;
|
||||
}
|
||||
|
||||
// prompt the user for a file name to save the unknown content to as instructed
|
||||
NS_IMETHODIMP
|
||||
nsUnknownContentTypeHandler::PromptForSaveToFile(nsISupports * aWindowContext, const PRUnichar * aDefaultFile, const PRUnichar * aSuggestedFileExtension, nsILocalFile ** aNewFile)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("component://mozilla/filepicker", &rv);
|
||||
if (filePicker)
|
||||
{
|
||||
nsCOMPtr<nsIStringBundleService> stringService = do_GetService(kStringBundleServiceCID);
|
||||
nsCOMPtr<nsIStringBundle> stringBundle;
|
||||
NS_ENSURE_TRUE(stringService, NS_ERROR_FAILURE);
|
||||
|
||||
NS_ENSURE_SUCCESS(stringService->CreateBundle(HELPERAPP_DIALOG_URL, nsnull, getter_AddRefs(stringBundle)),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
nsXPIDLString windowTitle;
|
||||
stringBundle->GetStringFromName(NS_LITERAL_STRING("saveDialogTitle"), getter_Copies(windowTitle));
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> parent( do_GetInterface( aWindowContext ) );
|
||||
filePicker->Init(parent, windowTitle, nsIFilePicker::modeSave);
|
||||
filePicker->SetDefaultString(aDefaultFile);
|
||||
filePicker->AppendFilter(aSuggestedFileExtension, aSuggestedFileExtension);
|
||||
filePicker->AppendFilters(nsIFilePicker::filterAll);
|
||||
|
||||
PRInt16 dialogResult;
|
||||
filePicker->Show(&dialogResult);
|
||||
if (dialogResult == nsIFilePicker::returnCancel)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
else
|
||||
rv = filePicker->GetFile(aNewFile);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUnknownContentTypeHandler::CreateComponent( nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
|
|
Загрузка…
Ссылка в новой задаче