include: Add event trace flags and guid to evntrace.h.
[wine.git] / dlls / ieframe / webbrowser.c
blob1f58bbb199f5a521c8a3843002a624bc4eeccb17
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 /* This is implemented since IE10 */
139 WARN("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
140 return E_NOINTERFACE;
141 }else if(HlinkFrame_QI(&This->hlink_frame, riid, ppv)) {
142 return S_OK;
145 if(*ppv) {
146 IUnknown_AddRef((IUnknown*)*ppv);
147 return S_OK;
150 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
151 return E_NOINTERFACE;
154 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
156 WebBrowser *This = impl_from_IWebBrowser2(iface);
157 LONG ref = InterlockedIncrement(&This->ref);
158 TRACE("(%p) ref=%d\n", This, ref);
159 return ref;
162 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
164 WebBrowser *This = impl_from_IWebBrowser2(iface);
165 LONG ref = InterlockedDecrement(&This->ref);
167 TRACE("(%p) ref=%d\n", This, ref);
169 if(!ref) {
170 if(This->doc_host.document)
171 IUnknown_Release(This->doc_host.document);
173 DocHost_Release(&This->doc_host);
175 WebBrowser_OleObject_Destroy(This);
177 heap_free(This);
178 unlock_module();
181 return ref;
184 /* IDispatch methods */
185 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
187 WebBrowser *This = impl_from_IWebBrowser2(iface);
189 TRACE("(%p)->(%p)\n", This, pctinfo);
191 *pctinfo = 1;
192 return S_OK;
195 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
196 LPTYPEINFO *ppTInfo)
198 WebBrowser *This = impl_from_IWebBrowser2(iface);
199 ITypeInfo *typeinfo;
200 HRESULT hres;
202 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
204 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
205 if(FAILED(hres))
206 return hres;
208 ITypeInfo_AddRef(typeinfo);
209 *ppTInfo = typeinfo;
210 return S_OK;
213 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
214 LPOLESTR *rgszNames, UINT cNames,
215 LCID lcid, DISPID *rgDispId)
217 WebBrowser *This = impl_from_IWebBrowser2(iface);
218 ITypeInfo *typeinfo;
219 HRESULT hres;
221 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
222 lcid, rgDispId);
224 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
225 if(FAILED(hres))
226 return hres;
228 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
231 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
232 REFIID riid, LCID lcid, WORD wFlags,
233 DISPPARAMS *pDispParams, VARIANT *pVarResult,
234 EXCEPINFO *pExepInfo, UINT *puArgErr)
236 WebBrowser *This = impl_from_IWebBrowser2(iface);
237 ITypeInfo *typeinfo;
238 HRESULT hres;
240 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
241 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
243 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
244 if(FAILED(hres))
245 return hres;
247 return ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags, pDispParams,
248 pVarResult, pExepInfo, puArgErr);
251 /* IWebBrowser methods */
252 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
254 WebBrowser *This = impl_from_IWebBrowser2(iface);
255 TRACE("(%p)\n", This);
256 return go_back(&This->doc_host);
259 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
261 WebBrowser *This = impl_from_IWebBrowser2(iface);
262 TRACE("(%p)\n", This);
263 return go_forward(&This->doc_host);
266 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
268 WebBrowser *This = impl_from_IWebBrowser2(iface);
269 TRACE("(%p)\n", This);
270 return go_home(&This->doc_host);
273 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
275 WebBrowser *This = impl_from_IWebBrowser2(iface);
276 FIXME("(%p)\n", This);
277 return E_NOTIMPL;
280 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
281 VARIANT *Flags, VARIANT *TargetFrameName,
282 VARIANT *PostData, VARIANT *Headers)
284 WebBrowser *This = impl_from_IWebBrowser2(iface);
286 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
287 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
288 debugstr_variant(Headers));
290 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
293 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
295 WebBrowser *This = impl_from_IWebBrowser2(iface);
297 TRACE("(%p)\n", This);
299 return refresh_document(&This->doc_host, NULL);
302 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
304 WebBrowser *This = impl_from_IWebBrowser2(iface);
306 TRACE("(%p)->(%s)\n", This, debugstr_variant(Level));
308 return refresh_document(&This->doc_host, Level);
311 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
313 WebBrowser *This = impl_from_IWebBrowser2(iface);
314 FIXME("(%p)\n", This);
315 return S_OK;
318 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
320 WebBrowser *This = impl_from_IWebBrowser2(iface);
322 TRACE("(%p)->(%p)\n", This, ppDisp);
324 if(!ppDisp)
325 return E_POINTER;
327 *ppDisp = (IDispatch*)&This->IWebBrowser2_iface;
328 IDispatch_AddRef(*ppDisp);
329 return S_OK;
332 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
334 WebBrowser *This = impl_from_IWebBrowser2(iface);
335 FIXME("(%p)->(%p)\n", This, ppDisp);
336 return E_NOTIMPL;
339 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
341 WebBrowser *This = impl_from_IWebBrowser2(iface);
342 FIXME("(%p)->(%p)\n", This, ppDisp);
343 return E_NOTIMPL;
346 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
348 WebBrowser *This = impl_from_IWebBrowser2(iface);
349 IDispatch *disp = NULL;
351 TRACE("(%p)->(%p)\n", This, ppDisp);
353 if(This->doc_host.document) {
354 HRESULT hres;
356 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
357 if(SUCCEEDED(hres)) {
358 IDispatch *html_doc;
360 /* Some broken apps cast returned IDispatch to IHTMLDocument2
361 * without QueryInterface call */
362 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
363 if(SUCCEEDED(hres)) {
364 IDispatch_Release(disp);
365 disp = html_doc;
370 *ppDisp = disp;
371 return S_OK;
374 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
376 WebBrowser *This = impl_from_IWebBrowser2(iface);
377 FIXME("(%p)->(%p)\n", This, pBool);
378 return E_NOTIMPL;
381 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
383 WebBrowser *This = impl_from_IWebBrowser2(iface);
384 FIXME("(%p)->(%p)\n", This, Type);
385 return E_NOTIMPL;
388 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
390 WebBrowser *This = impl_from_IWebBrowser2(iface);
392 TRACE("(%p)->(%p)\n", This, pl);
394 *pl = This->pos_rect.left;
395 return S_OK;
398 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
400 WebBrowser *This = impl_from_IWebBrowser2(iface);
401 RECT rect;
403 TRACE("(%p)->(%d)\n", This, Left);
405 if(!This->inplace)
406 return E_UNEXPECTED;
408 rect = This->pos_rect;
409 rect.left = Left;
411 /* We don't really change the window position here.
412 * We just notify the embedder that he should do so. */
413 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
416 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
418 WebBrowser *This = impl_from_IWebBrowser2(iface);
420 TRACE("(%p)->(%p)\n", This, pl);
422 *pl = This->pos_rect.top;
423 return S_OK;
426 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
428 WebBrowser *This = impl_from_IWebBrowser2(iface);
429 RECT rect;
431 TRACE("(%p)->(%d)\n", This, Top);
433 if(!This->inplace)
434 return E_UNEXPECTED;
436 rect = This->pos_rect;
437 rect.top = Top;
439 /* We don't really change the window position here.
440 * We just notify the embedder that he should do so. */
441 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
444 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
446 WebBrowser *This = impl_from_IWebBrowser2(iface);
448 TRACE("(%p)->(%p)\n", This, pl);
450 *pl = This->pos_rect.right - This->pos_rect.left;
451 return S_OK;
454 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
456 WebBrowser *This = impl_from_IWebBrowser2(iface);
457 RECT rect;
459 TRACE("(%p)->(%d)\n", This, Width);
461 if(!This->inplace)
462 return E_UNEXPECTED;
464 rect = This->pos_rect;
465 rect.right = rect.left+Width;
467 /* We don't really change the window size here.
468 * We just notify the embedder that he should do so. */
469 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
472 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
474 WebBrowser *This = impl_from_IWebBrowser2(iface);
476 TRACE("(%p)->(%p)\n", This, pl);
478 *pl = This->pos_rect.bottom - This->pos_rect.top;
479 return S_OK;
482 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
484 WebBrowser *This = impl_from_IWebBrowser2(iface);
485 RECT rect;
487 TRACE("(%p)->(%d)\n", This, Height);
489 if(!This->inplace)
490 return E_UNEXPECTED;
492 rect = This->pos_rect;
493 rect.bottom = rect.top+Height;
495 /* We don't really change the window size here.
496 * We just notify the embedder that he should do so. */
497 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
500 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
502 WebBrowser *This = impl_from_IWebBrowser2(iface);
503 FIXME("(%p)->(%p)\n", This, LocationName);
504 return E_NOTIMPL;
507 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
509 WebBrowser *This = impl_from_IWebBrowser2(iface);
511 TRACE("(%p)->(%p)\n", This, LocationURL);
513 return get_location_url(&This->doc_host, LocationURL);
516 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
518 WebBrowser *This = impl_from_IWebBrowser2(iface);
520 TRACE("(%p)->(%p)\n", This, pBool);
522 *pBool = This->doc_host.busy;
523 return S_OK;
526 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
528 WebBrowser *This = impl_from_IWebBrowser2(iface);
530 TRACE("(%p)\n", This);
532 /* It's a InternetExplorer specific method, we have nothing to do here. */
533 return E_FAIL;
536 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
538 WebBrowser *This = impl_from_IWebBrowser2(iface);
539 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
540 return E_NOTIMPL;
543 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
545 WebBrowser *This = impl_from_IWebBrowser2(iface);
546 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
547 return E_NOTIMPL;
550 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
552 WebBrowser *This = impl_from_IWebBrowser2(iface);
553 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
554 return E_NOTIMPL;
557 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
559 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
560 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
561 WebBrowser *This = impl_from_IWebBrowser2(iface);
563 TRACE("(%p)->(%p)\n", This, Name);
565 *Name = SysAllocString(sName);
567 return S_OK;
570 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, SHANDLE_PTR *pHWND)
572 WebBrowser *This = impl_from_IWebBrowser2(iface);
574 TRACE("(%p)->(%p)\n", This, pHWND);
576 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
577 *pHWND = 0;
578 return E_FAIL;
581 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
583 WebBrowser *This = impl_from_IWebBrowser2(iface);
584 FIXME("(%p)->(%p)\n", This, FullName);
585 return E_NOTIMPL;
588 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
590 WebBrowser *This = impl_from_IWebBrowser2(iface);
591 FIXME("(%p)->(%p)\n", This, Path);
592 return E_NOTIMPL;
595 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
597 WebBrowser *This = impl_from_IWebBrowser2(iface);
599 TRACE("(%p)->(%p)\n", This, pBool);
601 *pBool = This->visible;
602 return S_OK;
605 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
607 WebBrowser *This = impl_from_IWebBrowser2(iface);
608 VARIANTARG arg;
609 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
611 TRACE("(%p)->(%x)\n", This, Value);
613 This->visible = Value;
615 V_VT(&arg) = VT_BOOL;
616 V_BOOL(&arg) = Value;
617 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
619 return S_OK;
622 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
624 WebBrowser *This = impl_from_IWebBrowser2(iface);
626 TRACE("(%p)->(%p)\n", This, pBool);
628 *pBool = This->status_bar;
629 return S_OK;
632 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
634 WebBrowser *This = impl_from_IWebBrowser2(iface);
635 VARIANTARG arg;
636 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
638 TRACE("(%p)->(%x)\n", This, Value);
640 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
642 /* In opposition to InternetExplorer, all we should do here is
643 * inform the embedder about the status bar change. */
645 V_VT(&arg) = VT_BOOL;
646 V_BOOL(&arg) = Value;
647 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
649 return S_OK;
652 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
654 WebBrowser *This = impl_from_IWebBrowser2(iface);
655 FIXME("(%p)->(%p)\n", This, StatusText);
656 return E_NOTIMPL;
659 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
661 WebBrowser *This = impl_from_IWebBrowser2(iface);
662 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
663 return E_NOTIMPL;
666 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
668 WebBrowser *This = impl_from_IWebBrowser2(iface);
670 TRACE("(%p)->(%p)\n", This, Value);
672 *Value = This->tool_bar;
673 return S_OK;
676 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
678 WebBrowser *This = impl_from_IWebBrowser2(iface);
679 VARIANTARG arg;
680 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
682 TRACE("(%p)->(%x)\n", This, Value);
684 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
686 /* In opposition to InternetExplorer, all we should do here is
687 * inform the embedder about the tool bar change. */
689 V_VT(&arg) = VT_BOOL;
690 V_BOOL(&arg) = This->tool_bar;
691 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
693 return S_OK;
696 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
698 WebBrowser *This = impl_from_IWebBrowser2(iface);
700 TRACE("(%p)->(%p)\n", This, Value);
702 *Value = This->menu_bar;
703 return S_OK;
706 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
708 WebBrowser *This = impl_from_IWebBrowser2(iface);
709 VARIANTARG arg;
710 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
712 TRACE("(%p)->(%x)\n", This, Value);
714 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
716 /* In opposition to InternetExplorer, all we should do here is
717 * inform the embedder about the menu bar change. */
719 V_VT(&arg) = VT_BOOL;
720 V_BOOL(&arg) = Value;
721 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
723 return S_OK;
726 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
728 WebBrowser *This = impl_from_IWebBrowser2(iface);
730 TRACE("(%p)->(%p)\n", This, pbFullScreen);
732 *pbFullScreen = This->full_screen;
733 return S_OK;
736 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
738 WebBrowser *This = impl_from_IWebBrowser2(iface);
739 VARIANTARG arg;
740 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
742 /* In opposition to InternetExplorer, all we should do here is
743 * inform the embedder about the fullscreen change. */
745 TRACE("(%p)->(%x)\n", This, bFullScreen);
747 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
749 V_VT(&arg) = VT_BOOL;
750 V_BOOL(&arg) = bFullScreen;
751 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
753 return S_OK;
756 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
757 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
759 WebBrowser *This = impl_from_IWebBrowser2(iface);
760 LPCWSTR url;
762 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
763 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
765 if(!This->client)
766 return E_FAIL;
768 if(!URL)
769 return S_OK;
771 switch (V_VT(URL))
773 case VT_BSTR:
774 url = V_BSTR(URL);
775 break;
776 case VT_BSTR|VT_BYREF:
777 url = *V_BSTRREF(URL);
778 break;
779 default:
780 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
781 return E_INVALIDARG;
784 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
787 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
789 WebBrowser *This = impl_from_IWebBrowser2(iface);
790 IOleCommandTarget *target = NULL;
791 OLECMD ole_command[1];
792 HRESULT hres;
794 TRACE("(%p)->(%d %p)\n", This, cmdID, pcmdf);
796 if (!pcmdf)
797 return E_POINTER;
798 ole_command[0].cmdID = cmdID;
799 ole_command[0].cmdf = *pcmdf;
801 if (This->container)
803 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
804 if(FAILED(hres))
805 target = NULL;
807 if (!target && This->doc_host.document)
809 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
810 if(FAILED(hres))
811 target = NULL;
814 if (!target)
815 return E_UNEXPECTED;
817 hres = IOleCommandTarget_QueryStatus(target, NULL, 1, ole_command, NULL);
818 if (SUCCEEDED(hres))
819 *pcmdf = ole_command[0].cmdf;
820 if (hres == OLECMDERR_E_NOTSUPPORTED)
822 *pcmdf = 0;
823 hres = S_OK;
825 IOleCommandTarget_Release(target);
827 return hres;
830 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
831 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
833 WebBrowser *This = impl_from_IWebBrowser2(iface);
834 IOleCommandTarget *target = NULL;
835 HRESULT hres;
837 TRACE("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
839 if(This->container)
841 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
842 if(FAILED(hres))
843 target = NULL;
845 if(!target && This->doc_host.document)
847 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
848 if(FAILED(hres))
849 target = NULL;
852 if(!target)
853 return E_UNEXPECTED;
855 hres = IOleCommandTarget_Exec(target, NULL, cmdID, cmdexecopt, pvaIn, pvaOut);
856 IOleCommandTarget_Release(target);
858 return hres;
861 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
862 VARIANT *pvarShow, VARIANT *pvarSize)
864 WebBrowser *This = impl_from_IWebBrowser2(iface);
865 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
866 debugstr_variant(pvarSize));
867 return E_NOTIMPL;
870 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
872 WebBrowser *This = impl_from_IWebBrowser2(iface);
874 TRACE("(%p)->(%p)\n", This, lpReadyState);
876 *lpReadyState = This->doc_host.ready_state;
877 return S_OK;
880 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
882 WebBrowser *This = impl_from_IWebBrowser2(iface);
884 TRACE("(%p)->(%p)\n", This, pbOffline);
886 *pbOffline = This->doc_host.offline;
887 return S_OK;
890 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
892 WebBrowser *This = impl_from_IWebBrowser2(iface);
894 TRACE("(%p)->(%x)\n", This, bOffline);
896 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
897 return S_OK;
900 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
902 WebBrowser *This = impl_from_IWebBrowser2(iface);
904 TRACE("(%p)->(%p)\n", This, pbSilent);
906 *pbSilent = This->doc_host.silent;
907 return S_OK;
910 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
912 WebBrowser *This = impl_from_IWebBrowser2(iface);
914 TRACE("(%p)->(%x)\n", This, bSilent);
916 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
917 return S_OK;
920 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
921 VARIANT_BOOL *pbRegister)
923 WebBrowser *This = impl_from_IWebBrowser2(iface);
925 FIXME("(%p)->(%p)\n", This, pbRegister);
927 *pbRegister = This->register_browser;
928 return S_OK;
931 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
932 VARIANT_BOOL bRegister)
934 WebBrowser *This = impl_from_IWebBrowser2(iface);
936 FIXME("(%p)->(%x)\n", This, bRegister);
938 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
939 return S_OK;
942 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
943 VARIANT_BOOL *pbRegister)
945 WebBrowser *This = impl_from_IWebBrowser2(iface);
947 FIXME("(%p)->(%p)\n", This, pbRegister);
949 if(!pbRegister)
950 return E_INVALIDARG;
952 *pbRegister=0;
953 return S_OK;
956 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
957 VARIANT_BOOL bRegister)
959 WebBrowser *This = impl_from_IWebBrowser2(iface);
960 FIXME("(%p)->(%x)\n", This, bRegister);
961 return S_OK;
964 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
966 WebBrowser *This = impl_from_IWebBrowser2(iface);
968 TRACE("(%p)->(%p)\n", This, pbRegister);
970 *pbRegister = This->theater_mode;
971 return S_OK;
974 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
976 WebBrowser *This = impl_from_IWebBrowser2(iface);
977 VARIANTARG arg;
978 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
980 TRACE("(%p)->(%x)\n", This, bRegister);
982 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
984 /* In opposition to InternetExplorer, all we should do here is
985 * inform the embedder about the theater mode change. */
987 V_VT(&arg) = VT_BOOL;
988 V_BOOL(&arg) = bRegister;
989 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
991 return S_OK;
994 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
996 WebBrowser *This = impl_from_IWebBrowser2(iface);
998 TRACE("(%p)->(%p)\n", This, Value);
1000 *Value = This->address_bar;
1001 return S_OK;
1004 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
1006 WebBrowser *This = impl_from_IWebBrowser2(iface);
1007 VARIANTARG arg;
1008 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1010 TRACE("(%p)->(%x)\n", This, Value);
1012 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
1014 /* In opposition to InternetExplorer, all we should do here is
1015 * inform the embedder about the address bar change. */
1017 V_VT(&arg) = VT_BOOL;
1018 V_BOOL(&arg) = Value;
1019 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
1021 return S_OK;
1024 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1026 WebBrowser *This = impl_from_IWebBrowser2(iface);
1028 TRACE("(%p)->(%p)\n", This, Value);
1030 /* It's InternetExplorer object's method. We have nothing to do here. */
1031 return E_NOTIMPL;
1034 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
1036 WebBrowser *This = impl_from_IWebBrowser2(iface);
1037 VARIANTARG arg;
1038 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1040 TRACE("(%p)->(%x)\n", This, Value);
1042 /* In opposition to InternetExplorer, all we should do here is
1043 * inform the embedder about the resizable change. */
1045 V_VT(&arg) = VT_BOOL;
1046 V_BOOL(&arg) = Value;
1047 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
1049 return S_OK;
1052 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
1054 WebBrowser_QueryInterface,
1055 WebBrowser_AddRef,
1056 WebBrowser_Release,
1057 WebBrowser_GetTypeInfoCount,
1058 WebBrowser_GetTypeInfo,
1059 WebBrowser_GetIDsOfNames,
1060 WebBrowser_Invoke,
1061 WebBrowser_GoBack,
1062 WebBrowser_GoForward,
1063 WebBrowser_GoHome,
1064 WebBrowser_GoSearch,
1065 WebBrowser_Navigate,
1066 WebBrowser_Refresh,
1067 WebBrowser_Refresh2,
1068 WebBrowser_Stop,
1069 WebBrowser_get_Application,
1070 WebBrowser_get_Parent,
1071 WebBrowser_get_Container,
1072 WebBrowser_get_Document,
1073 WebBrowser_get_TopLevelContainer,
1074 WebBrowser_get_Type,
1075 WebBrowser_get_Left,
1076 WebBrowser_put_Left,
1077 WebBrowser_get_Top,
1078 WebBrowser_put_Top,
1079 WebBrowser_get_Width,
1080 WebBrowser_put_Width,
1081 WebBrowser_get_Height,
1082 WebBrowser_put_Height,
1083 WebBrowser_get_LocationName,
1084 WebBrowser_get_LocationURL,
1085 WebBrowser_get_Busy,
1086 WebBrowser_Quit,
1087 WebBrowser_ClientToWindow,
1088 WebBrowser_PutProperty,
1089 WebBrowser_GetProperty,
1090 WebBrowser_get_Name,
1091 WebBrowser_get_HWND,
1092 WebBrowser_get_FullName,
1093 WebBrowser_get_Path,
1094 WebBrowser_get_Visible,
1095 WebBrowser_put_Visible,
1096 WebBrowser_get_StatusBar,
1097 WebBrowser_put_StatusBar,
1098 WebBrowser_get_StatusText,
1099 WebBrowser_put_StatusText,
1100 WebBrowser_get_ToolBar,
1101 WebBrowser_put_ToolBar,
1102 WebBrowser_get_MenuBar,
1103 WebBrowser_put_MenuBar,
1104 WebBrowser_get_FullScreen,
1105 WebBrowser_put_FullScreen,
1106 WebBrowser_Navigate2,
1107 WebBrowser_QueryStatusWB,
1108 WebBrowser_ExecWB,
1109 WebBrowser_ShowBrowserBar,
1110 WebBrowser_get_ReadyState,
1111 WebBrowser_get_Offline,
1112 WebBrowser_put_Offline,
1113 WebBrowser_get_Silent,
1114 WebBrowser_put_Silent,
1115 WebBrowser_get_RegisterAsBrowser,
1116 WebBrowser_put_RegisterAsBrowser,
1117 WebBrowser_get_RegisterAsDropTarget,
1118 WebBrowser_put_RegisterAsDropTarget,
1119 WebBrowser_get_TheaterMode,
1120 WebBrowser_put_TheaterMode,
1121 WebBrowser_get_AddressBar,
1122 WebBrowser_put_AddressBar,
1123 WebBrowser_get_Resizable,
1124 WebBrowser_put_Resizable
1127 static inline WebBrowser *impl_from_IServiceProvider(IServiceProvider *iface)
1129 return CONTAINING_RECORD(iface, WebBrowser, IServiceProvider_iface);
1132 static HRESULT WINAPI WBServiceProvider_QueryInterface(IServiceProvider *iface,
1133 REFIID riid, LPVOID *ppv)
1135 WebBrowser *This = impl_from_IServiceProvider(iface);
1136 return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
1139 static ULONG WINAPI WBServiceProvider_AddRef(IServiceProvider *iface)
1141 WebBrowser *This = impl_from_IServiceProvider(iface);
1142 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
1145 static ULONG WINAPI WBServiceProvider_Release(IServiceProvider *iface)
1147 WebBrowser *This = impl_from_IServiceProvider(iface);
1148 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
1151 static HRESULT STDMETHODCALLTYPE WBServiceProvider_QueryService(IServiceProvider *iface,
1152 REFGUID guidService, REFIID riid, void **ppv)
1154 WebBrowser *This = impl_from_IServiceProvider(iface);
1156 if(IsEqualGUID(&SID_SHTMLWindow, riid)) {
1157 TRACE("(%p)->(SID_SHTMLWindow)\n", This);
1158 return IHTMLWindow2_QueryInterface(&This->doc_host.html_window.IHTMLWindow2_iface, riid, ppv);
1161 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1162 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1163 *ppv = NULL;
1164 return E_FAIL;
1167 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1168 *ppv = NULL;
1169 return E_NOINTERFACE;
1172 static const IServiceProviderVtbl ServiceProviderVtbl =
1174 WBServiceProvider_QueryInterface,
1175 WBServiceProvider_AddRef,
1176 WBServiceProvider_Release,
1177 WBServiceProvider_QueryService
1180 static inline WebBrowser *impl_from_DocHost(DocHost *iface)
1182 return CONTAINING_RECORD(iface, WebBrowser, doc_host);
1185 static ULONG WebBrowser_addref(DocHost *iface)
1187 WebBrowser *This = impl_from_DocHost(iface);
1188 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
1191 static ULONG WebBrowser_release(DocHost *iface)
1193 WebBrowser *This = impl_from_DocHost(iface);
1194 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
1197 static void WINAPI DocHostContainer_GetDocObjRect(DocHost* This, RECT* rc)
1199 GetClientRect(This->frame_hwnd, rc);
1202 static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost* This, LPCWSTR text)
1204 return E_NOTIMPL;
1207 static void WINAPI DocHostContainer_SetURL(DocHost* This, LPCWSTR url)
1212 static HRESULT DocHostContainer_exec(DocHost *doc_host, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in,
1213 VARIANT *out)
1215 WebBrowser *This = impl_from_DocHost(doc_host);
1216 IOleCommandTarget *cmdtrg = NULL;
1217 HRESULT hres;
1219 if(This->client) {
1220 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
1221 if(FAILED(hres))
1222 cmdtrg = NULL;
1225 if(!cmdtrg && This->container) {
1226 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (void**)&cmdtrg);
1227 if(FAILED(hres))
1228 cmdtrg = NULL;
1231 if(!cmdtrg)
1232 return E_NOTIMPL;
1234 hres = IOleCommandTarget_Exec(cmdtrg, cmd_group, cmdid, execopt, in, out);
1235 IOleCommandTarget_Release(cmdtrg);
1236 if(SUCCEEDED(hres))
1237 TRACE("Exec returned %08x %s\n", hres, debugstr_variant(out));
1238 else
1239 FIXME("Exec failed\n");
1241 return hres;
1244 static const IDocHostContainerVtbl DocHostContainerVtbl = {
1245 WebBrowser_addref,
1246 WebBrowser_release,
1247 DocHostContainer_GetDocObjRect,
1248 DocHostContainer_SetStatusText,
1249 DocHostContainer_SetURL,
1250 DocHostContainer_exec
1253 static HRESULT create_webbrowser(int version, IUnknown *outer, REFIID riid, void **ppv)
1255 WebBrowser *ret;
1256 HRESULT hres;
1258 TRACE("(%p %s %p) version=%d\n", outer, debugstr_guid(riid), ppv, version);
1260 ret = heap_alloc_zero(sizeof(WebBrowser));
1262 ret->IWebBrowser2_iface.lpVtbl = &WebBrowser2Vtbl;
1263 ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
1264 ret->ref = 1;
1265 ret->version = version;
1267 DocHost_Init(&ret->doc_host, &ret->IWebBrowser2_iface, &DocHostContainerVtbl);
1269 ret->visible = VARIANT_TRUE;
1270 ret->menu_bar = VARIANT_TRUE;
1271 ret->address_bar = VARIANT_TRUE;
1272 ret->status_bar = VARIANT_TRUE;
1273 ret->tool_bar = VARIANT_TRUE;
1275 WebBrowser_OleObject_Init(ret);
1276 WebBrowser_ViewObject_Init(ret);
1277 WebBrowser_Persist_Init(ret);
1278 WebBrowser_ClassInfo_Init(ret);
1280 HlinkFrame_Init(&ret->hlink_frame, (IUnknown*)&ret->IWebBrowser2_iface, &ret->doc_host);
1282 lock_module();
1284 hres = IWebBrowser2_QueryInterface(&ret->IWebBrowser2_iface, riid, ppv);
1286 IWebBrowser2_Release(&ret->IWebBrowser2_iface);
1287 return hres;
1290 HRESULT WINAPI WebBrowserV1_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1292 return create_webbrowser(1, pOuter, riid, ppv);
1295 HRESULT WINAPI WebBrowser_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1297 return create_webbrowser(2, pOuter, riid, ppv);