diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index a2f1fe2ea89..2ca86cbe07f 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -632,27 +632,6 @@ nsDocShell::StopLoad() return NS_OK; } - -NS_IMETHODIMP -nsDocShell::GetDocLoaderObserver(nsIDocumentLoaderObserver * - *aDocLoaderObserver) -{ - NS_ENSURE_ARG_POINTER(aDocLoaderObserver); - - *aDocLoaderObserver = mDocLoaderObserver; - NS_IF_ADDREF(*aDocLoaderObserver); - return NS_OK; -} - -NS_IMETHODIMP -nsDocShell::SetDocLoaderObserver(nsIDocumentLoaderObserver * - aDocLoaderObserver) -{ - // it's legal for aDocLoaderObserver to be null. - mDocLoaderObserver = aDocLoaderObserver; - return NS_OK; -} - NS_IMETHODIMP nsDocShell::GetPresContext(nsIPresContext ** aPresContext) { @@ -1870,8 +1849,6 @@ nsDocShell::Destroy() mDocLoader->SetContainer(nsnull); } - SetDocLoaderObserver(nsnull); - // Save the state of the current document, before destroying the window. // This is needed to capture the state of a frameset when the new document // causes the frameset to be destroyed... @@ -1900,7 +1877,6 @@ nsDocShell::Destroy() DestroyChildren(); mDocLoader = nsnull; - mDocLoaderObserver = nsnull; mParentWidget = nsnull; mPrefs = nsnull; mCurrentURI = nsnull; diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index d76a798864b..a089d872218 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -39,7 +39,6 @@ #include "nsIDeviceContext.h" #include "nsIDocumentLoader.h" -#include "nsIDocumentLoaderObserver.h" #include "nsWeakReference.h" @@ -276,7 +275,6 @@ protected: nsCOMPtr mDocumentCharsetInfo; nsCOMPtr mDeviceContext; nsCOMPtrmDocLoader; - nsCOMPtr mDocLoaderObserver; nsCOMPtr mParentWidget; nsCOMPtr mPrefs; nsCOMPtr mCurrentURI; diff --git a/mozilla/docshell/base/nsIDocShell.idl b/mozilla/docshell/base/nsIDocShell.idl index 7e74c900457..4cdbc2985be 100644 --- a/mozilla/docshell/base/nsIDocShell.idl +++ b/mozilla/docshell/base/nsIDocShell.idl @@ -100,11 +100,6 @@ interface nsIDocShell : nsISupports */ void stopLoad(); - /* clients may get and set an nsIDocumentLoaderObserver, which will be notified - * during loadURI, loadURIVia, and setDocument - */ - attribute nsIDocumentLoaderObserver docLoaderObserver; - /* Presentation context for the currently loaded document. This may be null. */ diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index fad7b6b1492..b5a7b03cb84 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -37,7 +37,6 @@ typedef unsigned long HMTX; #include "nsIInterfaceRequestor.h" #include "nsIWebProgress.h" #include "nsIDocumentLoader.h" -#include "nsIDocumentLoaderObserver.h" #include "nsIDocumentLoaderFactory.h" #include "nsIContentViewer.h" #include "nsIDocumentViewer.h" @@ -863,91 +862,6 @@ nsWebShell::GetLinkState(const char* aLinkURI, nsLinkState& aState) return NS_OK; } -// -// XXX: This is a temporary method to emulate the mDocLoaderObserver -// notifications that are fired as a result of calling -// SetDocLoaderObserver(...) -// -// This method will go away once all of the callers of SetDocLoaderObserver(...) -// are cleaned up. -// -NS_IMETHODIMP -nsWebShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *request, - PRInt32 aStateFlags, nsresult aStatus) -{ - if (!request) { - return NS_OK; - } - - if (aStateFlags & STATE_IS_DOCUMENT) { - nsCOMPtr webProgress(do_QueryInterface(mLoadCookie)); - - if (aProgress == webProgress.get()) { - nsCOMPtr url; - - nsCOMPtr channel = do_QueryInterface(request); - nsCOMPtr dlObserver; - - (void) channel->GetURI(getter_AddRefs(url)); - - if(!mDocLoaderObserver && mParent) { - /* If this is a frame (in which case it would have a parent && doesn't - * have a documentloaderObserver, get it from the rootWebShell - */ - nsCOMPtr rootItem; - GetSameTypeRootTreeItem(getter_AddRefs(rootItem)); - nsCOMPtr rootDocShell(do_QueryInterface(rootItem)); - if(rootDocShell) { - rootDocShell->GetDocLoaderObserver(getter_AddRefs(dlObserver)); - } - } - else { - dlObserver = do_QueryInterface(mDocLoaderObserver); // we need this to addref - } - - if (aStateFlags & STATE_START) { - /* - * Fire the OnStartDocumentLoad of the webshell observer - */ - if(mContainer && dlObserver) { - dlObserver->OnStartDocumentLoad(mDocLoader, url, "command is bogus"); - } - } - else if (aStateFlags & STATE_STOP) { - /* - * Fire the OnEndDocumentLoad of the DocLoaderobserver - */ - if(dlObserver && url) { - dlObserver->OnEndDocumentLoad(mDocLoader, request, aStatus); - } - } - } - } - - if (aStateFlags & STATE_IS_REQUEST) { - nsCOMPtr channel = do_QueryInterface(request); - - if (aStateFlags & STATE_START) { - /* - *Fire the OnStartDocumentLoad of the webshell observer - */ - if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver)) { - mDocLoaderObserver->OnStartURLLoad(mDocLoader, request); - } - } - else if (aStateFlags & STATE_STOP) { - /* - *Fire the OnEndDocumentLoad of the webshell observer - */ - if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver)) { - mDocLoaderObserver->OnEndURLLoad(mDocLoader, request, aStatus); - } - } - } - - return nsDocShell::OnStateChange(aProgress, request, aStateFlags, aStatus); -} - //---------------------------------------------------------------------- nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, nsIChannel* channel, diff --git a/mozilla/docshell/base/nsWebShell.h b/mozilla/docshell/base/nsWebShell.h index 356cfe31f62..089f576e45e 100644 --- a/mozilla/docshell/base/nsWebShell.h +++ b/mozilla/docshell/base/nsWebShell.h @@ -121,12 +121,6 @@ public: NS_IMETHOD SetURL(const PRUnichar* aURL); - // XXX: Temporary - until I can get rid of SetDocLoaderObserver :-) - NS_IMETHOD OnStateChange(nsIWebProgress *aProgress, - nsIRequest *aRequest, - PRInt32 aStateFlags, - nsresult aStatus); - protected: void GetRootWebShellEvenIfChrome(nsIWebShell** aResult); void InitFrameData(); diff --git a/mozilla/embedding/browser/activex/src/control/MozillaBrowser.cpp b/mozilla/embedding/browser/activex/src/control/MozillaBrowser.cpp index c7f9ff6b178..7c65b128738 100644 --- a/mozilla/embedding/browser/activex/src/control/MozillaBrowser.cpp +++ b/mozilla/embedding/browser/activex/src/control/MozillaBrowser.cpp @@ -1015,7 +1015,6 @@ HRESULT CMozillaBrowser::CreateBrowser() SetStartupErrorMessage(IDS_CANNOTCREATEPREFS); return rv; } - rootDocShell->SetDocLoaderObserver(NS_STATIC_CAST(nsIDocumentLoaderObserver*, mWebBrowserContainer)); mWebBrowserAsWin->SetVisibility(PR_TRUE); // Subscribe for progress notifications diff --git a/mozilla/embedding/browser/activex/src/control/StdAfx.h b/mozilla/embedding/browser/activex/src/control/StdAfx.h index ed7eec23015..b2e1518b50f 100644 --- a/mozilla/embedding/browser/activex/src/control/StdAfx.h +++ b/mozilla/embedding/browser/activex/src/control/StdAfx.h @@ -87,7 +87,6 @@ #include "nsIDocument.h" #include "nsIDocumentObserver.h" -#include "nsIDocumentLoaderObserver.h" #include "nsIStreamListener.h" #include "nsUnitConversion.h" #include "nsVoidArray.h" diff --git a/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp b/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp index a080f4101eb..0bf477961d8 100644 --- a/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp +++ b/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp @@ -59,7 +59,6 @@ NS_INTERFACE_MAP_BEGIN(CWebBrowserContainer) NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeOwner) NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow) NS_INTERFACE_MAP_ENTRY(nsIRequestObserver) - NS_INTERFACE_MAP_ENTRY(nsIDocumentLoaderObserver) NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) NS_INTERFACE_MAP_ENTRY(nsIPrompt) NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener) @@ -212,7 +211,77 @@ NS_IMETHODIMP CWebBrowserContainer::OnProgressChange(nsIWebProgress *aProgress, /* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest request, in long progressStateFlags, in unsinged long aStatus); */ NS_IMETHODIMP CWebBrowserContainer::OnStateChange(nsIWebProgress* aWebProgress, nsIRequest *aRequest, PRInt32 progressStateFlags, nsresult aStatus) { - NG_TRACE(_T("CWebBrowserContainer::OnStateChange(...)\n")); + nsresult rv = NS_OK; + + NG_TRACE(_T("CWebBrowserContainer::OnStateChange(...)\n")); + + // determine whether or not the document load has started or stopped. + if (progressStateFlags & STATE_IS_DOCUMENT) + { + if (progressStateFlags & STATE_START) + { + NG_TRACE(_T("CWebBrowserContainer::OnStateChange->Doc Start(..., \"\")\n")); + + nsCOMPtr channel(do_QueryInterface(aRequest)); + if (channel) + { + nsCOMPtr uri; + rv = channel->GetURI(getter_AddRefs(uri)); + if (NS_SUCCEEDED(rv)) + { + nsXPIDLCString aURI; + uri->GetSpec(getter_Copies(aURI)); + NG_TRACE(_T("CWebBrowserContainer::OnStateChange->Doc Start(..., %s, \"\")\n"), A2CT(aURI)); + } + } + + //Fire a DownloadBegin + m_pEvents1->Fire_DownloadBegin(); + m_pEvents2->Fire_DownloadBegin(); + } + else if (progressStateFlags & STATE_STOP) + { + NG_TRACE(_T("CWebBrowserContainer::OnStateChange->Doc Stop(..., \"\")\n")); + + if (m_pOwner->mIERootDocument) + { + // allow to keep old document around + m_pOwner->mIERootDocument->Release(); + m_pOwner->mIERootDocument = NULL; + } + + //Fire a DownloadComplete + m_pEvents1->Fire_DownloadComplete(); + m_pEvents2->Fire_DownloadComplete(); + + nsCOMPtr pURI; + + nsCOMPtr aChannel = do_QueryInterface(aRequest); + if (!aChannel) return NS_ERROR_NULL_POINTER; + + rv = aChannel->GetURI(getter_AddRefs(pURI)); + if (NS_FAILED(rv)) return rv; + + nsXPIDLCString aURI; + rv = pURI->GetSpec(getter_Copies(aURI)); + if (NS_FAILED(rv)) return rv; + + USES_CONVERSION; + BSTR bstrURI = SysAllocString(A2OLE((const char *) aURI)); + + // Fire a DocumentComplete event + CComVariant vURI(bstrURI); + m_pEvents2->Fire_DocumentComplete(m_pOwner, &vURI); + SysFreeString(bstrURI); + + //Fire a StatusTextChange event + BSTR bstrStatus = SysAllocString(A2OLE((CHAR *) "Done")); + m_pEvents1->Fire_StatusTextChange(bstrStatus); + m_pEvents2->Fire_StatusTextChange(bstrStatus); + SysFreeString(bstrStatus); + } + + } if (progressStateFlags & STATE_IS_NETWORK) { @@ -293,6 +362,13 @@ CWebBrowserContainer::OnStatusChange(nsIWebProgress* aWebProgress, nsresult aStatus, const PRUnichar* aMessage) { + NG_TRACE(_T("CWebBrowserContainer::OnStatusChange(..., \"\")\n")); + + BSTR bstrStatus = SysAllocString(W2OLE((PRUnichar *) aMessage)); + m_pEvents1->Fire_StatusTextChange(bstrStatus); + m_pEvents2->Fire_StatusTextChange(bstrStatus); + SysFreeString(bstrStatus); + return NS_OK; } @@ -702,123 +778,6 @@ CWebBrowserContainer::OnStopRequest(nsIRequest *request, nsISupports* aContext, return NS_OK; } - -/////////////////////////////////////////////////////////////////////////////// -// nsIDocumentLoaderObserver implementation - - -NS_IMETHODIMP -CWebBrowserContainer::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* pURI, const char* aCommand) -{ - nsXPIDLCString aURI; - pURI->GetSpec(getter_Copies(aURI)); - NG_TRACE(_T("CWebBrowserContainer::OnStartDocumentLoad(..., %s, \"%s\")\n"), A2CT(aURI), A2CT(aCommand)); - - //Fire a DownloadBegin - m_pEvents1->Fire_DownloadBegin(); - m_pEvents2->Fire_DownloadBegin(); - - return NS_OK; -} - - -// we need this to fire the document complete -NS_IMETHODIMP -CWebBrowserContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus) -{ - NG_TRACE(_T("CWebBrowserContainer::OnEndDocumentLoad(..., \"\")\n")); - - if (m_pOwner->mIERootDocument) - { - // allow to keep old document around - m_pOwner->mIERootDocument->Release(); - m_pOwner->mIERootDocument = NULL; - } - - //Fire a DownloadComplete - m_pEvents1->Fire_DownloadComplete(); - m_pEvents2->Fire_DownloadComplete(); - - char* aString = nsnull; - nsIURI* pURI = nsnull; - - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) return NS_ERROR_NULL_POINTER; - - aChannel->GetURI(&pURI); - if (pURI == nsnull) - { - return NS_ERROR_NULL_POINTER; - } - nsXPIDLCString aURI; - pURI->GetSpec(getter_Copies(aURI)); - NS_RELEASE(pURI); - - USES_CONVERSION; - BSTR bstrURI = SysAllocString(A2OLE((const char *) aURI)); - - // Fire a DocumentComplete event - CComVariant vURI(bstrURI); - m_pEvents2->Fire_DocumentComplete(m_pOwner, &vURI); - SysFreeString(bstrURI); - - //Fire a StatusTextChange event - BSTR bstrStatus = SysAllocString(A2OLE((CHAR *) "Done")); - m_pEvents1->Fire_StatusTextChange(bstrStatus); - m_pEvents2->Fire_StatusTextChange(bstrStatus); - SysFreeString(bstrStatus); - - return NS_OK; -} - - -NS_IMETHODIMP -CWebBrowserContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *request) -{ - NG_TRACE(_T("CWebBrowserContainer::OnStartURLLoad(..., \"\")\n")); - - //NOTE: This appears to get fired once for each individual item on a page. - - return NS_OK; -} - - -NS_IMETHODIMP -CWebBrowserContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) -{ - USES_CONVERSION; - NG_TRACE(_T("CWebBrowserContainer::OnProgress(..., \"%d\", \"%d\")\n"), (int) aProgress, (int) aProgressMax); - - return NS_OK; -} - - -NS_IMETHODIMP -CWebBrowserContainer::OnStatusURLLoad(nsIDocumentLoader* loader, nsIRequest *request, nsString& aMsg) -{ - NG_TRACE(_T("CWebBrowserContainer::OnStatusURLLoad(..., \"\")\n")); - - //NOTE: This appears to get fired for each individual item on a page, indicating the status of that item. - BSTR bstrStatus = SysAllocString(W2OLE((PRUnichar *) aMsg.GetUnicode())); - m_pEvents1->Fire_StatusTextChange(bstrStatus); - m_pEvents2->Fire_StatusTextChange(bstrStatus); - SysFreeString(bstrStatus); - - return NS_OK; -} - - -NS_IMETHODIMP -CWebBrowserContainer::OnEndURLLoad(nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus) -{ - NG_TRACE(_T("CWebBrowserContainer::OnEndURLLoad(..., \"\")\n")); - - //NOTE: This appears to get fired once for each individual item on a page. - - return NS_OK; -} - - /////////////////////////////////////////////////////////////////////////////// // nsICommandHandler implementation diff --git a/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.h b/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.h index 99cef171461..0bafbd43253 100644 --- a/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.h +++ b/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.h @@ -40,7 +40,6 @@ class CWebBrowserContainer : public nsIWebProgressListener, public nsIRequestObserver, public nsIURIContentListener, - public nsIDocumentLoaderObserver, public nsIDocShellTreeOwner, public nsIInterfaceRequestor, public nsIPrompt, @@ -72,7 +71,6 @@ public: NS_DECL_NSIDOCSHELLTREEOWNER NS_DECL_NSIURICONTENTLISTENER NS_DECL_NSIREQUESTOBSERVER - NS_DECL_NSIDOCUMENTLOADEROBSERVER NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSICONTEXTMENULISTENER diff --git a/mozilla/extensions/cookie/nsCookieService.cpp b/mozilla/extensions/cookie/nsCookieService.cpp index 490806b1b0b..aad852c75cf 100644 --- a/mozilla/extensions/cookie/nsCookieService.cpp +++ b/mozilla/extensions/cookie/nsCookieService.cpp @@ -32,6 +32,7 @@ #include "nsIPrompt.h" #include "nsIObserverService.h" #include "nsIDocumentLoader.h" +#include "nsIWebProgress.h" #include "nsCURILoader.h" static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID); @@ -43,7 +44,7 @@ static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID); // nsCookieService Implementation NS_IMPL_ISUPPORTS4(nsCookieService, nsICookieService, - nsIObserver, nsIDocumentLoaderObserver, nsISupportsWeakReference); + nsIObserver, nsIWebProgressListener, nsISupportsWeakReference); nsCookieService::nsCookieService() { @@ -71,7 +72,9 @@ nsresult nsCookieService::Init() // Register as an observer for the document loader NS_WITH_SERVICE(nsIDocumentLoader, docLoaderService, kDocLoaderServiceCID, &rv) if (NS_SUCCEEDED(rv) && docLoaderService) { - docLoaderService->AddObserver((nsIDocumentLoaderObserver*)this); + nsCOMPtr progress(do_QueryInterface(docLoaderService)); + if (progress) + (void) progress->AddProgressListener((nsIWebProgressListener*)this); } else { NS_ASSERTION(PR_FALSE, "Could not get nsIDocumentLoader"); } @@ -79,48 +82,57 @@ nsresult nsCookieService::Init() return NS_OK; } +// nsIWebProgressListener implementation NS_IMETHODIMP -nsCookieService::OnStartDocumentLoad(nsIDocumentLoader* aLoader, nsIURI* aURL, const char* aCommand) +nsCookieService::OnProgressChange(nsIWebProgress *aProgress, + nsIRequest *aRequest, + PRInt32 curSelfProgress, + PRInt32 maxSelfProgress, + PRInt32 curTotalProgress, + PRInt32 maxTotalProgress) { - return NS_OK; + return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP -nsCookieService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIRequest *request, nsresult aStatus) +NS_IMETHODIMP +nsCookieService::OnStateChange(nsIWebProgress* aWebProgress, + nsIRequest *aRequest, + PRInt32 progressStateFlags, + nsresult aStatus) { - COOKIE_Write(); - return NS_OK; -} - -NS_IMETHODIMP -nsCookieService::OnStartURLLoad - (nsIDocumentLoader* loader, nsIRequest *request) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsCookieService::OnProgressURLLoad - (nsIDocumentLoader* loader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsCookieService::OnStatusURLLoad - (nsIDocumentLoader* loader, nsIRequest *request, nsString& aMsg) -{ - return NS_OK; + if (progressStateFlags & STATE_IS_DOCUMENT) + if (progressStateFlags & STATE_STOP) + COOKIE_Write(); + return NS_OK; } -NS_IMETHODIMP -nsCookieService::OnEndURLLoad - (nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus) +/* void onLocationChange (in nsIURI location); */ +NS_IMETHODIMP nsCookieService::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) { - return NS_OK; + return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsCookieService::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsCookieService::OnSecurityChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 state) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + NS_IMETHODIMP nsCookieService::GetCookieString(nsIURI *aURL, char ** aCookie) { nsXPIDLCString spec; diff --git a/mozilla/extensions/cookie/nsCookieService.h b/mozilla/extensions/cookie/nsCookieService.h index 57f9dc31458..e0dfc991092 100644 --- a/mozilla/extensions/cookie/nsCookieService.h +++ b/mozilla/extensions/cookie/nsCookieService.h @@ -25,21 +25,21 @@ #include "nsICookieService.h" #include "nsIObserver.h" -#include "nsIDocumentLoaderObserver.h" +#include "nsIWebProgressListener.h" #include "nsWeakReference.h" //////////////////////////////////////////////////////////////////////////////// class nsCookieService : public nsICookieService, public nsIObserver, - public nsIDocumentLoaderObserver, + public nsIWebProgressListener, public nsSupportsWeakReference { public: // nsISupports NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER - NS_DECL_NSIDOCUMENTLOADEROBSERVER + NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSICOOKIESERVICE nsCookieService(); diff --git a/mozilla/extensions/pics/src/nsPICS.cpp b/mozilla/extensions/pics/src/nsPICS.cpp index dbb6f7e2bb1..9d302236abe 100644 --- a/mozilla/extensions/pics/src/nsPICS.cpp +++ b/mozilla/extensions/pics/src/nsPICS.cpp @@ -41,7 +41,8 @@ #include "nsFileSpec.h" #include "nsIDocumentViewer.h" #include "nsIDocumentLoader.h" -#include "nsIDocumentLoaderObserver.h" +#include "nsIWebProgressListener.h" +#include "nsIWebProgress.h" #include "nsCURILoader.h" //#include "nsIWebShell.h" #include "nsIWebShellServices.h" @@ -126,11 +127,12 @@ typedef struct { //////////////////////////////////////////////////////////////////////////////// class nsPICS : public nsIPICS, - public nsIDocumentLoaderObserver { + public nsIWebProgressListener { public: // nsISupports NS_DECL_ISUPPORTS + NS_DECL_NSIWEBPROGRESSLISTENER // nsIPICS static nsresult GetPICS(nsIPICS** aPICS); @@ -144,16 +146,6 @@ public: nsPICS(); virtual ~nsPICS(void); - // nsIDocumentLoaderObserver - NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand); - NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus); - NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *request); - NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax); - NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader, nsIRequest *request, nsString& aMsg); - NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus); -// NS_IMETHOD OnConnectionsComplete(); - - protected: void GetUserPreferences(); @@ -165,7 +157,7 @@ private: nsIObserver* mPICSElementObserver; nsCOMPtr mWebShellServices; - nsIDocumentLoader* mDocLoaderService; + nsCOMPtr mDocLoaderService; // nsVoidArray* currentURLList; nsHashtable* mWebShellServicesURLTable; @@ -325,7 +317,7 @@ PrefChangedCallback(const char* aPrefName, void* instance_data) // nsPICS Implementation -NS_IMPL_ISUPPORTS2(nsPICS, nsIPICS, nsIDocumentLoaderObserver) +NS_IMPL_ISUPPORTS2(nsPICS, nsIPICS, nsIWebProgressListener) NS_EXPORT nsresult NS_NewPICS(nsIPICS** aPICS) { @@ -340,7 +332,6 @@ nsPICS::nsPICS() mPICSElementObserver = nsnull; mWebShellServicesURLTable = nsnull; // currentURLList = nsnull; - mDocLoaderService = nsnull; mPICSRatingsEnabled = PR_FALSE; mPICSPagesMustBeRatedPref = PR_FALSE; @@ -453,12 +444,12 @@ nsPICS::Init() // Get the global document loader service... - rv = nsServiceManager::GetService(kDocLoaderServiceCID, - kIDocumentLoaderIID, - (nsISupports **)&mDocLoaderService); + mDocLoaderService = do_GetService(kDocLoaderServiceCID, &rv); if (NS_SUCCEEDED(rv)) { - //Register ourselves as an observer for the new doc loader - mDocLoaderService->AddObserver((nsIDocumentLoaderObserver*)this); + nsCOMPtr progress(do_QueryInterface(mDocLoaderService, &rv)); + if (NS_SUCCEEDED(rv)) { + (void) process->AddProgressListener((nsIWebProgressListener*)this); + } } if(mPICSRatingsEnabled) { @@ -678,248 +669,213 @@ nsPICS::ParsePICSLabel(char * label) return(new_rs); } + +// nsIWebProgressListener implementation NS_IMETHODIMP -nsPICS::OnStartDocumentLoad(nsIDocumentLoader* loader, - nsIURI* aURL, - const char* aCommand) -{ - nsresult rv = NS_ERROR_FAILURE; - - mWebShellServices = nsnull; - if(!mPICSRatingsEnabled) - return rv; - return rv; -} - - - -NS_IMETHODIMP -nsPICS::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIRequest *request, - nsresult aStatus) +nsPICS::OnStateChange(nsIWebProgress* aWebProgress, + nsIRequest *aRequest, + PRInt32 progressStateFlags, + nsresult aStatus) { nsresult rv = NS_OK; - if(!mPICSRatingsEnabled) - return rv; - mWebShellServices = nsnull; + // XXX HACK-ALERT XXX + // I'm not adding this usage, just moving it around and I thought + // I'd note that the fact that you can get a nsIWebShellServices + // from here is an implementation detail and will likely fail at + // some point in the future. + nsCOMPtr domWin; + rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWin)); + if (NS_FAILED(rv)) return rv; - nsCOMPtr cont; - rv = loader->GetContainer(getter_AddRefs(cont)); - if (NS_OK == rv) { - nsCOMPtr ws(do_QueryInterface(cont)); - if(ws) { - mWebShellServices = ws; - ws->SetRendering(PR_TRUE); + nsCOMPtr wsServices(do_GetInterface(domWin)); + NS_ASSERTION(wsServices, "no nsIWebShellService available"); + + // top-level URL loads + if (progressStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) { + if (progressStateFlags & nsIWebProgressListener::STATE_STOP) { + if(!mPICSRatingsEnabled) return rv; + nsCOMPtr cont; + if(wsServices) { + mWebShellServices = wsServices; + mWebShellServices->SetRendering(PR_TRUE); + } } - } - return rv; + } // END - STATE_IS_DOCUMENT -} + // inline URL loads + if (progressStateFlags & nsIWebProgressListener::STATE_IS_REQUEST) { + rv = NS_OK; + if (progressStateFlags & nsIWebProgressListener::STATE_START) { + nsCOMPtr channel = do_QueryInterface(aRequest); + if (!channel) return NS_ERROR_FAILURE; -NS_IMETHODIMP -nsPICS::OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *request) -{ - nsresult rv = NS_OK; - - nsCOMPtr channel = do_QueryInterface(request); - if (!channel) - return NS_ERROR_FAILURE; + nsCOMPtr uri; + rv = channel->GetURI(getter_AddRefs(uri)); + if (NS_FAILED(rv)) return rv; - nsCOMPtr aURL; - rv = channel->GetURI(getter_AddRefs(aURL)); - if (NS_FAILED(rv)) return rv; + nsXPIDLCString aContentType; + rv = channel->GetContentType(getter_Copies(aContentType)); + if (NS_FAILED(rv)) return rv; - char* aContentType; - rv = channel->GetContentType(&aContentType); - if (NS_FAILED(rv)) return rv; - - if(!mPICSRatingsEnabled) - goto done; + if(!mPICSRatingsEnabled) return rv; - PICS_URLData* urlData; - nsVoidArray* currentURLList; + PICS_URLData* urlData; + nsVoidArray* currentURLList; - if(0 == PL_strcmp("text/html", aContentType)) { - mWebShellServices = nsnull; + if(0 == PL_strcmp("text/html", aContentType)) { + if (wsServices) { + mWebShellServices = wsServices; + mWebShellServices->SetRendering(PR_FALSE); + } - nsCOMPtr cont; - rv = loader->GetContainer(getter_AddRefs(cont)); - if (NS_OK == rv) { - nsCOMPtr ws(do_QueryInterface(cont)); - if (ws) { - mWebShellServices = ws; - ws->SetRendering(PR_FALSE); - } - } + if (nsnull != uri) { + urlData = PR_NEWZAP(PICS_URLData); + urlData->url = (nsIURI*)PR_Malloc(sizeof(uri)); + urlData->url = uri; + urlData->notified = PR_FALSE; + } - if (nsnull != aURL) { - urlData = PR_NEWZAP(PICS_URLData); - urlData->url = (nsIURI*)PR_Malloc(sizeof(aURL)); - urlData->url = aURL; - urlData->notified = PR_FALSE; - - } + nsVoidKey key((void*)ws); - nsVoidKey key((void*)ws); + if(mWebShellServicesURLTable == nsnull) { + mWebShellServicesURLTable = new nsHashtable(256, PR_TRUE); + if (mWebShellServicesURLTable == nsnull) return NS_ERROR_OUT_OF_MEMORY; + } - if(mWebShellServicesURLTable == nsnull) { - mWebShellServicesURLTable = new nsHashtable(256, PR_TRUE); - if (mWebShellServicesURLTable == nsnull) { - rv = NS_ERROR_OUT_OF_MEMORY; - goto done; - } - } + if(mWebShellServicesURLTable->Exists(&key)) { + currentURLList = (nsVoidArray *) mWebShellServicesURLTable->Get(&key); + if (currentURLList != NULL) { + currentURLList->AppendElement(urlData); + mWebShellServicesURLTable->Put(&key, currentURLList); + } else { + currentURLList = new nsVoidArray(); + if(!currentURLList) return NS_ERROR_OUT_OF_MEMORY; - if(mWebShellServicesURLTable->Exists(&key)) { - currentURLList = (nsVoidArray *) mWebShellServicesURLTable->Get(&key); - if (currentURLList != NULL) { - currentURLList->AppendElement(urlData); - mWebShellServicesURLTable->Put(&key, currentURLList); - } else { - currentURLList = new nsVoidArray(); - if(!currentURLList) { - rv = NS_ERROR_OUT_OF_MEMORY; - goto done; - } - mWebShellServicesURLTable->Put(&key, currentURLList); - } - } else { - currentURLList = new nsVoidArray(); - if (!currentURLList) { - rv = NS_ERROR_OUT_OF_MEMORY; - goto done; - } - mWebShellServicesURLTable->Put(&key, currentURLList); - } + mWebShellServicesURLTable->Put(&key, currentURLList); + } + } else { + currentURLList = new nsVoidArray(); + if (!currentURLList) return NS_ERROR_OUT_OF_MEMORY; + + mWebShellServicesURLTable->Put(&key, currentURLList); + } - } - done: - nsCRT::free(aContentType); - return rv; -} + } + return rv; + } -NS_IMETHODIMP -nsPICS::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, - PRUint32 aProgress, - PRUint32 aProgressMax) -{ - if(!mPICSRatingsEnabled) - return NS_OK; - return NS_OK; -} + if (progressStateFlags & nsIWebProgressListener::STATE_STOP) { + nsCOMPtr channel = do_QueryInterface(aRequest); -NS_IMETHODIMP -nsPICS::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, - nsString& aMsg) -{ - if(!mPICSRatingsEnabled) - return NS_OK; - return NS_OK; -} + nsCOMPtr aURL; + rv = channel->GetURI(getter_AddRefs(aURL)); + if (NS_FAILED(rv)) return rv; -NS_IMETHODIMP -nsPICS::OnEndURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, - nsresult aStatus) -{ - nsresult rv; + nsVoidArray* currentURLList; - nsCOMPtr channel = do_QueryInterface(request); - - nsCOMPtr aURL; - rv = channel->GetURI(getter_AddRefs(aURL)); - if (NS_FAILED(rv)) return rv; - - char* uProtocol; - char* uHost; - char* uFile; - - nsVoidArray* currentURLList; - - if(!mPICSRatingsEnabled) - return NS_OK; + if(!mPICSRatingsEnabled) return NS_OK; - nsCOMPtr cont; - NS_ENSURE_SUCCESS(loader->GetContainer(getter_AddRefs(cont)), NS_ERROR_FAILURE); - - nsCOMPtr ws(do_QueryInterface(cont)); - NS_ENSURE_TRUE(ws, NS_ERROR_FAILURE); - - mWebShellServices = ws; + mWebShellServices = wsServices; - nsVoidKey key((void*)ws); + nsVoidKey key((void*)wsServices); - if(mWebShellServicesURLTable == nsnull) { - return NS_ERROR_NULL_POINTER; - } + if(mWebShellServicesURLTable == nsnull) { + return NS_ERROR_NULL_POINTER; + } - - if(mWebShellServicesURLTable->Exists(&key)) { - currentURLList = (nsVoidArray *) mWebShellServicesURLTable->Get(&key); - if (currentURLList != NULL) { - PRInt32 count = currentURLList->Count(); - for (PRInt32 i = 0; i < count; i++) { - PICS_URLData* urlData = (PICS_URLData*)currentURLList->ElementAt(i); - if(urlData == nsnull) - continue; - char* spec1; - char* spec2; + if(mWebShellServicesURLTable->Exists(&key)) { + currentURLList = (nsVoidArray *) mWebShellServicesURLTable->Get(&key); + if (currentURLList != NULL) { + PRInt32 count = currentURLList->Count(); + for (PRInt32 i = 0; i < count; i++) { + PICS_URLData* urlData = (PICS_URLData*)currentURLList->ElementAt(i); + if(urlData == nsnull) + continue; + nsXPIDLCString spec1; + nsXPIDLCString spec2; - if(aURL == nsnull) - continue; - aURL->GetSpec(&spec1); + if(aURL == nsnull) + continue; + aURL->GetSpec(getter_Copies(spec1)); + if(spec1 == nsnull) + continue; - if(spec1 == nsnull) - continue; + if(urlData->url == nsnull) + continue; - if(urlData->url == nsnull) { - nsCRT::free(spec1); - continue; - } - (urlData->url)->GetSpec(&spec2); + (urlData->url)->GetSpec(getter_Copies(spec2)); + if(spec2 == nsnull) + continue; - if(spec2 == nsnull) { - nsCRT::free(spec1); - continue; - } + if(0 == PL_strcmp(spec1, spec2)) { + if(!urlData->notified) { + currentURLList->RemoveElementAt(i); + if (nsnull != aURL) { + nsXPIDLCString uProtocol; + nsXPIDLCString uHost; + nsXPIDLCString uFile; - if(0 == PL_strcmp(spec1, spec2)) { - if(!urlData->notified) { - currentURLList->RemoveElementAt(i); - if (nsnull != aURL) { - aURL->GetScheme(&uProtocol); - aURL->GetHost(&uHost); - aURL->GetPath(&uFile); - if ((0 != PL_strcmp("/", uFile)) && (0 != PL_strcmp("/index.html", uFile))) { - if (0 != PL_strcmp("file", uProtocol)) { - nsAutoString protocolStr(uProtocol); - nsAutoString hostStr(uHost); + aURL->GetScheme(getter_Copies(uProtocol)); + aURL->GetHost(getter_Copies(uHost)); + aURL->GetPath(getter_Copies(uFile)); + if ((0 != PL_strcmp("/", uFile)) && (0 != PL_strcmp("/index.html", uFile))) { + if (0 != PL_strcmp("file", uProtocol)) { + nsAutoString protocolStr(uProtocol); + nsAutoString hostStr(uHost); - // Construct a chrome URL and use it to look up a resource. - nsAutoString rootStr(protocolStr + "://" + hostStr + "/"); + // Construct a chrome URL and use it to look up a resource. + nsAutoString rootStr(protocolStr + "://" + hostStr + "/"); - // XXX if we're no longer calling GetRootURL, these calls can go away - // rv = NS_NewURI(&rootURL, rootStr); - // rv = GetRootURL(rootURL); + // XXX if we're no longer calling GetRootURL, these calls can go away + // rv = NS_NewURI(&rootURL, rootStr); + // rv = GetRootURL(rootURL); + } + } + } + } } } - nsCRT::free(uProtocol); - nsCRT::free(uHost); - nsCRT::free(uFile); } } - } - nsCRT::free(spec1); - nsCRT::free(spec2); } - } - } + } // END - STATE_IS_REQUEST - - return NS_OK; + return rv; +} + +NS_IMETHODIMP +nsPICS::OnProgressChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 aCurSelfProgress, + PRInt32 aMaxSelfProgress, + PRInt32 aCurTotalProgress, + PRInt32 aMaxTotalProgress) { + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +nsPICS::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) { + return NS_ERROR_NOT_IMPLEMENTED; +} + + +NS_IMETHODIMP +nsPICS::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) { + return NS_ERROR_NOT_IMPLEMENTED; +} + + +NS_IMETHODIMP +nsPICS::OnSecurityChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 state) { + return NS_ERROR_NOT_IMPLEMENTED; } void diff --git a/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp b/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp index 2309bf18c30..0fb5f9692c2 100644 --- a/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp +++ b/mozilla/extensions/psm-glue/src/nsPSMComponent.cpp @@ -54,7 +54,6 @@ #include "nsPSMUICallbacks.h" #include "nsISecureBrowserUI.h" -#include "nsIDocumentLoaderObserver.h" #include "nsIScriptSecurityManager.h" #include "nsICertificatePrincipal.h" diff --git a/mozilla/extensions/wallet/src/nsWalletService.cpp b/mozilla/extensions/wallet/src/nsWalletService.cpp index 82aef64c97b..9c5ac8d48ed 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -45,6 +45,8 @@ #include "nsIPrompt.h" #include "nsIChannel.h" #include "nsIWindowWatcher.h" +#include "nsIWebProgress.h" +#include "nsXPIDLString.h" // for making the leap from nsIDOMWindowInternal -> nsIPresShell #include "nsIScriptGlobalObject.h" @@ -70,7 +72,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS5(nsWalletlibService, nsIWalletService, nsIObserver, nsIFormSubmitObserver, - nsIDocumentLoaderObserver, + nsIWebProgressListener, nsISupportsWeakReference) NS_IMETHODIMP nsWalletlibService::WALLET_PreEdit(nsAutoString& walletList) { @@ -229,8 +231,9 @@ nsresult nsWalletlibService::Init() // Get the global document loader service... NS_WITH_SERVICE(nsIDocumentLoader, docLoaderService, kDocLoaderServiceCID, &rv) if (NS_SUCCEEDED(rv) && docLoaderService) { - //Register ourselves as an observer for the new doc loader - docLoaderService->AddObserver((nsIDocumentLoaderObserver*)this); + nsCOMPtr progress(do_QueryInterface(docLoaderService, &rv)); + if (NS_SUCCEEDED(rv)) + (void) progress->AddProgressListener((nsIWebProgressListener*)this); } else NS_ASSERTION(PR_FALSE, "Could not get nsIDocumentLoader"); @@ -238,155 +241,136 @@ nsresult nsWalletlibService::Init() return NS_OK; } +// nsIWebProgressListener implementation NS_IMETHODIMP -nsWalletlibService::OnStartDocumentLoad(nsIDocumentLoader* aLoader, nsIURI* aURL, const char* aCommand) +nsWalletlibService::OnStateChange(nsIWebProgress* aWebProgress, + nsIRequest *aRequest, + PRInt32 progressStateFlags, + nsresult aStatus) { - return NS_OK; -} + nsresult rv = NS_OK; + if (progressStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) { + if (progressStateFlags & nsIWebProgressListener::STATE_STOP) { -#include "prmem.h" + nsCOMPtr domWin; + rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWin)); + if (NS_FAILED(rv)) return rv; -NS_IMETHODIMP -nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIRequest *request, nsresult aStatus) -{ - nsresult rv = NS_OK; + nsCOMPtr domDoc; + rv = domWin->GetDocument(getter_AddRefs(domDoc)); + if (NS_FAILED(rv)) return rv; - if (aLoader == nsnull) { - return rv; - } - nsCOMPtr cont; - rv = aLoader->GetContainer(getter_AddRefs(cont)); - if (NS_FAILED(rv) || (cont == nsnull)) { - return rv; - } - nsCOMPtr docShell(do_QueryInterface(cont)); - NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE); - - nsCOMPtr cv; - rv = docShell->GetContentViewer(getter_AddRefs(cv)); - if (NS_FAILED(rv) || (cv == nsnull)) { - return rv; - } - nsCOMPtr docViewer(do_QueryInterface(cv)); - NS_ENSURE_TRUE(docViewer, NS_ERROR_FAILURE); - - nsCOMPtr doc; - rv = docViewer->GetDocument(*getter_AddRefs(doc)); - if (NS_FAILED(rv) || (doc == nsnull)) { - return rv; - } + // we only want to handle HTML documents as they're the + // only one's that can have forms which we might want to + // pre-fill. + nsCOMPtr htmldoc(do_QueryInterface(domDoc, &rv)); + if (NS_FAILED(rv)) return NS_OK; + + nsCOMPtr doc(do_QueryInterface(htmldoc, &rv)); + if (NS_FAILED(rv)) { + NS_ASSERTION(0, "no document available"); + return NS_OK; + } - /* get url name as ascii string */ - char *URLName = nsnull; - nsIURI* docURL = nsnull; - char* spec; - if (!doc) { - return NS_OK; - } - docURL = doc->GetDocumentURL(); - if (!docURL) { - return NS_OK; - } - (void)docURL->GetSpec(&spec); - URLName = (char*)PR_Malloc(PL_strlen(spec)+1); - PL_strcpy(URLName, spec); - NS_IF_RELEASE(docURL); - nsCRT::free(spec); - - nsCOMPtr htmldoc(do_QueryInterface(doc)); - if (htmldoc == nsnull) { - PR_Free(URLName); - return NS_ERROR_FAILURE; - } - - nsCOMPtr forms; - rv = htmldoc->GetForms(getter_AddRefs(forms)); - if (NS_FAILED(rv) || (forms == nsnull)) { - PR_Free(URLName); - return rv; - } - - PRUint32 elementNumber = 0; - PRUint32 numForms; - forms->GetLength(&numForms); - for (PRUint32 formX = 0; formX < numForms; formX++) { - nsCOMPtr formNode; - forms->Item(formX, getter_AddRefs(formNode)); - if (nsnull != formNode) { - nsCOMPtr formElement(do_QueryInterface(formNode)); - if ((nsnull != formElement)) { - nsCOMPtr elements; - rv = formElement->GetElements(getter_AddRefs(elements)); - if ((NS_SUCCEEDED(rv)) && (nsnull != elements)) { - /* got to the form elements at long last */ - PRUint32 numElements; - elements->GetLength(&numElements); - /* get number of passwords on form */ - PRInt32 passwordCount = 0; - for (PRUint32 elementXX = 0; elementXX < numElements; elementXX++) { - nsCOMPtr elementNode; - elements->Item(elementXX, getter_AddRefs(elementNode)); - if (nsnull != elementNode) { - nsCOMPtr inputElement(do_QueryInterface(elementNode)); - if ((NS_SUCCEEDED(rv)) && (nsnull != inputElement)) { - nsAutoString type; - rv = inputElement->GetType(type); - if (NS_SUCCEEDED(rv)) { - if (type.CompareWithConversion("password", PR_TRUE) == 0) { - passwordCount++; - } - } - } - } + nsCOMPtr uri(getter_AddRefs(doc->GetDocumentURL())); + if (!uri) { + NS_ASSERTION(0, "no URI available"); + return NS_OK; } - /* don't prefill if there were no passwords on the form */ - if (passwordCount == 0) { - continue; - } - for (PRUint32 elementX = 0; elementX < numElements; elementX++) { - nsCOMPtr elementNode; - elements->Item(elementX, getter_AddRefs(elementNode)); - if (nsnull != elementNode) { - nsCOMPtr inputElement(do_QueryInterface(elementNode)); - if ((NS_SUCCEEDED(rv)) && (nsnull != inputElement)) { - nsAutoString type; - rv = inputElement->GetType(type); - if (NS_SUCCEEDED(rv)) { - if ((type.IsEmpty()) || (type.CompareWithConversion("text", PR_TRUE) == 0) || - (type.CompareWithConversion("password", PR_TRUE) == 0)) { - nsAutoString field; - rv = inputElement->GetName(field); - if (NS_SUCCEEDED(rv)) { - PRUnichar* nameString = field.ToNewUnicode(); - if (nameString) { - /* note: we do not want to prefill if there is a default value */ - nsAutoString value; - rv = inputElement->GetValue(value); - if (NS_FAILED(rv) || value.Length() == 0) { - PRUnichar* valueString = NULL; - nsCOMPtr interfaces; - nsCOMPtr prompter; - nsCOMPtr channel = do_QueryInterface(request); - if (channel) - channel->GetNotificationCallbacks(getter_AddRefs(interfaces)); - if (interfaces) - interfaces->GetInterface(NS_GET_IID(nsIPrompt), getter_AddRefs(prompter)); - if (!prompter) { - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - if (wwatch) - wwatch->GetNewPrompter(0, getter_AddRefs(prompter)); - } - if (prompter) { - SINGSIGN_RestoreSignonData(prompter, URLName, nameString, &valueString, elementNumber++); - } - if (valueString) { - value = valueString; - rv = inputElement->SetValue(value); - // warning! don't delete valueString + nsXPIDLCString spec; + rv = uri->GetSpec(getter_Copies(spec)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr forms; + rv = htmldoc->GetForms(getter_AddRefs(forms)); + if (NS_FAILED(rv) || (forms == nsnull)) return rv; + + PRUint32 elementNumber = 0; + PRUint32 numForms; + forms->GetLength(&numForms); + for (PRUint32 formX = 0; formX < numForms; formX++) { + nsCOMPtr formNode; + forms->Item(formX, getter_AddRefs(formNode)); + if (nsnull != formNode) { + nsCOMPtr formElement(do_QueryInterface(formNode)); + if ((nsnull != formElement)) { + nsCOMPtr elements; + rv = formElement->GetElements(getter_AddRefs(elements)); + if ((NS_SUCCEEDED(rv)) && (nsnull != elements)) { + /* got to the form elements at long last */ + PRUint32 numElements; + elements->GetLength(&numElements); + /* get number of passwords on form */ + PRInt32 passwordCount = 0; + for (PRUint32 elementXX = 0; elementXX < numElements; elementXX++) { + nsCOMPtr elementNode; + elements->Item(elementXX, getter_AddRefs(elementNode)); + if (nsnull != elementNode) { + nsCOMPtr inputElement(do_QueryInterface(elementNode)); + if ((NS_SUCCEEDED(rv)) && (nsnull != inputElement)) { + nsAutoString type; + rv = inputElement->GetType(type); + if (NS_SUCCEEDED(rv)) { + if (type.CompareWithConversion("password", PR_TRUE) == 0) { + passwordCount++; + } + } + } + } + } + /* don't prefill if there were no passwords on the form */ + if (passwordCount == 0) { + continue; + } + for (PRUint32 elementX = 0; elementX < numElements; elementX++) { + nsCOMPtr elementNode; + elements->Item(elementX, getter_AddRefs(elementNode)); + if (nsnull != elementNode) { + nsCOMPtr inputElement(do_QueryInterface(elementNode)); + if ((NS_SUCCEEDED(rv)) && (nsnull != inputElement)) { + nsAutoString type; + rv = inputElement->GetType(type); + if (NS_SUCCEEDED(rv)) { + if ((type.IsEmpty()) || (type.CompareWithConversion("text", PR_TRUE) == 0) || + (type.CompareWithConversion("password", PR_TRUE) == 0)) { + nsAutoString field; + rv = inputElement->GetName(field); + if (NS_SUCCEEDED(rv)) { + PRUnichar* nameString = field.ToNewUnicode(); + if (nameString) { + /* note: we do not want to prefill if there is a default value */ + nsAutoString value; + rv = inputElement->GetValue(value); + if (NS_FAILED(rv) || value.Length() == 0) { + PRUnichar* valueString = NULL; + nsCOMPtr interfaces; + nsCOMPtr prompter; + + nsCOMPtr channel = do_QueryInterface(aRequest); + if (channel) + channel->GetNotificationCallbacks(getter_AddRefs(interfaces)); + if (interfaces) + interfaces->GetInterface(NS_GET_IID(nsIPrompt), getter_AddRefs(prompter)); + if (!prompter) { + nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + if (wwatch) + wwatch->GetNewPrompter(0, getter_AddRefs(prompter)); + } + if (prompter) { + SINGSIGN_RestoreSignonData(prompter, spec, nameString, &valueString, elementNumber++); + } + if (valueString) { + value = valueString; + rv = inputElement->SetValue(value); + // warning! don't delete valueString + } + } + Recycle(nameString); + } + } } } - Recycle(nameString); } } } @@ -395,43 +379,49 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIRequest *re } } } - } } - } - - PR_Free(URLName); - return rv; + return rv; } NS_IMETHODIMP -nsWalletlibService::OnStartURLLoad - (nsIDocumentLoader* loader, nsIRequest *request) +nsWalletlibService::OnProgressChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 aCurSelfProgress, + PRInt32 aMaxSelfProgress, + PRInt32 aCurTotalProgress, + PRInt32 aMaxTotalProgress) { - return NS_OK; + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsWalletlibService::OnProgressURLLoad - (nsIDocumentLoader* loader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) +nsWalletlibService::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) { - return NS_OK; -} - -NS_IMETHODIMP -nsWalletlibService::OnStatusURLLoad - (nsIDocumentLoader* loader, nsIRequest *request, nsString& aMsg) -{ - return NS_OK; + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsWalletlibService::OnEndURLLoad - (nsIDocumentLoader* loader, nsIRequest *request, nsresult aStatus) +nsWalletlibService::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) { - return NS_OK; + return NS_ERROR_NOT_IMPLEMENTED; } + +NS_IMETHODIMP +nsWalletlibService::OnSecurityChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 state) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + NS_IMETHODIMP nsWalletlibService::GetPassword(PRUnichar **password) { diff --git a/mozilla/extensions/wallet/src/nsWalletService.h b/mozilla/extensions/wallet/src/nsWalletService.h index ee1525ec7e3..5f46878cf4f 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.h +++ b/mozilla/extensions/wallet/src/nsWalletService.h @@ -26,17 +26,17 @@ #include "nsIWalletService.h" #include "nsIObserver.h" #include "nsIFormSubmitObserver.h" -#include "nsIDocumentLoaderObserver.h" #include "nsWeakReference.h" #include "nsIPasswordSink.h" #include "nsIPrompt.h" #include "nsIDOMWindowInternal.h" #include "nsIURI.h" +#include "nsIWebProgressListener.h" class nsWalletlibService : public nsIWalletService, public nsIObserver, public nsIFormSubmitObserver, - public nsIDocumentLoaderObserver, + public nsIWebProgressListener, public nsIPasswordSink, public nsSupportsWeakReference { @@ -44,7 +44,7 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIWALLETSERVICE NS_DECL_NSIOBSERVER - NS_DECL_NSIDOCUMENTLOADEROBSERVER + NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSIPASSWORDSINK // NS_DECL_NSSUPPORTSWEAKREFERENCE diff --git a/mozilla/extensions/xmlterm/base/README b/mozilla/extensions/xmlterm/base/README index 5909ce42691..7d68e4d88b8 100644 --- a/mozilla/extensions/xmlterm/base/README +++ b/mozilla/extensions/xmlterm/base/README @@ -84,7 +84,7 @@ mozXMLTermShell.cpp Implementation of mozIXMLTermShell mozXMLTerminal.h mozXMLTerminal.cpp Implementation of mozIXMLTerminal, - nsIDocumentLoaderObserver, and + nsIWebProgressListener, and nsIObserver Uses mozILineTermAux to create LineTerm Uses mozXMLTermListeners to capture user input diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index 447b719e386..105c04e8c99 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -34,7 +34,6 @@ #include "nsIDocument.h" #include "nsIDOMHTMLDocument.h" #include "nsIDocumentViewer.h" -#include "nsIDocumentLoaderObserver.h" #include "nsIObserver.h" #include "nsIPresContext.h" @@ -60,6 +59,8 @@ #include "mozIXMLTermSuspend.h" #include "nsIWebNavigation.h" +#include "nsIInterfaceRequestor.h" +#include "nsIWebProgress.h" //////////////////////////////////////////////////////////////////////// @@ -143,7 +144,7 @@ NS_INTERFACE_MAP_BEGIN(mozXMLTerminal) */ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, mozIXMLTerminal) NS_INTERFACE_MAP_ENTRY(mozIXMLTerminal) - NS_INTERFACE_MAP_ENTRY(nsIDocumentLoaderObserver) + NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) NS_INTERFACE_MAP_ENTRY(nsIObserver) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_END @@ -253,7 +254,10 @@ NS_IMETHODIMP mozXMLTerminal::Init(nsIDocShell* aDocShell, XMLT_LOG(mozXMLTerminal::Init,22,("setting DocLoaderObs\n")); // About to create owning reference to this - result = aDocShell->SetDocLoaderObserver((nsIDocumentLoaderObserver*)this); + nsCOMPtr progress(do_GetInterface(aDocShell, &result)); + if (NS_FAILED(result)) return result; + + result = progress->AddProgressListener((nsIWebProgressListener*)this); if (NS_FAILED(result)) return NS_ERROR_FAILURE; @@ -343,11 +347,6 @@ NS_IMETHODIMP mozXMLTerminal::Finalize(void) mLineTermAux = nsnull; } - nsCOMPtr docShell = do_QueryReferent(mDocShell); - if (docShell) { - // Stop observing document loading - docShell->SetDocLoaderObserver((nsIDocumentLoaderObserver *)nsnull); - } mDocShell = nsnull; mPresShell = nsnull; @@ -1049,53 +1048,53 @@ NS_IMETHODIMP mozXMLTerminal::Resize(void) return NS_OK; } - -// nsIDocumentLoaderObserver methods +// nsIWebProgressListener methods NS_IMETHODIMP -mozXMLTerminal::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, - const char* aCommand) -{ - return NS_OK; +mozXMLTerminal::OnStateChange(nsIWebProgress* aWebProgress, + nsIRequest *aRequest, + PRInt32 progressStateFlags, + nsresult aStatus) { + if (progressStateFlags & nsIWebProgressListener::STATE_IS_REQUEST) + if (progressStateFlags & nsIWebProgressListener::STATE_START) { + XMLT_LOG(mozXMLTerminal::OnStateChange,20,("\n")); + + // Activate XMLTerm + Activate(); + } + return NS_OK; + } NS_IMETHODIMP -mozXMLTerminal::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIRequest* request, - nsresult aStatus) -{ - - return NS_OK; +mozXMLTerminal::OnProgressChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 aCurSelfProgress, + PRInt32 aMaxSelfProgress, + PRInt32 aCurTotalProgress, + PRInt32 aMaxTotalProgress) { + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -mozXMLTerminal::OnStartURLLoad(nsIDocumentLoader* loader, - nsIRequest* request) -{ - - return NS_OK; +mozXMLTerminal::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) { + return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHODIMP -mozXMLTerminal::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, PRUint32 aProgress, - PRUint32 aProgressMax) -{ - return NS_OK; +mozXMLTerminal::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) { + return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHODIMP -mozXMLTerminal::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, nsString& aMsg) -{ - return NS_OK; -} - -NS_IMETHODIMP -mozXMLTerminal::OnEndURLLoad(nsIDocumentLoader* loader, - nsIRequest* request, nsresult aStatus) -{ - XMLT_LOG(mozXMLTerminal::OnEndURLLoad,20,("\n")); - - // Activate XMLTerm - Activate(); - return NS_OK; +mozXMLTerminal::OnSecurityChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 state) { + return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.h b/mozilla/extensions/xmlterm/base/mozXMLTerminal.h index e5602c0bedb..cc24e0d49b9 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.h +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.h @@ -28,6 +28,7 @@ #include "nsWeakReference.h" #include "nsWeakPtr.h" #include "nsString.h" +#include "nsIWebProgressListener.h" #include "mozXMLT.h" @@ -39,7 +40,7 @@ class mozXMLTerminal : public mozIXMLTerminal, - public nsIDocumentLoaderObserver, + public nsIWebProgressListener, public nsIObserver, public nsSupportsWeakReference { @@ -51,6 +52,9 @@ class mozXMLTerminal : public mozIXMLTerminal, // nsISupports interface NS_DECL_ISUPPORTS + // nsIWebProgressListener interface + NS_DECL_NSIWEBPROGRESSLISTENER + // mozIXMLTerminal interface NS_IMETHOD Init(nsIDocShell* aDocShell, @@ -95,8 +99,6 @@ class mozXMLTerminal : public mozIXMLTerminal, NS_IMETHOD ScreenSize(PRInt32& rows, PRInt32& cols, PRInt32& xPixels, PRInt32& yPixels); - // nsIDocumentLoaderObserver interface - NS_DECL_NSIDOCUMENTLOADEROBSERVER // nsIObserver interface NS_IMETHOD Observe(nsISupports *aSubject, const PRUnichar *aTopic, diff --git a/mozilla/htmlparser/robot/nsDebugRobot.cpp b/mozilla/htmlparser/robot/nsDebugRobot.cpp index 648b849f29d..1e5846714a3 100644 --- a/mozilla/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/htmlparser/robot/nsDebugRobot.cpp @@ -24,10 +24,10 @@ #include "nsIRobotSinkObserver.h" #include "nsIParser.h" #include "nsIDocShell.h" -#include "nsIWebNavigation.h" -#include "nsIWebShell.h" -#include "nsIDocumentLoader.h" -#include "nsIDocumentLoaderObserver.h" +#include "nsIWebNavigation.h" +#include "nsIWebProgress.h" +#include "nsIWebProgressListener.h" +#include "nsWeakReference.h" #include "nsVoidArray.h" #include "nsString.h" #include "nsIURL.h" @@ -37,6 +37,7 @@ #include "nsNetCID.h" #include "nsIComponentManager.h" #include "nsParserCIID.h" +#include "nsIInterfaceRequestor.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_IID(kIRobotSinkObserverIID, NS_IROBOTSINKOBSERVER_IID); @@ -125,7 +126,8 @@ NS_IMETHODIMP RobotSinkObserver::ProcessLink(const nsString& aURLSpec) extern "C" NS_EXPORT void SetVerificationDirectory(char * verify_dir); -class CStreamListener: public nsIDocumentLoaderObserver +class CStreamListener: public nsIWebProgressListener, + public nsSupportsWeakReference { public: CStreamListener() { @@ -138,69 +140,61 @@ public: NS_DECL_ISUPPORTS - // nsIDocumentLoaderObserver - NS_DECL_NSIDOCUMENTLOADEROBSERVER + // nsIWebProgressListener + NS_DECL_NSIWEBPROGRESSLISTENER }; -// document loader observer implementation +// nsIWebProgressListener implementation NS_IMETHODIMP -CStreamListener::OnStartDocumentLoad(nsIDocumentLoader* loader, - nsIURI* aURL, - const char* aCommand) -{ - return NS_OK; +CStreamListener::OnStateChange(nsIWebProgress* aWebProgress, + nsIRequest *aRequest, + PRInt32 progressStateFlags, + nsresult aStatus) { + if (progressStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) + if (progressStateFlags & nsIWebProgressListener::STATE_STOP) { + fputs("done.\n",stdout); + g_bReadyForNextUrl = PR_TRUE; + } + return NS_OK; } NS_IMETHODIMP -CStreamListener::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIRequest *request, - nsresult aStatus) -{ - fputs("done.\n",stdout); - g_bReadyForNextUrl = PR_TRUE; - return NS_OK; +CStreamListener::OnProgressChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 aCurSelfProgress, + PRInt32 aMaxSelfProgress, + PRInt32 aCurTotalProgress, + PRInt32 aMaxTotalProgress) { + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -CStreamListener::OnStartURLLoad(nsIDocumentLoader* loader, - nsIRequest *request) -{ - return NS_OK; +CStreamListener::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) { + return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHODIMP -CStreamListener::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, - PRUint32 aProgress, - PRUint32 aProgressMax) -{ - return NS_OK; +CStreamListener::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) { + return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHODIMP -CStreamListener::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, - nsString& aMsg) -{ - return NS_OK; +CStreamListener::OnSecurityChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 state) { + return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP -CStreamListener::OnEndURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, - nsresult aStatus) -{ - return NS_OK; -} - - -nsresult CStreamListener::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - return NS_ERROR_NOT_IMPLEMENTED; // never called -} - -NS_IMPL_ADDREF(CStreamListener) -NS_IMPL_RELEASE(CStreamListener) +NS_IMPL_ISUPPORTS2(CStreamListener, + nsIWebProgressListener, + nsISupportsWeakReference) extern "C" NS_EXPORT void DumpVectorRecord(void); //---------------------------------------------------------------------- @@ -318,14 +312,11 @@ extern "C" NS_EXPORT int DebugRobot( } g_bReadyForNextUrl = PR_FALSE; if (docShell) { - nsIDocumentLoader *docLoader; + nsCOMPtr progress(do_GetInterface(docShell, &rv)); + if (NS_FAILED(rv)) return rv; + + (void) progress->AddProgressListener(pl); - nsCOMPtr webShell(do_QueryInterface(docShell)); - webShell->GetDocumentLoader(docLoader); - if (docLoader) { - docLoader->AddObserver(pl); - NS_RELEASE(docLoader); - } char* spec; (void)url->GetSpec(&spec); nsAutoString theSpec; theSpec.AssignWithConversion(spec); diff --git a/mozilla/mailnews/base/public/nsIMsgPrintEngine.idl b/mozilla/mailnews/base/public/nsIMsgPrintEngine.idl index 63bdbac4c77..c8020636258 100644 --- a/mozilla/mailnews/base/public/nsIMsgPrintEngine.idl +++ b/mozilla/mailnews/base/public/nsIMsgPrintEngine.idl @@ -20,8 +20,6 @@ * Contributor(s): */ -#include "nsIStreamListener.idl" -#include "nsIDocumentLoaderObserver.idl" #include "nsrootidl.idl" #include "domstubs.idl" #include "nsIMsgStatusFeedback.idl" @@ -31,7 +29,7 @@ %} [scriptable, uuid(91FD6B10-E0BC-11d3-8F97-000064657374)] -interface nsIMsgPrintEngine : nsIDocumentLoaderObserver { +interface nsIMsgPrintEngine : nsISupports { void SetWindow(in nsIDOMWindowInternal ptr); void SetStatusFeedback(in nsIMsgStatusFeedback feedback); diff --git a/mozilla/mailnews/base/src/nsMessenger.cpp b/mozilla/mailnews/base/src/nsMessenger.cpp index 2bcdd81ffcd..5fa4331111e 100644 --- a/mozilla/mailnews/base/src/nsMessenger.cpp +++ b/mozilla/mailnews/base/src/nsMessenger.cpp @@ -307,12 +307,10 @@ nsMessenger::SetWindow(nsIDOMWindowInternal *aWin, nsIMsgWindow *aMsgWindow) nsCOMPtr aStatusFeedback; aMsgWindow->GetStatusFeedback(getter_AddRefs(aStatusFeedback)); - m_docLoaderObserver = do_QueryInterface(aStatusFeedback); if (aStatusFeedback) { aStatusFeedback->SetDocShell(mDocShell, mWindow); } - mDocShell->SetDocLoaderObserver(m_docLoaderObserver); aMsgWindow->GetTransactionManager(getter_AddRefs(mTxnMgr)); } } diff --git a/mozilla/mailnews/base/src/nsMessenger.h b/mozilla/mailnews/base/src/nsMessenger.h index 1064de43376..7ea00a261b0 100644 --- a/mozilla/mailnews/base/src/nsMessenger.h +++ b/mozilla/mailnews/base/src/nsMessenger.h @@ -28,7 +28,6 @@ #include "nsIMessenger.h" #include "nsCOMPtr.h" #include "nsITransactionManager.h" -#include "nsIDocumentLoaderObserver.h" #include "nsFileSpec.h" #include "nsIDocShell.h" #include "nsIStringBundle.h" @@ -71,8 +70,6 @@ private: // String bundles... nsCOMPtr mStringBundle; - nsCOMPtr m_docLoaderObserver; - PRBool mCharsetInitialized; void InitializeDisplayCharset(); nsCOMPtr mSearchContext; diff --git a/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp b/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp index f742cad7d91..51f35a8ee4a 100644 --- a/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp +++ b/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp @@ -35,8 +35,8 @@ #include "nsIContentViewer.h" #include "nsIMsgMessageService.h" #include "nsMsgUtils.h" -#include "nsIDocumentLoader.h" -#include "nsIDocumentLoaderObserver.h" +#include "nsIWebProgress.h" +#include "nsIInterfaceRequestor.h" #include "nsIMarkupDocumentViewer.h" #include "nsIMsgMailSession.h" #include "nsMsgPrintEngine.h" @@ -57,9 +57,7 @@ static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID); static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); -nsMsgPrintEngine::nsMsgPrintEngine() : - mDocShell(nsnull), - mWindow(nsnull) +nsMsgPrintEngine::nsMsgPrintEngine() { mCurrentlyPrintingURI = -1; mContentViewer = nsnull; @@ -77,81 +75,93 @@ nsMsgPrintEngine::~nsMsgPrintEngine() NS_IMPL_ADDREF(nsMsgPrintEngine) NS_IMPL_RELEASE(nsMsgPrintEngine) -NS_IMPL_QUERY_INTERFACE3(nsMsgPrintEngine, nsIMsgPrintEngine, nsIDocumentLoaderObserver, nsIPrintListener); +NS_IMPL_QUERY_INTERFACE4(nsMsgPrintEngine, + nsIMsgPrintEngine, + nsIWebProgressListener, + nsISupportsWeakReference, + nsIPrintListener); nsresult nsMsgPrintEngine::Init() { return NS_OK; } + +// nsIWebProgressListener implementation NS_IMETHODIMP -nsMsgPrintEngine::OnStartDocumentLoad(nsIDocumentLoader *aLoader, nsIURI *aURL, const char *aCommand) +nsMsgPrintEngine::OnStateChange(nsIWebProgress* aWebProgress, + nsIRequest *aRequest, + PRInt32 progressStateFlags, + nsresult aStatus) { - // Tell the user we are loading... - PRUnichar *msg = GetString(NS_ConvertASCIItoUCS2("LoadingMessageToPrint").GetUnicode()); - SetStatusMessage( msg ); - PR_FREEIF(msg); + nsresult rv = NS_OK; - return NS_OK; -} + // top-level document load data + if (progressStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) { + if (progressStateFlags & nsIWebProgressListener::STATE_START) { + // Tell the user we are loading... + PRUnichar *msg = GetString(NS_ConvertASCIItoUCS2("LoadingMessageToPrint").GetUnicode()); + SetStatusMessage( msg ); + PR_FREEIF(msg); + } -NS_IMETHODIMP -nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIRequest *request, PRUint32 aStatus) -{ - // Now, fire off the print operation! - nsresult rv = NS_ERROR_FAILURE; + if (progressStateFlags & nsIWebProgressListener::STATE_STOP) { + // Now, fire off the print operation! + rv = NS_ERROR_FAILURE; - // Tell the user the message is loaded... - PRUnichar *msg = GetString(NS_ConvertASCIItoUCS2("MessageLoaded").GetUnicode()); - SetStatusMessage( msg ); - PR_FREEIF(msg); + // Tell the user the message is loaded... + PRUnichar *msg = GetString(NS_ConvertASCIItoUCS2("MessageLoaded").GetUnicode()); + SetStatusMessage( msg ); + PR_FREEIF(msg); - NS_ASSERTION(mDocShell,"can't print, there is no docshell"); - if ( (!mDocShell) || (!request) ) - { - return StartNextPrintOperation(); - } - nsCOMPtr aChannel = do_QueryInterface(request); - if (!aChannel) return NS_ERROR_FAILURE; - - // Make sure this isn't just "about:blank" finishing.... - nsCOMPtr originalURI = nsnull; - if (NS_SUCCEEDED(aChannel->GetOriginalURI(getter_AddRefs(originalURI)))) - { - nsXPIDLCString spec; - - if (NS_SUCCEEDED(originalURI->GetSpec(getter_Copies(spec))) && spec) - { - if (!nsCRT::strcasecmp(spec, "about:blank")) + NS_ASSERTION(mDocShell,"can't print, there is no docshell"); + if ( (!mDocShell) || (!aRequest) ) { return StartNextPrintOperation(); } - } - } + nsCOMPtr aChannel = do_QueryInterface(aRequest); + if (!aChannel) return NS_ERROR_FAILURE; - mDocShell->GetContentViewer(getter_AddRefs(mContentViewer)); - if (mContentViewer) - { - mViewerFile = do_QueryInterface(mContentViewer); - if (mViewerFile) - { - if (mCurrentlyPrintingURI == 0) - rv = mViewerFile->Print(PR_FALSE, nsnull, (nsIPrintListener *)this); - else - rv = mViewerFile->Print(PR_TRUE, nsnull, (nsIPrintListener *)this); - - if (NS_FAILED(rv)) + // Make sure this isn't just "about:blank" finishing.... + nsCOMPtr originalURI = nsnull; + if (NS_SUCCEEDED(aChannel->GetOriginalURI(getter_AddRefs(originalURI)))) { - mViewerFile = nsnull; - mContentViewer = nsnull; - OnEndPrinting(rv); + nsXPIDLCString spec; + + if (NS_SUCCEEDED(originalURI->GetSpec(getter_Copies(spec))) && spec) + { + if (!nsCRT::strcasecmp(spec, "about:blank")) + { + return StartNextPrintOperation(); + } + } } - else + + mDocShell->GetContentViewer(getter_AddRefs(mContentViewer)); + if (mContentViewer) { - // Tell the user we started printing... - msg = GetString(NS_LITERAL_STRING("PrintingMessage").get()); - SetStatusMessage( msg ); - PR_FREEIF(msg); + mViewerFile = do_QueryInterface(mContentViewer); + if (mViewerFile) + { + if (mCurrentlyPrintingURI == 0) + rv = mViewerFile->Print(PR_FALSE, nsnull, (nsIPrintListener *)this); + else + rv = mViewerFile->Print(PR_TRUE, nsnull, (nsIPrintListener *)this); + + if (NS_FAILED(rv)) + { + mViewerFile = nsnull; + mContentViewer = nsnull; + OnEndPrinting(rv); + } + else + { + // Tell the user we started printing... + msg = GetString(NS_LITERAL_STRING("PrintingMessage").get()); + SetStatusMessage( msg ); + PR_FREEIF(msg); + } + } } } } @@ -160,27 +170,37 @@ nsMsgPrintEngine::OnEndDocumentLoad(nsIDocumentLoader *loader, nsIRequest *reque } NS_IMETHODIMP -nsMsgPrintEngine::OnStartURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request) -{ - return NS_OK; +nsMsgPrintEngine::OnProgressChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 aCurSelfProgress, + PRInt32 aMaxSelfProgress, + PRInt32 aCurTotalProgress, + PRInt32 aMaxTotalProgress) { + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsMsgPrintEngine::OnProgressURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request, PRUint32 aProgress, PRUint32 aProgressMax) -{ - return NS_OK; +nsMsgPrintEngine::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) { + return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP -nsMsgPrintEngine::OnStatusURLLoad(nsIDocumentLoader *loader, nsIRequest *request, nsString & aMsg) -{ - return NS_OK; -} NS_IMETHODIMP -nsMsgPrintEngine::OnEndURLLoad(nsIDocumentLoader *aLoader, nsIRequest *request, PRUint32 aStatus) -{ - return NS_OK; +nsMsgPrintEngine::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) { + return NS_ERROR_NOT_IMPLEMENTED; +} + + +NS_IMETHODIMP +nsMsgPrintEngine::OnSecurityChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 state) { + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP @@ -348,7 +368,11 @@ nsMsgPrintEngine::SetupObserver() if (mDocShell) { - mDocShell->SetDocLoaderObserver((nsIDocumentLoaderObserver *)this); + nsCOMPtr progress(do_GetInterface(mDocShell)); + NS_ASSERTION(progress, "we were expecting a nsIWebProgress"); + if (progress) { + (void) progress->AddProgressListener((nsIWebProgressListener *)this); + } } } diff --git a/mozilla/mailnews/base/src/nsMsgPrintEngine.h b/mozilla/mailnews/base/src/nsMsgPrintEngine.h index 1e68e31b608..9a848eecf99 100644 --- a/mozilla/mailnews/base/src/nsMsgPrintEngine.h +++ b/mozilla/mailnews/base/src/nsMsgPrintEngine.h @@ -36,8 +36,13 @@ #include "nsIMsgStatusFeedback.h" #include "nsIStringBundle.h" #include "nsIContentViewerFile.h" +#include "nsIWebProgressListener.h" +#include "nsWeakReference.h" -class nsMsgPrintEngine : public nsIMsgPrintEngine, public nsIPrintListener { +class nsMsgPrintEngine : public nsIMsgPrintEngine, + public nsIWebProgressListener, + public nsSupportsWeakReference, + public nsIPrintListener { public: nsMsgPrintEngine(); @@ -51,8 +56,8 @@ public: // nsIMsgPrintEngine interface NS_DECL_NSIMSGPRINTENGINE - // For nsIDocumentLoaderObserver... - NS_DECL_NSIDOCUMENTLOADEROBSERVER + // For nsIWebProgressListener + NS_DECL_NSIWEBPROGRESSLISTENER // For nIPrintListener NS_DECL_NSIPRINTLISTENER diff --git a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp index 648b849f29d..1e5846714a3 100644 --- a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp @@ -24,10 +24,10 @@ #include "nsIRobotSinkObserver.h" #include "nsIParser.h" #include "nsIDocShell.h" -#include "nsIWebNavigation.h" -#include "nsIWebShell.h" -#include "nsIDocumentLoader.h" -#include "nsIDocumentLoaderObserver.h" +#include "nsIWebNavigation.h" +#include "nsIWebProgress.h" +#include "nsIWebProgressListener.h" +#include "nsWeakReference.h" #include "nsVoidArray.h" #include "nsString.h" #include "nsIURL.h" @@ -37,6 +37,7 @@ #include "nsNetCID.h" #include "nsIComponentManager.h" #include "nsParserCIID.h" +#include "nsIInterfaceRequestor.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_IID(kIRobotSinkObserverIID, NS_IROBOTSINKOBSERVER_IID); @@ -125,7 +126,8 @@ NS_IMETHODIMP RobotSinkObserver::ProcessLink(const nsString& aURLSpec) extern "C" NS_EXPORT void SetVerificationDirectory(char * verify_dir); -class CStreamListener: public nsIDocumentLoaderObserver +class CStreamListener: public nsIWebProgressListener, + public nsSupportsWeakReference { public: CStreamListener() { @@ -138,69 +140,61 @@ public: NS_DECL_ISUPPORTS - // nsIDocumentLoaderObserver - NS_DECL_NSIDOCUMENTLOADEROBSERVER + // nsIWebProgressListener + NS_DECL_NSIWEBPROGRESSLISTENER }; -// document loader observer implementation +// nsIWebProgressListener implementation NS_IMETHODIMP -CStreamListener::OnStartDocumentLoad(nsIDocumentLoader* loader, - nsIURI* aURL, - const char* aCommand) -{ - return NS_OK; +CStreamListener::OnStateChange(nsIWebProgress* aWebProgress, + nsIRequest *aRequest, + PRInt32 progressStateFlags, + nsresult aStatus) { + if (progressStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) + if (progressStateFlags & nsIWebProgressListener::STATE_STOP) { + fputs("done.\n",stdout); + g_bReadyForNextUrl = PR_TRUE; + } + return NS_OK; } NS_IMETHODIMP -CStreamListener::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIRequest *request, - nsresult aStatus) -{ - fputs("done.\n",stdout); - g_bReadyForNextUrl = PR_TRUE; - return NS_OK; +CStreamListener::OnProgressChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 aCurSelfProgress, + PRInt32 aMaxSelfProgress, + PRInt32 aCurTotalProgress, + PRInt32 aMaxTotalProgress) { + return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -CStreamListener::OnStartURLLoad(nsIDocumentLoader* loader, - nsIRequest *request) -{ - return NS_OK; +CStreamListener::OnLocationChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsIURI *location) { + return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHODIMP -CStreamListener::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, - PRUint32 aProgress, - PRUint32 aProgressMax) -{ - return NS_OK; +CStreamListener::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + nsresult aStatus, + const PRUnichar* aMessage) { + return NS_ERROR_NOT_IMPLEMENTED; } + NS_IMETHODIMP -CStreamListener::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, - nsString& aMsg) -{ - return NS_OK; +CStreamListener::OnSecurityChange(nsIWebProgress *aWebProgress, + nsIRequest *aRequest, + PRInt32 state) { + return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP -CStreamListener::OnEndURLLoad(nsIDocumentLoader* loader, - nsIRequest *request, - nsresult aStatus) -{ - return NS_OK; -} - - -nsresult CStreamListener::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - return NS_ERROR_NOT_IMPLEMENTED; // never called -} - -NS_IMPL_ADDREF(CStreamListener) -NS_IMPL_RELEASE(CStreamListener) +NS_IMPL_ISUPPORTS2(CStreamListener, + nsIWebProgressListener, + nsISupportsWeakReference) extern "C" NS_EXPORT void DumpVectorRecord(void); //---------------------------------------------------------------------- @@ -318,14 +312,11 @@ extern "C" NS_EXPORT int DebugRobot( } g_bReadyForNextUrl = PR_FALSE; if (docShell) { - nsIDocumentLoader *docLoader; + nsCOMPtr progress(do_GetInterface(docShell, &rv)); + if (NS_FAILED(rv)) return rv; + + (void) progress->AddProgressListener(pl); - nsCOMPtr webShell(do_QueryInterface(docShell)); - webShell->GetDocumentLoader(docLoader); - if (docLoader) { - docLoader->AddObserver(pl); - NS_RELEASE(docLoader); - } char* spec; (void)url->GetSpec(&spec); nsAutoString theSpec; theSpec.AssignWithConversion(spec); diff --git a/mozilla/uriloader/base/MANIFEST_IDL b/mozilla/uriloader/base/MANIFEST_IDL index 6650fde968a..6cf29fcda06 100644 --- a/mozilla/uriloader/base/MANIFEST_IDL +++ b/mozilla/uriloader/base/MANIFEST_IDL @@ -7,6 +7,5 @@ nsIContentHandler.idl nsIURIContentListener.idl nsIURILoader.idl nsIDocumentLoader.idl -nsIDocumentLoaderObserver.idl nsIWebProgress.idl nsIWebProgressListener.idl diff --git a/mozilla/uriloader/base/Makefile.in b/mozilla/uriloader/base/Makefile.in index 6337f787553..679bd436769 100644 --- a/mozilla/uriloader/base/Makefile.in +++ b/mozilla/uriloader/base/Makefile.in @@ -40,7 +40,6 @@ XPIDLSRCS = \ nsIURILoader.idl \ nsCURILoader.idl \ nsIDocumentLoader.idl \ - nsIDocumentLoaderObserver.idl \ nsIWebProgress.idl \ nsIWebProgressListener.idl \ $(NULL) diff --git a/mozilla/uriloader/base/makefile.win b/mozilla/uriloader/base/makefile.win index 8698bc1b399..5cdc834b3d7 100644 --- a/mozilla/uriloader/base/makefile.win +++ b/mozilla/uriloader/base/makefile.win @@ -34,7 +34,6 @@ XPIDLSRCS= \ .\nsIURIContentListener.idl \ .\nsIURILoader.idl \ .\nsIDocumentLoader.idl \ - .\nsIDocumentLoaderObserver.idl \ .\nsIWebProgress.idl \ .\nsIWebProgressListener.idl \ $(NULL) diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 3b4452a9255..69fbc8fdd49 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -23,7 +23,6 @@ #include "nspr.h" #include "prlog.h" -#include "nsIDocumentLoaderObserver.h" #include "nsDocLoader.h" #include "nsCURILoader.h" #include "nsNetUtil.h" @@ -323,38 +322,6 @@ nsDocLoaderImpl::IsBusy(PRBool * aResult) return NS_OK; } - -/* - * Do not hold refs to the objects in the observer lists. Observers - * are expected to remove themselves upon their destruction if they - * have not removed themselves previously - */ -NS_IMETHODIMP -nsDocLoaderImpl::AddObserver(nsIDocumentLoaderObserver* aObserver) -{ - nsresult rv; - - if (mDocObservers.IndexOf(aObserver) == -1) { - // - // XXX this method incorrectly returns a bool - // - rv = mDocObservers.AppendElement(aObserver) ? NS_OK : NS_ERROR_FAILURE; - } else { - // The observer is already in the list... - rv = NS_ERROR_FAILURE; - } - return rv; -} - -NS_IMETHODIMP -nsDocLoaderImpl::RemoveObserver(nsIDocumentLoaderObserver* aObserver) -{ - if (PR_TRUE == mDocObservers.RemoveElement(aObserver)) { - return NS_OK; - } - return NS_ERROR_FAILURE; -} - NS_IMETHODIMP nsDocLoaderImpl::SetContainer(nsISupports* aContainer) { @@ -505,8 +472,6 @@ nsDocLoaderImpl::OnStartRequest(nsIRequest *request, nsISupports *aCtxt) // Fire the start document load notification doStartDocumentLoad(); - FireOnStartDocumentLoad(this, request); - return NS_OK; } } @@ -520,7 +485,6 @@ nsDocLoaderImpl::OnStartRequest(nsIRequest *request, nsISupports *aCtxt) "mDocumentRequest MUST be set for the duration of a page load!"); doStartURLLoad(request); - FireOnStartURLLoad(this, request); return NS_OK; } @@ -582,7 +546,6 @@ nsDocLoaderImpl::OnStopRequest(nsIRequest *aRequest, // Fire the OnStateChange(...) notification for stop request // doStopURLLoad(aRequest, aStatus); - FireOnEndURLLoad(this, aRequest, aStatus); rv = mLoadGroup->GetActiveCount(&count); if (NS_FAILED(rv)) return rv; @@ -596,7 +559,6 @@ nsDocLoaderImpl::OnStopRequest(nsIRequest *aRequest, } else { doStopURLLoad(aRequest, aStatus); - FireOnEndURLLoad(this, aRequest, aStatus); } return NS_OK; @@ -663,7 +625,6 @@ void nsDocLoaderImpl::DocLoaderIsEmpty() // was called from a handler! // doStopDocumentLoad(docRequest, loadGroupStatus); - FireOnEndDocumentLoad(this, docRequest, loadGroupStatus); if (mParent) { mParent->DocLoaderIsEmpty(); @@ -770,218 +731,6 @@ void nsDocLoaderImpl::doStopDocumentLoad(nsIRequest *request, aStatus); } - - - -void nsDocLoaderImpl::FireOnStartDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *aDocRequest) -{ - PRInt32 count; - - nsCOMPtr uri; - nsCOMPtr channel = do_QueryInterface(aDocRequest); - if (channel) - channel->GetURI(getter_AddRefs(uri)); - -#if defined(DEBUG) - nsXPIDLCString buffer; - - GetURIStringFromRequest(aDocRequest, buffer); - if (aLoadInitiator == this) { - PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, - ("DocLoader:%p: ++ Firing OnStartDocumentLoad(...).\tURI: %s\n", - this, (const char *) buffer)); - } else { - PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, - ("DocLoader:%p: -- Propagating OnStartDocumentLoad(...)." - "DocLoader:%p URI:%s\n", - this, aLoadInitiator, (const char *) buffer)); - } -#endif /* DEBUG */ - - /* - * First notify any observers that the document load has begun... - * - * Operate the elements from back to front so that if items get - * get removed from the list it won't affect our iteration - */ - count = mDocObservers.Count(); - while (count > 0) { - nsIDocumentLoaderObserver *observer; - - observer = NS_STATIC_CAST(nsIDocumentLoaderObserver*, mDocObservers.ElementAt(--count)); - - NS_ASSERTION(observer, "NULL observer found in list."); - if (! observer) { - continue; - } - - observer->OnStartDocumentLoad(aLoadInitiator, uri, mCommand); - } - - /* - * Finally notify the parent... - */ - if (mParent) { - mParent->FireOnStartDocumentLoad(aLoadInitiator, aDocRequest); - } -} - -void nsDocLoaderImpl::FireOnEndDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *aDocRequest, - nsresult aStatus) - -{ -#if defined(DEBUG) - nsXPIDLCString buffer; - - GetURIStringFromRequest(aDocRequest, buffer); - if (aLoadInitiator == this) { - PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, - ("DocLoader:%p: ++ Firing OnEndDocumentLoad(...)" - "\tURI: %s Status: %x\n", - this, (const char *) buffer, aStatus)); - } else { - PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, - ("DocLoader:%p: -- Propagating OnEndDocumentLoad(...)." - "DocLoader:%p URI:%s\n", - this, aLoadInitiator, (const char *)buffer)); - } -#endif /* DEBUG */ - - /* - * First notify any observers that the document load has finished... - * - * Operate the elements from back to front so that if items get - * get removed from the list it won't affect our iteration - */ - PRInt32 count; - - count = mDocObservers.Count(); - while (count > 0) { - nsIDocumentLoaderObserver *observer; - - observer = NS_STATIC_CAST(nsIDocumentLoaderObserver*, mDocObservers.ElementAt(--count)); - - NS_ASSERTION(observer, "NULL observer found in list."); - if (! observer) { - continue; - } - - observer->OnEndDocumentLoad(aLoadInitiator, aDocRequest, aStatus); - } - - /* - * Next notify the parent... - */ - if (mParent) { - mParent->FireOnEndDocumentLoad(aLoadInitiator, aDocRequest, aStatus); - } -} - - -void nsDocLoaderImpl::FireOnStartURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest* aRequest) -{ -#if defined(DEBUG) - nsXPIDLCString buffer; - - GetURIStringFromRequest(aRequest, buffer); - if (aLoadInitiator == this) { - PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, - ("DocLoader:%p: ++ Firing OnStartURLLoad(...)" - "\tURI: %s\n", - this, (const char *) buffer)); - } else { - PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, - ("DocLoader:%p: -- Propagating OnStartURLLoad(...)." - "DocLoader:%p URI:%s\n", - this, aLoadInitiator, (const char *) buffer)); - } -#endif /* DEBUG */ - - - PRInt32 count; - - /* - * First notify any observers that the URL load has begun... - * - * Operate the elements from back to front so that if items get - * get removed from the list it won't affect our iteration - */ - count = mDocObservers.Count(); - while (count > 0) { - nsIDocumentLoaderObserver *observer; - - observer = NS_STATIC_CAST(nsIDocumentLoaderObserver*, mDocObservers.ElementAt(--count)); - - NS_ASSERTION(observer, "NULL observer found in list."); - if (! observer) { - continue; - } - - observer->OnStartURLLoad(aLoadInitiator, aRequest); - } - - /* - * Finally notify the parent... - */ - if (mParent) { - mParent->FireOnStartURLLoad(aLoadInitiator, aRequest); - } -} - - -void nsDocLoaderImpl::FireOnEndURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *request, nsresult aStatus) -{ -#if defined(DEBUG) - nsXPIDLCString buffer; - - GetURIStringFromRequest(request, buffer); - if (aLoadInitiator == this) { - PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, - ("DocLoader:%p: ++ Firing OnEndURLLoad(...)" - "\tURI: %s Status: %x\n", - this, (const char *) buffer, aStatus)); - } else { - PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, - ("DocLoader:%p: -- Propagating OnEndURLLoad(...)." - "DocLoader:%p URI:%s\n", - this, aLoadInitiator, (const char *) buffer)); - } -#endif /* DEBUG */ - - PRInt32 count; - - /* - * First notify any observers that the URL load has completed... - * - * Operate the elements from back to front so that if items get - * get removed from the list it won't affect our iteration - */ - count = mDocObservers.Count(); - while (count > 0) { - nsIDocumentLoaderObserver *observer; - - observer = NS_STATIC_CAST(nsIDocumentLoaderObserver*, mDocObservers.ElementAt(--count)); - - NS_ASSERTION(observer, "NULL observer found in list."); - if (! observer) { - continue; - } - - observer->OnEndURLLoad(aLoadInitiator, request, aStatus); - } - - /* - * Finally notify the parent... - */ - if (mParent) { - mParent->FireOnEndURLLoad(aLoadInitiator, request, aStatus); - } -} - //////////////////////////////////////////////////////////////////////////////////// // The following section contains support for nsIWebProgress and related stuff //////////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/uriloader/base/nsDocLoader.h b/mozilla/uriloader/base/nsDocLoader.h index 5f46c851552..fae3a48ff42 100644 --- a/mozilla/uriloader/base/nsDocLoader.h +++ b/mozilla/uriloader/base/nsDocLoader.h @@ -89,19 +89,6 @@ protected: nsresult RemoveChildGroup(nsDocLoaderImpl *aLoader); void DocLoaderIsEmpty(); - void FireOnStartDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *request); - - void FireOnEndDocumentLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *aDocRequest, - nsresult aStatus); - - void FireOnStartURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *request); - - void FireOnEndURLLoad(nsDocLoaderImpl* aLoadInitiator, - nsIRequest *request, nsresult aStatus); - void FireOnProgressChange(nsDocLoaderImpl* aLoadInitiator, nsIRequest *request, PRInt32 aProgress, @@ -134,7 +121,6 @@ protected: // class, please make the ownership explicit (pinkerton, scc). nsCOMPtr mDocumentRequest; // [OWNER] ???compare with document - nsVoidArray mDocObservers; nsCOMPtr mListenerList; nsISupports* mContainer; // [WEAK] it owns me! diff --git a/mozilla/uriloader/base/nsIDocumentLoader.idl b/mozilla/uriloader/base/nsIDocumentLoader.idl index 9842a40e00b..5571d82b947 100644 --- a/mozilla/uriloader/base/nsIDocumentLoader.idl +++ b/mozilla/uriloader/base/nsIDocumentLoader.idl @@ -26,7 +26,6 @@ #include "nsISupports.idl" interface nsILoadGroup; -interface nsIDocumentLoaderObserver; interface nsIContentViewerContainer; interface nsIChannel; interface nsIURI; @@ -40,8 +39,6 @@ interface nsIDocumentLoader : nsISupports boolean isBusy(); void createDocumentLoader(out nsIDocumentLoader anInstance); - void addObserver(in nsIDocumentLoaderObserver aObserver); - void removeObserver(in nsIDocumentLoaderObserver aObserver); attribute nsISupports container; [noscript] void getContentViewerContainer(in nsISupports aDocumentID, out nsIContentViewerContainer aResult); diff --git a/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl b/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl deleted file mode 100644 index 75ec3a47033..00000000000 --- a/mozilla/uriloader/base/nsIDocumentLoaderObserver.idl +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1999 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -/* nsIDocumentLoaderObserver --> - -*/ - -#include "nsISupports.idl" - -interface nsIDocumentLoader; -interface nsIURI; -interface nsIRequest; -/* we'll be phasing this interface out in place of a new - improved progress sink interface -*/ - -%{C++ -#include "nsString.h" -%} - - native nsString(nsString); -[ref] native nsStringRef(nsString); - -[scriptable, uuid(f6b4f550-317c-11d2-bd8c-00805f8ae3f4)] -interface nsIDocumentLoaderObserver : nsISupports -{ - /** - * Notify the observer that a new document will be loaded. - * - * This notification occurs before any DNS resolution occurs, or - * a connection is established with the server... - */ - void onStartDocumentLoad(in nsIDocumentLoader aLoader, in nsIURI aURL, in string aCommand); - - /** - * Notify the observer that a document has been completely loaded. - */ - void onEndDocumentLoad(in nsIDocumentLoader loader, in nsIRequest request, in unsigned long aStatus); - - /** - * Notify the observer that the specified nsIURI has just started to load. - * - * This notification occurs after DNS resolution, and a connection to the - * server has been established. - */ - void onStartURLLoad(in nsIDocumentLoader aLoader, in nsIRequest request); - - /** - * Notify the observer that progress has occurred in the loading of the - * specified URL... - */ - void onProgressURLLoad(in nsIDocumentLoader aLoader, - in nsIRequest aRequest, in unsigned long aProgress, - in unsigned long aProgressMax); - - /** - * Notify the observer that status text is available regarding the URL - * being loaded... - */ - [noscript] void onStatusURLLoad(in nsIDocumentLoader loader, in nsIRequest request, in nsStringRef aMsg); - - /** - * Notify the observer that the specified nsIURI has finished loading. - */ - void onEndURLLoad(in nsIDocumentLoader aLoader, in nsIRequest aRequest, in unsigned long aStatus); -}; - -/* the following is a transition define. nsIDocumentLoaderObserver wasn't scriptable and now it is. - so lots of people refer to the IID using the old non-scriptable generated IID... -*/ - -%{C++ -#define NS_IDOCUMENT_LOADER_OBSERVER_IID NS_IDOCUMENTLOADEROBSERVER_IID -%} diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 8a0f4a24b82..08a508e89a6 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -37,7 +37,6 @@ #define NS_IMPL_IDS #include "nsBrowserWindow.h" #endif -#include "nsIStreamListener.h" #include "nsIAppShell.h" #include "nsIWidget.h" #include "nsITextWidget.h" @@ -76,6 +75,7 @@ #include "nsIBaseWindow.h" #include "nsXPIDLString.h" #include "nsIViewManager.h" +#include "nsIWebProgress.h" #include "nsCWebBrowser.h" @@ -1547,18 +1547,16 @@ nsBrowserWindow::SetWebCrawler(nsWebCrawler* aCrawler) { if (mWebCrawler) { if (mDocShell) { - mDocShell->SetDocLoaderObserver(nsnull); + nsCOMPtr progress(do_GetInterface(mDocShell)); + NS_ASSERTION(progress, "no web progress avail"); + + (void) progress->RemoveProgressListener( + (nsIWebProgressListener*)mWebCrawler); } NS_RELEASE(mWebCrawler); } if (aCrawler) { mWebCrawler = aCrawler; - /* Nisheeth: the crawler registers as a document loader observer with - * the webshell when nsWebCrawler::Start() is called. - if (mDocShell) { - mDocShell->SetDocLoaderObserver(aCrawler); - } - */ NS_ADDREF(aCrawler); } } diff --git a/mozilla/webshell/tests/viewer/nsWebCrawler.h b/mozilla/webshell/tests/viewer/nsWebCrawler.h index ca7c6333b79..7b624f3bbf4 100644 --- a/mozilla/webshell/tests/viewer/nsWebCrawler.h +++ b/mozilla/webshell/tests/viewer/nsWebCrawler.h @@ -49,7 +49,7 @@ public: // nsISupports NS_DECL_ISUPPORTS - // nsIDocumentLoaderObserver + // nsIWebProgressListener NS_DECL_NSIWEBPROGRESSLISTENER // Add a url to load diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.h b/mozilla/webshell/tests/viewer/nsXPBaseWindow.h index eb7c3788f45..1579f09e57c 100644 --- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.h +++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.h @@ -32,7 +32,6 @@ #include "nsIContent.h" #include "nsIDOMNode.h" #include "nsIDOMElement.h" -#include "nsIDocumentLoaderObserver.h" #include "nsIDOMMouseListener.h" class nsViewerApp; diff --git a/mozilla/webshell/tests/viewer/public/nsIXPBaseWindow.h b/mozilla/webshell/tests/viewer/public/nsIXPBaseWindow.h index 322bbae2753..1678910c2de 100644 --- a/mozilla/webshell/tests/viewer/public/nsIXPBaseWindow.h +++ b/mozilla/webshell/tests/viewer/public/nsIXPBaseWindow.h @@ -29,7 +29,6 @@ class nsIFactory; class nsIWebShell; class nsString; class nsIPresShell; -class nsIDocumentLoaderObserver; class nsIDOMElement; class nsIDOMNode; class nsIWindowListener;