Fix for bug 84106. Save As for a page with post data tries to get the page out of the cache using its cache key. If the page is not in the cache, it prompts before re-posting. r=adamlock, sr=rpotts

This commit is contained in:
vidur%netscape.com 2006-07-29 05:37:13 +00:00
Родитель b19767d477
Коммит 43a3f41db8
2 изменённых файлов: 9 добавлений и 4 удалений

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

@ -79,21 +79,23 @@
function savePage(url)
{
var postData = null; // No post data, usually.
var cacheKey = null;
// Default is to save current page.
if ( !url )
url = window._content.location.href;
try {
var sessionHistory = getWebNavigation().sessionHistory;
var entry = sessionHistory.getEntryAtIndex(sessionHistory.index, false);
var entry = sessionHistory.getEntryAtIndex(sessionHistory.index, false).QueryInterface(Components.interfaces.nsISHEntry);
postData = entry.postData;
cacheKey = entry.cacheKey;
} catch(e) {
}
// Use stream xfer component to prompt for destination and save.
var xfer = Components.classes["@mozilla.org/appshell/component/xfer;1"].getService(Components.interfaces["nsIStreamTransfer"]);
try {
xfer.SelectFileAndTransferLocationSpec( url, window, "", "", true, postData );
xfer.SelectFileAndTransferLocationSpec( url, window, "", "", true, postData, cacheKey );
} catch( exception ) {
return false;
}

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

@ -685,14 +685,17 @@ nsContextMenu.prototype = {
// Save specified URL in user-selected file.
savePage : function ( url, doNotValidate ) {
var postData = null; // No post data, usually.
var cacheKey = null;
// Default is to save current page.
if ( !url ) {
url = window._content.location.href;
try {
var sessionHistory = getWebNavigation().sessionHistory;
var entry = sessionHistory.getEntryAtIndex(sessionHistory.index, false);
var entry = sessionHistory.getEntryAtIndex(sessionHistory.index, false).QueryInterface(Components.interfaces.nsISHEntry);
postData = entry.postData;
cacheKey = entry.cacheKey;
} catch(e) {
}
}
@ -701,7 +704,7 @@ nsContextMenu.prototype = {
var xfer = this.getService( "@mozilla.org/appshell/component/xfer;1",
"nsIStreamTransfer" );
try {
xfer.SelectFileAndTransferLocationSpec( url, window, "", "", doNotValidate, postData );
xfer.SelectFileAndTransferLocationSpec( url, window, "", "", doNotValidate, postData, cacheKey );
} catch( exception ) {
// Failed (or cancelled), give them another chance.
}