diff --git a/dlls/shdocvw/factory.c b/dlls/shdocvw/factory.c index 264539a5d75..2fa096eb4ec 100644 --- a/dlls/shdocvw/factory.c +++ b/dlls/shdocvw/factory.c @@ -30,10 +30,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(shdocvw); * (Based on implementation in ddraw/main.c) */ +#define FACTORY(x) ((IClassFactory*) &(x)->lpClassFactoryVtbl) + typedef struct { /* IUnknown fields */ - const IClassFactoryVtbl *lpVtbl; + const IClassFactoryVtbl *lpClassFactoryVtbl; HRESULT (*cf)(LPUNKNOWN, REFIID, LPVOID *); LONG ref; } IClassFactoryImpl; @@ -115,9 +117,24 @@ static const IClassFactoryVtbl WBCF_Vtbl = WBCF_LockServer }; -static IClassFactoryImpl SHDOCVW_WBClassFactory = {&WBCF_Vtbl, WebBrowser_Create}; - -IClassFactory *get_class_factory(void) +/************************************************************************* + * DllGetClassObject (SHDOCVW.@) + */ +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); } diff --git a/dlls/shdocvw/shdocvw.h b/dlls/shdocvw/shdocvw.h index 66730cfd4f7..a86a5950964 100644 --- a/dlls/shdocvw/shdocvw.h +++ b/dlls/shdocvw/shdocvw.h @@ -169,6 +169,8 @@ void deactivate_document(DocHost*); void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*); HRESULT navigate_url(DocHost*,LPCWSTR,PBYTE,ULONG,LPWSTR); +HRESULT create_mozctl(REFIID,void**); + #define WB_WM_NAVIGATE2 (WM_USER+100) #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 unregister_iewindow_class(void); extern BOOL create_ie_window(LPCWSTR url); -extern IClassFactory *get_class_factory(void); #endif /* __WINE_SHDOCVW_H */ diff --git a/dlls/shdocvw/shdocvw_main.c b/dlls/shdocvw/shdocvw_main.c index f192db7f792..e93609574ba 100644 --- a/dlls/shdocvw/shdocvw_main.c +++ b/dlls/shdocvw/shdocvw_main.c @@ -444,46 +444,24 @@ static BOOL SHDOCVW_TryLoadMozillaControl(void) } } -/************************************************************************* - * DllGetClassObject (SHDOCVW.@) - */ -HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) +HRESULT create_mozctl(REFIID riid, void **ppv) { - TRACE("\n"); + fnGetClassObject pGetClassObject; + HRESULT hres; - if( IsEqualGUID( &CLSID_WebBrowser, rclsid ) && - SHDOCVW_TryLoadMozillaControl() ) - { - HRESULT r; - fnGetClassObject pGetClassObject; + if(!SHDOCVW_TryLoadMozillaControl()) + return CLASS_E_CLASSNOTAVAILABLE; - TRACE("WebBrowser class %s\n", debugstr_guid(rclsid) ); + pGetClassObject = (fnGetClassObject)GetProcAddress( hMozCtl, "DllGetClassObject" ); - pGetClassObject = (fnGetClassObject) - GetProcAddress( hMozCtl, "DllGetClassObject" ); + if( !pGetClassObject ) + return CLASS_E_CLASSNOTAVAILABLE; - if( !pGetClassObject ) - return CLASS_E_CLASSNOTAVAILABLE; - r = pGetClassObject( &CLSID_MozillaBrowser, riid, ppv ); + hres = pGetClassObject( &CLSID_MozillaBrowser, riid, ppv ); - TRACE("r = %08lx *ppv = %p\n", r, *ppv ); + TRACE("hres = %08lx *ppv = %p\n", hres, *ppv ); - return r; - } - - 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); + return hres; } /***********************************************************************