From dc64ef1f065f95fca7976421acfe70b95909593e Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Fri, 12 Nov 1999 09:07:28 +0000 Subject: [PATCH] Added CreateContentViewer and NewContentViewerObj methods for docShell. --- docshell/base/nsDocShell.cpp | 44 ++++++++++++++++++++++++++++++++++++ docshell/base/nsDocShell.h | 4 ++++ 2 files changed, 48 insertions(+) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index f7bdd39954d8..911516e58744 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -32,6 +32,7 @@ #include "nsLayoutCID.h" #include "nsNeckoUtil.h" #include "nsRect.h" +#include "prprf.h" #include "nsIFrame.h" #include "nsIContent.h" @@ -1798,6 +1799,49 @@ void nsDocShell::SetCurrentURI(nsIURI* aUri) mCurrentURI = aUri; //This assignment addrefs } +nsresult nsDocShell::CreateContentViewer(const char* aContentType, + const char* aCommand, nsIChannel* aOpenedChannel, + nsIStreamListener** aContentHandler) +{ + NS_ENSURE_STATE(mCreated); + + //XXXQ Can we check the content type of the current content viewer + // and reuse it without destroying it and re-creating it? + + // XXXIMPL Do cleanup.... + + // Instantiate the content viewer object + NS_ENSURE_SUCCESS(NewContentViewerObj(aContentType, aCommand, aOpenedChannel, + aContentHandler), NS_ERROR_FAILURE); + + //XXXIMPL Do stuff found in embed here. Don't call embed it is going away. + + return NS_ERROR_FAILURE; +} + +nsresult nsDocShell::NewContentViewerObj(const char* aContentType, + const char* aCommand, nsIChannel* aOpenedChannel, + nsIStreamListener** aContentHandler) +{ + //XXX This should probably be some category thing.... + char id[256]; + PR_snprintf(id, sizeof(id), NS_DOCUMENT_LOADER_FACTORY_PROGID_PREFIX "%s/%s", + aCommand , aContentType); + + // Create an instance of the document-loader-factory + nsCOMPtr docLoaderFactory(do_CreateInstance(id)); + NS_ENSURE_TRUE(docLoaderFactory, NS_ERROR_FAILURE); + + nsCOMPtr loadGroup(do_QueryInterface(mLoadCookie)); + // Now create an instance of the content viewer + NS_ENSURE_SUCCESS(docLoaderFactory->CreateInstance(aCommand, aOpenedChannel, + loadGroup, aContentType, this /* this should become nsIDocShell*/, + nsnull /*XXXQ Need ExtraInfo???*/, + aContentHandler, getter_AddRefs(mContentViewer)), NS_ERROR_FAILURE); + + return NS_OK; +} + NS_IMETHODIMP nsDocShell::FireStartDocumentLoad(nsIDocumentLoader* aLoader, nsIURI * aURL, //XXX: should be the channel? diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 6b76493465ed..b48a683ae198 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -113,6 +113,10 @@ protected: nsresult EnsureContentListener(); void SetCurrentURI(nsIURI* aUri); + nsresult CreateContentViewer(const char* aContentType, const char* aCommand, + nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler); + nsresult NewContentViewerObj(const char* aContentType, const char* aCommand, + nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler); NS_IMETHOD FireStartDocumentLoad(nsIDocumentLoader* aLoader, nsIURI* aURL,