Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
Bug 722868 - Part 5: Use the channel's private browsing flag to deter…
Browse files Browse the repository at this point in the history
…mine how to handle the temporary file in nsExternalAppHandler::OpenWithApplication; r=bzbarsky
  • Loading branch information
ehsan committed Apr 25, 2012
1 parent 1ad0f4b commit eb1a591
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 15 additions & 2 deletions uriloader/exthandler/nsExternalHelperAppService.cpp
Expand Up @@ -108,6 +108,7 @@
#include "nsIDocShellTreeOwner.h"
#include "nsIDocShellTreeItem.h"
#include "ExternalHelperAppChild.h"
#include "nsILoadContext.h"

#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
Expand Down Expand Up @@ -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);
Expand All @@ -2211,7 +2224,7 @@ nsresult nsExternalAppHandler::OpenWithApplication()
else if (deleteTempFileOnExit) {
mExtProtSvc->DeleteTemporaryFileOnExit(mFinalFileDestination);
}
else if (mExtProtSvc->InPrivateBrowsing()) {
else if (inPrivateBrowsing) {
mExtProtSvc->DeleteTemporaryPrivateFileWhenPossible(mFinalFileDestination);
}
}
Expand Down
6 changes: 0 additions & 6 deletions uriloader/exthandler/nsExternalHelperAppService.h
Expand Up @@ -111,12 +111,6 @@ class nsExternalHelperAppService
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
Expand Down

0 comments on commit eb1a591

Please sign in to comment.