Backout a6175c97f365, 3ceeeaf0519f, bde34cebdcdc, 66dfa9606626, 86762d8c4de9, 717f908c990a, aa83d71fe7ee (bug 722868) for compilation failures

This commit is contained in:
Ed Morley 2012-06-28 19:00:30 +01:00
parent fb509773b1
commit a82421537c
5 changed files with 46 additions and 95 deletions

View File

@ -2879,13 +2879,8 @@ nsDownload::OpenWithApplication()
// Even if we are unable to get this service we return the result
// of LaunchWithFile() which makes more sense.
if (appLauncher) {
if (nsDownloadManager::gDownloadManagerService->mInPrivateBrowsing) {
(void)appLauncher->DeleteTemporaryPrivateFileWhenPossible(target);
} else {
(void)appLauncher->DeleteTemporaryFileOnExit(target);
}
}
if (appLauncher)
(void)appLauncher->DeleteTemporaryFileOnExit(target);
}
return retVal;

View File

@ -119,28 +119,10 @@ var gViewSourceUtils = {
webBrowserPersist.progressListener = this.viewSourceProgressListener;
webBrowserPersist.saveURI(uri, null, null, null, null, file);
let fromPrivateWindow = false;
if (aDocument) {
try {
fromPrivateWindow =
aDocument.defaultView
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsILoadContext)
.usePrivateBrowsing;
} catch (e) {
}
}
let helperService = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"]
.getService(Components.interfaces.nsPIExternalAppLauncher);
if (fromPrivateWindow) {
// register the file to be deleted when possible
helperService.deleteTemporaryPrivateFileWhenPossible(file);
} else {
// register the file to be deleted on app exit
helperService.deleteTemporaryFileOnExit(file);
}
// register the file to be deleted on app exit
Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"]
.getService(Components.interfaces.nsPIExternalAppLauncher)
.deleteTemporaryFileOnExit(file);
} else {
// we'll use nsIWebPageDescriptor to get the source because it may
// not have to refetch the file from the server
@ -282,22 +264,10 @@ var gViewSourceUtils = {
coStream.close();
foStream.close();
let fromPrivateWindow =
this.data.doc.defaultView
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsILoadContext)
.usePrivateBrowsing;
let helperService = Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"]
.getService(Components.interfaces.nsPIExternalAppLauncher);
if (fromPrivateWindow) {
// register the file to be deleted when possible
helperService.deleteTemporaryPrivateFileWhenPossible(this.file);
} else {
// register the file to be deleted on app exit
helperService.deleteTemporaryFileOnExit(this.file);
}
// register the file to be deleted on app exit
Components.classes["@mozilla.org/uriloader/external-helper-app-service;1"]
.getService(Components.interfaces.nsPIExternalAppLauncher)
.deleteTemporaryFileOnExit(this.file);
}
var editorArgs = gViewSourceUtils.buildEditorArgs(this.file.path,

View File

@ -100,13 +100,14 @@
#include "plbase64.h"
#include "prmem.h"
#include "nsIPrivateBrowsingService.h"
#include "ContentChild.h"
#include "nsXULAppAPI.h"
#include "nsPIDOMWindow.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIDocShellTreeItem.h"
#include "ExternalHelperAppChild.h"
#include "nsILoadContext.h"
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
@ -503,11 +504,18 @@ NS_IMPL_ISUPPORTS6(
nsIObserver,
nsISupportsWeakReference)
nsExternalHelperAppService::nsExternalHelperAppService()
nsExternalHelperAppService::nsExternalHelperAppService() :
mInPrivateBrowsing(false)
{
}
nsresult nsExternalHelperAppService::Init()
{
nsCOMPtr<nsIPrivateBrowsingService> pbs =
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
if (pbs) {
pbs->GetPrivateBrowsingEnabled(&mInPrivateBrowsing);
}
// Add an observer for profile change
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (!obs)
@ -523,7 +531,7 @@ nsresult nsExternalHelperAppService::Init()
nsresult rv = obs->AddObserver(this, "profile-before-change", true);
NS_ENSURE_SUCCESS(rv, rv);
return obs->AddObserver(this, "last-pb-context-exited", true);
return obs->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, true);
}
nsExternalHelperAppService::~nsExternalHelperAppService()
@ -915,10 +923,7 @@ NS_IMETHODIMP nsExternalHelperAppService::GetApplicationDescription(const nsACSt
// Methods related to deleting temporary files on exit
//////////////////////////////////////////////////////////////////////////////////////////////////////
/* static */
nsresult
nsExternalHelperAppService::DeleteTemporaryFileHelper(nsIFile * aTemporaryFile,
nsCOMArray<nsILocalFile> &aFileList)
NS_IMETHODIMP nsExternalHelperAppService::DeleteTemporaryFileOnExit(nsIFile * aTemporaryFile)
{
bool isFile = false;
@ -926,23 +931,14 @@ nsExternalHelperAppService::DeleteTemporaryFileHelper(nsIFile * aTemporaryFile,
aTemporaryFile->IsFile(&isFile);
if (!isFile) return NS_OK;
aFileList.AppendObject(localFile);
if (mInPrivateBrowsing)
mTemporaryPrivateFilesList.AppendObject(aTemporaryFile);
else
mTemporaryFilesList.AppendObject(aTemporaryFile);
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)
{
// This space intentionally left blank
@ -1056,8 +1052,13 @@ nsExternalHelperAppService::Observe(nsISupports *aSubject, const char *aTopic, c
{
if (!strcmp(aTopic, "profile-before-change")) {
ExpungeTemporaryFiles();
} else if (!strcmp(aTopic, "last-pb-context-exited")) {
ExpungeTemporaryPrivateFiles();
} else if (!strcmp(aTopic, NS_PRIVATE_BROWSING_SWITCH_TOPIC)) {
if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_ENTER).Equals(someData))
mInPrivateBrowsing = true;
else if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_LEAVE).Equals(someData)) {
mInPrivateBrowsing = false;
ExpungeTemporaryPrivateFiles();
}
}
return NS_OK;
}
@ -2179,21 +2180,9 @@ 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 || inPrivateBrowsing)
if (deleteTempFileOnExit || mExtProtSvc->InPrivateBrowsing())
mFinalFileDestination->SetPermissions(0400);
rv = mMimeInfo->LaunchWithFile(mFinalFileDestination);
@ -2207,12 +2196,9 @@ nsresult nsExternalAppHandler::OpenWithApplication()
}
// Always schedule files to be deleted at the end of the private browsing
// mode, regardless of the value of the pref.
else if (deleteTempFileOnExit) {
else if (deleteTempFileOnExit || mExtProtSvc->InPrivateBrowsing()) {
mExtProtSvc->DeleteTemporaryFileOnExit(mFinalFileDestination);
}
else if (inPrivateBrowsing) {
mExtProtSvc->DeleteTemporaryPrivateFileWhenPossible(mFinalFileDestination);
}
}
return rv;

