diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index ce0442d443a..efea868bddc 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -2371,6 +2371,26 @@ nsDocShell::GetSessionHistory(nsISHistory ** aSessionHistory) } +NS_IMETHODIMP +nsDocShell::GetPostData(nsIInputStream **aPostStream) +{ + NS_ENSURE_ARG_POINTER(aPostStream); + + if (mLSHE) { + mLSHE->GetPostData(aPostStream); + } + else if (mOSHE) { + mOSHE->GetPostData(aPostStream); + } + else { + // XXX: If session history is disabled, then there is no way to + // get the post data :-( + *aPostStream = nsnull; + } + + return NS_OK; +} + //***************************************************************************** // nsDocShell::nsIBaseWindow //***************************************************************************** diff --git a/mozilla/docshell/base/nsIWebNavigation.idl b/mozilla/docshell/base/nsIWebNavigation.idl index 5028dcd637b..3f775569c65 100644 --- a/mozilla/docshell/base/nsIWebNavigation.idl +++ b/mozilla/docshell/base/nsIWebNavigation.idl @@ -185,6 +185,18 @@ interface nsIWebNavigation : nsISupports */ readonly attribute nsIURI currentURI; + /** + * This input stream contains the post data associated with a HTTP POST + * request... + * It is also assumed that the stream supports the nsIRandomAccessStore + * interface. This allows the stream to be "rewound" back to the beginning + * of the data in the case of a reload. + * + * If this attribute is nsnull, then it is assumed that the current document + * is not the result of a HTTP POST request. + */ + readonly attribute nsIInputStream postData; + /** * The session history object used to store the session history for the * session. diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp index d01ebe76e50..6cba5a2c114 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -622,6 +622,14 @@ NS_IMETHODIMP nsWebBrowser::GetDocument(nsIDOMDocument** aDocument) return mDocShellAsNav->GetDocument(aDocument); } +NS_IMETHODIMP +nsWebBrowser::GetPostData(nsIInputStream** aPostStream) +{ + NS_ENSURE_ARG_POINTER(aPostStream); + NS_ENSURE_STATE(mDocShell); + + return mDocShellAsNav->GetPostData(aPostStream); +} //***************************************************************************** // nsWebBrowser::nsIWebBrowserSetup diff --git a/mozilla/xpfe/browser/resources/content/navigator.js b/mozilla/xpfe/browser/resources/content/navigator.js index 7d4c7d377e4..c522940ee90 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.js +++ b/mozilla/xpfe/browser/resources/content/navigator.js @@ -956,11 +956,17 @@ function OpenAddressbook() function BrowserViewSource() { + var isPostData = false; + var webNav = getWebNavigation(); + if (webNav) + isPostData = webNav.postData; + + if (isPostData) return; + var focusedWindow = document.commandDispatcher.focusedWindow; if (focusedWindow == window) focusedWindow = _content; - dump("focusedWindow = " + focusedWindow + "\n"); if (focusedWindow) var docCharset = "charset=" + focusedWindow.document.characterSet; @@ -1480,3 +1486,17 @@ function updateToolbarStates(toolbarMenuElt) updateComponentBarBroadcaster(); } +function UpdateNecessaryItems(eltId) +{ + var eltToUpdate = document.getElementById(eltId); + if (!eltToUpdate) return; + var webNav = getWebNavigation(); + if (!webNav) return; + + if (webNav.postData) + eltToUpdate.setAttribute("disabled", "true"); + else if (eltToUpdate.getAttribute("disabled")) + eltToUpdate.removeAttribute("disabled"); +} + + diff --git a/mozilla/xpfe/browser/resources/content/navigatorOverlay.xul b/mozilla/xpfe/browser/resources/content/navigatorOverlay.xul index 9ffc5c302ab..84753c2b6b7 100644 --- a/mozilla/xpfe/browser/resources/content/navigatorOverlay.xul +++ b/mozilla/xpfe/browser/resources/content/navigatorOverlay.xul @@ -164,7 +164,7 @@ - + @@ -206,7 +206,7 @@ - + diff --git a/mozilla/xpfe/communicator/resources/content/nsContextMenu.js b/mozilla/xpfe/communicator/resources/content/nsContextMenu.js index eb35014417a..bfb7b710c37 100644 --- a/mozilla/xpfe/communicator/resources/content/nsContextMenu.js +++ b/mozilla/xpfe/communicator/resources/content/nsContextMenu.js @@ -33,6 +33,7 @@ | Currently, this code is relatively useless for any other purpose. In the | | longer term, this code will be restructured to make it more reusable. | ------------------------------------------------------------------------------*/ +var gBrowserElt = -1; function nsContextMenu( xulMenu ) { this.target = null; this.menu = null; @@ -129,7 +130,23 @@ nsContextMenu.prototype = { }, initViewItems : function () { // View source is always OK, unless in directory listing. + var isPostData = false; + if ( gBrowserElt == -1 ) + gBrowserElt = document.getElementById( "content" ); + if ( gBrowserElt ) + isPostData = gBrowserElt.webNavigation.postData; + this.showItem( "context-viewsource", !( this.inDirList || this.onImage ) ); + if ( !this.inDirList && !this.onImage ) { + try { + var viewSourceElt = document.getElementById( "context-viewsource" ); + if ( isPostData ) + viewSourceElt.setAttribute( "disabled", "true" ); + else if ( viewSourceElt.getAttribute( "disabled" ) ) + viewSourceElt.removeAttribute( "disabled" ); + } + } + // View frame source depends on whether we're in a frame. this.showItem( "context-viewframesource", this.inFrame ); diff --git a/mozilla/xpfe/communicator/resources/content/utilityOverlay.js b/mozilla/xpfe/communicator/resources/content/utilityOverlay.js index 99100394ee9..16ae2ef124d 100644 --- a/mozilla/xpfe/communicator/resources/content/utilityOverlay.js +++ b/mozilla/xpfe/communicator/resources/content/utilityOverlay.js @@ -315,6 +315,12 @@ function NewEditorFromDraft() // and we need a delay to let dialog close) function editPage(url, launchWindow, delay) { + var webNav = null; + if ("getWebNavigation" in window) + webNav = getWebNavigation(); + if (webNav && webNav.postData) + return; + // User may not have supplied a window if (!launchWindow) { diff --git a/mozilla/xpfe/components/shistory/src/nsSHistory.cpp b/mozilla/xpfe/components/shistory/src/nsSHistory.cpp index da23d7a631c..9220e166bed 100644 --- a/mozilla/xpfe/components/shistory/src/nsSHistory.cpp +++ b/mozilla/xpfe/components/shistory/src/nsSHistory.cpp @@ -550,6 +550,23 @@ nsSHistory::SetSessionHistory(nsISHistory* aSessionHistory) return NS_OK; } +NS_IMETHODIMP +nsSHistory::GetPostData(nsIInputStream** aPostStream) +{ + nsresult rv; + nsCOMPtr currentEntry; + + NS_ENSURE_ARG_POINTER(aPostStream); + *aPostStream = nsnull; + rv = GetEntryAtIndex(mIndex, PR_FALSE, getter_AddRefs(currentEntry)); + + if (currentEntry) { + rv = currentEntry->GetPostData(aPostStream); + } + + return rv; +} + NS_IMETHODIMP nsSHistory::GetSessionHistory(nsISHistory** aSessionHistory)