oleaut32/tests: Skip some tests when OleLoadPictureEx() is not available.
[wine/multimedia.git] / dlls / ieframe / webbrowser.c
blob706600d6801ca7ffdec1e38c963d224cffb74320
1 /*
2 * Implementation of IWebBrowser interface for WebBrowser control
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
5 * Copyright 2005 Jacek Caban
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "ieframe.h"
24 #include "exdispid.h"
25 #include "mshtml.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
31 static inline WebBrowser *impl_from_IWebBrowser2(IWebBrowser2 *iface)
33 return CONTAINING_RECORD(iface, WebBrowser, IWebBrowser2_iface);
36 static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
38 WebBrowser *This = impl_from_IWebBrowser2(iface);
40 if (ppv == NULL)
41 return E_POINTER;
42 *ppv = NULL;
44 if(IsEqualGUID(&IID_IUnknown, riid)) {
45 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
46 *ppv = &This->IWebBrowser2_iface;
47 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
48 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
49 *ppv = &This->IWebBrowser2_iface;
50 }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
51 TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
52 *ppv = &This->IWebBrowser2_iface;
53 }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
54 TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
55 *ppv = &This->IWebBrowser2_iface;
56 }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
57 TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
58 *ppv = &This->IWebBrowser2_iface;
59 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
60 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
61 *ppv = &This->IOleObject_iface;
62 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
63 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
64 *ppv = &This->IOleInPlaceObject_iface;
65 }else if(IsEqualGUID (&IID_IOleInPlaceObject, riid)) {
66 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
67 *ppv = &This->IOleInPlaceObject_iface;
68 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
69 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
70 *ppv = &This->IOleControl_iface;
71 }else if(IsEqualGUID(&IID_IPersist, riid)) {
72 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
73 *ppv = &This->IPersistStorage_iface;
74 }else if(IsEqualGUID(&IID_IPersistStorage, riid)) {
75 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
76 *ppv = &This->IPersistStorage_iface;
77 }else if(IsEqualGUID(&IID_IPersistMemory, riid)) {
78 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
79 *ppv = &This->IPersistMemory_iface;
80 }else if(IsEqualGUID (&IID_IPersistStreamInit, riid)) {
81 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
82 *ppv = &This->IPersistStreamInit_iface;
83 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
84 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
85 *ppv = &This->IProvideClassInfo2_iface;
86 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
87 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
88 *ppv = &This->IProvideClassInfo2_iface;
89 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
90 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
91 *ppv = &This->doc_host.cps.IConnectionPointContainer_iface;
92 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
93 TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
94 *ppv = &This->IViewObject2_iface;
95 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
96 TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
97 *ppv = &This->IViewObject2_iface;
98 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
99 TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
100 *ppv = &This->IOleInPlaceActiveObject_iface;
101 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
102 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
103 *ppv = &This->IOleCommandTarget_iface;
104 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
105 *ppv = &This->IServiceProvider_iface;
106 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
107 }else if(IsEqualGUID(&IID_IDataObject, riid)) {
108 *ppv = &This->IDataObject_iface;
109 TRACE("(%p)->(IID_IDataObject %p)\n", This, ppv);
110 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
111 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
112 return E_NOINTERFACE;
113 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
114 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
115 return E_NOINTERFACE;
116 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
117 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
118 return E_NOINTERFACE;
119 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
120 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
121 return E_NOINTERFACE;
122 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
123 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
124 return E_NOINTERFACE;
125 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
126 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
127 return E_NOINTERFACE;
128 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
129 TRACE("(%p)->(IID_IViewObjectEx %p) returning NULL\n", This, ppv);
130 return E_NOINTERFACE;
131 }else if(IsEqualGUID(&IID_IOleLink, riid)) {
132 TRACE("(%p)->(IID_IOleLink %p) returning NULL\n", This, ppv);
133 return E_NOINTERFACE;
134 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
135 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
136 return E_NOINTERFACE;
137 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
138 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
139 return E_NOINTERFACE;
140 }else if(HlinkFrame_QI(&This->hlink_frame, riid, ppv)) {
141 return S_OK;
144 if(*ppv) {
145 IUnknown_AddRef((IUnknown*)*ppv);
146 return S_OK;
149 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
150 return E_NOINTERFACE;
153 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
155 WebBrowser *This = impl_from_IWebBrowser2(iface);
156 LONG ref = InterlockedIncrement(&This->ref);
157 TRACE("(%p) ref=%d\n", This, ref);
158 return ref;
161 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
163 WebBrowser *This = impl_from_IWebBrowser2(iface);
164 LONG ref = InterlockedDecrement(&This->ref);
166 TRACE("(%p) ref=%d\n", This, ref);
168 if(!ref) {
169 if(This->doc_host.document)
170 IUnknown_Release(This->doc_host.document);
172 DocHost_Release(&This->doc_host);
174 WebBrowser_OleObject_Destroy(This);
176 heap_free(This);
177 unlock_module();
180 return ref;
183 /* IDispatch methods */
184 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
186 WebBrowser *This = impl_from_IWebBrowser2(iface);
188 TRACE("(%p)->(%p)\n", This, pctinfo);
190 *pctinfo = 1;
191 return S_OK;
194 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
195 LPTYPEINFO *ppTInfo)
197 WebBrowser *This = impl_from_IWebBrowser2(iface);
198 ITypeInfo *typeinfo;
199 HRESULT hres;
201 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
203 hres = get_typeinfo(&typeinfo);
204 if(FAILED(hres))
205 return hres;
207 ITypeInfo_AddRef(typeinfo);
208 *ppTInfo = typeinfo;
209 return S_OK;
212 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
213 LPOLESTR *rgszNames, UINT cNames,
214 LCID lcid, DISPID *rgDispId)
216 WebBrowser *This = impl_from_IWebBrowser2(iface);
217 ITypeInfo *typeinfo;
218 HRESULT hres;
220 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
221 lcid, rgDispId);
223 hres = get_typeinfo(&typeinfo);
224 if(FAILED(hres))
225 return hres;
227 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
230 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
231 REFIID riid, LCID lcid, WORD wFlags,
232 DISPPARAMS *pDispParams, VARIANT *pVarResult,
233 EXCEPINFO *pExepInfo, UINT *puArgErr)
235 WebBrowser *This = impl_from_IWebBrowser2(iface);
236 ITypeInfo *typeinfo;
237 HRESULT hres;
239 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
240 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
242 hres = get_typeinfo(&typeinfo);
243 if(FAILED(hres))
244 return hres;
246 return ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags, pDispParams,
247 pVarResult, pExepInfo, puArgErr);
250 /* IWebBrowser methods */
251 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
253 WebBrowser *This = impl_from_IWebBrowser2(iface);
254 FIXME("(%p)\n", This);
255 return E_NOTIMPL;
258 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
260 WebBrowser *This = impl_from_IWebBrowser2(iface);
261 FIXME("(%p)\n", This);
262 return E_NOTIMPL;
265 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
267 WebBrowser *This = impl_from_IWebBrowser2(iface);
268 TRACE("(%p)\n", This);
269 return go_home(&This->doc_host);
272 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
274 WebBrowser *This = impl_from_IWebBrowser2(iface);
275 FIXME("(%p)\n", This);
276 return E_NOTIMPL;
279 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
280 VARIANT *Flags, VARIANT *TargetFrameName,
281 VARIANT *PostData, VARIANT *Headers)
283 WebBrowser *This = impl_from_IWebBrowser2(iface);
285 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
286 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
287 debugstr_variant(Headers));
289 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
292 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
294 WebBrowser *This = impl_from_IWebBrowser2(iface);
295 FIXME("(%p)\n", This);
296 return E_NOTIMPL;
299 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
301 WebBrowser *This = impl_from_IWebBrowser2(iface);
302 FIXME("(%p)->(%s)\n", This, debugstr_variant(Level));
303 return E_NOTIMPL;
306 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
308 WebBrowser *This = impl_from_IWebBrowser2(iface);
309 FIXME("(%p)\n", This);
310 return S_OK;
313 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
315 WebBrowser *This = impl_from_IWebBrowser2(iface);
317 TRACE("(%p)->(%p)\n", This, ppDisp);
319 if(!ppDisp)
320 return E_POINTER;
322 *ppDisp = (IDispatch*)&This->IWebBrowser2_iface;
323 IDispatch_AddRef(*ppDisp);
324 return S_OK;
327 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
329 WebBrowser *This = impl_from_IWebBrowser2(iface);
330 FIXME("(%p)->(%p)\n", This, ppDisp);
331 return E_NOTIMPL;
334 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
336 WebBrowser *This = impl_from_IWebBrowser2(iface);
337 FIXME("(%p)->(%p)\n", This, ppDisp);
338 return E_NOTIMPL;
341 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
343 WebBrowser *This = impl_from_IWebBrowser2(iface);
344 IDispatch *disp = NULL;
346 TRACE("(%p)->(%p)\n", This, ppDisp);
348 if(This->doc_host.document) {
349 HRESULT hres;
351 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
352 if(SUCCEEDED(hres)) {
353 IDispatch *html_doc;
355 /* Some broken apps cast returned IDispatch to IHTMLDocument2
356 * without QueryInterface call */
357 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
358 if(SUCCEEDED(hres)) {
359 IDispatch_Release(disp);
360 disp = html_doc;
365 *ppDisp = disp;
366 return S_OK;
369 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
371 WebBrowser *This = impl_from_IWebBrowser2(iface);
372 FIXME("(%p)->(%p)\n", This, pBool);
373 return E_NOTIMPL;
376 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
378 WebBrowser *This = impl_from_IWebBrowser2(iface);
379 FIXME("(%p)->(%p)\n", This, Type);
380 return E_NOTIMPL;
383 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
385 WebBrowser *This = impl_from_IWebBrowser2(iface);
387 TRACE("(%p)->(%p)\n", This, pl);
389 *pl = This->pos_rect.left;
390 return S_OK;
393 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
395 WebBrowser *This = impl_from_IWebBrowser2(iface);
396 RECT rect;
398 TRACE("(%p)->(%d)\n", This, Left);
400 if(!This->inplace)
401 return E_UNEXPECTED;
403 rect = This->pos_rect;
404 rect.left = Left;
406 /* We don't really change the window position here.
407 * We just notify the embedder that he should do so. */
408 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
411 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
413 WebBrowser *This = impl_from_IWebBrowser2(iface);
415 TRACE("(%p)->(%p)\n", This, pl);
417 *pl = This->pos_rect.top;
418 return S_OK;
421 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
423 WebBrowser *This = impl_from_IWebBrowser2(iface);
424 RECT rect;
426 TRACE("(%p)->(%d)\n", This, Top);
428 if(!This->inplace)
429 return E_UNEXPECTED;
431 rect = This->pos_rect;
432 rect.top = Top;
434 /* We don't really change the window position here.
435 * We just notify the embedder that he should do so. */
436 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
439 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
441 WebBrowser *This = impl_from_IWebBrowser2(iface);
443 TRACE("(%p)->(%p)\n", This, pl);
445 *pl = This->pos_rect.right - This->pos_rect.left;
446 return S_OK;
449 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
451 WebBrowser *This = impl_from_IWebBrowser2(iface);
452 RECT rect;
454 TRACE("(%p)->(%d)\n", This, Width);
456 if(!This->inplace)
457 return E_UNEXPECTED;
459 rect = This->pos_rect;
460 rect.right = rect.left+Width;
462 /* We don't really change the window size here.
463 * We just notify the embedder that he should do so. */
464 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
467 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
469 WebBrowser *This = impl_from_IWebBrowser2(iface);
471 TRACE("(%p)->(%p)\n", This, pl);
473 *pl = This->pos_rect.bottom - This->pos_rect.top;
474 return S_OK;
477 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
479 WebBrowser *This = impl_from_IWebBrowser2(iface);
480 RECT rect;
482 TRACE("(%p)->(%d)\n", This, Height);
484 if(!This->inplace)
485 return E_UNEXPECTED;
487 rect = This->pos_rect;
488 rect.bottom = rect.top+Height;
490 /* We don't really change the window size here.
491 * We just notify the embedder that he should do so. */
492 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
495 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
497 WebBrowser *This = impl_from_IWebBrowser2(iface);
498 FIXME("(%p)->(%p)\n", This, LocationName);
499 return E_NOTIMPL;
502 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
504 WebBrowser *This = impl_from_IWebBrowser2(iface);
506 TRACE("(%p)->(%p)\n", This, LocationURL);
508 return get_location_url(&This->doc_host, LocationURL);
511 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
513 WebBrowser *This = impl_from_IWebBrowser2(iface);
515 TRACE("(%p)->(%p)\n", This, pBool);
517 *pBool = This->doc_host.busy;
518 return S_OK;
521 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
523 WebBrowser *This = impl_from_IWebBrowser2(iface);
525 TRACE("(%p)\n", This);
527 /* It's a InternetExplorer specific method, we have nothing to do here. */
528 return E_FAIL;
531 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
533 WebBrowser *This = impl_from_IWebBrowser2(iface);
534 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
535 return E_NOTIMPL;
538 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
540 WebBrowser *This = impl_from_IWebBrowser2(iface);
541 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
542 return E_NOTIMPL;
545 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
547 WebBrowser *This = impl_from_IWebBrowser2(iface);
548 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
549 return E_NOTIMPL;
552 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
554 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
555 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
556 WebBrowser *This = impl_from_IWebBrowser2(iface);
558 TRACE("(%p)->(%p)\n", This, Name);
560 *Name = SysAllocString(sName);
562 return S_OK;
565 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND)
567 WebBrowser *This = impl_from_IWebBrowser2(iface);
569 TRACE("(%p)->(%p)\n", This, pHWND);
571 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
572 *pHWND = 0;
573 return E_FAIL;
576 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
578 WebBrowser *This = impl_from_IWebBrowser2(iface);
579 FIXME("(%p)->(%p)\n", This, FullName);
580 return E_NOTIMPL;
583 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
585 WebBrowser *This = impl_from_IWebBrowser2(iface);
586 FIXME("(%p)->(%p)\n", This, Path);
587 return E_NOTIMPL;
590 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
592 WebBrowser *This = impl_from_IWebBrowser2(iface);
594 TRACE("(%p)->(%p)\n", This, pBool);
596 *pBool = This->visible;
597 return S_OK;
600 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
602 WebBrowser *This = impl_from_IWebBrowser2(iface);
603 VARIANTARG arg;
604 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
606 TRACE("(%p)->(%x)\n", This, Value);
608 This->visible = Value;
610 V_VT(&arg) = VT_BOOL;
611 V_BOOL(&arg) = Value;
612 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
614 return S_OK;
617 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
619 WebBrowser *This = impl_from_IWebBrowser2(iface);
621 TRACE("(%p)->(%p)\n", This, pBool);
623 *pBool = This->status_bar;
624 return S_OK;
627 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
629 WebBrowser *This = impl_from_IWebBrowser2(iface);
630 VARIANTARG arg;
631 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
633 TRACE("(%p)->(%x)\n", This, Value);
635 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
637 /* In opposition to InternetExplorer, all we should do here is
638 * inform the embedder about the status bar change. */
640 V_VT(&arg) = VT_BOOL;
641 V_BOOL(&arg) = Value;
642 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
644 return S_OK;
647 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
649 WebBrowser *This = impl_from_IWebBrowser2(iface);
650 FIXME("(%p)->(%p)\n", This, StatusText);
651 return E_NOTIMPL;
654 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
656 WebBrowser *This = impl_from_IWebBrowser2(iface);
657 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
658 return E_NOTIMPL;
661 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
663 WebBrowser *This = impl_from_IWebBrowser2(iface);
665 TRACE("(%p)->(%p)\n", This, Value);
667 *Value = This->tool_bar;
668 return S_OK;
671 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
673 WebBrowser *This = impl_from_IWebBrowser2(iface);
674 VARIANTARG arg;
675 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
677 TRACE("(%p)->(%x)\n", This, Value);
679 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
681 /* In opposition to InternetExplorer, all we should do here is
682 * inform the embedder about the tool bar change. */
684 V_VT(&arg) = VT_BOOL;
685 V_BOOL(&arg) = This->tool_bar;
686 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
688 return S_OK;
691 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
693 WebBrowser *This = impl_from_IWebBrowser2(iface);
695 TRACE("(%p)->(%p)\n", This, Value);
697 *Value = This->menu_bar;
698 return S_OK;
701 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
703 WebBrowser *This = impl_from_IWebBrowser2(iface);
704 VARIANTARG arg;
705 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
707 TRACE("(%p)->(%x)\n", This, Value);
709 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
711 /* In opposition to InternetExplorer, all we should do here is
712 * inform the embedder about the menu bar change. */
714 V_VT(&arg) = VT_BOOL;
715 V_BOOL(&arg) = Value;
716 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
718 return S_OK;
721 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
723 WebBrowser *This = impl_from_IWebBrowser2(iface);
725 TRACE("(%p)->(%p)\n", This, pbFullScreen);
727 *pbFullScreen = This->full_screen;
728 return S_OK;
731 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
733 WebBrowser *This = impl_from_IWebBrowser2(iface);
734 VARIANTARG arg;
735 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
737 /* In opposition to InternetExplorer, all we should do here is
738 * inform the embedder about the fullscreen change. */
740 TRACE("(%p)->(%x)\n", This, bFullScreen);
742 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
744 V_VT(&arg) = VT_BOOL;
745 V_BOOL(&arg) = bFullScreen;
746 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
748 return S_OK;
751 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
752 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
754 WebBrowser *This = impl_from_IWebBrowser2(iface);
755 LPCWSTR url;
757 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
758 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
760 if(!This->client)
761 return E_FAIL;
763 if(!URL)
764 return S_OK;
766 switch (V_VT(URL))
768 case VT_BSTR:
769 url = V_BSTR(URL);
770 break;
771 case VT_BSTR|VT_BYREF:
772 url = *V_BSTRREF(URL);
773 break;
774 default:
775 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
776 return E_INVALIDARG;
779 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
782 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
784 WebBrowser *This = impl_from_IWebBrowser2(iface);
785 IOleCommandTarget *target = NULL;
786 OLECMD ole_command[1];
787 HRESULT hres;
789 TRACE("(%p)->(%d %p)\n", This, cmdID, pcmdf);
791 if (!pcmdf)
792 return E_POINTER;
793 ole_command[0].cmdID = cmdID;
794 ole_command[0].cmdf = *pcmdf;
796 if (This->container)
798 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
799 if(FAILED(hres))
800 target = NULL;
802 if (!target && This->doc_host.document)
804 hres = IOleContainer_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
805 if(FAILED(hres))
806 target = NULL;
809 if (!target)
810 return E_UNEXPECTED;
812 hres = IOleCommandTarget_QueryStatus(target, NULL, 1, ole_command, NULL);
813 if (SUCCEEDED(hres))
814 *pcmdf = ole_command[0].cmdf;
815 if (hres == OLECMDERR_E_NOTSUPPORTED)
817 *pcmdf = 0;
818 hres = S_OK;
820 IOleCommandTarget_Release(target);
822 return hres;
825 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
826 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
828 WebBrowser *This = impl_from_IWebBrowser2(iface);
829 IOleCommandTarget *target = NULL;
830 HRESULT hres;
832 TRACE("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
834 if(This->container)
836 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
837 if(FAILED(hres))
838 target = NULL;
840 if(!target && This->doc_host.document)
842 hres = IOleContainer_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
843 if(FAILED(hres))
844 target = NULL;
847 if(!target)
848 return E_UNEXPECTED;
850 hres = IOleCommandTarget_Exec(target, NULL, cmdID, cmdexecopt, pvaIn, pvaOut);
851 IOleCommandTarget_Release(target);
853 return hres;
856 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
857 VARIANT *pvarShow, VARIANT *pvarSize)
859 WebBrowser *This = impl_from_IWebBrowser2(iface);
860 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
861 debugstr_variant(pvarSize));
862 return E_NOTIMPL;
865 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
867 WebBrowser *This = impl_from_IWebBrowser2(iface);
869 TRACE("(%p)->(%p)\n", This, lpReadyState);
871 *lpReadyState = This->doc_host.ready_state;
872 return S_OK;
875 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
877 WebBrowser *This = impl_from_IWebBrowser2(iface);
879 TRACE("(%p)->(%p)\n", This, pbOffline);
881 *pbOffline = This->doc_host.offline;
882 return S_OK;
885 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
887 WebBrowser *This = impl_from_IWebBrowser2(iface);
889 TRACE("(%p)->(%x)\n", This, bOffline);
891 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
892 return S_OK;
895 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
897 WebBrowser *This = impl_from_IWebBrowser2(iface);
899 TRACE("(%p)->(%p)\n", This, pbSilent);
901 *pbSilent = This->doc_host.silent;
902 return S_OK;
905 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
907 WebBrowser *This = impl_from_IWebBrowser2(iface);
909 TRACE("(%p)->(%x)\n", This, bSilent);
911 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
912 return S_OK;
915 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
916 VARIANT_BOOL *pbRegister)
918 WebBrowser *This = impl_from_IWebBrowser2(iface);
920 FIXME("(%p)->(%p)\n", This, pbRegister);
922 *pbRegister = This->register_browser;
923 return S_OK;
926 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
927 VARIANT_BOOL bRegister)
929 WebBrowser *This = impl_from_IWebBrowser2(iface);
931 FIXME("(%p)->(%x)\n", This, bRegister);
933 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
934 return S_OK;
937 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
938 VARIANT_BOOL *pbRegister)
940 WebBrowser *This = impl_from_IWebBrowser2(iface);
941 FIXME("(%p)->(%p)\n", This, pbRegister);
942 *pbRegister=0;
943 return S_OK;
946 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
947 VARIANT_BOOL bRegister)
949 WebBrowser *This = impl_from_IWebBrowser2(iface);
950 FIXME("(%p)->(%x)\n", This, bRegister);
951 return S_OK;
954 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
956 WebBrowser *This = impl_from_IWebBrowser2(iface);
958 TRACE("(%p)->(%p)\n", This, pbRegister);
960 *pbRegister = This->theater_mode;
961 return S_OK;
964 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
966 WebBrowser *This = impl_from_IWebBrowser2(iface);
967 VARIANTARG arg;
968 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
970 TRACE("(%p)->(%x)\n", This, bRegister);
972 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
974 /* In opposition to InternetExplorer, all we should do here is
975 * inform the embedder about the theater mode change. */
977 V_VT(&arg) = VT_BOOL;
978 V_BOOL(&arg) = bRegister;
979 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
981 return S_OK;
984 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
986 WebBrowser *This = impl_from_IWebBrowser2(iface);
988 TRACE("(%p)->(%p)\n", This, Value);
990 *Value = This->address_bar;
991 return S_OK;
994 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
996 WebBrowser *This = impl_from_IWebBrowser2(iface);
997 VARIANTARG arg;
998 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1000 TRACE("(%p)->(%x)\n", This, Value);
1002 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
1004 /* In opposition to InternetExplorer, all we should do here is
1005 * inform the embedder about the address bar change. */
1007 V_VT(&arg) = VT_BOOL;
1008 V_BOOL(&arg) = Value;
1009 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
1011 return S_OK;
1014 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1016 WebBrowser *This = impl_from_IWebBrowser2(iface);
1018 TRACE("(%p)->(%p)\n", This, Value);
1020 /* It's InternetExplorer object's method. We have nothing to do here. */
1021 return E_NOTIMPL;
1024 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
1026 WebBrowser *This = impl_from_IWebBrowser2(iface);
1027 VARIANTARG arg;
1028 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1030 TRACE("(%p)->(%x)\n", This, Value);
1032 /* In opposition to InternetExplorer, all we should do here is
1033 * inform the embedder about the resizable change. */
1035 V_VT(&arg) = VT_BOOL;
1036 V_BOOL(&arg) = Value;
1037 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
1039 return S_OK;
1042 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
1044 WebBrowser_QueryInterface,
1045 WebBrowser_AddRef,
1046 WebBrowser_Release,
1047 WebBrowser_GetTypeInfoCount,
1048 WebBrowser_GetTypeInfo,
1049 WebBrowser_GetIDsOfNames,
1050 WebBrowser_Invoke,
1051 WebBrowser_GoBack,
1052 WebBrowser_GoForward,
1053 WebBrowser_GoHome,
1054 WebBrowser_GoSearch,
1055 WebBrowser_Navigate,
1056 WebBrowser_Refresh,
1057 WebBrowser_Refresh2,
1058 WebBrowser_Stop,
1059 WebBrowser_get_Application,
1060 WebBrowser_get_Parent,
1061 WebBrowser_get_Container,
1062 WebBrowser_get_Document,
1063 WebBrowser_get_TopLevelContainer,
1064 WebBrowser_get_Type,
1065 WebBrowser_get_Left,
1066 WebBrowser_put_Left,
1067 WebBrowser_get_Top,
1068 WebBrowser_put_Top,
1069 WebBrowser_get_Width,
1070 WebBrowser_put_Width,
1071 WebBrowser_get_Height,
1072 WebBrowser_put_Height,
1073 WebBrowser_get_LocationName,
1074 WebBrowser_get_LocationURL,
1075 WebBrowser_get_Busy,
1076 WebBrowser_Quit,
1077 WebBrowser_ClientToWindow,
1078 WebBrowser_PutProperty,
1079 WebBrowser_GetProperty,
1080 WebBrowser_get_Name,
1081 WebBrowser_get_HWND,
1082 WebBrowser_get_FullName,
1083 WebBrowser_get_Path,
1084 WebBrowser_get_Visible,
1085 WebBrowser_put_Visible,
1086 WebBrowser_get_StatusBar,
1087 WebBrowser_put_StatusBar,
1088 WebBrowser_get_StatusText,
1089 WebBrowser_put_StatusText,
1090 WebBrowser_get_ToolBar,
1091 WebBrowser_put_ToolBar,
1092 WebBrowser_get_MenuBar,
1093 WebBrowser_put_MenuBar,
1094 WebBrowser_get_FullScreen,
1095 WebBrowser_put_FullScreen,
1096 WebBrowser_Navigate2,
1097 WebBrowser_QueryStatusWB,
1098 WebBrowser_ExecWB,
1099 WebBrowser_ShowBrowserBar,
1100 WebBrowser_get_ReadyState,
1101 WebBrowser_get_Offline,
1102 WebBrowser_put_Offline,
1103 WebBrowser_get_Silent,
1104 WebBrowser_put_Silent,
1105 WebBrowser_get_RegisterAsBrowser,
1106 WebBrowser_put_RegisterAsBrowser,
1107 WebBrowser_get_RegisterAsDropTarget,
1108 WebBrowser_put_RegisterAsDropTarget,
1109 WebBrowser_get_TheaterMode,
1110 WebBrowser_put_TheaterMode,
1111 WebBrowser_get_AddressBar,
1112 WebBrowser_put_AddressBar,
1113 WebBrowser_get_Resizable,
1114 WebBrowser_put_Resizable
1117 static inline WebBrowser *impl_from_IServiceProvider(IServiceProvider *iface)
1119 return CONTAINING_RECORD(iface, WebBrowser, IServiceProvider_iface);
1122 static HRESULT WINAPI WBServiceProvider_QueryInterface(IServiceProvider *iface,
1123 REFIID riid, LPVOID *ppv)
1125 WebBrowser *This = impl_from_IServiceProvider(iface);
1126 return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
1129 static ULONG WINAPI WBServiceProvider_AddRef(IServiceProvider *iface)
1131 WebBrowser *This = impl_from_IServiceProvider(iface);
1132 return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
1135 static ULONG WINAPI WBServiceProvider_Release(IServiceProvider *iface)
1137 WebBrowser *This = impl_from_IServiceProvider(iface);
1138 return IWebBrowser_Release(&This->IWebBrowser2_iface);
1141 static HRESULT STDMETHODCALLTYPE WBServiceProvider_QueryService(IServiceProvider *iface,
1142 REFGUID guidService, REFIID riid, void **ppv)
1144 WebBrowser *This = impl_from_IServiceProvider(iface);
1146 if(*ppv)
1147 ppv = NULL;
1149 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1150 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1151 return E_FAIL;
1154 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1156 return E_NOINTERFACE;
1159 static const IServiceProviderVtbl ServiceProviderVtbl =
1161 WBServiceProvider_QueryInterface,
1162 WBServiceProvider_AddRef,
1163 WBServiceProvider_Release,
1164 WBServiceProvider_QueryService
1167 static inline WebBrowser *impl_from_DocHost(DocHost *iface)
1169 return CONTAINING_RECORD(iface, WebBrowser, doc_host);
1172 static ULONG WebBrowser_addref(DocHost *iface)
1174 WebBrowser *This = impl_from_DocHost(iface);
1175 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
1178 static ULONG WebBrowser_release(DocHost *iface)
1180 WebBrowser *This = impl_from_DocHost(iface);
1181 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
1184 static void WINAPI DocHostContainer_GetDocObjRect(DocHost* This, RECT* rc)
1186 GetClientRect(This->frame_hwnd, rc);
1189 static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost* This, LPCWSTR text)
1191 return E_NOTIMPL;
1194 static void WINAPI DocHostContainer_SetURL(DocHost* This, LPCWSTR url)
1199 static HRESULT DocHostContainer_exec(DocHost *doc_host, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in,
1200 VARIANT *out)
1202 WebBrowser *This = impl_from_DocHost(doc_host);
1203 IOleCommandTarget *cmdtrg = NULL;
1204 HRESULT hres;
1206 if(This->client) {
1207 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
1208 if(FAILED(hres))
1209 cmdtrg = NULL;
1212 if(!cmdtrg && This->container) {
1213 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (void**)&cmdtrg);
1214 if(FAILED(hres))
1215 cmdtrg = NULL;
1218 if(!cmdtrg)
1219 return S_OK;
1221 hres = IOleCommandTarget_Exec(cmdtrg, cmd_group, cmdid, execopt, in, out);
1222 IOleCommandTarget_Release(cmdtrg);
1223 if(FAILED(hres))
1224 FIXME("Exec failed\n");
1226 return hres;
1229 static const IDocHostContainerVtbl DocHostContainerVtbl = {
1230 WebBrowser_addref,
1231 WebBrowser_release,
1232 DocHostContainer_GetDocObjRect,
1233 DocHostContainer_SetStatusText,
1234 DocHostContainer_SetURL,
1235 DocHostContainer_exec
1238 static HRESULT create_webbrowser(int version, IUnknown *outer, REFIID riid, void **ppv)
1240 WebBrowser *ret;
1241 HRESULT hres;
1243 TRACE("(%p %s %p) version=%d\n", outer, debugstr_guid(riid), ppv, version);
1245 ret = heap_alloc_zero(sizeof(WebBrowser));
1247 ret->IWebBrowser2_iface.lpVtbl = &WebBrowser2Vtbl;
1248 ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
1249 ret->ref = 1;
1250 ret->version = version;
1252 DocHost_Init(&ret->doc_host, (IDispatch*)&ret->IWebBrowser2_iface, &DocHostContainerVtbl);
1254 ret->visible = VARIANT_TRUE;
1255 ret->menu_bar = VARIANT_TRUE;
1256 ret->address_bar = VARIANT_TRUE;
1257 ret->status_bar = VARIANT_TRUE;
1258 ret->tool_bar = VARIANT_TRUE;
1260 WebBrowser_OleObject_Init(ret);
1261 WebBrowser_ViewObject_Init(ret);
1262 WebBrowser_Persist_Init(ret);
1263 WebBrowser_ClassInfo_Init(ret);
1265 HlinkFrame_Init(&ret->hlink_frame, (IUnknown*)&ret->IWebBrowser2_iface, &ret->doc_host);
1267 lock_module();
1269 hres = IWebBrowser_QueryInterface(&ret->IWebBrowser2_iface, riid, ppv);
1271 IWebBrowser2_Release(&ret->IWebBrowser2_iface);
1272 return hres;
1275 HRESULT WINAPI WebBrowserV1_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1277 return create_webbrowser(1, pOuter, riid, ppv);
1280 HRESULT WINAPI WebBrowser_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1282 return create_webbrowser(2, pOuter, riid, ppv);