1998-11-25 00:03:28 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
1998-09-01 08:07:56 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
#include "WebShellContainer.h"
|
|
|
|
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
|
1998-10-03 22:35:08 +00:00
|
|
|
static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID);
|
1998-12-13 21:41:46 +00:00
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
1998-11-03 08:04:03 +00:00
|
|
|
/* static NS_DEFINE_IID(kINetSupportIID, NS_INETSUPPORT_IID); */
|
1998-09-01 08:07:56 +00:00
|
|
|
|
|
|
|
|
1998-10-03 22:35:08 +00:00
|
|
|
CWebShellContainer::CWebShellContainer(CMozillaBrowser *pOwner)
|
1998-09-01 08:07:56 +00:00
|
|
|
{
|
1998-11-29 18:06:34 +00:00
|
|
|
NS_INIT_REFCNT();
|
1998-10-03 22:35:08 +00:00
|
|
|
m_pOwner = pOwner;
|
1998-10-18 22:14:47 +00:00
|
|
|
m_pEvents1 = m_pOwner;
|
|
|
|
m_pEvents2 = m_pOwner;
|
1998-09-01 08:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CWebShellContainer::~CWebShellContainer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-10-03 22:35:08 +00:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports implementation
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-09-01 08:07:56 +00:00
|
|
|
NS_IMPL_ADDREF(CWebShellContainer)
|
|
|
|
NS_IMPL_RELEASE(CWebShellContainer)
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-09-01 08:07:56 +00:00
|
|
|
nsresult CWebShellContainer::QueryInterface(const nsIID& aIID, void** aInstancePtrResult)
|
|
|
|
{
|
1998-12-13 21:41:46 +00:00
|
|
|
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
|
|
|
if (nsnull == aInstancePtrResult)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aInstancePtrResult = NULL;
|
|
|
|
|
|
|
|
if (aIID.Equals(kIStreamObserverIID))
|
|
|
|
{
|
|
|
|
*aInstancePtrResult = (void*) ((nsIStreamObserver*)this);
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aIID.Equals(kIWebShellContainerIID))
|
|
|
|
{
|
|
|
|
*aInstancePtrResult = (void*) ((nsIWebShellContainer*)this);
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aIID.Equals(kISupportsIID))
|
|
|
|
{
|
|
|
|
*aInstancePtrResult = (void*) ((nsIStreamObserver*)this);
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_NOINTERFACE;
|
1998-09-01 08:07:56 +00:00
|
|
|
}
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-10-03 22:35:08 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIWebShellContainer implementation
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-09-01 08:07:56 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CWebShellContainer::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason)
|
|
|
|
{
|
1998-10-08 22:06:59 +00:00
|
|
|
ATLTRACE(_T("CWebShellContainer::WillLoadURL()\n"));
|
1998-09-01 08:07:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-09-01 08:07:56 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CWebShellContainer::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
|
|
|
|
{
|
1998-10-08 22:06:59 +00:00
|
|
|
ATLTRACE(_T("CWebShellContainer::BeginLoadURL()\n"));
|
|
|
|
|
1998-11-25 00:03:28 +00:00
|
|
|
//Fire a BeforeNavigate event
|
1998-10-03 22:35:08 +00:00
|
|
|
USES_CONVERSION;
|
|
|
|
OLECHAR *pszURL = W2OLE((WCHAR *)aURL);
|
|
|
|
BSTR bstrURL = SysAllocString(pszURL);
|
|
|
|
BSTR bstrTargetFrameName = NULL;
|
|
|
|
BSTR bstrHeaders = NULL;
|
|
|
|
VARIANT *pvPostData = NULL;
|
|
|
|
VARIANT_BOOL bCancel = VARIANT_FALSE;
|
|
|
|
long lFlags = 0;
|
|
|
|
|
1998-10-18 22:14:47 +00:00
|
|
|
m_pEvents1->Fire_BeforeNavigate(bstrURL, lFlags, bstrTargetFrameName, pvPostData, bstrHeaders, &bCancel);
|
1998-11-25 00:03:28 +00:00
|
|
|
|
|
|
|
//Fire a BeforeNavigate2 event
|
|
|
|
CComVariant vURL(bstrURL);
|
|
|
|
CComVariant vFlags(lFlags);
|
|
|
|
CComVariant vTargetFrameName(bstrTargetFrameName);
|
|
|
|
CComVariant vHeaders(bstrHeaders);
|
|
|
|
|
|
|
|
m_pEvents2->Fire_BeforeNavigate2(m_pOwner, &vURL, &vFlags, &vTargetFrameName, pvPostData, &vHeaders, &bCancel);
|
1998-10-18 22:14:47 +00:00
|
|
|
|
1998-10-03 22:35:08 +00:00
|
|
|
SysFreeString(bstrURL);
|
|
|
|
SysFreeString(bstrTargetFrameName);
|
|
|
|
SysFreeString(bstrHeaders);
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
if (bCancel == VARIANT_TRUE)
|
|
|
|
{
|
|
|
|
if (aShell)
|
|
|
|
{
|
|
|
|
aShell->Stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pOwner->m_bBusy = TRUE;
|
|
|
|
}
|
1998-09-01 08:07:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-09-01 08:07:56 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CWebShellContainer::ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
|
|
|
|
{
|
1998-10-08 22:06:59 +00:00
|
|
|
ATLTRACE(_T("CWebShellContainer::ProgressLoadURL()\n"));
|
1998-12-13 21:41:46 +00:00
|
|
|
|
1998-10-18 22:14:47 +00:00
|
|
|
m_pEvents1->Fire_ProgressChange(aProgress, aProgressMax);
|
|
|
|
m_pEvents2->Fire_ProgressChange(aProgress, aProgressMax);
|
1998-09-01 08:07:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-09-01 08:07:56 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CWebShellContainer::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus)
|
|
|
|
{
|
1998-10-08 22:06:59 +00:00
|
|
|
ATLTRACE(_T("CWebShellContainer::EndLoadURL()\n"));
|
1998-11-25 00:03:28 +00:00
|
|
|
|
|
|
|
//Fire a NavigateComplete event
|
1998-10-03 22:35:08 +00:00
|
|
|
USES_CONVERSION;
|
|
|
|
OLECHAR *pszURL = W2OLE((WCHAR *) aURL);
|
|
|
|
BSTR bstrURL = SysAllocString(pszURL);
|
1998-10-18 22:14:47 +00:00
|
|
|
m_pEvents1->Fire_NavigateComplete(bstrURL);
|
1998-11-25 00:03:28 +00:00
|
|
|
|
|
|
|
//Fire a NavigateComplete2 event
|
|
|
|
CComVariant vURL(bstrURL);
|
|
|
|
m_pEvents2->Fire_NavigateComplete2(m_pOwner, &vURL);
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
m_pOwner->m_bBusy = FALSE;
|
1998-10-03 22:35:08 +00:00
|
|
|
SysFreeString(bstrURL);
|
|
|
|
|
1998-09-01 08:07:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-09-01 08:07:56 +00:00
|
|
|
NS_IMETHODIMP
|
1998-12-08 15:51:42 +00:00
|
|
|
CWebShellContainer::NewWebShell(PRUint32 aChromeMask,
|
|
|
|
PRBool aVisible,
|
|
|
|
nsIWebShell *&aNewWebShell)
|
1998-09-01 08:07:56 +00:00
|
|
|
{
|
1998-10-08 22:06:59 +00:00
|
|
|
ATLTRACE(_T("CWebShellContainer::NewWebShell()\n"));
|
|
|
|
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
return rv;
|
1998-09-01 08:07:56 +00:00
|
|
|
}
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-09-18 00:35:55 +00:00
|
|
|
NS_IMETHODIMP
|
1998-09-18 05:25:15 +00:00
|
|
|
CWebShellContainer::FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult)
|
1998-09-18 00:35:55 +00:00
|
|
|
{
|
1998-10-08 22:06:59 +00:00
|
|
|
ATLTRACE(_T("CWebShellContainer::FindWebShellWithName()\n"));
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-09-18 00:35:55 +00:00
|
|
|
}
|
1998-10-03 22:35:08 +00:00
|
|
|
|
1998-11-06 01:30:07 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
CWebShellContainer::FocusAvailable(nsIWebShell* aFocusedWebShell)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-10-03 22:35:08 +00:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIStreamObserver implementation
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
CWebShellContainer::OnStartBinding(nsIURL* aURL, const char *aContentType)
|
|
|
|
{
|
1998-10-08 22:06:59 +00:00
|
|
|
ATLTRACE(_T("CWebShellContainer::OnStartBinding()\n"));
|
1998-10-18 22:14:47 +00:00
|
|
|
return NS_OK;
|
1998-10-03 22:35:08 +00:00
|
|
|
}
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-10-03 22:35:08 +00:00
|
|
|
NS_IMETHODIMP
|
1998-12-16 05:40:20 +00:00
|
|
|
CWebShellContainer::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax)
|
1998-10-03 22:35:08 +00:00
|
|
|
{
|
1998-10-08 22:06:59 +00:00
|
|
|
ATLTRACE(_T("CWebShellContainer::OnProgress()\n"));
|
1998-10-18 22:14:47 +00:00
|
|
|
return NS_OK;
|
1998-10-03 22:35:08 +00:00
|
|
|
}
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-10-03 22:35:08 +00:00
|
|
|
NS_IMETHODIMP
|
1998-12-16 05:40:20 +00:00
|
|
|
CWebShellContainer::OnStatus(nsIURL* aURL, const PRUnichar* aMsg)
|
1998-10-03 22:35:08 +00:00
|
|
|
{
|
1998-10-08 22:06:59 +00:00
|
|
|
ATLTRACE(_T("CWebShellContainer::OnStatus()\n"));
|
1998-10-18 22:14:47 +00:00
|
|
|
|
|
|
|
USES_CONVERSION;
|
|
|
|
BSTR bstrText = SysAllocString(W2OLE((PRUnichar *) aMsg));
|
|
|
|
m_pEvents1->Fire_StatusTextChange(bstrText);
|
|
|
|
m_pEvents2->Fire_StatusTextChange(bstrText);
|
|
|
|
SysFreeString(bstrText);
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-10-03 22:35:08 +00:00
|
|
|
}
|
|
|
|
|
1998-10-08 22:06:59 +00:00
|
|
|
|
1998-10-03 22:35:08 +00:00
|
|
|
NS_IMETHODIMP
|
1998-12-16 05:40:20 +00:00
|
|
|
CWebShellContainer::OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg)
|
1998-10-03 22:35:08 +00:00
|
|
|
{
|
1998-10-08 22:06:59 +00:00
|
|
|
ATLTRACE(_T("CWebShellContainer::OnStopBinding()\n"));
|
1998-10-18 22:14:47 +00:00
|
|
|
return NS_OK;
|
1998-10-03 22:35:08 +00:00
|
|
|
}
|