View File

@ -111,6 +111,12 @@ 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
@ -166,11 +172,6 @@ protected:
* Helper function for ExpungeTemporaryFiles and ExpungeTemporaryPrivateFiles
*/
static void ExpungeTemporaryFilesHelper(nsCOMArray<nsIFile> &fileList);
/**
* Helper function for DeleteTemporaryFileOnExit and DeleteTemporaryPrivateFileWhenPossible
*/
static nsresult DeleteTemporaryFileHelper(nsIFile* aTemporaryFile,
nsCOMArray<nsILocalFile> &aFileList);
/**
* Functions related to the tempory file cleanup service provided by
* nsExternalHelperAppService
@ -191,6 +192,10 @@ protected:
* added during the private browsing mode)
*/
nsCOMArray<nsIFile> mTemporaryPrivateFilesList;
/**
* Whether we are in private browsing mode
*/
bool mInPrivateBrowsing;
};
/**

View File

@ -53,7 +53,7 @@ interface nsIExternalHelperAppService : nsISupports
* This is a private interface shared between external app handlers and the platform specific
* external helper app service
*/
[scriptable, uuid(6613e2e7-feab-4e3a-bb1f-b03200d544ec)]
[scriptable, uuid(d0b5d7d3-9565-403d-9fb5-e5089c4567c6)]
interface nsPIExternalAppLauncher : nsISupports
{
/**
@ -62,11 +62,6 @@ interface nsPIExternalAppLauncher : nsISupports
* @param aTemporaryFile A temporary file we should delete on exit.
*/
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);
};
/**