diff --git a/docshell/base/nsDocShellBase.cpp b/docshell/base/nsDocShellBase.cpp index 1a561b476330..643dd711cf1c 100644 --- a/docshell/base/nsDocShellBase.cpp +++ b/docshell/base/nsDocShellBase.cpp @@ -65,15 +65,15 @@ NS_IMPL_ISUPPORTS6(nsDocShellBase, nsIDocShell, nsIDocShellEdit, // nsDocShellBase::nsIDocShell //***************************************************************************** -NS_IMETHODIMP nsDocShellBase::LoadURI(const PRUnichar* uri, +NS_IMETHODIMP nsDocShellBase::LoadURI(nsIURI* aUri, nsIPresContext* presContext) { - //NS_ENSURE_ARG(uri); // Done in LoadURIVia for us. + //NS_ENSURE_ARG(aUri); // Done in LoadURIVia for us. - return LoadURIVia(uri, presContext, 0); + return LoadURIVia(aUri, presContext, 0); } -NS_IMETHODIMP nsDocShellBase::LoadURIVia(const PRUnichar* aUri, +NS_IMETHODIMP nsDocShellBase::LoadURIVia(nsIURI* aUri, nsIPresContext* aPresContext, PRUint32 aAdapterBinding) { NS_ENSURE_ARG(aUri); @@ -83,17 +83,13 @@ NS_IMETHODIMP nsDocShellBase::LoadURIVia(const PRUnichar* aUri, nsnull, NS_GET_IID(nsIURILoader), getter_AddRefs(uriLoader)), NS_ERROR_FAILURE); - nsCOMPtr uri; - NS_ENSURE_SUCCESS(NewURI(aUri, getter_AddRefs(uri)), NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(EnsureContentListener(), NS_ERROR_FAILURE); + mContentListener->SetPresContext(aPresContext); - /* - Call uriloader passing mContentListener as the nsIURIContentListener - uriLoader->OpenURI(uri, nsnull, nsnull, - */ + NS_ENSURE_SUCCESS(uriLoader->OpenURI(aUri, nsnull, nsnull, nsnull, nsnull, + nsnull, mContentListener, nsnull), NS_ERROR_FAILURE); - return NS_ERROR_FAILURE; + return NS_OK; } NS_IMETHODIMP nsDocShellBase::GetDocument(nsIDOMDocument** aDocument) @@ -114,6 +110,16 @@ NS_IMETHODIMP nsDocShellBase::GetDocument(nsIDOMDocument** aDocument) return NS_OK; } +NS_IMETHODIMP nsDocShellBase::GetCurrentURI(nsIURI** aURI) +{ + NS_ENSURE_ARG_POINTER(aURI); + + *aURI = mCurrentURI; + NS_IF_ADDREF(*aURI); + + return NS_OK; +} + // SetDocument is only meaningful for doc shells that support DOM documents. Not all do. NS_IMETHODIMP nsDocShellBase::SetDocument(nsIDOMDocument* aDocument, nsIPresContext* presContext) @@ -1116,12 +1122,6 @@ nsresult nsDocShellBase::GetPresShell(nsIPresShell** aPresShell) return NS_OK; } -nsresult nsDocShellBase::NewURI(const PRUnichar* aUri, nsIURI** aURI) -{ - //XXX Get new URI - return NS_ERROR_FAILURE; -} - nsresult nsDocShellBase::EnsureContentListener() { if(mContentListener) @@ -1136,3 +1136,8 @@ nsresult nsDocShellBase::EnsureContentListener() return NS_OK; } +void nsDocShellBase::SetCurrentURI(nsIURI* aUri) +{ + mCurrentURI = aUri; //This assignment addrefs +} + diff --git a/docshell/base/nsDocShellBase.h b/docshell/base/nsDocShellBase.h index e99b089abc2b..58726dabbf4f 100644 --- a/docshell/base/nsDocShellBase.h +++ b/docshell/base/nsDocShellBase.h @@ -56,6 +56,8 @@ class nsDocShellBase : public nsIDocShell, public nsIDocShellEdit, public nsIDocShellFile, public nsIGenericWindow, public nsIScrollable, public nsITextScroll { +friend class nsDSURIContentListener; + public: NS_DECL_ISUPPORTS @@ -74,9 +76,10 @@ protected: PRInt32* aOffset); nsresult GetRootScrollableView(nsIScrollableView** aOutScrollView); nsresult GetPresShell(nsIPresShell** aPresShell); - nsresult NewURI(const PRUnichar* aUri, nsIURI** aURI); nsresult EnsureContentListener(); + void SetCurrentURI(nsIURI* aUri); + protected: PRBool mCreated; nsString mName; @@ -85,6 +88,7 @@ protected: nsCOMPtr mContentViewer; nsCOMPtr mParentWidget; nsCOMPtr mPrefs; + nsCOMPtr mCurrentURI; /* Note this can not be nsCOMPtr as that that would cause an addref on the parent thus a cycle. A weak reference would work, but not required as the