quartz: Free two assert calls from having side effects.
[wine/testsucceed.git] / dlls / ieframe / webbrowser.c
blobd1004df81b4c016b7dbdf5236a7701cd6f7e69ea
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"
26 #include "shdeprecated.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
32 static inline WebBrowser *impl_from_IWebBrowser2(IWebBrowser2 *iface)
34 return CONTAINING_RECORD(iface, WebBrowser, IWebBrowser2_iface);
37 static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
39 WebBrowser *This = impl_from_IWebBrowser2(iface);
41 if (ppv == NULL)
42 return E_POINTER;
43 *ppv = NULL;
45 if(IsEqualGUID(&IID_IUnknown, riid)) {
46 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
47 *ppv = &This->IWebBrowser2_iface;
48 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
49 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
50 *ppv = &This->IWebBrowser2_iface;
51 }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
52 TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
53 *ppv = &This->IWebBrowser2_iface;
54 }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
55 TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
56 *ppv = &This->IWebBrowser2_iface;
57 }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
58 TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
59 *ppv = &This->IWebBrowser2_iface;
60 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
61 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
62 *ppv = &This->IOleObject_iface;
63 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
64 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
65 *ppv = &This->IOleInPlaceObject_iface;
66 }else if(IsEqualGUID (&IID_IOleInPlaceObject, riid)) {
67 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
68 *ppv = &This->IOleInPlaceObject_iface;
69 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
70 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
71 *ppv = &This->IOleControl_iface;
72 }else if(IsEqualGUID(&IID_IPersist, riid)) {
73 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
74 *ppv = &This->IPersistStorage_iface;
75 }else if(IsEqualGUID(&IID_IPersistStorage, riid)) {
76 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
77 *ppv = &This->IPersistStorage_iface;
78 }else if(IsEqualGUID(&IID_IPersistMemory, riid)) {
79 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
80 *ppv = &This->IPersistMemory_iface;
81 }else if(IsEqualGUID (&IID_IPersistStreamInit, riid)) {
82 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
83 *ppv = &This->IPersistStreamInit_iface;
84 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
85 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
86 *ppv = &This->IProvideClassInfo2_iface;
87 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
88 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
89 *ppv = &This->IProvideClassInfo2_iface;
90 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
91 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
92 *ppv = &This->doc_host.cps.IConnectionPointContainer_iface;
93 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
94 TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
95 *ppv = &This->IViewObject2_iface;
96 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
97 TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
98 *ppv = &This->IViewObject2_iface;
99 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
100 TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
101 *ppv = &This->IOleInPlaceActiveObject_iface;
102 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
103 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
104 *ppv = &This->IOleCommandTarget_iface;
105 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
106 *ppv = &This->IServiceProvider_iface;
107 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
108 }else if(IsEqualGUID(&IID_IDataObject, riid)) {
109 *ppv = &This->IDataObject_iface;
110 TRACE("(%p)->(IID_IDataObject %p)\n", This, ppv);
111 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
112 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
113 return E_NOINTERFACE;
114 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
115 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
116 return E_NOINTERFACE;
117 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
118 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
119 return E_NOINTERFACE;
120 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
121 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
122 return E_NOINTERFACE;
123 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
124 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
125 return E_NOINTERFACE;
126 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
127 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
128 return E_NOINTERFACE;
129 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
130 TRACE("(%p)->(IID_IViewObjectEx %p) returning NULL\n", This, ppv);
131 return E_NOINTERFACE;
132 }else if(IsEqualGUID(&IID_IOleLink, riid)) {
133 TRACE("(%p)->(IID_IOleLink %p) returning NULL\n", This, ppv);
134 return E_NOINTERFACE;
135 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
136 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
137 return E_NOINTERFACE;
138 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
139 TRACE("(%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(&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(&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(&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 FIXME("(%p)\n", This);
256 return E_NOTIMPL;
259 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
261 WebBrowser *This = impl_from_IWebBrowser2(iface);
262 FIXME("(%p)\n", This);
263 return E_NOTIMPL;
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);
296 FIXME("(%p)\n", This);
297 return E_NOTIMPL;
300 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
302 WebBrowser *This = impl_from_IWebBrowser2(iface);
303 FIXME("(%p)->(%s)\n", This, debugstr_variant(Level));
304 return E_NOTIMPL;
307 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
309 WebBrowser *This = impl_from_IWebBrowser2(iface);
310 FIXME("(%p)\n", This);
311 return S_OK;
314 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
316 WebBrowser *This = impl_from_IWebBrowser2(iface);
318 TRACE("(%p)->(%p)\n", This, ppDisp);
320 if(!ppDisp)
321 return E_POINTER;
323 *ppDisp = (IDispatch*)&This->IWebBrowser2_iface;
324 IDispatch_AddRef(*ppDisp);
325 return S_OK;
328 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
330 WebBrowser *This = impl_from_IWebBrowser2(iface);
331 FIXME("(%p)->(%p)\n", This, ppDisp);
332 return E_NOTIMPL;
335 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
337 WebBrowser *This = impl_from_IWebBrowser2(iface);
338 FIXME("(%p)->(%p)\n", This, ppDisp);
339 return E_NOTIMPL;
342 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
344 WebBrowser *This = impl_from_IWebBrowser2(iface);
345 IDispatch *disp = NULL;
347 TRACE("(%p)->(%p)\n", This, ppDisp);
349 if(This->doc_host.document) {
350 HRESULT hres;
352 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
353 if(SUCCEEDED(hres)) {
354 IDispatch *html_doc;
356 /* Some broken apps cast returned IDispatch to IHTMLDocument2
357 * without QueryInterface call */
358 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
359 if(SUCCEEDED(hres)) {
360 IDispatch_Release(disp);
361 disp = html_doc;
366 *ppDisp = disp;
367 return S_OK;
370 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
372 WebBrowser *This = impl_from_IWebBrowser2(iface);
373 FIXME("(%p)->(%p)\n", This, pBool);
374 return E_NOTIMPL;
377 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
379 WebBrowser *This = impl_from_IWebBrowser2(iface);
380 FIXME("(%p)->(%p)\n", This, Type);
381 return E_NOTIMPL;
384 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
386 WebBrowser *This = impl_from_IWebBrowser2(iface);
388 TRACE("(%p)->(%p)\n", This, pl);
390 *pl = This->pos_rect.left;
391 return S_OK;
394 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
396 WebBrowser *This = impl_from_IWebBrowser2(iface);
397 RECT rect;
399 TRACE("(%p)->(%d)\n", This, Left);
401 if(!This->inplace)
402 return E_UNEXPECTED;
404 rect = This->pos_rect;
405 rect.left = Left;
407 /* We don't really change the window position here.
408 * We just notify the embedder that he should do so. */
409 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
412 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
414 WebBrowser *This = impl_from_IWebBrowser2(iface);
416 TRACE("(%p)->(%p)\n", This, pl);
418 *pl = This->pos_rect.top;
419 return S_OK;
422 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
424 WebBrowser *This = impl_from_IWebBrowser2(iface);
425 RECT rect;
427 TRACE("(%p)->(%d)\n", This, Top);
429 if(!This->inplace)
430 return E_UNEXPECTED;
432 rect = This->pos_rect;
433 rect.top = Top;
435 /* We don't really change the window position here.
436 * We just notify the embedder that he should do so. */
437 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
440 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
442 WebBrowser *This = impl_from_IWebBrowser2(iface);
444 TRACE("(%p)->(%p)\n", This, pl);
446 *pl = This->pos_rect.right - This->pos_rect.left;
447 return S_OK;
450 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
452 WebBrowser *This = impl_from_IWebBrowser2(iface);
453 RECT rect;
455 TRACE("(%p)->(%d)\n", This, Width);
457 if(!This->inplace)
458 return E_UNEXPECTED;
460 rect = This->pos_rect;
461 rect.right = rect.left+Width;
463 /* We don't really change the window size here.
464 * We just notify the embedder that he should do so. */
465 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
468 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
470 WebBrowser *This = impl_from_IWebBrowser2(iface);
472 TRACE("(%p)->(%p)\n", This, pl);
474 *pl = This->pos_rect.bottom - This->pos_rect.top;
475 return S_OK;
478 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
480 WebBrowser *This = impl_from_IWebBrowser2(iface);
481 RECT rect;
483 TRACE("(%p)->(%d)\n", This, Height);
485 if(!This->inplace)
486 return E_UNEXPECTED;
488 rect = This->pos_rect;
489 rect.bottom = rect.top+Height;
491 /* We don't really change the window size here.
492 * We just notify the embedder that he should do so. */
493 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
496 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
498 WebBrowser *This = impl_from_IWebBrowser2(iface);
499 FIXME("(%p)->(%p)\n", This, LocationName);
500 return E_NOTIMPL;
503 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
505 WebBrowser *This = impl_from_IWebBrowser2(iface);
507 TRACE("(%p)->(%p)\n", This, LocationURL);
509 return get_location_url(&This->doc_host, LocationURL);
512 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
514 WebBrowser *This = impl_from_IWebBrowser2(iface);
516 TRACE("(%p)->(%p)\n", This, pBool);
518 *pBool = This->doc_host.busy;
519 return S_OK;
522 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
524 WebBrowser *This = impl_from_IWebBrowser2(iface);
526 TRACE("(%p)\n", This);
528 /* It's a InternetExplorer specific method, we have nothing to do here. */
529 return E_FAIL;
532 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
534 WebBrowser *This = impl_from_IWebBrowser2(iface);
535 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
536 return E_NOTIMPL;
539 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
541 WebBrowser *This = impl_from_IWebBrowser2(iface);
542 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
543 return E_NOTIMPL;
546 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
548 WebBrowser *This = impl_from_IWebBrowser2(iface);
549 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
550 return E_NOTIMPL;
553 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
555 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
556 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
557 WebBrowser *This = impl_from_IWebBrowser2(iface);
559 TRACE("(%p)->(%p)\n", This, Name);
561 *Name = SysAllocString(sName);
563 return S_OK;
566 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND)
568 WebBrowser *This = impl_from_IWebBrowser2(iface);
570 TRACE("(%p)->(%p)\n", This, pHWND);
572 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
573 *pHWND = 0;
574 return E_FAIL;
577 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
579 WebBrowser *This = impl_from_IWebBrowser2(iface);
580 FIXME("(%p)->(%p)\n", This, FullName);
581 return E_NOTIMPL;
584 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
586 WebBrowser *This = impl_from_IWebBrowser2(iface);
587 FIXME("(%p)->(%p)\n", This, Path);
588 return E_NOTIMPL;
591 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
593 WebBrowser *This = impl_from_IWebBrowser2(iface);
595 TRACE("(%p)->(%p)\n", This, pBool);
597 *pBool = This->visible;
598 return S_OK;
601 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
603 WebBrowser *This = impl_from_IWebBrowser2(iface);
604 VARIANTARG arg;
605 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
607 TRACE("(%p)->(%x)\n", This, Value);
609 This->visible = Value;
611 V_VT(&arg) = VT_BOOL;
612 V_BOOL(&arg) = Value;
613 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
615 return S_OK;
618 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
620 WebBrowser *This = impl_from_IWebBrowser2(iface);
622 TRACE("(%p)->(%p)\n", This, pBool);
624 *pBool = This->status_bar;
625 return S_OK;
628 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
630 WebBrowser *This = impl_from_IWebBrowser2(iface);
631 VARIANTARG arg;
632 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
634 TRACE("(%p)->(%x)\n", This, Value);
636 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
638 /* In opposition to InternetExplorer, all we should do here is
639 * inform the embedder about the status bar change. */
641 V_VT(&arg) = VT_BOOL;
642 V_BOOL(&arg) = Value;
643 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
645 return S_OK;
648 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
650 WebBrowser *This = impl_from_IWebBrowser2(iface);
651 FIXME("(%p)->(%p)\n", This, StatusText);
652 return E_NOTIMPL;
655 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
657 WebBrowser *This = impl_from_IWebBrowser2(iface);
658 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
659 return E_NOTIMPL;
662 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
664 WebBrowser *This = impl_from_IWebBrowser2(iface);
666 TRACE("(%p)->(%p)\n", This, Value);
668 *Value = This->tool_bar;
669 return S_OK;
672 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
674 WebBrowser *This = impl_from_IWebBrowser2(iface);
675 VARIANTARG arg;
676 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
678 TRACE("(%p)->(%x)\n", This, Value);
680 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
682 /* In opposition to InternetExplorer, all we should do here is
683 * inform the embedder about the tool bar change. */
685 V_VT(&arg) = VT_BOOL;
686 V_BOOL(&arg) = This->tool_bar;
687 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
689 return S_OK;
692 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
694 WebBrowser *This = impl_from_IWebBrowser2(iface);
696 TRACE("(%p)->(%p)\n", This, Value);
698 *Value = This->menu_bar;
699 return S_OK;
702 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
704 WebBrowser *This = impl_from_IWebBrowser2(iface);
705 VARIANTARG arg;
706 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
708 TRACE("(%p)->(%x)\n", This, Value);
710 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
712 /* In opposition to InternetExplorer, all we should do here is
713 * inform the embedder about the menu bar change. */
715 V_VT(&arg) = VT_BOOL;
716 V_BOOL(&arg) = Value;
717 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
719 return S_OK;
722 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
724 WebBrowser *This = impl_from_IWebBrowser2(iface);
726 TRACE("(%p)->(%p)\n", This, pbFullScreen);
728 *pbFullScreen = This->full_screen;
729 return S_OK;
732 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
734 WebBrowser *This = impl_from_IWebBrowser2(iface);
735 VARIANTARG arg;
736 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
738 /* In opposition to InternetExplorer, all we should do here is
739 * inform the embedder about the fullscreen change. */
741 TRACE("(%p)->(%x)\n", This, bFullScreen);
743 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
745 V_VT(&arg) = VT_BOOL;
746 V_BOOL(&arg) = bFullScreen;
747 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
749 return S_OK;
752 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
753 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
755 WebBrowser *This = impl_from_IWebBrowser2(iface);
756 LPCWSTR url;
758 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
759 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
761 if(!This->client)
762 return E_FAIL;
764 if(!URL)
765 return S_OK;
767 switch (V_VT(URL))
769 case VT_BSTR:
770 url = V_BSTR(URL);
771 break;
772 case VT_BSTR|VT_BYREF:
773 url = *V_BSTRREF(URL);
774 break;
775 default:
776 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
777 return E_INVALIDARG;
780 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
783 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
785 WebBrowser *This = impl_from_IWebBrowser2(iface);
786 IOleCommandTarget *target = NULL;
787 OLECMD ole_command[1];
788 HRESULT hres;
790 TRACE("(%p)->(%d %p)\n", This, cmdID, pcmdf);
792 if (!pcmdf)
793 return E_POINTER;
794 ole_command[0].cmdID = cmdID;
795 ole_command[0].cmdf = *pcmdf;
797 if (This->container)
799 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
800 if(FAILED(hres))
801 target = NULL;
803 if (!target && This->doc_host.document)
805 hres = IOleContainer_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
806 if(FAILED(hres))
807 target = NULL;
810 if (!target)
811 return E_UNEXPECTED;
813 hres = IOleCommandTarget_QueryStatus(target, NULL, 1, ole_command, NULL);
814 if (SUCCEEDED(hres))
815 *pcmdf = ole_command[0].cmdf;
816 if (hres == OLECMDERR_E_NOTSUPPORTED)
818 *pcmdf = 0;
819 hres = S_OK;
821 IOleCommandTarget_Release(target);
823 return hres;
826 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
827 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
829 WebBrowser *This = impl_from_IWebBrowser2(iface);
830 IOleCommandTarget *target = NULL;
831 HRESULT hres;
833 TRACE("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
835 if(This->container)
837 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
838 if(FAILED(hres))
839 target = NULL;
841 if(!target && This->doc_host.document)
843 hres = IOleContainer_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
844 if(FAILED(hres))
845 target = NULL;
848 if(!target)
849 return E_UNEXPECTED;
851 hres = IOleCommandTarget_Exec(target, NULL, cmdID, cmdexecopt, pvaIn, pvaOut);
852 IOleCommandTarget_Release(target);
854 return hres;
857 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
858 VARIANT *pvarShow, VARIANT *pvarSize)
860 WebBrowser *This = impl_from_IWebBrowser2(iface);
861 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
862 debugstr_variant(pvarSize));
863 return E_NOTIMPL;
866 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
868 WebBrowser *This = impl_from_IWebBrowser2(iface);
870 TRACE("(%p)->(%p)\n", This, lpReadyState);
872 *lpReadyState = This->doc_host.ready_state;
873 return S_OK;
876 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
878 WebBrowser *This = impl_from_IWebBrowser2(iface);
880 TRACE("(%p)->(%p)\n", This, pbOffline);
882 *pbOffline = This->doc_host.offline;
883 return S_OK;
886 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
888 WebBrowser *This = impl_from_IWebBrowser2(iface);
890 TRACE("(%p)->(%x)\n", This, bOffline);
892 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
893 return S_OK;
896 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
898 WebBrowser *This = impl_from_IWebBrowser2(iface);
900 TRACE("(%p)->(%p)\n", This, pbSilent);
902 *pbSilent = This->doc_host.silent;
903 return S_OK;
906 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
908 WebBrowser *This = impl_from_IWebBrowser2(iface);
910 TRACE("(%p)->(%x)\n", This, bSilent);
912 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
913 return S_OK;
916 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
917 VARIANT_BOOL *pbRegister)
919 WebBrowser *This = impl_from_IWebBrowser2(iface);
921 FIXME("(%p)->(%p)\n", This, pbRegister);
923 *pbRegister = This->register_browser;
924 return S_OK;
927 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
928 VARIANT_BOOL bRegister)
930 WebBrowser *This = impl_from_IWebBrowser2(iface);
932 FIXME("(%p)->(%x)\n", This, bRegister);
934 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
935 return S_OK;
938 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
939 VARIANT_BOOL *pbRegister)
941 WebBrowser *This = impl_from_IWebBrowser2(iface);
942 FIXME("(%p)->(%p)\n", This, pbRegister);
943 *pbRegister=0;
944 return S_OK;
947 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
948 VARIANT_BOOL bRegister)
950 WebBrowser *This = impl_from_IWebBrowser2(iface);
951 FIXME("(%p)->(%x)\n", This, bRegister);
952 return S_OK;
955 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
957 WebBrowser *This = impl_from_IWebBrowser2(iface);
959 TRACE("(%p)->(%p)\n", This, pbRegister);
961 *pbRegister = This->theater_mode;
962 return S_OK;
965 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
967 WebBrowser *This = impl_from_IWebBrowser2(iface);
968 VARIANTARG arg;
969 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
971 TRACE("(%p)->(%x)\n", This, bRegister);
973 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
975 /* In opposition to InternetExplorer, all we should do here is
976 * inform the embedder about the theater mode change. */
978 V_VT(&arg) = VT_BOOL;
979 V_BOOL(&arg) = bRegister;
980 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
982 return S_OK;
985 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
987 WebBrowser *This = impl_from_IWebBrowser2(iface);
989 TRACE("(%p)->(%p)\n", This, Value);
991 *Value = This->address_bar;
992 return S_OK;
995 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
997 WebBrowser *This = impl_from_IWebBrowser2(iface);
998 VARIANTARG arg;
999 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1001 TRACE("(%p)->(%x)\n", This, Value);
1003 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
1005 /* In opposition to InternetExplorer, all we should do here is
1006 * inform the embedder about the address bar change. */
1008 V_VT(&arg) = VT_BOOL;
1009 V_BOOL(&arg) = Value;
1010 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
1012 return S_OK;
1015 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1017 WebBrowser *This = impl_from_IWebBrowser2(iface);
1019 TRACE("(%p)->(%p)\n", This, Value);
1021 /* It's InternetExplorer object's method. We have nothing to do here. */
1022 return E_NOTIMPL;
1025 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
1027 WebBrowser *This = impl_from_IWebBrowser2(iface);
1028 VARIANTARG arg;
1029 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1031 TRACE("(%p)->(%x)\n", This, Value);
1033 /* In opposition to InternetExplorer, all we should do here is
1034 * inform the embedder about the resizable change. */
1036 V_VT(&arg) = VT_BOOL;
1037 V_BOOL(&arg) = Value;
1038 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
1040 return S_OK;
1043 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
1045 WebBrowser_QueryInterface,
1046 WebBrowser_AddRef,
1047 WebBrowser_Release,
1048 WebBrowser_GetTypeInfoCount,
1049 WebBrowser_GetTypeInfo,
1050 WebBrowser_GetIDsOfNames,
1051 WebBrowser_Invoke,
1052 WebBrowser_GoBack,
1053 WebBrowser_GoForward,
1054 WebBrowser_GoHome,
1055 WebBrowser_GoSearch,
1056 WebBrowser_Navigate,
1057 WebBrowser_Refresh,
1058 WebBrowser_Refresh2,
1059 WebBrowser_Stop,
1060 WebBrowser_get_Application,
1061 WebBrowser_get_Parent,
1062 WebBrowser_get_Container,
1063 WebBrowser_get_Document,
1064 WebBrowser_get_TopLevelContainer,
1065 WebBrowser_get_Type,
1066 WebBrowser_get_Left,
1067 WebBrowser_put_Left,
1068 WebBrowser_get_Top,
1069 WebBrowser_put_Top,
1070 WebBrowser_get_Width,
1071 WebBrowser_put_Width,
1072 WebBrowser_get_Height,
1073 WebBrowser_put_Height,
1074 WebBrowser_get_LocationName,
1075 WebBrowser_get_LocationURL,
1076 WebBrowser_get_Busy,
1077 WebBrowser_Quit,
1078 WebBrowser_ClientToWindow,
1079 WebBrowser_PutProperty,
1080 WebBrowser_GetProperty,
1081 WebBrowser_get_Name,
1082 WebBrowser_get_HWND,
1083 WebBrowser_get_FullName,
1084 WebBrowser_get_Path,
1085 WebBrowser_get_Visible,
1086 WebBrowser_put_Visible,
1087 WebBrowser_get_StatusBar,
1088 WebBrowser_put_StatusBar,
1089 WebBrowser_get_StatusText,
1090 WebBrowser_put_StatusText,
1091 WebBrowser_get_ToolBar,
1092 WebBrowser_put_ToolBar,
1093 WebBrowser_get_MenuBar,
1094 WebBrowser_put_MenuBar,
1095 WebBrowser_get_FullScreen,
1096 WebBrowser_put_FullScreen,
1097 WebBrowser_Navigate2,
1098 WebBrowser_QueryStatusWB,
1099 WebBrowser_ExecWB,
1100 WebBrowser_ShowBrowserBar,
1101 WebBrowser_get_ReadyState,
1102 WebBrowser_get_Offline,
1103 WebBrowser_put_Offline,
1104 WebBrowser_get_Silent,
1105 WebBrowser_put_Silent,
1106 WebBrowser_get_RegisterAsBrowser,
1107 WebBrowser_put_RegisterAsBrowser,
1108 WebBrowser_get_RegisterAsDropTarget,
1109 WebBrowser_put_RegisterAsDropTarget,
1110 WebBrowser_get_TheaterMode,
1111 WebBrowser_put_TheaterMode,
1112 WebBrowser_get_AddressBar,
1113 WebBrowser_put_AddressBar,
1114 WebBrowser_get_Resizable,
1115 WebBrowser_put_Resizable
1118 static inline WebBrowser *impl_from_IServiceProvider(IServiceProvider *iface)
1120 return CONTAINING_RECORD(iface, WebBrowser, IServiceProvider_iface);
1123 static HRESULT WINAPI WBServiceProvider_QueryInterface(IServiceProvider *iface,
1124 REFIID riid, LPVOID *ppv)
1126 WebBrowser *This = impl_from_IServiceProvider(iface);
1127 return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
1130 static ULONG WINAPI WBServiceProvider_AddRef(IServiceProvider *iface)
1132 WebBrowser *This = impl_from_IServiceProvider(iface);
1133 return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
1136 static ULONG WINAPI WBServiceProvider_Release(IServiceProvider *iface)
1138 WebBrowser *This = impl_from_IServiceProvider(iface);
1139 return IWebBrowser_Release(&This->IWebBrowser2_iface);
1142 static HRESULT STDMETHODCALLTYPE WBServiceProvider_QueryService(IServiceProvider *iface,
1143 REFGUID guidService, REFIID riid, void **ppv)
1145 WebBrowser *This = impl_from_IServiceProvider(iface);
1147 if(*ppv)
1148 ppv = NULL;
1150 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1151 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1152 return E_FAIL;
1155 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1157 return E_NOINTERFACE;
1160 static const IServiceProviderVtbl ServiceProviderVtbl =
1162 WBServiceProvider_QueryInterface,
1163 WBServiceProvider_AddRef,
1164 WBServiceProvider_Release,
1165 WBServiceProvider_QueryService
1168 static inline WebBrowser *impl_from_DocHost(DocHost *iface)
1170 return CONTAINING_RECORD(iface, WebBrowser, doc_host);
1173 static ULONG WebBrowser_addref(DocHost *iface)
1175 WebBrowser *This = impl_from_DocHost(iface);
1176 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
1179 static ULONG WebBrowser_release(DocHost *iface)
1181 WebBrowser *This = impl_from_DocHost(iface);
1182 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
1185 static void WINAPI DocHostContainer_GetDocObjRect(DocHost* This, RECT* rc)
1187 GetClientRect(This->frame_hwnd, rc);
1190 static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost* This, LPCWSTR text)
1192 return E_NOTIMPL;
1195 static void WINAPI DocHostContainer_SetURL(DocHost* This, LPCWSTR url)
1200 static HRESULT DocHostContainer_exec(DocHost *doc_host, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in,
1201 VARIANT *out)
1203 WebBrowser *This = impl_from_DocHost(doc_host);
1204 IOleCommandTarget *cmdtrg = NULL;
1205 HRESULT hres;
1207 if(This->client) {
1208 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
1209 if(FAILED(hres))
1210 cmdtrg = NULL;
1213 if(!cmdtrg && This->container) {
1214 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (void**)&cmdtrg);
1215 if(FAILED(hres))
1216 cmdtrg = NULL;
1219 if(!cmdtrg)
1220 return S_OK;
1222 hres = IOleCommandTarget_Exec(cmdtrg, cmd_group, cmdid, execopt, in, out);
1223 IOleCommandTarget_Release(cmdtrg);
1224 if(FAILED(hres))
1225 FIXME("Exec failed\n");
1227 return hres;
1230 static const IDocHostContainerVtbl DocHostContainerVtbl = {
1231 WebBrowser_addref,
1232 WebBrowser_release,
1233 DocHostContainer_GetDocObjRect,
1234 DocHostContainer_SetStatusText,
1235 DocHostContainer_SetURL,
1236 DocHostContainer_exec
1239 static HRESULT create_webbrowser(int version, IUnknown *outer, REFIID riid, void **ppv)
1241 WebBrowser *ret;
1242 HRESULT hres;
1244 TRACE("(%p %s %p) version=%d\n", outer, debugstr_guid(riid), ppv, version);
1246 ret = heap_alloc_zero(sizeof(WebBrowser));
1248 ret->IWebBrowser2_iface.lpVtbl = &WebBrowser2Vtbl;
1249 ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
1250 ret->ref = 1;
1251 ret->version = version;
1253 DocHost_Init(&ret->doc_host, (IDispatch*)&ret->IWebBrowser2_iface, &DocHostContainerVtbl);
1255 ret->visible = VARIANT_TRUE;
1256 ret->menu_bar = VARIANT_TRUE;
1257 ret->address_bar = VARIANT_TRUE;
1258 ret->status_bar = VARIANT_TRUE;
1259 ret->tool_bar = VARIANT_TRUE;
1261 WebBrowser_OleObject_Init(ret);
1262 WebBrowser_ViewObject_Init(ret);
1263 WebBrowser_Persist_Init(ret);
1264 WebBrowser_ClassInfo_Init(ret);
1266 HlinkFrame_Init(&ret->hlink_frame, (IUnknown*)&ret->IWebBrowser2_iface, &ret->doc_host);
1268 lock_module();
1270 hres = IWebBrowser_QueryInterface(&ret->IWebBrowser2_iface, riid, ppv);
1272 IWebBrowser2_Release(&ret->IWebBrowser2_iface);
1273 return hres;
1276 HRESULT WINAPI WebBrowserV1_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1278 return create_webbrowser(1, pOuter, riid, ppv);
1281 HRESULT WINAPI WebBrowser_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1283 return create_webbrowser(2, pOuter, riid, ppv);