diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index e5330c0beda2..9aad64042993 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -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 channel = do_QueryInterface(mRequest); + if (channel) { + nsCOMPtr 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); } } diff --git a/uriloader/exthandler/nsExternalHelperAppService.h b/uriloader/exthandler/nsExternalHelperAppService.h index 3813479ccd39..c677a72bfa22 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.h +++ b/uriloader/exthandler/nsExternalHelperAppService.h @@ -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