gecko-dev/webshell/embed/ActiveX/WebShellContainer.cpp

241 lines
5.8 KiB
C++
Raw Normal View History

/* -*- 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.
*/
#include "stdafx.h"
#include "WebShellContainer.h"
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID);
1998-12-13 21:41:46 +00:00
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
/* static NS_DEFINE_IID(kINetSupportIID, NS_INETSUPPORT_IID); */
CWebShellContainer::CWebShellContainer(CMozillaBrowser *pOwner)
{
1998-11-29 18:06:34 +00:00
NS_INIT_REFCNT();
m_pOwner = pOwner;
m_pEvents1 = m_pOwner;
m_pEvents2 = m_pOwner;
}
CWebShellContainer::~CWebShellContainer()
{
}
///////////////////////////////////////////////////////////////////////////////
// nsISupports implementation
1998-10-08 22:06:59 +00:00
NS_IMPL_ADDREF(CWebShellContainer)
NS_IMPL_RELEASE(CWebShellContainer)
1998-10-08 22:06:59 +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-10-08 22:06:59 +00:00
///////////////////////////////////////////////////////////////////////////////
// nsIWebShellContainer implementation
1998-10-08 22:06:59 +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"));
return NS_OK;
}
1998-10-08 22:06:59 +00:00
NS_IMETHODIMP
CWebShellContainer::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
{
1998-10-08 22:06:59 +00:00
ATLTRACE(_T("CWebShellContainer::BeginLoadURL()\n"));
//Fire a BeforeNavigate event
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;
m_pEvents1->Fire_BeforeNavigate(bstrURL, lFlags, bstrTargetFrameName, pvPostData, bstrHeaders, &bCancel);
//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);
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;
}
return NS_OK;
}
1998-10-08 22:06:59 +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
m_pEvents1->Fire_ProgressChange(aProgress, aProgressMax);
m_pEvents2->Fire_ProgressChange(aProgress, aProgressMax);
return NS_OK;
}
1998-10-08 22:06:59 +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"));
//Fire a NavigateComplete event
USES_CONVERSION;
OLECHAR *pszURL = W2OLE((WCHAR *) aURL);
BSTR bstrURL = SysAllocString(pszURL);
m_pEvents1->Fire_NavigateComplete(bstrURL);
//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;
SysFreeString(bstrURL);
return NS_OK;
}
1998-10-08 22:06:59 +00:00
NS_IMETHODIMP
CWebShellContainer::NewWebShell(PRUint32 aChromeMask,
PRBool aVisible,
nsIWebShell *&aNewWebShell)
{
1998-10-08 22:06:59 +00:00
ATLTRACE(_T("CWebShellContainer::NewWebShell()\n"));
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
return rv;
}
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
}
NS_IMETHODIMP
CWebShellContainer::FocusAvailable(nsIWebShell* aFocusedWebShell)
{
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsIStreamObserver implementation
NS_IMETHODIMP
CWebShellContainer::OnStartBinding(nsIURL* aURL, const char *aContentType)
{
1998-10-08 22:06:59 +00:00
ATLTRACE(_T("CWebShellContainer::OnStartBinding()\n"));
return NS_OK;
}
1998-10-08 22:06:59 +00:00
NS_IMETHODIMP
CWebShellContainer::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax)
{
1998-10-08 22:06:59 +00:00
ATLTRACE(_T("CWebShellContainer::OnProgress()\n"));
return NS_OK;
}
1998-10-08 22:06:59 +00:00
NS_IMETHODIMP
CWebShellContainer::OnStatus(nsIURL* aURL, const PRUnichar* aMsg)
{
1998-10-08 22:06:59 +00:00
ATLTRACE(_T("CWebShellContainer::OnStatus()\n"));
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-08 22:06:59 +00:00
NS_IMETHODIMP
CWebShellContainer::OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar* aMsg)
{
1998-10-08 22:06:59 +00:00
ATLTRACE(_T("CWebShellContainer::OnStopBinding()\n"));
return NS_OK;
}