2002-05-05 21:40:57 +02:00
|
|
|
/*
|
|
|
|
* Implementation of class factory for IE Web Browser
|
|
|
|
*
|
|
|
|
* Copyright 2001 John R. Sheets (for CodeWeavers)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "shdocvw.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
|
|
|
|
|
|
|
|
/**********************************************************************
|
2005-09-06 13:41:14 +02:00
|
|
|
* Implement the WebBrowser class factory
|
2002-05-05 21:40:57 +02:00
|
|
|
*
|
|
|
|
* (Based on implementation in ddraw/main.c)
|
|
|
|
*/
|
|
|
|
|
2006-04-19 20:31:59 +02:00
|
|
|
#define FACTORY(x) ((IClassFactory*) &(x)->lpClassFactoryVtbl)
|
|
|
|
|
2006-04-11 07:48:49 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
/* IUnknown fields */
|
2006-04-19 20:31:59 +02:00
|
|
|
const IClassFactoryVtbl *lpClassFactoryVtbl;
|
2006-04-11 07:48:49 +02:00
|
|
|
HRESULT (*cf)(LPUNKNOWN, REFIID, LPVOID *);
|
|
|
|
LONG ref;
|
|
|
|
} IClassFactoryImpl;
|
|
|
|
|
|
|
|
|
2002-05-05 21:40:57 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* WBCF_QueryInterface (IUnknown)
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI WBCF_QueryInterface(LPCLASSFACTORY iface,
|
|
|
|
REFIID riid, LPVOID *ppobj)
|
|
|
|
{
|
2005-09-06 13:41:14 +02:00
|
|
|
TRACE("(%s %p)\n", debugstr_guid(riid), ppobj);
|
|
|
|
|
|
|
|
if (!ppobj)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
|
|
|
|
*ppobj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Not supported interface %s\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
*ppobj = NULL;
|
2002-05-05 21:40:57 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* WBCF_AddRef (IUnknown)
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI WBCF_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
2005-01-27 11:43:53 +01:00
|
|
|
SHDOCVW_LockModule();
|
2002-05-05 21:40:57 +02:00
|
|
|
|
2005-01-27 11:43:53 +01:00
|
|
|
return 2; /* non-heap based object */
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* WBCF_Release (IUnknown)
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI WBCF_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
2005-01-27 11:43:53 +01:00
|
|
|
SHDOCVW_UnlockModule();
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2005-01-27 11:43:53 +01:00
|
|
|
return 1; /* non-heap based object */
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* WBCF_CreateInstance (IClassFactory)
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI WBCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
|
|
|
|
REFIID riid, LPVOID *ppobj)
|
|
|
|
{
|
2006-04-11 07:48:49 +02:00
|
|
|
IClassFactoryImpl *This = (IClassFactoryImpl *) iface;
|
|
|
|
return This->cf(pOuter, riid, ppobj);
|
2002-05-05 21:40:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* WBCF_LockServer (IClassFactory)
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI WBCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
|
|
|
|
{
|
2005-01-27 11:43:53 +01:00
|
|
|
TRACE("(%d)\n", dolock);
|
|
|
|
|
|
|
|
if (dolock)
|
2005-09-06 13:41:14 +02:00
|
|
|
SHDOCVW_LockModule();
|
2005-01-27 11:43:53 +01:00
|
|
|
else
|
2005-09-06 13:41:14 +02:00
|
|
|
SHDOCVW_UnlockModule();
|
2005-01-27 11:43:53 +01:00
|
|
|
|
2002-05-05 21:40:57 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IClassFactoryVtbl WBCF_Vtbl =
|
2002-05-05 21:40:57 +02:00
|
|
|
{
|
|
|
|
WBCF_QueryInterface,
|
|
|
|
WBCF_AddRef,
|
|
|
|
WBCF_Release,
|
|
|
|
WBCF_CreateInstance,
|
|
|
|
WBCF_LockServer
|
|
|
|
};
|
|
|
|
|
2006-04-19 20:31:59 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* DllGetClassObject (SHDOCVW.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
|
2006-04-11 07:48:49 +02:00
|
|
|
{
|
2006-04-19 20:31:59 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
static IClassFactoryImpl WBClassFactory = {&WBCF_Vtbl, WebBrowser_Create};
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if(IsEqualGUID(&CLSID_WebBrowser, rclsid)) {
|
|
|
|
hres = create_mozctl(riid, ppv);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
return hres;
|
|
|
|
return IClassFactory_QueryInterface(FACTORY(&WBClassFactory), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* As a last resort, figure if the CLSID belongs to a 'Shell Instance Object' */
|
|
|
|
return SHDOCVW_GetShellInstanceObjectClassObject(rclsid, riid, ppv);
|
2006-04-11 07:48:49 +02:00
|
|
|
}
|