Bug 722868 - Part 4: Make the view source window aware of the deleteTemporaryPrivateFileWhenPossible API; r=Mossop

This commit is contained in:
Ehsan Akhgari 2012-04-24 23:14:16 -04:00
Родитель 8fa8c9e94c
Коммит 2d1d49791d
1 изменённых файлов: 38 добавлений и 8 удалений

Просмотреть файл

@ -119,10 +119,28 @@ var gViewSourceUtils = {
webBrowserPersist.progressListener = this.viewSourceProgressListener;
webBrowserPersist.saveURI(uri, null, null, null, null, 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);
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);
}
} else {
// we'll use nsIWebPageDescriptor to get the source because it may
// not have to refetch the file from the server
@ -264,10 +282,22 @@ var gViewSourceUtils = {
coStream.close();
foStream.close();
// 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);
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);
}
}
var editorArgs = gViewSourceUtils.buildEditorArgs(this.file.path,