Bug 465756 - Ignore browser.helperApps.deleteTempFileOnExit not being set in private browsing; r=bz,sdwilsh sr=bz a=blocking1.9.1+
authorEhsan Akhgari <ehsan.akhgari@gmail.com>
Fri, 28 Nov 2008 09:08:56 -0800
changeset 22086 f8ade83cc5fbe0713e1be56b217261ed7e18d7ca
parent 22085 9bf88e2ecc45293646f6f3972e770193c1e2165b
child 22087 49519a2a183e97e5977b4783ccdad5bdc24b4ef4
child 22089 b2871b89d0ef9cc6a84cd0d15d0ad167007002fc
push id3794
push usersdwilsh@shawnwilsher.com
push dateFri, 28 Nov 2008 17:13:40 +0000
treeherdermozilla-central@f8ade83cc5fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sdwilsh, bz, blocking1.9.1
bugs465756
milestone1.9.1b3pre
Bug 465756 - Ignore browser.helperApps.deleteTempFileOnExit not being set in private browsing; r=bz,sdwilsh sr=bz a=blocking1.9.1+
toolkit/components/downloads/src/nsDownloadManager.cpp
uriloader/exthandler/nsExternalHelperAppService.cpp
uriloader/exthandler/nsExternalHelperAppService.h
--- a/toolkit/components/downloads/src/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/src/nsDownloadManager.cpp
@@ -2887,17 +2887,20 @@ nsDownload::OpenWithApplication()
     // 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) {
+  // Always schedule files to be deleted at the end of the private browsing
+  // mode, regardless of the value of the pref.
+  if (deleteTempFileOnExit ||
+      nsDownloadManager::gDownloadManagerService->mInPrivateBrowsing) {
     // Use the ExternalHelperAppService to push the temporary file to the list
     // of files to be deleted on exit.
     nsCOMPtr<nsPIExternalAppLauncher> appLauncher(do_GetService
                     (NS_EXTERNALHELPERAPPSERVICE_CONTRACTID));
 
     // Even if we are unable to get this service we return the result
     // of LaunchWithFile() which makes more sense.
     if (appLauncher)
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -2195,29 +2195,31 @@ nsresult nsExternalAppHandler::OpenWithA
       deleteTempFileOnExit = PR_TRUE;
 #else
       deleteTempFileOnExit = PR_FALSE;
 #endif
     }
 
     // make the tmp file readonly so users won't edit it and lose the changes
     // only if we're going to delete the file
-    if (deleteTempFileOnExit)
+    if (deleteTempFileOnExit || gExtProtSvc->InPrivateBrowsing())
       mFinalFileDestination->SetPermissions(0400);
 
     rv = mMimeInfo->LaunchWithFile(mFinalFileDestination);        
     if (NS_FAILED(rv))
     {
       // Send error notification.
       nsAutoString path;
       mFinalFileDestination->GetPath(path);
       SendStatusChange(kLaunchError, rv, nsnull, path);
       Cancel(rv); // Cancel, and clean up temp file.
     }
-    else if (deleteTempFileOnExit) {
+    // Always schedule files to be deleted at the end of the private browsing
+    // mode, regardless of the value of the pref.
+    else if (deleteTempFileOnExit || gExtProtSvc->InPrivateBrowsing()) {
       NS_ASSERTION(gExtProtSvc, "Service gone away!?");
       gExtProtSvc->DeleteTemporaryFileOnExit(mFinalFileDestination);
     }
   }
 
   return rv;
 }
 
--- a/uriloader/exthandler/nsExternalHelperAppService.h
+++ b/uriloader/exthandler/nsExternalHelperAppService.h
@@ -145,16 +145,22 @@ public:
    *                        application path.
    */
   virtual nsresult GetFileTokenForPath(const PRUnichar * platformAppPath,
                                        nsIFile ** aFile);
 
   virtual NS_HIDDEN_(nsresult) OSProtocolHandlerExists(const char *aScheme,
                                                        PRBool *aExists) = 0;
 
+  /**
+   * Simple accessor to let nsExternalAppHandler know if we are currently
+   * inside the private browsing mode.
+   */
+  PRBool InPrivateBrowsing() const { return mInPrivateBrowsing; }
+
 protected:
   /**
    * Searches the "extra" array of MIMEInfo objects for an object
    * with a specific type. If found, it will modify the passed-in
    * MIMEInfo. Otherwise, it will return an error and the MIMEInfo
    * will be untouched.
    * @param aContentType The type to search for.
    * @param aMIMEInfo    [inout] The mime info, if found