winewayland.drv: Update desktop window size on display changes.
[wine.git] / dlls / ieframe / webbrowser.c
blobcd0143acd2251b24a11289bbff70f6a9e5724bc7
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=%ld\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=%ld\n", This, ref);
169 if(!ref) {
170 if(This->sink)
171 IAdviseSink_Release(This->sink);
173 if(This->advise_holder)
174 IOleAdviseHolder_Release(This->advise_holder);
176 if(This->doc_host.document)
177 IUnknown_Release(This->doc_host.document);
179 DocHost_Release(&This->doc_host);
181 WebBrowser_OleObject_Destroy(This);
183 free(This);
184 unlock_module();
187 return ref;
190 static const struct IUnknownVtbl internal_unk_vtbl =
192 WebBrowser_QueryInterface,
193 WebBrowser_AddRef,
194 WebBrowser_Release
197 static inline WebBrowser *impl_from_IWebBrowser2(IWebBrowser2 *iface)
199 return CONTAINING_RECORD(iface, WebBrowser, IWebBrowser2_iface);
202 static HRESULT WINAPI WebBrowser2_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
204 WebBrowser *This = impl_from_IWebBrowser2(iface);
206 return IUnknown_QueryInterface(This->hlink_frame.outer, riid, ppv);
209 static ULONG WINAPI WebBrowser2_AddRef(IWebBrowser2 *iface)
211 WebBrowser *This = impl_from_IWebBrowser2(iface);
213 return IUnknown_AddRef(This->hlink_frame.outer);
216 static ULONG WINAPI WebBrowser2_Release(IWebBrowser2 *iface)
218 WebBrowser *This = impl_from_IWebBrowser2(iface);
220 return IUnknown_Release(This->hlink_frame.outer);
223 /* IDispatch methods */
224 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
226 WebBrowser *This = impl_from_IWebBrowser2(iface);
228 TRACE("(%p)->(%p)\n", This, pctinfo);
230 *pctinfo = 1;
231 return S_OK;
234 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
235 LPTYPEINFO *ppTInfo)
237 WebBrowser *This = impl_from_IWebBrowser2(iface);
238 ITypeInfo *typeinfo;
239 HRESULT hres;
241 TRACE("(%p)->(%d %ld %p)\n", This, iTInfo, lcid, ppTInfo);
243 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
244 if(FAILED(hres))
245 return hres;
247 ITypeInfo_AddRef(typeinfo);
248 *ppTInfo = typeinfo;
249 return S_OK;
252 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
253 LPOLESTR *rgszNames, UINT cNames,
254 LCID lcid, DISPID *rgDispId)
256 WebBrowser *This = impl_from_IWebBrowser2(iface);
257 ITypeInfo *typeinfo;
258 HRESULT hres;
260 TRACE("(%p)->(%s %p %d %ld %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
261 lcid, rgDispId);
263 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
264 if(FAILED(hres))
265 return hres;
267 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
270 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
271 REFIID riid, LCID lcid, WORD wFlags,
272 DISPPARAMS *pDispParams, VARIANT *pVarResult,
273 EXCEPINFO *pExepInfo, UINT *puArgErr)
275 WebBrowser *This = impl_from_IWebBrowser2(iface);
276 ITypeInfo *typeinfo;
277 HRESULT hres;
279 TRACE("(%p)->(%ld %s %ld %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
280 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
282 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
283 if(FAILED(hres))
284 return hres;
286 return ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags, pDispParams,
287 pVarResult, pExepInfo, puArgErr);
290 /* IWebBrowser methods */
291 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
293 WebBrowser *This = impl_from_IWebBrowser2(iface);
294 TRACE("(%p)\n", This);
295 return go_back(&This->doc_host);
298 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
300 WebBrowser *This = impl_from_IWebBrowser2(iface);
301 TRACE("(%p)\n", This);
302 return go_forward(&This->doc_host);
305 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
307 WebBrowser *This = impl_from_IWebBrowser2(iface);
308 TRACE("(%p)\n", This);
309 return go_home(&This->doc_host);
312 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
314 WebBrowser *This = impl_from_IWebBrowser2(iface);
315 FIXME("(%p)\n", This);
316 return E_NOTIMPL;
319 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
320 VARIANT *Flags, VARIANT *TargetFrameName,
321 VARIANT *PostData, VARIANT *Headers)
323 WebBrowser *This = impl_from_IWebBrowser2(iface);
325 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
326 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
327 debugstr_variant(Headers));
329 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
332 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
334 WebBrowser *This = impl_from_IWebBrowser2(iface);
336 TRACE("(%p)\n", This);
338 return refresh_document(&This->doc_host, NULL);
341 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
343 WebBrowser *This = impl_from_IWebBrowser2(iface);
345 TRACE("(%p)->(%s)\n", This, debugstr_variant(Level));
347 return refresh_document(&This->doc_host, Level);
350 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
352 WebBrowser *This = impl_from_IWebBrowser2(iface);
353 FIXME("(%p)\n", This);
354 return S_OK;
357 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
359 WebBrowser *This = impl_from_IWebBrowser2(iface);
361 TRACE("(%p)->(%p)\n", This, ppDisp);
363 if(!ppDisp)
364 return E_POINTER;
366 *ppDisp = (IDispatch*)&This->IWebBrowser2_iface;
367 IDispatch_AddRef(*ppDisp);
368 return S_OK;
371 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
373 WebBrowser *This = impl_from_IWebBrowser2(iface);
374 FIXME("(%p)->(%p)\n", This, ppDisp);
375 return E_NOTIMPL;
378 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
380 WebBrowser *This = impl_from_IWebBrowser2(iface);
381 FIXME("(%p)->(%p)\n", This, ppDisp);
382 return E_NOTIMPL;
385 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
387 WebBrowser *This = impl_from_IWebBrowser2(iface);
388 IDispatch *disp = NULL;
390 TRACE("(%p)->(%p)\n", This, ppDisp);
392 if(This->doc_host.document) {
393 HRESULT hres;
395 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
396 if(SUCCEEDED(hres)) {
397 IDispatch *html_doc;
399 /* Some broken apps cast returned IDispatch to IHTMLDocument2
400 * without QueryInterface call */
401 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
402 if(SUCCEEDED(hres)) {
403 IDispatch_Release(disp);
404 disp = html_doc;
409 *ppDisp = disp;
410 return disp ? S_OK : S_FALSE;
413 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
415 WebBrowser *This = impl_from_IWebBrowser2(iface);
416 FIXME("(%p)->(%p)\n", This, pBool);
417 return E_NOTIMPL;
420 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
422 WebBrowser *This = impl_from_IWebBrowser2(iface);
423 FIXME("(%p)->(%p)\n", This, Type);
424 return E_NOTIMPL;
427 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
429 WebBrowser *This = impl_from_IWebBrowser2(iface);
431 TRACE("(%p)->(%p)\n", This, pl);
433 *pl = This->pos_rect.left;
434 return S_OK;
437 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
439 WebBrowser *This = impl_from_IWebBrowser2(iface);
440 RECT rect;
442 TRACE("(%p)->(%ld)\n", This, Left);
444 if(!This->inplace)
445 return E_UNEXPECTED;
447 rect = This->pos_rect;
448 rect.left = Left;
450 /* We don't really change the window position here.
451 * We just notify the embedder that he should do so. */
452 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
455 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
457 WebBrowser *This = impl_from_IWebBrowser2(iface);
459 TRACE("(%p)->(%p)\n", This, pl);
461 *pl = This->pos_rect.top;
462 return S_OK;
465 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
467 WebBrowser *This = impl_from_IWebBrowser2(iface);
468 RECT rect;
470 TRACE("(%p)->(%ld)\n", This, Top);
472 if(!This->inplace)
473 return E_UNEXPECTED;
475 rect = This->pos_rect;
476 rect.top = Top;
478 /* We don't really change the window position here.
479 * We just notify the embedder that he should do so. */
480 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
483 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
485 WebBrowser *This = impl_from_IWebBrowser2(iface);
487 TRACE("(%p)->(%p)\n", This, pl);
489 *pl = This->pos_rect.right - This->pos_rect.left;
490 return S_OK;
493 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
495 WebBrowser *This = impl_from_IWebBrowser2(iface);
496 RECT rect;
498 TRACE("(%p)->(%ld)\n", This, Width);
500 if(!This->inplace)
501 return E_UNEXPECTED;
503 rect = This->pos_rect;
504 rect.right = rect.left+Width;
506 /* We don't really change the window size here.
507 * We just notify the embedder that he should do so. */
508 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
511 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
513 WebBrowser *This = impl_from_IWebBrowser2(iface);
515 TRACE("(%p)->(%p)\n", This, pl);
517 *pl = This->pos_rect.bottom - This->pos_rect.top;
518 return S_OK;
521 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
523 WebBrowser *This = impl_from_IWebBrowser2(iface);
524 RECT rect;
526 TRACE("(%p)->(%ld)\n", This, Height);
528 if(!This->inplace)
529 return E_UNEXPECTED;
531 rect = This->pos_rect;
532 rect.bottom = rect.top+Height;
534 /* We don't really change the window size here.
535 * We just notify the embedder that he should do so. */
536 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
539 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
541 WebBrowser *This = impl_from_IWebBrowser2(iface);
542 IHTMLDocument2 *doc;
543 HRESULT hres;
545 TRACE("(%p)->(%p)\n", This, LocationName);
547 if(This->doc_host.document &&
548 SUCCEEDED(IUnknown_QueryInterface(This->doc_host.document, &IID_IHTMLDocument2, (void **)&doc))) {
549 hres = IHTMLDocument2_get_title(doc, LocationName);
550 if(hres == S_OK && !SysStringLen(*LocationName)) {
551 SysFreeString(*LocationName);
552 hres = get_location_url(&This->doc_host, LocationName);
554 IHTMLDocument2_Release(doc);
555 } else {
556 *LocationName = SysAllocString(L"");
557 hres = S_FALSE;
560 return hres;
563 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
565 WebBrowser *This = impl_from_IWebBrowser2(iface);
567 TRACE("(%p)->(%p)\n", This, LocationURL);
569 return get_location_url(&This->doc_host, LocationURL);
572 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
574 WebBrowser *This = impl_from_IWebBrowser2(iface);
576 TRACE("(%p)->(%p)\n", This, pBool);
578 *pBool = This->doc_host.busy;
579 return S_OK;
582 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
584 WebBrowser *This = impl_from_IWebBrowser2(iface);
586 TRACE("(%p)\n", This);
588 /* It's a InternetExplorer specific method, we have nothing to do here. */
589 return E_FAIL;
592 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
594 WebBrowser *This = impl_from_IWebBrowser2(iface);
595 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
596 return E_NOTIMPL;
599 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
601 WebBrowser *This = impl_from_IWebBrowser2(iface);
602 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
603 return E_NOTIMPL;
606 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
608 WebBrowser *This = impl_from_IWebBrowser2(iface);
609 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
610 return E_NOTIMPL;
613 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
615 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
616 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
617 WebBrowser *This = impl_from_IWebBrowser2(iface);
619 TRACE("(%p)->(%p)\n", This, Name);
621 *Name = SysAllocString(sName);
623 return S_OK;
626 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, SHANDLE_PTR *pHWND)
628 WebBrowser *This = impl_from_IWebBrowser2(iface);
630 TRACE("(%p)->(%p)\n", This, pHWND);
632 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
633 *pHWND = 0;
634 return E_FAIL;
637 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
639 WebBrowser *This = impl_from_IWebBrowser2(iface);
640 FIXME("(%p)->(%p)\n", This, FullName);
641 return E_NOTIMPL;
644 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
646 WebBrowser *This = impl_from_IWebBrowser2(iface);
647 FIXME("(%p)->(%p)\n", This, Path);
648 return E_NOTIMPL;
651 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
653 WebBrowser *This = impl_from_IWebBrowser2(iface);
655 TRACE("(%p)->(%p)\n", This, pBool);
657 *pBool = This->visible;
658 return S_OK;
661 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
663 WebBrowser *This = impl_from_IWebBrowser2(iface);
664 VARIANTARG arg;
665 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
667 TRACE("(%p)->(%x)\n", This, Value);
669 This->visible = Value;
671 V_VT(&arg) = VT_BOOL;
672 V_BOOL(&arg) = Value;
673 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
675 return S_OK;
678 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
680 WebBrowser *This = impl_from_IWebBrowser2(iface);
682 TRACE("(%p)->(%p)\n", This, pBool);
684 *pBool = This->status_bar;
685 return S_OK;
688 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
690 WebBrowser *This = impl_from_IWebBrowser2(iface);
691 VARIANTARG arg;
692 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
694 TRACE("(%p)->(%x)\n", This, Value);
696 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
698 /* In opposition to InternetExplorer, all we should do here is
699 * inform the embedder about the status bar change. */
701 V_VT(&arg) = VT_BOOL;
702 V_BOOL(&arg) = Value;
703 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
705 return S_OK;
708 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
710 WebBrowser *This = impl_from_IWebBrowser2(iface);
711 FIXME("(%p)->(%p)\n", This, StatusText);
712 return E_NOTIMPL;
715 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
717 WebBrowser *This = impl_from_IWebBrowser2(iface);
718 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
719 return E_NOTIMPL;
722 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
724 WebBrowser *This = impl_from_IWebBrowser2(iface);
726 TRACE("(%p)->(%p)\n", This, Value);
728 *Value = This->tool_bar;
729 return S_OK;
732 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
734 WebBrowser *This = impl_from_IWebBrowser2(iface);
735 VARIANTARG arg;
736 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
738 TRACE("(%p)->(%x)\n", This, Value);
740 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
742 /* In opposition to InternetExplorer, all we should do here is
743 * inform the embedder about the tool bar change. */
745 V_VT(&arg) = VT_BOOL;
746 V_BOOL(&arg) = This->tool_bar;
747 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
749 return S_OK;
752 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
754 WebBrowser *This = impl_from_IWebBrowser2(iface);
756 TRACE("(%p)->(%p)\n", This, Value);
758 *Value = This->menu_bar;
759 return S_OK;
762 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
764 WebBrowser *This = impl_from_IWebBrowser2(iface);
765 VARIANTARG arg;
766 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
768 TRACE("(%p)->(%x)\n", This, Value);
770 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
772 /* In opposition to InternetExplorer, all we should do here is
773 * inform the embedder about the menu bar change. */
775 V_VT(&arg) = VT_BOOL;
776 V_BOOL(&arg) = Value;
777 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
779 return S_OK;
782 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
784 WebBrowser *This = impl_from_IWebBrowser2(iface);
786 TRACE("(%p)->(%p)\n", This, pbFullScreen);
788 *pbFullScreen = This->full_screen;
789 return S_OK;
792 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
794 WebBrowser *This = impl_from_IWebBrowser2(iface);
795 VARIANTARG arg;
796 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
798 /* In opposition to InternetExplorer, all we should do here is
799 * inform the embedder about the fullscreen change. */
801 TRACE("(%p)->(%x)\n", This, bFullScreen);
803 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
805 V_VT(&arg) = VT_BOOL;
806 V_BOOL(&arg) = bFullScreen;
807 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
809 return S_OK;
812 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
813 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
815 WebBrowser *This = impl_from_IWebBrowser2(iface);
816 LPCWSTR url;
818 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
819 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
821 if(!This->client)
822 return E_FAIL;
824 if(!URL)
825 return S_OK;
827 switch (V_VT(URL))
829 case VT_BSTR:
830 url = V_BSTR(URL);
831 break;
832 case VT_BSTR|VT_BYREF:
833 url = *V_BSTRREF(URL);
834 break;
835 default:
836 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
837 return E_INVALIDARG;
840 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
843 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
845 WebBrowser *This = impl_from_IWebBrowser2(iface);
846 IOleCommandTarget *target = NULL;
847 OLECMD ole_command[1];
848 HRESULT hres;
850 TRACE("(%p)->(%d %p)\n", This, cmdID, pcmdf);
852 if (!pcmdf)
853 return E_POINTER;
854 ole_command[0].cmdID = cmdID;
855 ole_command[0].cmdf = *pcmdf;
857 if (This->container)
859 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
860 if(FAILED(hres))
861 target = NULL;
863 if (!target && This->doc_host.document)
865 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
866 if(FAILED(hres))
867 target = NULL;
870 if (!target)
871 return E_UNEXPECTED;
873 hres = IOleCommandTarget_QueryStatus(target, NULL, 1, ole_command, NULL);
874 if (SUCCEEDED(hres))
875 *pcmdf = ole_command[0].cmdf;
876 if (hres == OLECMDERR_E_NOTSUPPORTED)
878 *pcmdf = 0;
879 hres = S_OK;
881 IOleCommandTarget_Release(target);
883 return hres;
886 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
887 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
889 WebBrowser *This = impl_from_IWebBrowser2(iface);
890 IOleCommandTarget *target = NULL;
891 HRESULT hres;
893 TRACE("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
895 if(This->container)
897 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
898 if(FAILED(hres))
899 target = NULL;
901 if(!target && This->doc_host.document)
903 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
904 if(FAILED(hres))
905 target = NULL;
908 if(!target)
909 return E_UNEXPECTED;
911 hres = IOleCommandTarget_Exec(target, NULL, cmdID, cmdexecopt, pvaIn, pvaOut);
912 IOleCommandTarget_Release(target);
914 return hres;
917 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
918 VARIANT *pvarShow, VARIANT *pvarSize)
920 WebBrowser *This = impl_from_IWebBrowser2(iface);
921 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
922 debugstr_variant(pvarSize));
923 return E_NOTIMPL;
926 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
928 WebBrowser *This = impl_from_IWebBrowser2(iface);
930 TRACE("(%p)->(%p)\n", This, lpReadyState);
932 *lpReadyState = This->doc_host.ready_state;
933 return S_OK;
936 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
938 WebBrowser *This = impl_from_IWebBrowser2(iface);
940 TRACE("(%p)->(%p)\n", This, pbOffline);
942 *pbOffline = This->doc_host.offline;
943 return S_OK;
946 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
948 WebBrowser *This = impl_from_IWebBrowser2(iface);
950 TRACE("(%p)->(%x)\n", This, bOffline);
952 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
953 return S_OK;
956 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
958 WebBrowser *This = impl_from_IWebBrowser2(iface);
960 TRACE("(%p)->(%p)\n", This, pbSilent);
962 *pbSilent = This->doc_host.silent;
963 return S_OK;
966 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
968 WebBrowser *This = impl_from_IWebBrowser2(iface);
970 TRACE("(%p)->(%x)\n", This, bSilent);
972 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
973 return S_OK;
976 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
977 VARIANT_BOOL *pbRegister)
979 WebBrowser *This = impl_from_IWebBrowser2(iface);
981 FIXME("(%p)->(%p)\n", This, pbRegister);
983 *pbRegister = This->register_browser;
984 return S_OK;
987 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
988 VARIANT_BOOL bRegister)
990 WebBrowser *This = impl_from_IWebBrowser2(iface);
992 FIXME("(%p)->(%x)\n", This, bRegister);
994 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
995 return S_OK;
998 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
999 VARIANT_BOOL *pbRegister)
1001 WebBrowser *This = impl_from_IWebBrowser2(iface);
1003 FIXME("(%p)->(%p)\n", This, pbRegister);
1005 if(!pbRegister)
1006 return E_INVALIDARG;
1008 *pbRegister=0;
1009 return S_OK;
1012 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
1013 VARIANT_BOOL bRegister)
1015 WebBrowser *This = impl_from_IWebBrowser2(iface);
1016 FIXME("(%p)->(%x)\n", This, bRegister);
1017 return S_OK;
1020 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
1022 WebBrowser *This = impl_from_IWebBrowser2(iface);
1024 TRACE("(%p)->(%p)\n", This, pbRegister);
1026 *pbRegister = This->theater_mode;
1027 return S_OK;
1030 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
1032 WebBrowser *This = impl_from_IWebBrowser2(iface);
1033 VARIANTARG arg;
1034 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1036 TRACE("(%p)->(%x)\n", This, bRegister);
1038 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
1040 /* In opposition to InternetExplorer, all we should do here is
1041 * inform the embedder about the theater mode change. */
1043 V_VT(&arg) = VT_BOOL;
1044 V_BOOL(&arg) = bRegister;
1045 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
1047 return S_OK;
1050 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1052 WebBrowser *This = impl_from_IWebBrowser2(iface);
1054 TRACE("(%p)->(%p)\n", This, Value);
1056 *Value = This->address_bar;
1057 return S_OK;
1060 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
1062 WebBrowser *This = impl_from_IWebBrowser2(iface);
1063 VARIANTARG arg;
1064 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1066 TRACE("(%p)->(%x)\n", This, Value);
1068 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
1070 /* In opposition to InternetExplorer, all we should do here is
1071 * inform the embedder about the address bar change. */
1073 V_VT(&arg) = VT_BOOL;
1074 V_BOOL(&arg) = Value;
1075 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
1077 return S_OK;
1080 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1082 WebBrowser *This = impl_from_IWebBrowser2(iface);
1084 TRACE("(%p)->(%p)\n", This, Value);
1086 /* It's InternetExplorer object's method. We have nothing to do here. */
1087 return E_NOTIMPL;
1090 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
1092 WebBrowser *This = impl_from_IWebBrowser2(iface);
1093 VARIANTARG arg;
1094 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1096 TRACE("(%p)->(%x)\n", This, Value);
1098 /* In opposition to InternetExplorer, all we should do here is
1099 * inform the embedder about the resizable change. */
1101 V_VT(&arg) = VT_BOOL;
1102 V_BOOL(&arg) = Value;
1103 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
1105 return S_OK;
1108 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
1110 WebBrowser2_QueryInterface,
1111 WebBrowser2_AddRef,
1112 WebBrowser2_Release,
1113 WebBrowser_GetTypeInfoCount,
1114 WebBrowser_GetTypeInfo,
1115 WebBrowser_GetIDsOfNames,
1116 WebBrowser_Invoke,
1117 WebBrowser_GoBack,
1118 WebBrowser_GoForward,
1119 WebBrowser_GoHome,
1120 WebBrowser_GoSearch,
1121 WebBrowser_Navigate,
1122 WebBrowser_Refresh,
1123 WebBrowser_Refresh2,
1124 WebBrowser_Stop,
1125 WebBrowser_get_Application,
1126 WebBrowser_get_Parent,
1127 WebBrowser_get_Container,
1128 WebBrowser_get_Document,
1129 WebBrowser_get_TopLevelContainer,
1130 WebBrowser_get_Type,
1131 WebBrowser_get_Left,
1132 WebBrowser_put_Left,
1133 WebBrowser_get_Top,
1134 WebBrowser_put_Top,
1135 WebBrowser_get_Width,
1136 WebBrowser_put_Width,
1137 WebBrowser_get_Height,
1138 WebBrowser_put_Height,
1139 WebBrowser_get_LocationName,
1140 WebBrowser_get_LocationURL,
1141 WebBrowser_get_Busy,
1142 WebBrowser_Quit,
1143 WebBrowser_ClientToWindow,
1144 WebBrowser_PutProperty,
1145 WebBrowser_GetProperty,
1146 WebBrowser_get_Name,
1147 WebBrowser_get_HWND,
1148 WebBrowser_get_FullName,
1149 WebBrowser_get_Path,
1150 WebBrowser_get_Visible,
1151 WebBrowser_put_Visible,
1152 WebBrowser_get_StatusBar,
1153 WebBrowser_put_StatusBar,
1154 WebBrowser_get_StatusText,
1155 WebBrowser_put_StatusText,
1156 WebBrowser_get_ToolBar,
1157 WebBrowser_put_ToolBar,
1158 WebBrowser_get_MenuBar,
1159 WebBrowser_put_MenuBar,
1160 WebBrowser_get_FullScreen,
1161 WebBrowser_put_FullScreen,
1162 WebBrowser_Navigate2,
1163 WebBrowser_QueryStatusWB,
1164 WebBrowser_ExecWB,
1165 WebBrowser_ShowBrowserBar,
1166 WebBrowser_get_ReadyState,
1167 WebBrowser_get_Offline,
1168 WebBrowser_put_Offline,
1169 WebBrowser_get_Silent,
1170 WebBrowser_put_Silent,
1171 WebBrowser_get_RegisterAsBrowser,
1172 WebBrowser_put_RegisterAsBrowser,
1173 WebBrowser_get_RegisterAsDropTarget,
1174 WebBrowser_put_RegisterAsDropTarget,
1175 WebBrowser_get_TheaterMode,
1176 WebBrowser_put_TheaterMode,
1177 WebBrowser_get_AddressBar,
1178 WebBrowser_put_AddressBar,
1179 WebBrowser_get_Resizable,
1180 WebBrowser_put_Resizable
1183 static inline WebBrowser *impl_from_IServiceProvider(IServiceProvider *iface)
1185 return CONTAINING_RECORD(iface, WebBrowser, IServiceProvider_iface);
1188 static HRESULT WINAPI WBServiceProvider_QueryInterface(IServiceProvider *iface,
1189 REFIID riid, LPVOID *ppv)
1191 WebBrowser *This = impl_from_IServiceProvider(iface);
1192 return IUnknown_QueryInterface(This->hlink_frame.outer, riid, ppv);
1195 static ULONG WINAPI WBServiceProvider_AddRef(IServiceProvider *iface)
1197 WebBrowser *This = impl_from_IServiceProvider(iface);
1198 return IUnknown_AddRef(This->hlink_frame.outer);
1201 static ULONG WINAPI WBServiceProvider_Release(IServiceProvider *iface)
1203 WebBrowser *This = impl_from_IServiceProvider(iface);
1204 return IUnknown_Release(This->hlink_frame.outer);
1207 static HRESULT STDMETHODCALLTYPE WBServiceProvider_QueryService(IServiceProvider *iface,
1208 REFGUID guidService, REFIID riid, void **ppv)
1210 WebBrowser *This = impl_from_IServiceProvider(iface);
1212 if(IsEqualGUID(&SID_SHTMLWindow, riid)) {
1213 TRACE("(%p)->(SID_SHTMLWindow)\n", This);
1214 return IHTMLWindow2_QueryInterface(&This->doc_host.html_window.IHTMLWindow2_iface, riid, ppv);
1217 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1218 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1219 *ppv = NULL;
1220 return E_FAIL;
1223 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1224 *ppv = NULL;
1225 return E_NOINTERFACE;
1228 static const IServiceProviderVtbl ServiceProviderVtbl =
1230 WBServiceProvider_QueryInterface,
1231 WBServiceProvider_AddRef,
1232 WBServiceProvider_Release,
1233 WBServiceProvider_QueryService
1236 static inline WebBrowser *impl_from_DocHost(DocHost *iface)
1238 return CONTAINING_RECORD(iface, WebBrowser, doc_host);
1241 static ULONG WebBrowser_addref(DocHost *iface)
1243 WebBrowser *This = impl_from_DocHost(iface);
1244 return IUnknown_AddRef(This->hlink_frame.outer);
1247 static ULONG WebBrowser_release(DocHost *iface)
1249 WebBrowser *This = impl_from_DocHost(iface);
1250 return IUnknown_Release(This->hlink_frame.outer);
1253 static void DocHostContainer_get_docobj_rect(DocHost *This, RECT *rc)
1255 GetClientRect(This->frame_hwnd, rc);
1258 static HRESULT DocHostContainer_set_status_text(DocHost *This, const WCHAR *text)
1260 return E_NOTIMPL;
1263 static void DocHostContainer_on_command_state_change(DocHost *This, LONG command, BOOL enable)
1267 static void DocHostContainer_set_url(DocHost *This, const WCHAR *url)
1271 static const IDocHostContainerVtbl DocHostContainerVtbl = {
1272 WebBrowser_addref,
1273 WebBrowser_release,
1274 DocHostContainer_get_docobj_rect,
1275 DocHostContainer_set_status_text,
1276 DocHostContainer_on_command_state_change,
1277 DocHostContainer_set_url
1280 static HRESULT create_webbrowser(int version, IUnknown *outer, REFIID riid, void **ppv)
1282 WebBrowser *ret;
1283 HRESULT hres;
1285 TRACE("(%p %s %p) version=%d\n", outer, debugstr_guid(riid), ppv, version);
1287 if (outer && !IsEqualIID(riid, &IID_IUnknown))
1288 return CLASS_E_NOAGGREGATION;
1290 ret = calloc(1, sizeof(WebBrowser));
1292 ret->IUnknown_inner.lpVtbl = &internal_unk_vtbl;
1293 ret->IWebBrowser2_iface.lpVtbl = &WebBrowser2Vtbl;
1294 ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
1295 ret->ref = 1;
1296 ret->version = version;
1298 HlinkFrame_Init(&ret->hlink_frame, outer ? outer : &ret->IUnknown_inner, &ret->doc_host);
1299 DocHost_Init(&ret->doc_host, &ret->IWebBrowser2_iface, &DocHostContainerVtbl);
1301 ret->visible = VARIANT_TRUE;
1302 ret->menu_bar = VARIANT_TRUE;
1303 ret->address_bar = VARIANT_TRUE;
1304 ret->status_bar = VARIANT_TRUE;
1305 ret->tool_bar = VARIANT_TRUE;
1307 WebBrowser_OleObject_Init(ret);
1308 WebBrowser_ViewObject_Init(ret);
1309 WebBrowser_Persist_Init(ret);
1310 WebBrowser_ClassInfo_Init(ret);
1312 lock_module();
1314 hres = IUnknown_QueryInterface(&ret->IUnknown_inner, riid, ppv);
1316 IUnknown_Release(&ret->IUnknown_inner);
1317 return hres;
1320 HRESULT WINAPI WebBrowserV1_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1322 return create_webbrowser(1, pOuter, riid, ppv);
1325 HRESULT WINAPI WebBrowser_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1327 return create_webbrowser(2, pOuter, riid, ppv);