Bug 401316 - Open-with downloads are readonly. r=biesi, sr=biesi, a1.9=damons

This commit is contained in:
edward.lee@engineering.uiuc.edu 2008-02-25 13:38:54 -08:00
Родитель f0f685cbd8
Коммит 547763099f
1 изменённых файлов: 21 добавлений и 25 удалений

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

@ -2068,8 +2068,25 @@ nsresult nsExternalAppHandler::OpenWithApplication()
// if a stop request was already issued then proceed with launching the application. // if a stop request was already issued then proceed with launching the application.
if (mStopRequestIssued) if (mStopRequestIssued)
{ {
PRBool deleteTempFileOnExit;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!prefs || NS_FAILED(prefs->GetBoolPref(
"browser.helperApps.deleteTempFileOnExit", &deleteTempFileOnExit))) {
// No prefservice or no pref set; use default value
#if !defined(XP_MACOSX)
// Mac users have been very verbal about temp files being deleted on
// app exit - they don't like it - but we'll continue to do this on
// other platforms for now.
deleteTempFileOnExit = PR_TRUE;
#else
deleteTempFileOnExit = PR_FALSE;
#endif
}
// make the tmp file readonly so users won't edit it and lose the changes // make the tmp file readonly so users won't edit it and lose the changes
mFinalFileDestination->SetPermissions(0400); // only if we're going to delete the file
if (deleteTempFileOnExit)
mFinalFileDestination->SetPermissions(0400);
rv = mMimeInfo->LaunchWithFile(mFinalFileDestination); rv = mMimeInfo->LaunchWithFile(mFinalFileDestination);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
@ -2080,30 +2097,9 @@ nsresult nsExternalAppHandler::OpenWithApplication()
SendStatusChange(kLaunchError, rv, nsnull, path); SendStatusChange(kLaunchError, rv, nsnull, path);
Cancel(rv); // Cancel, and clean up temp file. Cancel(rv); // Cancel, and clean up temp file.
} }
else else if (deleteTempFileOnExit) {
{ NS_ASSERTION(gExtProtSvc, "Service gone away!?");
PRBool deleteTempFileOnExit; gExtProtSvc->DeleteTemporaryFileOnExit(mFinalFileDestination);
nsresult result = NS_ERROR_NOT_AVAILABLE; // don't return this!
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
result = prefs->GetBoolPref("browser.helperApps.deleteTempFileOnExit",
&deleteTempFileOnExit);
}
if (NS_FAILED(result)) {
// No pref set; use default value
#if !defined(XP_MACOSX)
// Mac users have been very verbal about temp files being deleted on
// app exit - they don't like it - but we'll continue to do this on
// other platforms for now.
deleteTempFileOnExit = PR_TRUE;
#else
deleteTempFileOnExit = PR_FALSE;
#endif
}
if (deleteTempFileOnExit) {
NS_ASSERTION(gExtProtSvc, "Service gone away!?");
gExtProtSvc->DeleteTemporaryFileOnExit(mFinalFileDestination);
}
} }
} }