makefiles: Don't use standard libs for programs that specify -nodefaultlibs.
[wine/zf.git] / dlls / ieframe / webbrowser.c
blob1e50512e42755cae162e46ce13aebdf29e3fd257
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_IUnknown(IUnknown *iface)
33 return CONTAINING_RECORD(iface, WebBrowser, IUnknown_inner);
36 static HRESULT WINAPI WebBrowser_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
38 WebBrowser *This = impl_from_IUnknown(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->IUnknown_inner;
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(IUnknown *iface)
156 WebBrowser *This = impl_from_IUnknown(iface);
157 LONG ref = InterlockedIncrement(&This->ref);
158 TRACE("(%p) ref=%d\n", This, ref);
159 return ref;
162 static ULONG WINAPI WebBrowser_Release(IUnknown *iface)
164 WebBrowser *This = impl_from_IUnknown(iface);
165 LONG ref = InterlockedDecrement(&This->ref);
167 TRACE("(%p) ref=%d\n", This, ref);
169 if(!ref) {
170 if(This->sink)
171 IAdviseSink_Release(This->sink);
173 if(This->doc_host.document)
174 IUnknown_Release(This->doc_host.document);
176 DocHost_Release(&This->doc_host);
178 WebBrowser_OleObject_Destroy(This);
180 heap_free(This);
181 unlock_module();
184 return ref;
187 static const struct IUnknownVtbl internal_unk_vtbl =
189 WebBrowser_QueryInterface,
190 WebBrowser_AddRef,
191 WebBrowser_Release
194 static inline WebBrowser *impl_from_IWebBrowser2(IWebBrowser2 *iface)
196 return CONTAINING_RECORD(iface, WebBrowser, IWebBrowser2_iface);
199 static HRESULT WINAPI WebBrowser2_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
201 WebBrowser *This = impl_from_IWebBrowser2(iface);
203 return IUnknown_QueryInterface(This->hlink_frame.outer, riid, ppv);
206 static ULONG WINAPI WebBrowser2_AddRef(IWebBrowser2 *iface)
208 WebBrowser *This = impl_from_IWebBrowser2(iface);
210 return IUnknown_AddRef(This->hlink_frame.outer);
213 static ULONG WINAPI WebBrowser2_Release(IWebBrowser2 *iface)
215 WebBrowser *This = impl_from_IWebBrowser2(iface);
217 return IUnknown_Release(This->hlink_frame.outer);
220 /* IDispatch methods */
221 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
223 WebBrowser *This = impl_from_IWebBrowser2(iface);
225 TRACE("(%p)->(%p)\n", This, pctinfo);
227 *pctinfo = 1;
228 return S_OK;
231 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
232 LPTYPEINFO *ppTInfo)
234 WebBrowser *This = impl_from_IWebBrowser2(iface);
235 ITypeInfo *typeinfo;
236 HRESULT hres;
238 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
240 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
241 if(FAILED(hres))
242 return hres;
244 ITypeInfo_AddRef(typeinfo);
245 *ppTInfo = typeinfo;
246 return S_OK;
249 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
250 LPOLESTR *rgszNames, UINT cNames,
251 LCID lcid, DISPID *rgDispId)
253 WebBrowser *This = impl_from_IWebBrowser2(iface);
254 ITypeInfo *typeinfo;
255 HRESULT hres;
257 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
258 lcid, rgDispId);
260 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
261 if(FAILED(hres))
262 return hres;
264 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
267 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
268 REFIID riid, LCID lcid, WORD wFlags,
269 DISPPARAMS *pDispParams, VARIANT *pVarResult,
270 EXCEPINFO *pExepInfo, UINT *puArgErr)
272 WebBrowser *This = impl_from_IWebBrowser2(iface);
273 ITypeInfo *typeinfo;
274 HRESULT hres;
276 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
277 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
279 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
280 if(FAILED(hres))
281 return hres;
283 return ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags, pDispParams,
284 pVarResult, pExepInfo, puArgErr);
287 /* IWebBrowser methods */
288 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
290 WebBrowser *This = impl_from_IWebBrowser2(iface);
291 TRACE("(%p)\n", This);
292 return go_back(&This->doc_host);
295 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
297 WebBrowser *This = impl_from_IWebBrowser2(iface);
298 TRACE("(%p)\n", This);
299 return go_forward(&This->doc_host);
302 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
304 WebBrowser *This = impl_from_IWebBrowser2(iface);
305 TRACE("(%p)\n", This);
306 return go_home(&This->doc_host);
309 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
311 WebBrowser *This = impl_from_IWebBrowser2(iface);
312 FIXME("(%p)\n", This);
313 return E_NOTIMPL;
316 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
317 VARIANT *Flags, VARIANT *TargetFrameName,
318 VARIANT *PostData, VARIANT *Headers)
320 WebBrowser *This = impl_from_IWebBrowser2(iface);
322 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
323 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
324 debugstr_variant(Headers));
326 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
329 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
331 WebBrowser *This = impl_from_IWebBrowser2(iface);
333 TRACE("(%p)\n", This);
335 return refresh_document(&This->doc_host, NULL);
338 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
340 WebBrowser *This = impl_from_IWebBrowser2(iface);
342 TRACE("(%p)->(%s)\n", This, debugstr_variant(Level));
344 return refresh_document(&This->doc_host, Level);
347 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
349 WebBrowser *This = impl_from_IWebBrowser2(iface);
350 FIXME("(%p)\n", This);
351 return S_OK;
354 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
356 WebBrowser *This = impl_from_IWebBrowser2(iface);
358 TRACE("(%p)->(%p)\n", This, ppDisp);
360 if(!ppDisp)
361 return E_POINTER;
363 *ppDisp = (IDispatch*)&This->IWebBrowser2_iface;
364 IDispatch_AddRef(*ppDisp);
365 return S_OK;
368 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
370 WebBrowser *This = impl_from_IWebBrowser2(iface);
371 FIXME("(%p)->(%p)\n", This, ppDisp);
372 return E_NOTIMPL;
375 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
377 WebBrowser *This = impl_from_IWebBrowser2(iface);
378 FIXME("(%p)->(%p)\n", This, ppDisp);
379 return E_NOTIMPL;
382 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
384 WebBrowser *This = impl_from_IWebBrowser2(iface);
385 IDispatch *disp = NULL;
387 TRACE("(%p)->(%p)\n", This, ppDisp);
389 if(This->doc_host.document) {
390 HRESULT hres;
392 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
393 if(SUCCEEDED(hres)) {
394 IDispatch *html_doc;
396 /* Some broken apps cast returned IDispatch to IHTMLDocument2
397 * without QueryInterface call */
398 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
399 if(SUCCEEDED(hres)) {
400 IDispatch_Release(disp);
401 disp = html_doc;
406 *ppDisp = disp;
407 return S_OK;
410 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
412 WebBrowser *This = impl_from_IWebBrowser2(iface);
413 FIXME("(%p)->(%p)\n", This, pBool);
414 return E_NOTIMPL;
417 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
419 WebBrowser *This = impl_from_IWebBrowser2(iface);
420 FIXME("(%p)->(%p)\n", This, Type);
421 return E_NOTIMPL;
424 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
426 WebBrowser *This = impl_from_IWebBrowser2(iface);
428 TRACE("(%p)->(%p)\n", This, pl);
430 *pl = This->pos_rect.left;
431 return S_OK;
434 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
436 WebBrowser *This = impl_from_IWebBrowser2(iface);
437 RECT rect;
439 TRACE("(%p)->(%d)\n", This, Left);
441 if(!This->inplace)
442 return E_UNEXPECTED;
444 rect = This->pos_rect;
445 rect.left = Left;
447 /* We don't really change the window position here.
448 * We just notify the embedder that he should do so. */
449 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
452 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
454 WebBrowser *This = impl_from_IWebBrowser2(iface);
456 TRACE("(%p)->(%p)\n", This, pl);
458 *pl = This->pos_rect.top;
459 return S_OK;
462 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
464 WebBrowser *This = impl_from_IWebBrowser2(iface);
465 RECT rect;
467 TRACE("(%p)->(%d)\n", This, Top);
469 if(!This->inplace)
470 return E_UNEXPECTED;
472 rect = This->pos_rect;
473 rect.top = Top;
475 /* We don't really change the window position here.
476 * We just notify the embedder that he should do so. */
477 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
480 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
482 WebBrowser *This = impl_from_IWebBrowser2(iface);
484 TRACE("(%p)->(%p)\n", This, pl);
486 *pl = This->pos_rect.right - This->pos_rect.left;
487 return S_OK;
490 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
492 WebBrowser *This = impl_from_IWebBrowser2(iface);
493 RECT rect;
495 TRACE("(%p)->(%d)\n", This, Width);
497 if(!This->inplace)
498 return E_UNEXPECTED;
500 rect = This->pos_rect;
501 rect.right = rect.left+Width;
503 /* We don't really change the window size here.
504 * We just notify the embedder that he should do so. */
505 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
508 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
510 WebBrowser *This = impl_from_IWebBrowser2(iface);
512 TRACE("(%p)->(%p)\n", This, pl);
514 *pl = This->pos_rect.bottom - This->pos_rect.top;
515 return S_OK;
518 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
520 WebBrowser *This = impl_from_IWebBrowser2(iface);
521 RECT rect;
523 TRACE("(%p)->(%d)\n", This, Height);
525 if(!This->inplace)
526 return E_UNEXPECTED;
528 rect = This->pos_rect;
529 rect.bottom = rect.top+Height;
531 /* We don't really change the window size here.
532 * We just notify the embedder that he should do so. */
533 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
536 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
538 WebBrowser *This = impl_from_IWebBrowser2(iface);
539 FIXME("(%p)->(%p)\n", This, LocationName);
540 return E_NOTIMPL;
543 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
545 WebBrowser *This = impl_from_IWebBrowser2(iface);
547 TRACE("(%p)->(%p)\n", This, LocationURL);
549 return get_location_url(&This->doc_host, LocationURL);
552 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
554 WebBrowser *This = impl_from_IWebBrowser2(iface);
556 TRACE("(%p)->(%p)\n", This, pBool);
558 *pBool = This->doc_host.busy;
559 return S_OK;
562 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
564 WebBrowser *This = impl_from_IWebBrowser2(iface);
566 TRACE("(%p)\n", This);
568 /* It's a InternetExplorer specific method, we have nothing to do here. */
569 return E_FAIL;
572 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
574 WebBrowser *This = impl_from_IWebBrowser2(iface);
575 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
576 return E_NOTIMPL;
579 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
581 WebBrowser *This = impl_from_IWebBrowser2(iface);
582 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
583 return E_NOTIMPL;
586 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
588 WebBrowser *This = impl_from_IWebBrowser2(iface);
589 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
590 return E_NOTIMPL;
593 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
595 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
596 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
597 WebBrowser *This = impl_from_IWebBrowser2(iface);
599 TRACE("(%p)->(%p)\n", This, Name);
601 *Name = SysAllocString(sName);
603 return S_OK;
606 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, SHANDLE_PTR *pHWND)
608 WebBrowser *This = impl_from_IWebBrowser2(iface);
610 TRACE("(%p)->(%p)\n", This, pHWND);
612 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
613 *pHWND = 0;
614 return E_FAIL;
617 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
619 WebBrowser *This = impl_from_IWebBrowser2(iface);
620 FIXME("(%p)->(%p)\n", This, FullName);
621 return E_NOTIMPL;
624 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
626 WebBrowser *This = impl_from_IWebBrowser2(iface);
627 FIXME("(%p)->(%p)\n", This, Path);
628 return E_NOTIMPL;
631 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
633 WebBrowser *This = impl_from_IWebBrowser2(iface);
635 TRACE("(%p)->(%p)\n", This, pBool);
637 *pBool = This->visible;
638 return S_OK;
641 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
643 WebBrowser *This = impl_from_IWebBrowser2(iface);
644 VARIANTARG arg;
645 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
647 TRACE("(%p)->(%x)\n", This, Value);
649 This->visible = Value;
651 V_VT(&arg) = VT_BOOL;
652 V_BOOL(&arg) = Value;
653 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
655 return S_OK;
658 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
660 WebBrowser *This = impl_from_IWebBrowser2(iface);
662 TRACE("(%p)->(%p)\n", This, pBool);
664 *pBool = This->status_bar;
665 return S_OK;
668 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
670 WebBrowser *This = impl_from_IWebBrowser2(iface);
671 VARIANTARG arg;
672 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
674 TRACE("(%p)->(%x)\n", This, Value);
676 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
678 /* In opposition to InternetExplorer, all we should do here is
679 * inform the embedder about the status bar change. */
681 V_VT(&arg) = VT_BOOL;
682 V_BOOL(&arg) = Value;
683 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
685 return S_OK;
688 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
690 WebBrowser *This = impl_from_IWebBrowser2(iface);
691 FIXME("(%p)->(%p)\n", This, StatusText);
692 return E_NOTIMPL;
695 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
697 WebBrowser *This = impl_from_IWebBrowser2(iface);
698 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
699 return E_NOTIMPL;
702 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
704 WebBrowser *This = impl_from_IWebBrowser2(iface);
706 TRACE("(%p)->(%p)\n", This, Value);
708 *Value = This->tool_bar;
709 return S_OK;
712 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
714 WebBrowser *This = impl_from_IWebBrowser2(iface);
715 VARIANTARG arg;
716 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
718 TRACE("(%p)->(%x)\n", This, Value);
720 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
722 /* In opposition to InternetExplorer, all we should do here is
723 * inform the embedder about the tool bar change. */
725 V_VT(&arg) = VT_BOOL;
726 V_BOOL(&arg) = This->tool_bar;
727 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
729 return S_OK;
732 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
734 WebBrowser *This = impl_from_IWebBrowser2(iface);
736 TRACE("(%p)->(%p)\n", This, Value);
738 *Value = This->menu_bar;
739 return S_OK;
742 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
744 WebBrowser *This = impl_from_IWebBrowser2(iface);
745 VARIANTARG arg;
746 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
748 TRACE("(%p)->(%x)\n", This, Value);
750 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
752 /* In opposition to InternetExplorer, all we should do here is
753 * inform the embedder about the menu bar change. */
755 V_VT(&arg) = VT_BOOL;
756 V_BOOL(&arg) = Value;
757 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
759 return S_OK;
762 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
764 WebBrowser *This = impl_from_IWebBrowser2(iface);
766 TRACE("(%p)->(%p)\n", This, pbFullScreen);
768 *pbFullScreen = This->full_screen;
769 return S_OK;
772 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
774 WebBrowser *This = impl_from_IWebBrowser2(iface);
775 VARIANTARG arg;
776 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
778 /* In opposition to InternetExplorer, all we should do here is
779 * inform the embedder about the fullscreen change. */
781 TRACE("(%p)->(%x)\n", This, bFullScreen);
783 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
785 V_VT(&arg) = VT_BOOL;
786 V_BOOL(&arg) = bFullScreen;
787 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
789 return S_OK;
792 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
793 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
795 WebBrowser *This = impl_from_IWebBrowser2(iface);
796 LPCWSTR url;
798 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
799 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
801 if(!This->client)
802 return E_FAIL;
804 if(!URL)
805 return S_OK;
807 switch (V_VT(URL))
809 case VT_BSTR:
810 url = V_BSTR(URL);
811 break;
812 case VT_BSTR|VT_BYREF:
813 url = *V_BSTRREF(URL);
814 break;
815 default:
816 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
817 return E_INVALIDARG;
820 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
823 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
825 WebBrowser *This = impl_from_IWebBrowser2(iface);
826 IOleCommandTarget *target = NULL;
827 OLECMD ole_command[1];
828 HRESULT hres;
830 TRACE("(%p)->(%d %p)\n", This, cmdID, pcmdf);
832 if (!pcmdf)
833 return E_POINTER;
834 ole_command[0].cmdID = cmdID;
835 ole_command[0].cmdf = *pcmdf;
837 if (This->container)
839 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
840 if(FAILED(hres))
841 target = NULL;
843 if (!target && This->doc_host.document)
845 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
846 if(FAILED(hres))
847 target = NULL;
850 if (!target)
851 return E_UNEXPECTED;
853 hres = IOleCommandTarget_QueryStatus(target, NULL, 1, ole_command, NULL);
854 if (SUCCEEDED(hres))
855 *pcmdf = ole_command[0].cmdf;
856 if (hres == OLECMDERR_E_NOTSUPPORTED)
858 *pcmdf = 0;
859 hres = S_OK;
861 IOleCommandTarget_Release(target);
863 return hres;
866 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
867 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
869 WebBrowser *This = impl_from_IWebBrowser2(iface);
870 IOleCommandTarget *target = NULL;
871 HRESULT hres;
873 TRACE("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
875 if(This->container)
877 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
878 if(FAILED(hres))
879 target = NULL;
881 if(!target && This->doc_host.document)
883 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
884 if(FAILED(hres))
885 target = NULL;
888 if(!target)
889 return E_UNEXPECTED;
891 hres = IOleCommandTarget_Exec(target, NULL, cmdID, cmdexecopt, pvaIn, pvaOut);
892 IOleCommandTarget_Release(target);
894 return hres;
897 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
898 VARIANT *pvarShow, VARIANT *pvarSize)
900 WebBrowser *This = impl_from_IWebBrowser2(iface);
901 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
902 debugstr_variant(pvarSize));
903 return E_NOTIMPL;
906 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
908 WebBrowser *This = impl_from_IWebBrowser2(iface);
910 TRACE("(%p)->(%p)\n", This, lpReadyState);
912 *lpReadyState = This->doc_host.ready_state;
913 return S_OK;
916 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
918 WebBrowser *This = impl_from_IWebBrowser2(iface);
920 TRACE("(%p)->(%p)\n", This, pbOffline);
922 *pbOffline = This->doc_host.offline;
923 return S_OK;
926 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
928 WebBrowser *This = impl_from_IWebBrowser2(iface);
930 TRACE("(%p)->(%x)\n", This, bOffline);
932 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
933 return S_OK;
936 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
938 WebBrowser *This = impl_from_IWebBrowser2(iface);
940 TRACE("(%p)->(%p)\n", This, pbSilent);
942 *pbSilent = This->doc_host.silent;
943 return S_OK;
946 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
948 WebBrowser *This = impl_from_IWebBrowser2(iface);
950 TRACE("(%p)->(%x)\n", This, bSilent);
952 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
953 return S_OK;
956 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
957 VARIANT_BOOL *pbRegister)
959 WebBrowser *This = impl_from_IWebBrowser2(iface);
961 FIXME("(%p)->(%p)\n", This, pbRegister);
963 *pbRegister = This->register_browser;
964 return S_OK;
967 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
968 VARIANT_BOOL bRegister)
970 WebBrowser *This = impl_from_IWebBrowser2(iface);
972 FIXME("(%p)->(%x)\n", This, bRegister);
974 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
975 return S_OK;
978 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
979 VARIANT_BOOL *pbRegister)
981 WebBrowser *This = impl_from_IWebBrowser2(iface);
983 FIXME("(%p)->(%p)\n", This, pbRegister);
985 if(!pbRegister)
986 return E_INVALIDARG;
988 *pbRegister=0;
989 return S_OK;
992 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
993 VARIANT_BOOL bRegister)
995 WebBrowser *This = impl_from_IWebBrowser2(iface);
996 FIXME("(%p)->(%x)\n", This, bRegister);
997 return S_OK;
1000 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
1002 WebBrowser *This = impl_from_IWebBrowser2(iface);
1004 TRACE("(%p)->(%p)\n", This, pbRegister);
1006 *pbRegister = This->theater_mode;
1007 return S_OK;
1010 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
1012 WebBrowser *This = impl_from_IWebBrowser2(iface);
1013 VARIANTARG arg;
1014 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1016 TRACE("(%p)->(%x)\n", This, bRegister);
1018 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
1020 /* In opposition to InternetExplorer, all we should do here is
1021 * inform the embedder about the theater mode change. */
1023 V_VT(&arg) = VT_BOOL;
1024 V_BOOL(&arg) = bRegister;
1025 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
1027 return S_OK;
1030 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1032 WebBrowser *This = impl_from_IWebBrowser2(iface);
1034 TRACE("(%p)->(%p)\n", This, Value);
1036 *Value = This->address_bar;
1037 return S_OK;
1040 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
1042 WebBrowser *This = impl_from_IWebBrowser2(iface);
1043 VARIANTARG arg;
1044 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1046 TRACE("(%p)->(%x)\n", This, Value);
1048 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
1050 /* In opposition to InternetExplorer, all we should do here is
1051 * inform the embedder about the address bar change. */
1053 V_VT(&arg) = VT_BOOL;
1054 V_BOOL(&arg) = Value;
1055 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
1057 return S_OK;
1060 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1062 WebBrowser *This = impl_from_IWebBrowser2(iface);
1064 TRACE("(%p)->(%p)\n", This, Value);
1066 /* It's InternetExplorer object's method. We have nothing to do here. */
1067 return E_NOTIMPL;
1070 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
1072 WebBrowser *This = impl_from_IWebBrowser2(iface);
1073 VARIANTARG arg;
1074 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1076 TRACE("(%p)->(%x)\n", This, Value);
1078 /* In opposition to InternetExplorer, all we should do here is
1079 * inform the embedder about the resizable change. */
1081 V_VT(&arg) = VT_BOOL;
1082 V_BOOL(&arg) = Value;
1083 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
1085 return S_OK;
1088 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
1090 WebBrowser2_QueryInterface,
1091 WebBrowser2_AddRef,
1092 WebBrowser2_Release,
1093 WebBrowser_GetTypeInfoCount,
1094 WebBrowser_GetTypeInfo,
1095 WebBrowser_GetIDsOfNames,
1096 WebBrowser_Invoke,
1097 WebBrowser_GoBack,
1098 WebBrowser_GoForward,
1099 WebBrowser_GoHome,
1100 WebBrowser_GoSearch,
1101 WebBrowser_Navigate,
1102 WebBrowser_Refresh,
1103 WebBrowser_Refresh2,
1104 WebBrowser_Stop,
1105 WebBrowser_get_Application,
1106 WebBrowser_get_Parent,
1107 WebBrowser_get_Container,
1108 WebBrowser_get_Document,
1109 WebBrowser_get_TopLevelContainer,
1110 WebBrowser_get_Type,
1111 WebBrowser_get_Left,
1112 WebBrowser_put_Left,
1113 WebBrowser_get_Top,
1114 WebBrowser_put_Top,
1115 WebBrowser_get_Width,
1116 WebBrowser_put_Width,
1117 WebBrowser_get_Height,
1118 WebBrowser_put_Height,
1119 WebBrowser_get_LocationName,
1120 WebBrowser_get_LocationURL,
1121 WebBrowser_get_Busy,
1122 WebBrowser_Quit,
1123 WebBrowser_ClientToWindow,
1124 WebBrowser_PutProperty,
1125 WebBrowser_GetProperty,
1126 WebBrowser_get_Name,
1127 WebBrowser_get_HWND,
1128 WebBrowser_get_FullName,
1129 WebBrowser_get_Path,
1130 WebBrowser_get_Visible,
1131 WebBrowser_put_Visible,
1132 WebBrowser_get_StatusBar,
1133 WebBrowser_put_StatusBar,
1134 WebBrowser_get_StatusText,
1135 WebBrowser_put_StatusText,
1136 WebBrowser_get_ToolBar,
1137 WebBrowser_put_ToolBar,
1138 WebBrowser_get_MenuBar,
1139 WebBrowser_put_MenuBar,
1140 WebBrowser_get_FullScreen,
1141 WebBrowser_put_FullScreen,
1142 WebBrowser_Navigate2,
1143 WebBrowser_QueryStatusWB,
1144 WebBrowser_ExecWB,
1145 WebBrowser_ShowBrowserBar,
1146 WebBrowser_get_ReadyState,
1147 WebBrowser_get_Offline,
1148 WebBrowser_put_Offline,
1149 WebBrowser_get_Silent,
1150 WebBrowser_put_Silent,
1151 WebBrowser_get_RegisterAsBrowser,
1152 WebBrowser_put_RegisterAsBrowser,
1153 WebBrowser_get_RegisterAsDropTarget,
1154 WebBrowser_put_RegisterAsDropTarget,
1155 WebBrowser_get_TheaterMode,
1156 WebBrowser_put_TheaterMode,
1157 WebBrowser_get_AddressBar,
1158 WebBrowser_put_AddressBar,
1159 WebBrowser_get_Resizable,
1160 WebBrowser_put_Resizable
1163 static inline WebBrowser *impl_from_IServiceProvider(IServiceProvider *iface)
1165 return CONTAINING_RECORD(iface, WebBrowser, IServiceProvider_iface);
1168 static HRESULT WINAPI WBServiceProvider_QueryInterface(IServiceProvider *iface,
1169 REFIID riid, LPVOID *ppv)
1171 WebBrowser *This = impl_from_IServiceProvider(iface);
1172 return IUnknown_QueryInterface(This->hlink_frame.outer, riid, ppv);
1175 static ULONG WINAPI WBServiceProvider_AddRef(IServiceProvider *iface)
1177 WebBrowser *This = impl_from_IServiceProvider(iface);
1178 return IUnknown_AddRef(This->hlink_frame.outer);
1181 static ULONG WINAPI WBServiceProvider_Release(IServiceProvider *iface)
1183 WebBrowser *This = impl_from_IServiceProvider(iface);
1184 return IUnknown_Release(This->hlink_frame.outer);
1187 static HRESULT STDMETHODCALLTYPE WBServiceProvider_QueryService(IServiceProvider *iface,
1188 REFGUID guidService, REFIID riid, void **ppv)
1190 WebBrowser *This = impl_from_IServiceProvider(iface);
1192 if(IsEqualGUID(&SID_SHTMLWindow, riid)) {
1193 TRACE("(%p)->(SID_SHTMLWindow)\n", This);
1194 return IHTMLWindow2_QueryInterface(&This->doc_host.html_window.IHTMLWindow2_iface, riid, ppv);
1197 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1198 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1199 *ppv = NULL;
1200 return E_FAIL;
1203 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1204 *ppv = NULL;
1205 return E_NOINTERFACE;
1208 static const IServiceProviderVtbl ServiceProviderVtbl =
1210 WBServiceProvider_QueryInterface,
1211 WBServiceProvider_AddRef,
1212 WBServiceProvider_Release,
1213 WBServiceProvider_QueryService
1216 static inline WebBrowser *impl_from_DocHost(DocHost *iface)
1218 return CONTAINING_RECORD(iface, WebBrowser, doc_host);
1221 static ULONG WebBrowser_addref(DocHost *iface)
1223 WebBrowser *This = impl_from_DocHost(iface);
1224 return IUnknown_AddRef(This->hlink_frame.outer);
1227 static ULONG WebBrowser_release(DocHost *iface)
1229 WebBrowser *This = impl_from_DocHost(iface);
1230 return IUnknown_Release(This->hlink_frame.outer);
1233 static void DocHostContainer_get_docobj_rect(DocHost *This, RECT *rc)
1235 GetClientRect(This->frame_hwnd, rc);
1238 static HRESULT DocHostContainer_set_status_text(DocHost *This, const WCHAR *text)
1240 return E_NOTIMPL;
1243 static void DocHostContainer_on_command_state_change(DocHost *This, LONG command, BOOL enable)
1247 static void DocHostContainer_set_url(DocHost *This, const WCHAR *url)
1251 static const IDocHostContainerVtbl DocHostContainerVtbl = {
1252 WebBrowser_addref,
1253 WebBrowser_release,
1254 DocHostContainer_get_docobj_rect,
1255 DocHostContainer_set_status_text,
1256 DocHostContainer_on_command_state_change,
1257 DocHostContainer_set_url
1260 static HRESULT create_webbrowser(int version, IUnknown *outer, REFIID riid, void **ppv)
1262 WebBrowser *ret;
1263 HRESULT hres;
1265 TRACE("(%p %s %p) version=%d\n", outer, debugstr_guid(riid), ppv, version);
1267 if (outer && !IsEqualIID(riid, &IID_IUnknown))
1268 return CLASS_E_NOAGGREGATION;
1270 ret = heap_alloc_zero(sizeof(WebBrowser));
1272 ret->IUnknown_inner.lpVtbl = &internal_unk_vtbl;
1273 ret->IWebBrowser2_iface.lpVtbl = &WebBrowser2Vtbl;
1274 ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
1275 ret->ref = 1;
1276 ret->version = version;
1278 HlinkFrame_Init(&ret->hlink_frame, outer ? outer : &ret->IUnknown_inner, &ret->doc_host);
1279 DocHost_Init(&ret->doc_host, &ret->IWebBrowser2_iface, &DocHostContainerVtbl);
1281 ret->visible = VARIANT_TRUE;
1282 ret->menu_bar = VARIANT_TRUE;
1283 ret->address_bar = VARIANT_TRUE;
1284 ret->status_bar = VARIANT_TRUE;
1285 ret->tool_bar = VARIANT_TRUE;
1287 WebBrowser_OleObject_Init(ret);
1288 WebBrowser_ViewObject_Init(ret);
1289 WebBrowser_Persist_Init(ret);
1290 WebBrowser_ClassInfo_Init(ret);
1292 lock_module();
1294 hres = IUnknown_QueryInterface(&ret->IUnknown_inner, riid, ppv);
1296 IUnknown_Release(&ret->IUnknown_inner);
1297 return hres;
1300 HRESULT WINAPI WebBrowserV1_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1302 return create_webbrowser(1, pOuter, riid, ppv);
1305 HRESULT WINAPI WebBrowser_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1307 return create_webbrowser(2, pOuter, riid, ppv);