Bug 722868 - Part 5: Use the channel's private browsing flag to determine how to handle the temporary file in nsExternalAppHandler::OpenWithApplication; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2012-04-24 23:31:35 -04:00
parent 5259bfd587
commit 70c16c83cb
2 changed files with 15 additions and 8 deletions

View File

@ -108,6 +108,7 @@
#include "nsIDocShellTreeOwner.h"
#include "nsIDocShellTreeItem.h"
#include "ExternalHelperAppChild.h"
#include "nsILoadContext.h"
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
@ -2192,9 +2193,21 @@ nsresult nsExternalAppHandler::OpenWithApplication()
false);
#endif
// See whether the channel has been opened in private browsing mode
bool inPrivateBrowsing = false;
NS_ASSERTION(mRequest, "This should never be called with a null request");
nsCOMPtr<nsIChannel> channel = do_QueryInterface(mRequest);
if (channel) {
nsCOMPtr<nsILoadContext> ctx;
NS_QueryNotificationCallbacks(channel, ctx);
if (ctx) {
inPrivateBrowsing = ctx->UsePrivateBrowsing();
}
}
// 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 || mExtProtSvc->InPrivateBrowsing())
if (deleteTempFileOnExit || inPrivateBrowsing)
mFinalFileDestination->SetPermissions(0400);
rv = mMimeInfo->LaunchWithFile(mFinalFileDestination);
@ -2211,7 +2224,7 @@ nsresult nsExternalAppHandler::OpenWithApplication()
else if (deleteTempFileOnExit) {
mExtProtSvc->DeleteTemporaryFileOnExit(mFinalFileDestination);
}
else if (mExtProtSvc->InPrivateBrowsing()) {
else if (inPrivateBrowsing) {
mExtProtSvc->DeleteTemporaryPrivateFileWhenPossible(mFinalFileDestination);
}
}

View File

@ -111,12 +111,6 @@ public:
virtual NS_HIDDEN_(nsresult) OSProtocolHandlerExists(const char *aScheme,
bool *aExists) = 0;
/**
* Simple accessor to let nsExternalAppHandler know if we are currently
* inside the private browsing mode.
*/
bool InPrivateBrowsing() const { return mInPrivateBrowsing; }
protected:
/**
* Searches the "extra" array of MIMEInfo objects for an object