diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 06844da5c37..772c672eba2 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -138,14 +138,21 @@ NS_IMETHODIMP nsDocShell::LoadURIVia(nsIURI* aUri, { NS_ENSURE_ARG(aUri); - nsCOMPtr uriLoader = do_CreateInstance(NS_URI_LOADER_PROGID); + nsCOMPtr uriLoader = do_GetService(NS_URI_LOADER_PROGID); NS_ENSURE_TRUE(uriLoader, NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(EnsureContentListener(), NS_ERROR_FAILURE); mContentListener->SetPresContext(aPresContext); - NS_ENSURE_SUCCESS(uriLoader->OpenURIVia(aUri, nsIURILoader::viewNormal, nsnull, - NS_STATIC_CAST(nsIDocShell*, this), nsnull, mLoadCookie, + // first, open a channel for the url + nsCOMPtr channel; + nsCOMPtr capabilities (do_QueryInterface(NS_STATIC_CAST(nsIDocShell *, this))); + nsCOMPtr loadGroup(do_QueryInterface(mLoadCookie)); + NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(channel), aUri, loadGroup, capabilities), NS_ERROR_FAILURE); + + + NS_ENSURE_SUCCESS(uriLoader->OpenURIVia(channel, nsIURILoader::viewNormal, nsnull, + NS_STATIC_CAST(nsIDocShell*, this), mLoadCookie, getter_AddRefs(mLoadCookie), aAdapterBinding), NS_ERROR_FAILURE); return NS_OK; diff --git a/mozilla/gfx/src/nsImageNetContextAsync.cpp b/mozilla/gfx/src/nsImageNetContextAsync.cpp index 187ddba998a..15e4ae0300a 100644 --- a/mozilla/gfx/src/nsImageNetContextAsync.cpp +++ b/mozilla/gfx/src/nsImageNetContextAsync.cpp @@ -615,13 +615,22 @@ ImageNetContextImpl::GetURL (ilIURL * aURL, // See if a reconnect is being done...(XXX: hack!) if (mReconnectCallback == nsnull || !(*mReconnectCallback)(mReconnectArg, ic)) { - + // first, create a channel for the protocol.... + nsCOMPtr channel; + nsCOMPtr group = do_QueryReferent(mLoadGroup); + rv = NS_OpenURI(getter_AddRefs(channel), nsurl, group); + if (NS_FAILED(rv)) goto error; + + PRBool bIsBackground = aURL->GetBackgroundLoad(); + if (bIsBackground) { + (void)channel->SetLoadAttributes(nsIChannel::LOAD_BACKGROUND); + } + nsCOMPtr openContext (do_QueryInterface(mLoadGroup)); nsCOMPtr window (do_QueryInterface(NS_STATIC_CAST(nsIStreamListener *, ic))); - nsCOMPtr group = do_QueryReferent(mLoadGroup); // let's try uri dispatching... - NS_WITH_SERVICE(nsIURILoader, pURILoader, NS_URI_LOADER_PROGID, &rv); + nsCOMPtr pURILoader (do_GetService(NS_URI_LOADER_PROGID, &rv)); if (NS_SUCCEEDED(rv)) { nsURILoadCommand loadCmd = nsIURILoader::viewNormal; @@ -630,9 +639,8 @@ ImageNetContextImpl::GetURL (ilIURL * aURL, loadCmd = nsIURILoader::viewNormalBackground; } - rv = pURILoader->OpenURI(nsurl, loadCmd, nsnull /* window target */, + rv = pURILoader->OpenURI(channel, loadCmd, nsnull /* window target */, window, - nsnull /* refferring URI */, group, getter_AddRefs(openContext)); } diff --git a/mozilla/mailnews/compose/src/nsURLFetcher.cpp b/mozilla/mailnews/compose/src/nsURLFetcher.cpp index 7879ced4f0a..809232eaa8a 100644 --- a/mozilla/mailnews/compose/src/nsURLFetcher.cpp +++ b/mozilla/mailnews/compose/src/nsURLFetcher.cpp @@ -35,7 +35,7 @@ #include "nsURLFetcher.h" #include "nsIIOService.h" #include "nsIChannel.h" -#include "nsIHTTPChannel.h" +#include "nsNetUtil.h" #include "nsMimeTypes.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -262,18 +262,18 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut, return NS_ERROR_FAILURE; } + nsCOMPtr channel; + NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(channel), aURL, nsnull), NS_ERROR_FAILURE); + // let's try uri dispatching... - NS_WITH_SERVICE(nsIURILoader, pURILoader, NS_URI_LOADER_PROGID, &rv); - if (NS_SUCCEEDED(rv)) - { - nsCOMPtr openContext; - nsCOMPtr cntListener (do_QueryInterface(NS_STATIC_CAST(nsIStreamListener *, this))); - rv = pURILoader->OpenURI(aURL, nsIURILoader::viewNormal, nsnull /* window target */, - cntListener, - nsnull /* refferring URI */, - /* group */ nsnull, - getter_AddRefs(openContext)); - } + nsCOMPtr pURILoader (do_GetService(NS_URI_LOADER_PROGID)); + NS_ENSURE_TRUE(pURILoader, NS_ERROR_FAILURE); + nsCOMPtr openContext; + nsCOMPtr cntListener (do_QueryInterface(NS_STATIC_CAST(nsIStreamListener *, this))); + rv = pURILoader->OpenURI(channel, nsIURILoader::viewNormal, nsnull /* window target */, + cntListener, + /* group */ nsnull, + getter_AddRefs(openContext)); mURL = dont_QueryInterface(aURL); mOutStream = fOut; diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 1d5b62be451..8182eeb7fd6 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -51,6 +51,8 @@ #include "nsIDocument.h" #include "nsIPresShell.h" #include "nsIPresContext.h" +#include "nsIHTTPChannel.h" // add this to the ick include list...we need it to QI for post data interface +#include "nsHTTPEnums.h" #if defined(PR_LOGGING) // @@ -77,7 +79,7 @@ static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID); static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID); static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID); - +static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); /**************************************************************************** * nsDocLoaderImpl implementation... @@ -321,8 +323,6 @@ nsDocLoaderImpl::CreateDocumentLoader(nsIDocumentLoader** anInstance) } -static NS_DEFINE_CID(kURILoaderCID, NS_URI_LOADER_CID); - NS_IMETHODIMP nsDocLoaderImpl::LoadDocument(nsIURI * aUri, const char* aCommand, @@ -341,45 +341,45 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, nsCOMPtr openContext = do_QueryInterface(mLoadGroup); - // let's try uri dispatching... - NS_WITH_SERVICE(nsIURILoader, pURILoader, kURILoaderCID, &rv); - if (NS_FAILED(rv)) return rv; + // first, create a channel for the protocol.... + nsCOMPtr pNetService = do_GetService(kIOServiceCID, &rv); + if (NS_SUCCEEDED(rv)) { + nsCOMPtr pChannel; + nsCOMPtr requestor (do_QueryInterface(aContainer)); + rv = pNetService->NewChannelFromURI(aCommand, aUri, mLoadGroup, requestor, + aType, nsnull /* referring uri */, 0, 0, + getter_AddRefs(pChannel)); + if (NS_FAILED(rv)) return rv; // uhoh we were unable to get a channel to handle the url!!! + + // figure out if we need to set the post data stream on the channel...right now, + // this is only done for http channels..... + nsCOMPtr httpChannel(do_QueryInterface(pChannel)); + if (httpChannel && aPostDataStream) + { + httpChannel->SetRequestMethod(HM_POST); + httpChannel->SetPostDataStream(aPostDataStream); + } - /* - * Set the flag indicating that the document loader is in the process of - * loading a document. This flag will remain set until the - * OnConnectionsComplete(...) notification is fired for the loader... - */ - mIsLoadingDocument = PR_TRUE; + // now let's pass the channel into the uri loader + nsCOMPtr pURILoader = do_GetService(NS_URI_LOADER_PROGID, &rv); + if (NS_FAILED(rv)) return rv; - 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; + /* + * Set the flag indicating that the document loader is in the process of + * loading a document. This flag will remain set until the + * OnConnectionsComplete(...) notification is fired for the loader... + */ + + mIsLoadingDocument = PR_TRUE; - // temporary hack for post data...eventually this snippet of code - // should be moved into the layout call when callers go through the - // uri loader directly! + 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; - if (aPostDataStream) { - // query for private post data stream interface - nsCOMPtr postLoader = do_QueryInterface(pURILoader, &rv); - if (NS_SUCCEEDED(rv)) - rv = postLoader->OpenURIWithPostData(aUri, - loadCmd, - nsnull /* window target */, - aContainer, - nsnull /* referring uri */, - aPostDataStream, - mLoadGroup, - getter_AddRefs(openContext)); - - } - else - rv = pURILoader->OpenURI(aUri, loadCmd, nsnull /* window target */, + rv = pURILoader->OpenURI(pChannel, loadCmd, nsnull /* window target */, aContainer, - nsnull /* refferring URI */, mLoadGroup, getter_AddRefs(openContext)); @@ -389,7 +389,8 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, /// if (openContext) { /// mLoadGroup = do_QueryInterface(openContext); /// } - } + } // if we have a channel + } // if we have a uri to load return rv; } diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp index 1d5b62be451..8182eeb7fd6 100644 --- a/mozilla/webshell/src/nsDocLoader.cpp +++ b/mozilla/webshell/src/nsDocLoader.cpp @@ -51,6 +51,8 @@ #include "nsIDocument.h" #include "nsIPresShell.h" #include "nsIPresContext.h" +#include "nsIHTTPChannel.h" // add this to the ick include list...we need it to QI for post data interface +#include "nsHTTPEnums.h" #if defined(PR_LOGGING) // @@ -77,7 +79,7 @@ static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID); static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID); static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID); - +static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); /**************************************************************************** * nsDocLoaderImpl implementation... @@ -321,8 +323,6 @@ nsDocLoaderImpl::CreateDocumentLoader(nsIDocumentLoader** anInstance) } -static NS_DEFINE_CID(kURILoaderCID, NS_URI_LOADER_CID); - NS_IMETHODIMP nsDocLoaderImpl::LoadDocument(nsIURI * aUri, const char* aCommand, @@ -341,45 +341,45 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, nsCOMPtr openContext = do_QueryInterface(mLoadGroup); - // let's try uri dispatching... - NS_WITH_SERVICE(nsIURILoader, pURILoader, kURILoaderCID, &rv); - if (NS_FAILED(rv)) return rv; + // first, create a channel for the protocol.... + nsCOMPtr pNetService = do_GetService(kIOServiceCID, &rv); + if (NS_SUCCEEDED(rv)) { + nsCOMPtr pChannel; + nsCOMPtr requestor (do_QueryInterface(aContainer)); + rv = pNetService->NewChannelFromURI(aCommand, aUri, mLoadGroup, requestor, + aType, nsnull /* referring uri */, 0, 0, + getter_AddRefs(pChannel)); + if (NS_FAILED(rv)) return rv; // uhoh we were unable to get a channel to handle the url!!! + + // figure out if we need to set the post data stream on the channel...right now, + // this is only done for http channels..... + nsCOMPtr httpChannel(do_QueryInterface(pChannel)); + if (httpChannel && aPostDataStream) + { + httpChannel->SetRequestMethod(HM_POST); + httpChannel->SetPostDataStream(aPostDataStream); + } - /* - * Set the flag indicating that the document loader is in the process of - * loading a document. This flag will remain set until the - * OnConnectionsComplete(...) notification is fired for the loader... - */ - mIsLoadingDocument = PR_TRUE; + // now let's pass the channel into the uri loader + nsCOMPtr pURILoader = do_GetService(NS_URI_LOADER_PROGID, &rv); + if (NS_FAILED(rv)) return rv; - 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; + /* + * Set the flag indicating that the document loader is in the process of + * loading a document. This flag will remain set until the + * OnConnectionsComplete(...) notification is fired for the loader... + */ + + mIsLoadingDocument = PR_TRUE; - // temporary hack for post data...eventually this snippet of code - // should be moved into the layout call when callers go through the - // uri loader directly! + 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; - if (aPostDataStream) { - // query for private post data stream interface - nsCOMPtr postLoader = do_QueryInterface(pURILoader, &rv); - if (NS_SUCCEEDED(rv)) - rv = postLoader->OpenURIWithPostData(aUri, - loadCmd, - nsnull /* window target */, - aContainer, - nsnull /* referring uri */, - aPostDataStream, - mLoadGroup, - getter_AddRefs(openContext)); - - } - else - rv = pURILoader->OpenURI(aUri, loadCmd, nsnull /* window target */, + rv = pURILoader->OpenURI(pChannel, loadCmd, nsnull /* window target */, aContainer, - nsnull /* refferring URI */, mLoadGroup, getter_AddRefs(openContext)); @@ -389,7 +389,8 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, /// if (openContext) { /// mLoadGroup = do_QueryInterface(openContext); /// } - } + } // if we have a channel + } // if we have a uri to load return rv; }