sr=rpotts. cookie/wallet r=morse, xmlTerm r=saravn@mozdev.org, mailnews r=mscott, activeX r=adamlock, everything else covered by the sr from rpotts. 15345. These changes remove nsIDocumentLoaderObserver.idl from the build, and all of it's implementations and registrations have been moved over to nsIWebProgressListener.idl and nsIWebProgress.idl respectively. there are two (78762, 78760) mailnews printing bugs that I overturned *before* landing this. I've run this code through the mail-news and browser smoketests among other tests outlined in the patch description attatched to the bug.

This commit is contained in:
valeski%netscape.com 2001-05-04 20:15:38 +00:00
Родитель 77ee0d120c
Коммит 58072871cc
36 изменённых файлов: 723 добавлений и 1343 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -39,7 +39,6 @@
#include "nsIDeviceContext.h"
#include "nsIDocumentLoader.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsWeakReference.h"
@ -276,7 +275,6 @@ protected:
nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo;
nsCOMPtr<nsIDeviceContext> mDeviceContext;
nsCOMPtr<nsIDocumentLoader>mDocLoader;
nsCOMPtr<nsIDocumentLoaderObserver> mDocLoaderObserver;
nsCOMPtr<nsIWidget> mParentWidget;
nsCOMPtr<nsIPref> mPrefs;
nsCOMPtr<nsIURI> mCurrentURI;

Просмотреть файл

@ -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.
*/

Просмотреть файл

