Bug 722868 - Part 1: Add the deleteTemporaryPrivateFileWhenPossible API; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2012-04-24 22:56:55 -04:00
parent 477f96fa71
commit 953e8ce58b
3 changed files with 28 additions and 6 deletions

View File

@ -923,7 +923,10 @@ NS_IMETHODIMP nsExternalHelperAppService::GetApplicationDescription(const nsACSt
// Methods related to deleting temporary files on exit // Methods related to deleting temporary files on exit
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsExternalHelperAppService::DeleteTemporaryFileOnExit(nsIFile * aTemporaryFile) /* static */
nsresult
nsExternalHelperAppService::DeleteTemporaryFileHelper(nsIFile * aTemporaryFile,
nsCOMArray<nsIFile> &aFileList)
{ {
bool isFile = false; bool isFile = false;
@ -931,14 +934,23 @@ NS_IMETHODIMP nsExternalHelperAppService::DeleteTemporaryFileOnExit(nsIFile * aT
aTemporaryFile->IsFile(&isFile); aTemporaryFile->IsFile(&isFile);
if (!isFile) return NS_OK; if (!isFile) return NS_OK;
if (mInPrivateBrowsing) aFileList.AppendObject(aTemporaryFile);
mTemporaryPrivateFilesList.AppendObject(aTemporaryFile);
else
mTemporaryFilesList.AppendObject(aTemporaryFile);
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsExternalHelperAppService::DeleteTemporaryFileOnExit(nsIFile* aTemporaryFile)
{
return DeleteTemporaryFileHelper(aTemporaryFile, mTemporaryFilesList);
}
NS_IMETHODIMP
nsExternalHelperAppService::DeleteTemporaryPrivateFileWhenPossible(nsIFile* aTemporaryFile)
{
return DeleteTemporaryFileHelper(aTemporaryFile, mTemporaryPrivateFilesList);
}
void nsExternalHelperAppService::FixFilePermissions(nsIFile* aFile) void nsExternalHelperAppService::FixFilePermissions(nsIFile* aFile)
{ {
// This space intentionally left blank // This space intentionally left blank

View File

@ -172,6 +172,11 @@ protected:
* Helper function for ExpungeTemporaryFiles and ExpungeTemporaryPrivateFiles * Helper function for ExpungeTemporaryFiles and ExpungeTemporaryPrivateFiles
*/ */
static void ExpungeTemporaryFilesHelper(nsCOMArray<nsIFile> &fileList); static void ExpungeTemporaryFilesHelper(nsCOMArray<nsIFile> &fileList);
/**
* Helper function for DeleteTemporaryFileOnExit and DeleteTemporaryPrivateFileWhenPossible
*/
static nsresult DeleteTemporaryFileHelper(nsIFile* aTemporaryFile,
nsCOMArray<nsIFile> &aFileList);
/** /**
* Functions related to the tempory file cleanup service provided by * Functions related to the tempory file cleanup service provided by
* nsExternalHelperAppService * nsExternalHelperAppService

View File

@ -53,7 +53,7 @@ interface nsIExternalHelperAppService : nsISupports
* This is a private interface shared between external app handlers and the platform specific * This is a private interface shared between external app handlers and the platform specific
* external helper app service * external helper app service
*/ */
[scriptable, uuid(d0b5d7d3-9565-403d-9fb5-e5089c4567c6)] [scriptable, uuid(6613e2e7-feab-4e3a-bb1f-b03200d544ec)]
interface nsPIExternalAppLauncher : nsISupports interface nsPIExternalAppLauncher : nsISupports
{ {
/** /**
@ -62,6 +62,11 @@ interface nsPIExternalAppLauncher : nsISupports
* @param aTemporaryFile A temporary file we should delete on exit. * @param aTemporaryFile A temporary file we should delete on exit.
*/ */
void deleteTemporaryFileOnExit(in nsIFile aTemporaryFile); void deleteTemporaryFileOnExit(in nsIFile aTemporaryFile);
/**
* Delete a temporary file created inside private browsing mode when
* the private browsing mode has ended.
*/
void deleteTemporaryPrivateFileWhenPossible(in nsIFile aTemporaryFile);
}; };
/** /**