Bug #80866 --> new helper app dialog design. Also fixes 87888

r=hewitt
sr=sspitzer
This commit is contained in:
mscott%netscape.com 2001-06-28 02:18:54 +00:00
Родитель 8c372a328b
Коммит c00f3b6094
2 изменённых файлов: 18 добавлений и 19 удалений

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

@ -832,24 +832,11 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
httpChannel->SetApplyConversion( PR_FALSE );
}
PRBool forceAlwaysAsk = PR_TRUE;
nsCOMPtr<nsIPrefService> prefs =
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(prefs, &rv);
if (NS_SUCCEEDED(rv))
rv = prefBranch->GetBoolPref(FORCE_ALWAYS_ASK_PREF, &forceAlwaysAsk);
}
// now that the temp file is set up, find out if we need to invoke a dialog asking the user what
// they want us to do with this content...
PRBool alwaysAsk = PR_TRUE;
if (forceAlwaysAsk)
alwaysAsk = PR_TRUE;
else
mMimeInfo->GetAlwaysAskBeforeHandling(&alwaysAsk);
mMimeInfo->GetAlwaysAskBeforeHandling(&alwaysAsk);
if (alwaysAsk)
{
// do this first! make sure we don't try to take an action until the user tells us what they want to do
@ -996,7 +983,7 @@ nsresult nsExternalAppHandler::ShowProgressDialog()
return rv;
}
nsresult nsExternalAppHandler::PromptForSaveToFile(nsILocalFile ** aNewFile, const PRUnichar * aDefaultFile)
nsresult nsExternalAppHandler::PromptForSaveToFile(nsILocalFile ** aNewFile, const PRUnichar * aDefaultFile, const PRUnichar * aFileExtension)
{
// invoke the dialog!!!!! use mWindowContext as the window context parameter for the dialog request
// XXX Convert to use file picker?
@ -1008,7 +995,10 @@ nsresult nsExternalAppHandler::PromptForSaveToFile(nsILocalFile ** aNewFile, con
NS_ENSURE_SUCCESS(rv, rv);
}
rv = mDialog->PromptForSaveToFile(mWindowContext, aDefaultFile, NS_ConvertASCIItoUCS2(mTempFileExtension).get(), aNewFile);
// we want to explicitly unescape aDefaultFile b4 passing into the dialog. we can't unescape
// it because the dialog is implemented by a JS component which doesn't have a window so no unescape routine is defined...
rv = mDialog->PromptForSaveToFile(mWindowContext, aDefaultFile, aFileExtension, aNewFile);
return rv;
}
@ -1070,9 +1060,18 @@ NS_IMETHODIMP nsExternalAppHandler::SaveToDisk(nsIFile * aNewFileLocation, PRBoo
nsCOMPtr<nsILocalFile> fileToUse;
mTempFile->GetUnicodeLeafName(getter_Copies(leafName));
if (mSuggestedFileName.IsEmpty())
rv = PromptForSaveToFile(getter_AddRefs(fileToUse), leafName);
rv = PromptForSaveToFile(getter_AddRefs(fileToUse), leafName, NS_ConvertASCIItoUCS2(mTempFileExtension).get());
else
rv = PromptForSaveToFile(getter_AddRefs(fileToUse), mSuggestedFileName.GetUnicode());
{
nsAutoString fileExt;
PRInt32 pos = mSuggestedFileName.RFindChar(PRUnichar('.'));
if (pos >= 0)
mSuggestedFileName.Mid(fileExt, pos, -1);
if (fileExt.IsEmpty())
fileExt = NS_ConvertASCIItoUCS2(mTempFileExtension).get();
rv = PromptForSaveToFile(getter_AddRefs(fileToUse), mSuggestedFileName.GetUnicode(), fileExt.get());
}
if (NS_FAILED(rv))
return Cancel();

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

@ -185,7 +185,7 @@ protected:
// if the user tells us how they want to dispose of the content and we still haven't finished downloading while
// they were deciding, then throw a progress dialog so they know what's going on...
nsresult ShowProgressDialog();
nsresult PromptForSaveToFile(nsILocalFile ** aNewFile, const PRUnichar * aDefaultFile);
nsresult PromptForSaveToFile(nsILocalFile ** aNewFile, const PRUnichar * aDefaultFile, const PRUnichar * aDefaultFileExt);
// if the passed in channel is an nsIHTTPChannel, we'll attempt to extract a suggested file name
// from the content disposition header...
void ExtractSuggestedFileNameFromChannel(nsIChannel * aChannel);