shdocvw: Move DllGetClassObject implementation to factory.c.

This commit is contained in:
Jacek Caban 2006-04-19 20:31:59 +02:00 committed by Alexandre Julliard
parent b26ed16633
commit c48c50f575
3 changed files with 35 additions and 39 deletions

View File

@ -30,10 +30,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
* (Based on implementation in ddraw/main.c) * (Based on implementation in ddraw/main.c)
*/ */
#define FACTORY(x) ((IClassFactory*) &(x)->lpClassFactoryVtbl)
typedef struct typedef struct
{ {
/* IUnknown fields */ /* IUnknown fields */
const IClassFactoryVtbl *lpVtbl; const IClassFactoryVtbl *lpClassFactoryVtbl;
HRESULT (*cf)(LPUNKNOWN, REFIID, LPVOID *); HRESULT (*cf)(LPUNKNOWN, REFIID, LPVOID *);
LONG ref; LONG ref;
} IClassFactoryImpl; } IClassFactoryImpl;
@ -115,9 +117,24 @@ static const IClassFactoryVtbl WBCF_Vtbl =
WBCF_LockServer WBCF_LockServer
}; };
static IClassFactoryImpl SHDOCVW_WBClassFactory = {&WBCF_Vtbl, WebBrowser_Create}; /*************************************************************************
* DllGetClassObject (SHDOCVW.@)
IClassFactory *get_class_factory(void) */
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
{ {
return (IClassFactory*) &SHDOCVW_WBClassFactory; 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);
} }

View File

@ -169,6 +169,8 @@ void deactivate_document(DocHost*);
void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*); void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
HRESULT navigate_url(DocHost*,LPCWSTR,PBYTE,ULONG,LPWSTR); HRESULT navigate_url(DocHost*,LPCWSTR,PBYTE,ULONG,LPWSTR);
HRESULT create_mozctl(REFIID,void**);
#define WB_WM_NAVIGATE2 (WM_USER+100) #define WB_WM_NAVIGATE2 (WM_USER+100)
#define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl))) #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
@ -184,6 +186,5 @@ extern HINSTANCE shdocvw_hinstance;
extern void register_iewindow_class(void); extern void register_iewindow_class(void);
extern void unregister_iewindow_class(void); extern void unregister_iewindow_class(void);
extern BOOL create_ie_window(LPCWSTR url); extern BOOL create_ie_window(LPCWSTR url);
extern IClassFactory *get_class_factory(void);
#endif /* __WINE_SHDOCVW_H */ #endif /* __WINE_SHDOCVW_H */

View File

@ -444,46 +444,24 @@ static BOOL SHDOCVW_TryLoadMozillaControl(void)
} }
} }
/************************************************************************* HRESULT create_mozctl(REFIID riid, void **ppv)
* DllGetClassObject (SHDOCVW.@)
*/
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{ {
TRACE("\n"); fnGetClassObject pGetClassObject;
HRESULT hres;
if( IsEqualGUID( &CLSID_WebBrowser, rclsid ) && if(!SHDOCVW_TryLoadMozillaControl())
SHDOCVW_TryLoadMozillaControl() ) return CLASS_E_CLASSNOTAVAILABLE;
{
HRESULT r;
fnGetClassObject pGetClassObject;
TRACE("WebBrowser class %s\n", debugstr_guid(rclsid) ); pGetClassObject = (fnGetClassObject)GetProcAddress( hMozCtl, "DllGetClassObject" );
pGetClassObject = (fnGetClassObject) if( !pGetClassObject )
GetProcAddress( hMozCtl, "DllGetClassObject" ); return CLASS_E_CLASSNOTAVAILABLE;
if( !pGetClassObject ) hres = pGetClassObject( &CLSID_MozillaBrowser, riid, ppv );
return CLASS_E_CLASSNOTAVAILABLE;
r = pGetClassObject( &CLSID_MozillaBrowser, riid, ppv );
TRACE("r = %08lx *ppv = %p\n", r, *ppv ); TRACE("hres = %08lx *ppv = %p\n", hres, *ppv );
return r; return hres;
}
if (IsEqualCLSID(&CLSID_WebBrowser, rclsid) &&
IsEqualIID(&IID_IClassFactory, riid))
{
/* Pass back our shdocvw class factory */
IClassFactory *cf = get_class_factory();
IClassFactory_AddRef(cf);
*ppv = cf;
return S_OK;
}
/* As a last resort, figure if the CLSID belongs to a 'Shell Instance Object' */
return SHDOCVW_GetShellInstanceObjectClassObject(rclsid, riid, ppv);
} }
/*********************************************************************** /***********************************************************************