@ -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<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
if (aProgress == webProgress.get()) {
nsCOMPtr<nsIURI> url;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
nsCOMPtr<nsIDocumentLoaderObserver> 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<nsIDocShellTreeItem> rootItem;
GetSameTypeRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsIDocShell> 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<nsIChannel> 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,

Просмотреть файл

@ -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();

Просмотреть файл

@ -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

Просмотреть файл

@ -87,7 +87,6 @@
#include "nsIDocument.h"
#include "nsIDocumentObserver.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsIStreamListener.h"
#include "nsUnitConversion.h"
#include "nsVoidArray.h"

Просмотреть файл

@ -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<nsIChannel> channel(do_QueryInterface(aRequest));
if (channel)
{
nsCOMPtr<nsIURI> 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<nsIURI> pURI;
nsCOMPtr<nsIChannel> 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<nsIChannel> 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

Просмотреть файл

@ -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

Просмотреть файл

@ -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<nsIWebProgress> 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;

Просмотреть файл

@ -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();

Просмотреть файл

@ -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<nsIWebShellServices> mWebShellServices;
nsIDocumentLoader* mDocLoaderService;
nsCOMPtr<nsIDocumentLoader> 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<nsIWebProgress> 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<nsIDOMWindow> domWin;
rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWin));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> cont;
rv = loader->GetContainer(getter_AddRefs(cont));
if (NS_OK == rv) {
nsCOMPtr<nsIWebShellServices> ws(do_QueryInterface(cont));
if(ws) {
mWebShellServices = ws;
ws->SetRendering(PR_TRUE);
nsCOMPtr<nsIWebShellServices> 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<nsISupports> 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<nsIChannel> channel = do_QueryInterface(aRequest);
if (!channel) return NS_ERROR_FAILURE;
NS_IMETHODIMP
nsPICS::OnStartURLLoad(nsIDocumentLoader* loader, nsIRequest *request)
{
nsresult rv = NS_OK;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if (!channel)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIURI> uri;
rv = channel->GetURI(getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIURI> 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<nsISupports> cont;
rv = loader->GetContainer(getter_AddRefs(cont));
if (NS_OK == rv) {
nsCOMPtr<nsIWebShellServices> 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<nsIChannel> channel = do_QueryInterface(aRequest);
NS_IMETHODIMP
nsPICS::OnStatusURLLoad(nsIDocumentLoader* loader,
nsIRequest *request,
nsString& aMsg)
{
if(!mPICSRatingsEnabled)
return NS_OK;
return NS_OK;
}
nsCOMPtr<nsIURI> 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<nsIChannel> channel = do_QueryInterface(request);
nsCOMPtr<nsIURI> 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<nsISupports> cont;
NS_ENSURE_SUCCESS(loader->GetContainer(getter_AddRefs(cont)), NS_ERROR_FAILURE);
nsCOMPtr<nsIWebShellServices> 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

Просмотреть файл

@ -54,7 +54,6 @@
#include "nsPSMUICallbacks.h"
#include "nsISecureBrowserUI.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsIScriptSecurityManager.h"
#include "nsICertificatePrincipal.h"

Просмотреть файл

@ -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<nsIWebProgress> 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<nsIDOMWindow> 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<nsIDOMDocument> domDoc;
rv = domWin->GetDocument(getter_AddRefs(domDoc));
if (NS_FAILED(rv)) return rv;
if (aLoader == nsnull) {
return rv;
}
nsCOMPtr<nsISupports> cont;
rv = aLoader->GetContainer(getter_AddRefs(cont));
if (NS_FAILED(rv) || (cont == nsnull)) {
return rv;
}
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(cont));
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIContentViewer> cv;
rv = docShell->GetContentViewer(getter_AddRefs(cv));
if (NS_FAILED(rv) || (cv == nsnull)) {
return rv;
}
nsCOMPtr<nsIDocumentViewer> docViewer(do_QueryInterface(cv));
NS_ENSURE_TRUE(docViewer, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocument> 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<nsIDOMHTMLDocument> htmldoc(do_QueryInterface(domDoc, &rv));
if (NS_FAILED(rv)) return NS_OK;
nsCOMPtr<nsIDocument> 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<nsIDOMHTMLDocument> htmldoc(do_QueryInterface(doc));
if (htmldoc == nsnull) {
PR_Free(URLName);
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMHTMLCollection> 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<nsIDOMNode> formNode;
forms->Item(formX, getter_AddRefs(formNode));
if (nsnull != formNode) {
nsCOMPtr<nsIDOMHTMLFormElement> formElement(do_QueryInterface(formNode));
if ((nsnull != formElement)) {
nsCOMPtr<nsIDOMHTMLCollection> 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<nsIDOMNode> elementNode;
elements->Item(elementXX, getter_AddRefs(elementNode));
if (nsnull != elementNode) {
nsCOMPtr<nsIDOMHTMLInputElement> 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<nsIURI> 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<nsIDOMNode> elementNode;
elements->Item(elementX, getter_AddRefs(elementNode));
if (nsnull != elementNode) {
nsCOMPtr<nsIDOMHTMLInputElement> 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<nsIInterfaceRequestor> interfaces;
nsCOMPtr<nsIPrompt> prompter;
nsCOMPtr<nsIChannel> 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<nsIWindowWatcher> 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<nsIDOMHTMLCollection> 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<nsIDOMNode> formNode;
forms->Item(formX, getter_AddRefs(formNode));
if (nsnull != formNode) {
nsCOMPtr<nsIDOMHTMLFormElement> formElement(do_QueryInterface(formNode));
if ((nsnull != formElement)) {
nsCOMPtr<nsIDOMHTMLCollection> 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<nsIDOMNode> elementNode;
elements->Item(elementXX, getter_AddRefs(elementNode));
if (nsnull != elementNode) {
nsCOMPtr<nsIDOMHTMLInputElement> 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<nsIDOMNode> elementNode;
elements->Item(elementX, getter_AddRefs(elementNode));
if (nsnull != elementNode) {
nsCOMPtr<nsIDOMHTMLInputElement> 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<nsIInterfaceRequestor> interfaces;
nsCOMPtr<nsIPrompt> prompter;
nsCOMPtr<nsIChannel> 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<nsIWindowWatcher> 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)
{

Просмотреть файл

@ -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

Просмотреть файл

@ -1,139 +0,0 @@
base --- core source code for XMLterm and LineTerm
XMLterm may be invoked in one of two ways:
1. By loading "-chrome chrome://xmlterm/content/xmlterm.xul" in mozilla, or
2. By running the stand-alone executable "../geckoterm/xmlterm".
The diagram below shows the control-flow/layering hierarchy for both ways
of invoking XMLterm.
XMLterm control-flow/layering hierarchy
=======================================
mozilla-executable geckoterm-executable
| |
../ui/content/xmlterm.xul |
| |
../ui/content/xmlterm.html ../ui/content/xmlterm.html
| |
mozXMLTermShell ../geckoterm/mozGeckoTerm
| | |
+--------------+---------------+ |
| mozSimpleContainer
mozXMLTerminal
|
+-------------------+--------------------+
| | |
mozXMLTermSession mozLineTermAux mozXMLTermListeners
| | |
| | |
(rendering...) (LineTerm) (user input)
(pseudo-TTY/shell)
15 Mar 2000
============================================================================
FILES:
The core source code for XMLterm in this directory consists of two distinct
families of files, those with names that begin with the prefix "moz" and all
the other files. The former are the Mozilla-specific portions of XMLterm,
written in C++. The remaining files constitute the Mozilla-independent portion
of XMLterm, referred to as "LineTerm".
============================================================================
LINETERM:
LineTerm is a line-oriented terminal program, in some respects similar in
functionality to the GNU Readline package. It is completely independent of the
Mozilla source code, is written in plain C, and dually licensed under GPL and
MPL.
============================================================================
INTERFACES:
lineterm.h Plain C interface to LineTerm
(used by mozLineTerm)
mozILineTerm.idl Scriptable XPCOM/XPCONNECT interface to LineTerm
(not used at the moment)
mozILineTermAux.h XPCOM interface to LineTerm, with extra features
(used by mozXMLTerminal)
mozIXMLTermShell.h Scriptable XPCOM/XPCONNECT interface to XMLterm
(used by the Javascript glue code in the XMLterm
start page at ../ui/content/xmlterm.html)
mozIXMLTerminal.h XPCOM interface to XMLterm
(used by mozXMLTermShell, ../geckoterm/mozGeckoterm)
mozIXMLTermStream.h XPCOM interface for displaying HTML/XML streams in
IFRAMES (used by mozXMLTermSession)
IMPLEMENTATIONS:
mozLineTerm.h
mozLineTermcpp Implementation of mozILineTerm, mozILineTermAux
Uses LineTerm to access shell
mozXMLTermShell.h
mozXMLTermShell.cpp Implementation of mozIXMLTermShell
Uses mozIXMLTerminal to create XMLterm
mozXMLTerminal.h
mozXMLTerminal.cpp Implementation of mozIXMLTerminal,
nsIDocumentLoaderObserver, and
nsIObserver
Uses mozILineTermAux to create LineTerm
Uses mozXMLTermListeners to capture user input
Uses mozXMLTermSession to display input/output
mozXMLTermListeners.h
mozXMLTermListeners.cpp Implementations of nsIDOMKeyListener,
nsIDOMTextListener,
nsIDOMMouseListener,
nsIDOMDragListener
mozXMLTermStream.h
mozXMLTermStreamcpp Implementation of mozIXMLTermStream
CLASSES:
mozXMLTermSession.h/cpp Class to manage session input/output display
(used by mozXMLTerminal)
Uses mozIXMLTermStream to display streams
mozXMLTermUtils.h/cpp Abstract class for static utility functions
(for use by all classes)
============================================================================
The following are dually licensed under MPL and GPL:
LineTerm package:
lineterm.h Public interface to LineTerm
ltermPrivate.h Private common header file
ltermManager.c LineTerm manager
ltermIO.c Overlapping I/O functions
ltermInput.c Input handler
ltermOutput.c Output handler
ltermEscape.c Escape sequence handler
Low-level packages:
ptystream.h
ptystream.c Stream-like interface to Unix pseudo-TTY
tracelog.h
tracelog.c Simple tracing/logging diagnostic library
unistring.h
unistring.c Simple Unicode manipulation library
============================================================================

Просмотреть файл

@ -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<nsIWebProgress> 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<nsIDocShell> 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;
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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<nsIWebProgress> progress(do_GetInterface(docShell, &rv));
if (NS_FAILED(rv)) return rv;
(void) progress->AddProgressListener(pl);
nsCOMPtr<nsIWebShell> 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);

Просмотреть файл

@ -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);

Просмотреть файл

@ -307,12 +307,10 @@ nsMessenger::SetWindow(nsIDOMWindowInternal *aWin, nsIMsgWindow *aMsgWindow)
nsCOMPtr<nsIMsgStatusFeedback> 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));
}
}

Просмотреть файл

@ -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<nsIStringBundle> mStringBundle;
nsCOMPtr <nsIDocumentLoaderObserver> m_docLoaderObserver;
PRBool mCharsetInitialized;
void InitializeDisplayCharset();
nsCOMPtr<nsISupports> mSearchContext;

Просмотреть файл

@ -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<nsIChannel> aChannel = do_QueryInterface(request);
if (!aChannel) return NS_ERROR_FAILURE;
// Make sure this isn't just "about:blank" finishing....
nsCOMPtr<nsIURI> 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<nsIChannel> 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<nsIURI> 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<nsIWebProgress> progress(do_GetInterface(mDocShell));
NS_ASSERTION(progress, "we were expecting a nsIWebProgress");
if (progress) {
(void) progress->AddProgressListener((nsIWebProgressListener *)this);
}
}
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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<nsIWebProgress> progress(do_GetInterface(docShell, &rv));
if (NS_FAILED(rv)) return rv;
(void) progress->AddProgressListener(pl);
nsCOMPtr<nsIWebShell> 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);

Просмотреть файл

@ -7,6 +7,5 @@ nsIContentHandler.idl
nsIURIContentListener.idl
nsIURILoader.idl
nsIDocumentLoader.idl
nsIDocumentLoaderObserver.idl
nsIWebProgress.idl
nsIWebProgressListener.idl

Просмотреть файл

@ -40,7 +40,6 @@ XPIDLSRCS = \
nsIURILoader.idl \
nsCURILoader.idl \
nsIDocumentLoader.idl \
nsIDocumentLoaderObserver.idl \
nsIWebProgress.idl \
nsIWebProgressListener.idl \
$(NULL)

Просмотреть файл

@ -34,7 +34,6 @@ XPIDLSRCS= \
.\nsIURIContentListener.idl \
.\nsIURILoader.idl \
.\nsIDocumentLoader.idl \
.\nsIDocumentLoaderObserver.idl \
.\nsIWebProgress.idl \
.\nsIWebProgressListener.idl \
$(NULL)

Просмотреть файл

@ -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<nsIURI> uri;
nsCOMPtr<nsIChannel> 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
////////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -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<nsIRequest> mDocumentRequest; // [OWNER] ???compare with document
nsVoidArray mDocObservers;
nsCOMPtr<nsISupportsArray> mListenerList;
nsISupports* mContainer; // [WEAK] it owns me!

Просмотреть файл

@ -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);

Просмотреть файл

Просмотреть файл

@ -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<nsIWebProgress> 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);
}
}

Просмотреть файл

@ -49,7 +49,7 @@ public:
// nsISupports
NS_DECL_ISUPPORTS
// nsIDocumentLoaderObserver
// nsIWebProgressListener
NS_DECL_NSIWEBPROGRESSLISTENER
// Add a url to load

Просмотреть файл

@ -32,7 +32,6 @@
#include "nsIContent.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsIDOMMouseListener.h"
class nsViewerApp;

Просмотреть файл

@ -29,7 +29,6 @@ class nsIFactory;
class nsIWebShell;
class nsString;
class nsIPresShell;
class nsIDocumentLoaderObserver;
class nsIDOMElement;
class nsIDOMNode;
class nsIWindowListener;