diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index e90ce8c73b3..62ac3dd4978 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -1820,23 +1820,32 @@ nsWebShell::DoContent(const char * aContentType, nsIStreamListener ** aContentHandler, PRBool * aAbortProcess) { + nsresult rv = NS_OK; if (aAbortProcess) *aAbortProcess = PR_FALSE; + nsXPIDLCString strCommand; + // go to the uri loader and ask it to convert the uri load command into a old + // world style string + NS_WITH_SERVICE(nsIURILoader, pURILoader, NS_URI_LOADER_PROGID, &rv); + if (NS_SUCCEEDED(rv)) + pURILoader->GetStringForCommand(aCommand, getter_Copies(strCommand)); + + // first, run any uri preparation stuff that we would have run normally // had we gone through OpenURI nsCOMPtr aUri; aOpenedChannel->GetURI(getter_AddRefs(aUri)); - PrepareToLoadURI(aUri, "view", nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull); + PrepareToLoadURI(aUri, strCommand, nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull); // mscott: when I called DoLoadURL I found that we ran into problems because // we currently don't have channel retargeting yet. Basically, what happens is that // DoLoadURL calls StopBeforeRequestingURL and this cancels the current load group // however since we can't retarget yet, we were basically canceling our very // own load group!!! So the request would get canceled out from under us... // after retargeting we may be able to safely call DoLoadURL. - DoLoadURL(aUri, "view", nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE); + DoLoadURL(aUri, strCommand, nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE); return mDocLoader->LoadOpenedDocument(aOpenedChannel, - "view", + strCommand, this, nsnull, nsnull, diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 161ff7be4ad..2e567165e6d 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -579,6 +579,8 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, nsURILoadCommand loadCmd = nsIURILoader::viewNormal; if (nsCRT::strcasecmp(aCommand, "view-link-click") == 0) loadCmd = nsIURILoader::viewUserClick; + else if (nsCRT::strcasecmp(aCommand, "view-source") == 0) + loadCmd = nsIURILoader::viewSource; // temporary hack for post data...eventually this snippet of code // should be moved into the layout call when callers go through the diff --git a/mozilla/uriloader/base/nsIURILoader.idl b/mozilla/uriloader/base/nsIURILoader.idl index 95872961475..d26d74f15a7 100644 --- a/mozilla/uriloader/base/nsIURILoader.idl +++ b/mozilla/uriloader/base/nsIURILoader.idl @@ -123,6 +123,10 @@ interface nsIURILoader : nsISupports in nsIURIContentListener aContentListener, out string aDesiredContentType, out nsIURIContentListener aTargetListener); + /* this command should become obsolete once we get rid of the old layout "verb" command + string and replace it with the enumerated type nsURILoaderCommand + */ + void getStringForCommand (in nsURILoadCommand aCommand, out string aStringVersion); }; /* This is a private interface used by layout in order to invoke the uri loader diff --git a/mozilla/uriloader/base/nsURILoader.cpp b/mozilla/uriloader/base/nsURILoader.cpp index f6e651b9c88..01d8be4b4da 100644 --- a/mozilla/uriloader/base/nsURILoader.cpp +++ b/mozilla/uriloader/base/nsURILoader.cpp @@ -316,6 +316,16 @@ NS_INTERFACE_MAP_BEGIN(nsURILoader) NS_INTERFACE_MAP_ENTRY(nsPIURILoaderWithPostData) NS_INTERFACE_MAP_END +NS_IMETHODIMP nsURILoader::GetStringForCommand(nsURILoadCommand aCommand, char **aStringVersion) +{ + if (aCommand == nsIURILoader::viewSource) + *aStringVersion = nsCRT::strdup("view-source"); + else // for now, default everything else to view normal + *aStringVersion = nsCRT::strdup("view"); + + return NS_OK; +} + NS_IMETHODIMP nsURILoader::RegisterContentListener(nsIURIContentListener * aContentListener) { nsresult rv = NS_OK; diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp index 161ff7be4ad..2e567165e6d 100644 --- a/mozilla/webshell/src/nsDocLoader.cpp +++ b/mozilla/webshell/src/nsDocLoader.cpp @@ -579,6 +579,8 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, nsURILoadCommand loadCmd = nsIURILoader::viewNormal; if (nsCRT::strcasecmp(aCommand, "view-link-click") == 0) loadCmd = nsIURILoader::viewUserClick; + else if (nsCRT::strcasecmp(aCommand, "view-source") == 0) + loadCmd = nsIURILoader::viewSource; // temporary hack for post data...eventually this snippet of code // should be moved into the layout call when callers go through the diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index e90ce8c73b3..62ac3dd4978 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -1820,23 +1820,32 @@ nsWebShell::DoContent(const char * aContentType, nsIStreamListener ** aContentHandler, PRBool * aAbortProcess) { + nsresult rv = NS_OK; if (aAbortProcess) *aAbortProcess = PR_FALSE; + nsXPIDLCString strCommand; + // go to the uri loader and ask it to convert the uri load command into a old + // world style string + NS_WITH_SERVICE(nsIURILoader, pURILoader, NS_URI_LOADER_PROGID, &rv); + if (NS_SUCCEEDED(rv)) + pURILoader->GetStringForCommand(aCommand, getter_Copies(strCommand)); + + // first, run any uri preparation stuff that we would have run normally // had we gone through OpenURI nsCOMPtr aUri; aOpenedChannel->GetURI(getter_AddRefs(aUri)); - PrepareToLoadURI(aUri, "view", nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull); + PrepareToLoadURI(aUri, strCommand, nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull); // mscott: when I called DoLoadURL I found that we ran into problems because // we currently don't have channel retargeting yet. Basically, what happens is that // DoLoadURL calls StopBeforeRequestingURL and this cancels the current load group // however since we can't retarget yet, we were basically canceling our very // own load group!!! So the request would get canceled out from under us... // after retargeting we may be able to safely call DoLoadURL. - DoLoadURL(aUri, "view", nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE); + DoLoadURL(aUri, strCommand, nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE); return mDocLoader->LoadOpenedDocument(aOpenedChannel, - "view", + strCommand, this, nsnull, nsnull,