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 4: Make the view source window aware of the deleteT…
Browse files Browse the repository at this point in the history
…emporaryPrivateFileWhenPossible API; r=Mossop
  • Loading branch information
ehsan committed Apr 25, 2012
1 parent e303a91 commit 1ad0f4b
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions toolkit/components/viewsource/content/viewSourceUtils.js
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1ad0f4b

Please sign in to comment.