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
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
31 static inline WebBrowser *impl_from_IWebBrowser2(IWebBrowser2 *iface)
33 return CONTAINING_RECORD(iface, WebBrowser, IWebBrowser2_iface);
36 static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
38 WebBrowser *This = impl_from_IWebBrowser2(iface);
44 if(IsEqualGUID(&IID_IUnknown, riid)) {
45 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
46 *ppv = &This->IWebBrowser2_iface;
47 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
48 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
49 *ppv = &This->IWebBrowser2_iface;
50 }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
51 TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
52 *ppv = &This->IWebBrowser2_iface;
53 }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
54 TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
55 *ppv = &This->IWebBrowser2_iface;
56 }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
57 TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
58 *ppv = &This->IWebBrowser2_iface;
59 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
60 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
61 *ppv = &This->IOleObject_iface;
62 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
63 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
64 *ppv = &This->IOleInPlaceObject_iface;
65 }else if(IsEqualGUID (&IID_IOleInPlaceObject, riid)) {
66 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
67 *ppv = &This->IOleInPlaceObject_iface;
68 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
69 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
70 *ppv = &This->IOleControl_iface;
71 }else if(IsEqualGUID(&IID_IPersist, riid)) {
72 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
73 *ppv = &This->IPersistStorage_iface;
74 }else if(IsEqualGUID(&IID_IPersistStorage, riid)) {
75 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
76 *ppv = &This->IPersistStorage_iface;
77 }else if(IsEqualGUID(&IID_IPersistMemory, riid)) {
78 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
79 *ppv = &This->IPersistMemory_iface;
80 }else if(IsEqualGUID (&IID_IPersistStreamInit, riid)) {
81 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
82 *ppv = &This->IPersistStreamInit_iface;
83 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
84 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
85 *ppv = &This->IProvideClassInfo2_iface;
86 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
87 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
88 *ppv = &This->IProvideClassInfo2_iface;
89 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
90 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
91 *ppv = &This->doc_host.cps.IConnectionPointContainer_iface;
92 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
93 TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
94 *ppv = &This->IViewObject2_iface;
95 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
96 TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
97 *ppv = &This->IViewObject2_iface;
98 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
99 TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
100 *ppv = &This->IOleInPlaceActiveObject_iface;
101 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
102 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
103 *ppv = &This->IOleCommandTarget_iface;
104 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
105 *ppv = &This->IServiceProvider_iface;
106 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
107 }else if(IsEqualGUID(&IID_IDataObject, riid)) {
108 *ppv = &This->IDataObject_iface;
109 TRACE("(%p)->(IID_IDataObject %p)\n", This, ppv);
110 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
111 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
112 return E_NOINTERFACE;
113 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
114 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
115 return E_NOINTERFACE;
116 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
117 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
118 return E_NOINTERFACE;
119 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
120 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
121 return E_NOINTERFACE;
122 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
123 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
124 return E_NOINTERFACE;
125 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
126 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
127 return E_NOINTERFACE;
128 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
129 TRACE("(%p)->(IID_IViewObjectEx %p) returning NULL\n", This, ppv);
130 return E_NOINTERFACE;
131 }else if(IsEqualGUID(&IID_IOleLink, riid)) {
132 TRACE("(%p)->(IID_IOleLink %p) returning NULL\n", This, ppv);
133 return E_NOINTERFACE;
134 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
135 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
136 return E_NOINTERFACE;
137 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
138 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
139 return E_NOINTERFACE;
140 }else if(HlinkFrame_QI(&This->hlink_frame, riid, ppv)) {
145 IUnknown_AddRef((IUnknown*)*ppv);
149 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
150 return E_NOINTERFACE;
153 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
155 WebBrowser *This = impl_from_IWebBrowser2(iface);
156 LONG ref = InterlockedIncrement(&This->ref);
157 TRACE("(%p) ref=%d\n", This, ref);
161 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
163 WebBrowser *This = impl_from_IWebBrowser2(iface);
164 LONG ref = InterlockedDecrement(&This->ref);
166 TRACE("(%p) ref=%d\n", This, ref);
169 if(This->doc_host.document)
170 IUnknown_Release(This->doc_host.document);
172 DocHost_Release(&This->doc_host);
174 WebBrowser_OleObject_Destroy(This);
183 /* IDispatch methods */
184 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
186 WebBrowser *This = impl_from_IWebBrowser2(iface);
188 TRACE("(%p)->(%p)\n", This, pctinfo);
194 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
197 WebBrowser *This = impl_from_IWebBrowser2(iface);
201 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
203 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
207 ITypeInfo_AddRef(typeinfo);
212 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
213 LPOLESTR *rgszNames, UINT cNames,
214 LCID lcid, DISPID *rgDispId)
216 WebBrowser *This = impl_from_IWebBrowser2(iface);
220 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
223 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
227 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
230 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
231 REFIID riid, LCID lcid, WORD wFlags,
232 DISPPARAMS *pDispParams, VARIANT *pVarResult,
233 EXCEPINFO *pExepInfo, UINT *puArgErr)
235 WebBrowser *This = impl_from_IWebBrowser2(iface);
239 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
240 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
242 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
246 return ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags, pDispParams,
247 pVarResult, pExepInfo, puArgErr);
250 /* IWebBrowser methods */
251 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
253 WebBrowser *This = impl_from_IWebBrowser2(iface);
254 TRACE("(%p)\n", This);
255 return go_back(&This->doc_host);
258 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
260 WebBrowser *This = impl_from_IWebBrowser2(iface);
261 FIXME("(%p)\n", This);
265 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
267 WebBrowser *This = impl_from_IWebBrowser2(iface);
268 TRACE("(%p)\n", This);
269 return go_home(&This->doc_host);
272 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
274 WebBrowser *This = impl_from_IWebBrowser2(iface);
275 FIXME("(%p)\n", This);
279 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
280 VARIANT *Flags, VARIANT *TargetFrameName,
281 VARIANT *PostData, VARIANT *Headers)
283 WebBrowser *This = impl_from_IWebBrowser2(iface);
285 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
286 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
287 debugstr_variant(Headers));
289 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
292 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
294 WebBrowser *This = impl_from_IWebBrowser2(iface);
296 TRACE("(%p)\n", This);
298 return refresh_document(&This->doc_host);
301 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
303 WebBrowser *This = impl_from_IWebBrowser2(iface);
304 FIXME("(%p)->(%s)\n", This, debugstr_variant(Level));
308 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
310 WebBrowser *This = impl_from_IWebBrowser2(iface);
311 FIXME("(%p)\n", This);
315 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
317 WebBrowser *This = impl_from_IWebBrowser2(iface);
319 TRACE("(%p)->(%p)\n", This, ppDisp);
324 *ppDisp = (IDispatch*)&This->IWebBrowser2_iface;
325 IDispatch_AddRef(*ppDisp);
329 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
331 WebBrowser *This = impl_from_IWebBrowser2(iface);
332 FIXME("(%p)->(%p)\n", This, ppDisp);
336 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
338 WebBrowser *This = impl_from_IWebBrowser2(iface);
339 FIXME("(%p)->(%p)\n", This, ppDisp);
343 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
345 WebBrowser *This = impl_from_IWebBrowser2(iface);
346 IDispatch *disp = NULL;
348 TRACE("(%p)->(%p)\n", This, ppDisp);
350 if(This->doc_host.document) {
353 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
354 if(SUCCEEDED(hres)) {
357 /* Some broken apps cast returned IDispatch to IHTMLDocument2
358 * without QueryInterface call */
359 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
360 if(SUCCEEDED(hres)) {
361 IDispatch_Release(disp);
371 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
373 WebBrowser *This = impl_from_IWebBrowser2(iface);
374 FIXME("(%p)->(%p)\n", This, pBool);
378 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
380 WebBrowser *This = impl_from_IWebBrowser2(iface);
381 FIXME("(%p)->(%p)\n", This, Type);
385 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
387 WebBrowser *This = impl_from_IWebBrowser2(iface);
389 TRACE("(%p)->(%p)\n", This, pl);
391 *pl = This->pos_rect.left;
395 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
397 WebBrowser *This = impl_from_IWebBrowser2(iface);
400 TRACE("(%p)->(%d)\n", This, Left);
405 rect = This->pos_rect;
408 /* We don't really change the window position here.
409 * We just notify the embedder that he should do so. */
410 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
413 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
415 WebBrowser *This = impl_from_IWebBrowser2(iface);
417 TRACE("(%p)->(%p)\n", This, pl);
419 *pl = This->pos_rect.top;
423 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
425 WebBrowser *This = impl_from_IWebBrowser2(iface);
428 TRACE("(%p)->(%d)\n", This, Top);
433 rect = This->pos_rect;
436 /* We don't really change the window position here.
437 * We just notify the embedder that he should do so. */
438 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
441 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
443 WebBrowser *This = impl_from_IWebBrowser2(iface);
445 TRACE("(%p)->(%p)\n", This, pl);
447 *pl = This->pos_rect.right - This->pos_rect.left;
451 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
453 WebBrowser *This = impl_from_IWebBrowser2(iface);
456 TRACE("(%p)->(%d)\n", This, Width);
461 rect = This->pos_rect;
462 rect.right = rect.left+Width;
464 /* We don't really change the window size here.
465 * We just notify the embedder that he should do so. */
466 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
469 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
471 WebBrowser *This = impl_from_IWebBrowser2(iface);
473 TRACE("(%p)->(%p)\n", This, pl);
475 *pl = This->pos_rect.bottom - This->pos_rect.top;
479 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
481 WebBrowser *This = impl_from_IWebBrowser2(iface);
484 TRACE("(%p)->(%d)\n", This, Height);
489 rect = This->pos_rect;
490 rect.bottom = rect.top+Height;
492 /* We don't really change the window size here.
493 * We just notify the embedder that he should do so. */
494 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
497 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
499 WebBrowser *This = impl_from_IWebBrowser2(iface);
500 FIXME("(%p)->(%p)\n", This, LocationName);
504 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
506 WebBrowser *This = impl_from_IWebBrowser2(iface);
508 TRACE("(%p)->(%p)\n", This, LocationURL);
510 return get_location_url(&This->doc_host, LocationURL);
513 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
515 WebBrowser *This = impl_from_IWebBrowser2(iface);
517 TRACE("(%p)->(%p)\n", This, pBool);
519 *pBool = This->doc_host.busy;
523 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
525 WebBrowser *This = impl_from_IWebBrowser2(iface);
527 TRACE("(%p)\n", This);
529 /* It's a InternetExplorer specific method, we have nothing to do here. */
533 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
535 WebBrowser *This = impl_from_IWebBrowser2(iface);
536 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
540 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
542 WebBrowser *This = impl_from_IWebBrowser2(iface);
543 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
547 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
549 WebBrowser *This = impl_from_IWebBrowser2(iface);
550 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
554 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
556 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
557 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
558 WebBrowser *This = impl_from_IWebBrowser2(iface);
560 TRACE("(%p)->(%p)\n", This, Name);
562 *Name = SysAllocString(sName);
567 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND)
569 WebBrowser *This = impl_from_IWebBrowser2(iface);
571 TRACE("(%p)->(%p)\n", This, pHWND);
573 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
578 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
580 WebBrowser *This = impl_from_IWebBrowser2(iface);
581 FIXME("(%p)->(%p)\n", This, FullName);
585 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
587 WebBrowser *This = impl_from_IWebBrowser2(iface);
588 FIXME("(%p)->(%p)\n", This, Path);
592 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
594 WebBrowser *This = impl_from_IWebBrowser2(iface);
596 TRACE("(%p)->(%p)\n", This, pBool);
598 *pBool = This->visible;
602 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
604 WebBrowser *This = impl_from_IWebBrowser2(iface);
606 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
608 TRACE("(%p)->(%x)\n", This, Value);
610 This->visible = Value;
612 V_VT(&arg) = VT_BOOL;
613 V_BOOL(&arg) = Value;
614 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
619 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
621 WebBrowser *This = impl_from_IWebBrowser2(iface);
623 TRACE("(%p)->(%p)\n", This, pBool);
625 *pBool = This->status_bar;
629 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
631 WebBrowser *This = impl_from_IWebBrowser2(iface);
633 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
635 TRACE("(%p)->(%x)\n", This, Value);
637 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
639 /* In opposition to InternetExplorer, all we should do here is
640 * inform the embedder about the status bar change. */
642 V_VT(&arg) = VT_BOOL;
643 V_BOOL(&arg) = Value;
644 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
649 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
651 WebBrowser *This = impl_from_IWebBrowser2(iface);
652 FIXME("(%p)->(%p)\n", This, StatusText);
656 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
658 WebBrowser *This = impl_from_IWebBrowser2(iface);
659 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
663 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
665 WebBrowser *This = impl_from_IWebBrowser2(iface);
667 TRACE("(%p)->(%p)\n", This, Value);
669 *Value = This->tool_bar;
673 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
675 WebBrowser *This = impl_from_IWebBrowser2(iface);
677 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
679 TRACE("(%p)->(%x)\n", This, Value);
681 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
683 /* In opposition to InternetExplorer, all we should do here is
684 * inform the embedder about the tool bar change. */
686 V_VT(&arg) = VT_BOOL;
687 V_BOOL(&arg) = This->tool_bar;
688 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
693 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
695 WebBrowser *This = impl_from_IWebBrowser2(iface);
697 TRACE("(%p)->(%p)\n", This, Value);
699 *Value = This->menu_bar;
703 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
705 WebBrowser *This = impl_from_IWebBrowser2(iface);
707 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
709 TRACE("(%p)->(%x)\n", This, Value);
711 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
713 /* In opposition to InternetExplorer, all we should do here is
714 * inform the embedder about the menu bar change. */
716 V_VT(&arg) = VT_BOOL;
717 V_BOOL(&arg) = Value;
718 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
723 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
725 WebBrowser *This = impl_from_IWebBrowser2(iface);
727 TRACE("(%p)->(%p)\n", This, pbFullScreen);
729 *pbFullScreen = This->full_screen;
733 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
735 WebBrowser *This = impl_from_IWebBrowser2(iface);
737 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
739 /* In opposition to InternetExplorer, all we should do here is
740 * inform the embedder about the fullscreen change. */
742 TRACE("(%p)->(%x)\n", This, bFullScreen);
744 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
746 V_VT(&arg) = VT_BOOL;
747 V_BOOL(&arg) = bFullScreen;
748 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
753 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
754 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
756 WebBrowser *This = impl_from_IWebBrowser2(iface);
759 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
760 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
773 case VT_BSTR|VT_BYREF:
774 url = *V_BSTRREF(URL);
777 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
781 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
784 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
786 WebBrowser *This = impl_from_IWebBrowser2(iface);
787 IOleCommandTarget *target = NULL;
788 OLECMD ole_command[1];
791 TRACE("(%p)->(%d %p)\n", This, cmdID, pcmdf);
795 ole_command[0].cmdID = cmdID;
796 ole_command[0].cmdf = *pcmdf;
800 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
804 if (!target && This->doc_host.document)
806 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
814 hres = IOleCommandTarget_QueryStatus(target, NULL, 1, ole_command, NULL);
816 *pcmdf = ole_command[0].cmdf;
817 if (hres == OLECMDERR_E_NOTSUPPORTED)
822 IOleCommandTarget_Release(target);
827 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
828 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
830 WebBrowser *This = impl_from_IWebBrowser2(iface);
831 IOleCommandTarget *target = NULL;
834 TRACE("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
838 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
842 if(!target && This->doc_host.document)
844 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
852 hres = IOleCommandTarget_Exec(target, NULL, cmdID, cmdexecopt, pvaIn, pvaOut);
853 IOleCommandTarget_Release(target);
858 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
859 VARIANT *pvarShow, VARIANT *pvarSize)
861 WebBrowser *This = impl_from_IWebBrowser2(iface);
862 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
863 debugstr_variant(pvarSize));
867 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
869 WebBrowser *This = impl_from_IWebBrowser2(iface);
871 TRACE("(%p)->(%p)\n", This, lpReadyState);
873 *lpReadyState = This->doc_host.ready_state;
877 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
879 WebBrowser *This = impl_from_IWebBrowser2(iface);
881 TRACE("(%p)->(%p)\n", This, pbOffline);
883 *pbOffline = This->doc_host.offline;
887 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
889 WebBrowser *This = impl_from_IWebBrowser2(iface);
891 TRACE("(%p)->(%x)\n", This, bOffline);
893 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
897 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
899 WebBrowser *This = impl_from_IWebBrowser2(iface);
901 TRACE("(%p)->(%p)\n", This, pbSilent);
903 *pbSilent = This->doc_host.silent;
907 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
909 WebBrowser *This = impl_from_IWebBrowser2(iface);
911 TRACE("(%p)->(%x)\n", This, bSilent);
913 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
917 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
918 VARIANT_BOOL *pbRegister)
920 WebBrowser *This = impl_from_IWebBrowser2(iface);
922 FIXME("(%p)->(%p)\n", This, pbRegister);
924 *pbRegister = This->register_browser;
928 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
929 VARIANT_BOOL bRegister)
931 WebBrowser *This = impl_from_IWebBrowser2(iface);
933 FIXME("(%p)->(%x)\n", This, bRegister);
935 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
939 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
940 VARIANT_BOOL *pbRegister)
942 WebBrowser *This = impl_from_IWebBrowser2(iface);
943 FIXME("(%p)->(%p)\n", This, pbRegister);
948 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
949 VARIANT_BOOL bRegister)
951 WebBrowser *This = impl_from_IWebBrowser2(iface);
952 FIXME("(%p)->(%x)\n", This, bRegister);
956 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
958 WebBrowser *This = impl_from_IWebBrowser2(iface);
960 TRACE("(%p)->(%p)\n", This, pbRegister);
962 *pbRegister = This->theater_mode;
966 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
968 WebBrowser *This = impl_from_IWebBrowser2(iface);
970 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
972 TRACE("(%p)->(%x)\n", This, bRegister);
974 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
976 /* In opposition to InternetExplorer, all we should do here is
977 * inform the embedder about the theater mode change. */
979 V_VT(&arg) = VT_BOOL;
980 V_BOOL(&arg) = bRegister;
981 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
986 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
988 WebBrowser *This = impl_from_IWebBrowser2(iface);
990 TRACE("(%p)->(%p)\n", This, Value);
992 *Value = This->address_bar;
996 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
998 WebBrowser *This = impl_from_IWebBrowser2(iface);
1000 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1002 TRACE("(%p)->(%x)\n", This, Value);
1004 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
1006 /* In opposition to InternetExplorer, all we should do here is
1007 * inform the embedder about the address bar change. */
1009 V_VT(&arg) = VT_BOOL;
1010 V_BOOL(&arg) = Value;
1011 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
1016 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1018 WebBrowser *This = impl_from_IWebBrowser2(iface);
1020 TRACE("(%p)->(%p)\n", This, Value);
1022 /* It's InternetExplorer object's method. We have nothing to do here. */
1026 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
1028 WebBrowser *This = impl_from_IWebBrowser2(iface);
1030 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1032 TRACE("(%p)->(%x)\n", This, Value);
1034 /* In opposition to InternetExplorer, all we should do here is
1035 * inform the embedder about the resizable change. */
1037 V_VT(&arg) = VT_BOOL;
1038 V_BOOL(&arg) = Value;
1039 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
1044 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
1046 WebBrowser_QueryInterface,
1049 WebBrowser_GetTypeInfoCount,
1050 WebBrowser_GetTypeInfo,
1051 WebBrowser_GetIDsOfNames,
1054 WebBrowser_GoForward,
1056 WebBrowser_GoSearch,
1057 WebBrowser_Navigate,
1059 WebBrowser_Refresh2,
1061 WebBrowser_get_Application,
1062 WebBrowser_get_Parent,
1063 WebBrowser_get_Container,
1064 WebBrowser_get_Document,
1065 WebBrowser_get_TopLevelContainer,
1066 WebBrowser_get_Type,
1067 WebBrowser_get_Left,
1068 WebBrowser_put_Left,
1071 WebBrowser_get_Width,
1072 WebBrowser_put_Width,
1073 WebBrowser_get_Height,
1074 WebBrowser_put_Height,
1075 WebBrowser_get_LocationName,
1076 WebBrowser_get_LocationURL,
1077 WebBrowser_get_Busy,
1079 WebBrowser_ClientToWindow,
1080 WebBrowser_PutProperty,
1081 WebBrowser_GetProperty,
1082 WebBrowser_get_Name,
1083 WebBrowser_get_HWND,
1084 WebBrowser_get_FullName,
1085 WebBrowser_get_Path,
1086 WebBrowser_get_Visible,
1087 WebBrowser_put_Visible,
1088 WebBrowser_get_StatusBar,
1089 WebBrowser_put_StatusBar,
1090 WebBrowser_get_StatusText,
1091 WebBrowser_put_StatusText,
1092 WebBrowser_get_ToolBar,
1093 WebBrowser_put_ToolBar,
1094 WebBrowser_get_MenuBar,
1095 WebBrowser_put_MenuBar,
1096 WebBrowser_get_FullScreen,
1097 WebBrowser_put_FullScreen,
1098 WebBrowser_Navigate2,
1099 WebBrowser_QueryStatusWB,
1101 WebBrowser_ShowBrowserBar,
1102 WebBrowser_get_ReadyState,
1103 WebBrowser_get_Offline,
1104 WebBrowser_put_Offline,
1105 WebBrowser_get_Silent,
1106 WebBrowser_put_Silent,
1107 WebBrowser_get_RegisterAsBrowser,
1108 WebBrowser_put_RegisterAsBrowser,
1109 WebBrowser_get_RegisterAsDropTarget,
1110 WebBrowser_put_RegisterAsDropTarget,
1111 WebBrowser_get_TheaterMode,
1112 WebBrowser_put_TheaterMode,
1113 WebBrowser_get_AddressBar,
1114 WebBrowser_put_AddressBar,
1115 WebBrowser_get_Resizable,
1116 WebBrowser_put_Resizable
1119 static inline WebBrowser *impl_from_IServiceProvider(IServiceProvider *iface)
1121 return CONTAINING_RECORD(iface, WebBrowser, IServiceProvider_iface);
1124 static HRESULT WINAPI WBServiceProvider_QueryInterface(IServiceProvider *iface,
1125 REFIID riid, LPVOID *ppv)
1127 WebBrowser *This = impl_from_IServiceProvider(iface);
1128 return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
1131 static ULONG WINAPI WBServiceProvider_AddRef(IServiceProvider *iface)
1133 WebBrowser *This = impl_from_IServiceProvider(iface);
1134 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
1137 static ULONG WINAPI WBServiceProvider_Release(IServiceProvider *iface)
1139 WebBrowser *This = impl_from_IServiceProvider(iface);
1140 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
1143 static HRESULT STDMETHODCALLTYPE WBServiceProvider_QueryService(IServiceProvider *iface,
1144 REFGUID guidService, REFIID riid, void **ppv)
1146 WebBrowser *This = impl_from_IServiceProvider(iface);
1148 if(IsEqualGUID(&SID_SHTMLWindow, riid)) {
1149 TRACE("(%p)->(SID_SHTMLWindow)\n", This);
1150 return IHTMLWindow2_QueryInterface(&This->doc_host.html_window.IHTMLWindow2_iface, riid, ppv);
1153 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1154 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1159 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1161 return E_NOINTERFACE;
1164 static const IServiceProviderVtbl ServiceProviderVtbl =
1166 WBServiceProvider_QueryInterface,
1167 WBServiceProvider_AddRef,
1168 WBServiceProvider_Release,
1169 WBServiceProvider_QueryService
1172 static inline WebBrowser *impl_from_DocHost(DocHost *iface)
1174 return CONTAINING_RECORD(iface, WebBrowser, doc_host);
1177 static ULONG WebBrowser_addref(DocHost *iface)
1179 WebBrowser *This = impl_from_DocHost(iface);
1180 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
1183 static ULONG WebBrowser_release(DocHost *iface)
1185 WebBrowser *This = impl_from_DocHost(iface);
1186 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
1189 static void WINAPI DocHostContainer_GetDocObjRect(DocHost* This, RECT* rc)
1191 GetClientRect(This->frame_hwnd, rc);
1194 static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost* This, LPCWSTR text)
1199 static void WINAPI DocHostContainer_SetURL(DocHost* This, LPCWSTR url)
1204 static HRESULT DocHostContainer_exec(DocHost *doc_host, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in,
1207 WebBrowser *This = impl_from_DocHost(doc_host);
1208 IOleCommandTarget *cmdtrg = NULL;
1212 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
1217 if(!cmdtrg && This->container) {
1218 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (void**)&cmdtrg);
1226 hres = IOleCommandTarget_Exec(cmdtrg, cmd_group, cmdid, execopt, in, out);
1227 IOleCommandTarget_Release(cmdtrg);
1229 TRACE("Exec returned %08x %s\n", hres, debugstr_variant(out));
1231 FIXME("Exec failed\n");
1236 static const IDocHostContainerVtbl DocHostContainerVtbl = {
1239 DocHostContainer_GetDocObjRect,
1240 DocHostContainer_SetStatusText,
1241 DocHostContainer_SetURL,
1242 DocHostContainer_exec
1245 static HRESULT create_webbrowser(int version, IUnknown *outer, REFIID riid, void **ppv)
1250 TRACE("(%p %s %p) version=%d\n", outer, debugstr_guid(riid), ppv, version);
1252 ret = heap_alloc_zero(sizeof(WebBrowser));
1254 ret->IWebBrowser2_iface.lpVtbl = &WebBrowser2Vtbl;
1255 ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
1257 ret->version = version;
1259 DocHost_Init(&ret->doc_host, &ret->IWebBrowser2_iface, &DocHostContainerVtbl);
1261 ret->visible = VARIANT_TRUE;
1262 ret->menu_bar = VARIANT_TRUE;
1263 ret->address_bar = VARIANT_TRUE;
1264 ret->status_bar = VARIANT_TRUE;
1265 ret->tool_bar = VARIANT_TRUE;
1267 WebBrowser_OleObject_Init(ret);
1268 WebBrowser_ViewObject_Init(ret);
1269 WebBrowser_Persist_Init(ret);
1270 WebBrowser_ClassInfo_Init(ret);
1272 HlinkFrame_Init(&ret->hlink_frame, (IUnknown*)&ret->IWebBrowser2_iface, &ret->doc_host);
1276 hres = IWebBrowser2_QueryInterface(&ret->IWebBrowser2_iface, riid, ppv);
1278 IWebBrowser2_Release(&ret->IWebBrowser2_iface);
1282 HRESULT WINAPI WebBrowserV1_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1284 return create_webbrowser(1, pOuter, riid, ppv);
1287 HRESULT WINAPI WebBrowser_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1289 return create_webbrowser(2, pOuter, riid, ppv);