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 "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
28 /**********************************************************************
29 * Implement the IWebBrowser interface
32 #define WEBBROWSER_THIS(iface) DEFINE_THIS(WebBrowser, WebBrowser2, iface)
34 static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
36 WebBrowser *This = WEBBROWSER_THIS(iface);
42 if(IsEqualGUID(&IID_IUnknown, riid)) {
43 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
44 *ppv = WEBBROWSER(This);
45 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
46 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
47 *ppv = WEBBROWSER(This);
48 }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
49 TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
50 *ppv = WEBBROWSER(This);
51 }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
52 TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
53 *ppv = WEBBROWSER(This);
54 }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
55 TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
56 *ppv = WEBBROWSER(This);
57 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
58 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
60 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
61 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
62 *ppv = INPLACEOBJ(This);
63 }else if(IsEqualGUID (&IID_IOleInPlaceObject, riid)) {
64 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
65 *ppv = INPLACEOBJ(This);
66 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
67 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
69 }else if(IsEqualGUID(&IID_IPersist, riid)) {
70 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
71 *ppv = PERSTORAGE(This);
72 }else if(IsEqualGUID(&IID_IPersistStorage, riid)) {
73 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
74 *ppv = PERSTORAGE(This);
75 }else if(IsEqualGUID(&IID_IPersistMemory, riid)) {
76 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
77 *ppv = PERMEMORY(This);
78 }else if(IsEqualGUID (&IID_IPersistStreamInit, riid)) {
79 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
80 *ppv = PERSTRINIT(This);
81 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
82 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
83 *ppv = CLASSINFO(This);
84 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
85 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
86 *ppv = CLASSINFO(This);
87 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
88 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
89 *ppv = CONPTCONT(&This->doc_host.cps);
90 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
91 TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
93 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
94 TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
95 *ppv = VIEWOBJ2(This);
96 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
97 TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
98 *ppv = ACTIVEOBJ(This);
99 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
100 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
102 }else if(IsEqualGUID(&IID_IHlinkFrame, riid)) {
103 TRACE("(%p)->(IID_IHlinkFrame %p)\n", This, ppv);
104 *ppv = HLINKFRAME(This);
105 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
106 *ppv = SERVPROV(This);
107 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
108 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
109 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
110 return E_NOINTERFACE;
111 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
112 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
113 return E_NOINTERFACE;
114 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
115 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
116 return E_NOINTERFACE;
117 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
118 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
119 return E_NOINTERFACE;
120 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
121 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
122 return E_NOINTERFACE;
123 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
124 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
125 return E_NOINTERFACE;
126 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
127 TRACE("(%p)->(IID_IViewObjectEx %p) returning NULL\n", This, ppv);
128 return E_NOINTERFACE;
132 IUnknown_AddRef((IUnknown*)*ppv);
136 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
137 return E_NOINTERFACE;
140 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
142 WebBrowser *This = WEBBROWSER_THIS(iface);
143 LONG ref = InterlockedIncrement(&This->ref);
144 TRACE("(%p) ref=%d\n", This, ref);
148 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
150 WebBrowser *This = WEBBROWSER_THIS(iface);
151 LONG ref = InterlockedDecrement(&This->ref);
153 TRACE("(%p) ref=%d\n", This, ref);
156 if(This->doc_host.document)
157 IUnknown_Release(This->doc_host.document);
159 DocHost_Release(&This->doc_host);
161 WebBrowser_OleObject_Destroy(This);
164 SHDOCVW_UnlockModule();
170 /* IDispatch methods */
171 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
173 WebBrowser *This = WEBBROWSER_THIS(iface);
175 TRACE("(%p)->(%p)\n", This, pctinfo);
181 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
184 WebBrowser *This = WEBBROWSER_THIS(iface);
188 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
190 hres = get_typeinfo(&typeinfo);
194 ITypeInfo_AddRef(typeinfo);
199 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
200 LPOLESTR *rgszNames, UINT cNames,
201 LCID lcid, DISPID *rgDispId)
203 WebBrowser *This = WEBBROWSER_THIS(iface);
207 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
210 hres = get_typeinfo(&typeinfo);
214 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
217 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
218 REFIID riid, LCID lcid, WORD wFlags,
219 DISPPARAMS *pDispParams, VARIANT *pVarResult,
220 EXCEPINFO *pExepInfo, UINT *puArgErr)
222 WebBrowser *This = WEBBROWSER_THIS(iface);
226 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
227 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
229 hres = get_typeinfo(&typeinfo);
233 return ITypeInfo_Invoke(typeinfo, WEBBROWSER2(This), dispIdMember, wFlags, pDispParams,
234 pVarResult, pExepInfo, puArgErr);
237 /* IWebBrowser methods */
238 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
240 WebBrowser *This = WEBBROWSER_THIS(iface);
241 FIXME("(%p)\n", This);
245 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
247 WebBrowser *This = WEBBROWSER_THIS(iface);
248 FIXME("(%p)\n", This);
252 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
254 WebBrowser *This = WEBBROWSER_THIS(iface);
255 TRACE("(%p)\n", This);
256 return go_home(&This->doc_host);
259 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
261 WebBrowser *This = WEBBROWSER_THIS(iface);
262 FIXME("(%p)\n", This);
266 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
267 VARIANT *Flags, VARIANT *TargetFrameName,
268 VARIANT *PostData, VARIANT *Headers)
270 WebBrowser *This = WEBBROWSER_THIS(iface);
272 TRACE("(%p)->(%s %p %p %p %p)\n", This, debugstr_w(szUrl), Flags, TargetFrameName,
275 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
278 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
280 WebBrowser *This = WEBBROWSER_THIS(iface);
281 FIXME("(%p)\n", This);
285 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
287 WebBrowser *This = WEBBROWSER_THIS(iface);
288 FIXME("(%p)->(%p)\n", This, Level);
292 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
294 WebBrowser *This = WEBBROWSER_THIS(iface);
295 FIXME("(%p)\n", This);
299 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
301 WebBrowser *This = WEBBROWSER_THIS(iface);
303 TRACE("(%p)->(%p)\n", This, ppDisp);
308 *ppDisp = (IDispatch*)WEBBROWSER2(This);
309 IDispatch_AddRef(*ppDisp);
313 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
315 WebBrowser *This = WEBBROWSER_THIS(iface);
316 FIXME("(%p)->(%p)\n", This, ppDisp);
320 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
322 WebBrowser *This = WEBBROWSER_THIS(iface);
323 FIXME("(%p)->(%p)\n", This, ppDisp);
327 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
329 WebBrowser *This = WEBBROWSER_THIS(iface);
331 TRACE("(%p)->(%p)\n", This, ppDisp);
334 if(This->doc_host.document)
335 IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)ppDisp);
340 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
342 WebBrowser *This = WEBBROWSER_THIS(iface);
343 FIXME("(%p)->(%p)\n", This, pBool);
347 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
349 WebBrowser *This = WEBBROWSER_THIS(iface);
350 FIXME("(%p)->(%p)\n", This, Type);
354 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
356 WebBrowser *This = WEBBROWSER_THIS(iface);
358 TRACE("(%p)->(%p)\n", This, pl);
360 *pl = This->pos_rect.left;
364 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
366 WebBrowser *This = WEBBROWSER_THIS(iface);
369 TRACE("(%p)->(%d)\n", This, Left);
374 rect = This->pos_rect;
377 /* We don't really change the window position here.
378 * We just notify the embedder that he should do so. */
379 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
382 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
384 WebBrowser *This = WEBBROWSER_THIS(iface);
386 TRACE("(%p)->(%p)\n", This, pl);
388 *pl = This->pos_rect.top;
392 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
394 WebBrowser *This = WEBBROWSER_THIS(iface);
397 TRACE("(%p)->(%d)\n", This, Top);
402 rect = This->pos_rect;
405 /* We don't really change the window position here.
406 * We just notify the embedder that he should do so. */
407 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
410 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
412 WebBrowser *This = WEBBROWSER_THIS(iface);
414 TRACE("(%p)->(%p)\n", This, pl);
416 *pl = This->pos_rect.right - This->pos_rect.left;
420 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
422 WebBrowser *This = WEBBROWSER_THIS(iface);
425 TRACE("(%p)->(%d)\n", This, Width);
430 rect = This->pos_rect;
431 rect.right = rect.left+Width;
433 /* We don't really change the window size here.
434 * We just notify the embedder that he should do so. */
435 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
438 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
440 WebBrowser *This = WEBBROWSER_THIS(iface);
442 TRACE("(%p)->(%p)\n", This, pl);
444 *pl = This->pos_rect.bottom - This->pos_rect.top;
448 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
450 WebBrowser *This = WEBBROWSER_THIS(iface);
453 TRACE("(%p)->(%d)\n", This, Height);
458 rect = This->pos_rect;
459 rect.bottom = rect.top+Height;
461 /* We don't really change the window size here.
462 * We just notify the embedder that he should do so. */
463 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
466 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
468 WebBrowser *This = WEBBROWSER_THIS(iface);
469 FIXME("(%p)->(%p)\n", This, LocationName);
473 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
475 WebBrowser *This = WEBBROWSER_THIS(iface);
477 FIXME("(%p)->(%p)\n", This, LocationURL);
479 if(!This->doc_host.url) {
480 static const WCHAR null_char = 0;
481 *LocationURL = SysAllocString(&null_char);
485 *LocationURL = SysAllocString(This->doc_host.url);
489 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
491 WebBrowser *This = WEBBROWSER_THIS(iface);
493 TRACE("(%p)->(%p)\n", This, pBool);
495 *pBool = This->doc_host.busy;
499 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
501 WebBrowser *This = WEBBROWSER_THIS(iface);
503 TRACE("(%p)\n", This);
505 /* It's a InternetExplorer specific method, we have nothing to do here. */
509 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
511 WebBrowser *This = WEBBROWSER_THIS(iface);
512 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
516 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
518 WebBrowser *This = WEBBROWSER_THIS(iface);
519 FIXME("(%p)->(%s)\n", This, debugstr_w(szProperty));
523 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
525 WebBrowser *This = WEBBROWSER_THIS(iface);
526 FIXME("(%p)->(%s %p)\n", This, debugstr_w(szProperty), pvtValue);
530 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
532 WebBrowser *This = WEBBROWSER_THIS(iface);
533 FIXME("(%p)->(%p)\n", This, Name);
537 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND)
539 WebBrowser *This = WEBBROWSER_THIS(iface);
541 TRACE("(%p)->(%p)\n", This, pHWND);
543 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
548 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
550 WebBrowser *This = WEBBROWSER_THIS(iface);
551 FIXME("(%p)->(%p)\n", This, FullName);
555 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
557 WebBrowser *This = WEBBROWSER_THIS(iface);
558 FIXME("(%p)->(%p)\n", This, Path);
562 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
564 WebBrowser *This = WEBBROWSER_THIS(iface);
566 TRACE("(%p)->(%p)\n", This, pBool);
568 *pBool = This->visible;
572 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
574 WebBrowser *This = WEBBROWSER_THIS(iface);
576 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
578 TRACE("(%p)->(%x)\n", This, Value);
580 This->visible = Value;
582 V_VT(&arg) = VT_BOOL;
583 V_BOOL(&arg) = Value;
584 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
589 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
591 WebBrowser *This = WEBBROWSER_THIS(iface);
593 TRACE("(%p)->(%p)\n", This, pBool);
595 *pBool = This->status_bar;
599 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
601 WebBrowser *This = WEBBROWSER_THIS(iface);
603 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
605 TRACE("(%p)->(%x)\n", This, Value);
607 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
609 /* In opposition to InternetExplorer, all we should do here is
610 * inform the embedder about the status bar change. */
612 V_VT(&arg) = VT_BOOL;
613 V_BOOL(&arg) = Value;
614 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
619 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
621 WebBrowser *This = WEBBROWSER_THIS(iface);
622 FIXME("(%p)->(%p)\n", This, StatusText);
626 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
628 WebBrowser *This = WEBBROWSER_THIS(iface);
629 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
633 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
635 WebBrowser *This = WEBBROWSER_THIS(iface);
637 TRACE("(%p)->(%p)\n", This, Value);
639 *Value = This->tool_bar;
643 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
645 WebBrowser *This = WEBBROWSER_THIS(iface);
647 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
649 TRACE("(%p)->(%x)\n", This, Value);
651 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
653 /* In opposition to InternetExplorer, all we should do here is
654 * inform the embedder about the tool bar change. */
656 V_VT(&arg) = VT_BOOL;
657 V_BOOL(&arg) = This->tool_bar;
658 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
663 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
665 WebBrowser *This = WEBBROWSER_THIS(iface);
667 TRACE("(%p)->(%p)\n", This, Value);
669 *Value = This->menu_bar;
673 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
675 WebBrowser *This = WEBBROWSER_THIS(iface);
677 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
679 TRACE("(%p)->(%x)\n", This, Value);
681 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
683 /* In opposition to InternetExplorer, all we should do here is
684 * inform the embedder about the menu bar change. */
686 V_VT(&arg) = VT_BOOL;
687 V_BOOL(&arg) = Value;
688 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
693 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
695 WebBrowser *This = WEBBROWSER_THIS(iface);
697 TRACE("(%p)->(%p)\n", This, pbFullScreen);
699 *pbFullScreen = This->full_screen;
703 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
705 WebBrowser *This = WEBBROWSER_THIS(iface);
707 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
709 /* In opposition to InternetExplorer, all we should do here is
710 * inform the embedder about the fullscreen change. */
712 TRACE("(%p)->(%x)\n", This, bFullScreen);
714 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
716 V_VT(&arg) = VT_BOOL;
717 V_BOOL(&arg) = bFullScreen;
718 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
723 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
724 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
726 WebBrowser *This = WEBBROWSER_THIS(iface);
729 TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers);
742 case VT_BSTR|VT_BYREF:
743 url = *V_BSTRREF(URL);
746 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
750 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
753 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
755 WebBrowser *This = WEBBROWSER_THIS(iface);
756 FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
760 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
761 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
763 WebBrowser *This = WEBBROWSER_THIS(iface);
764 FIXME("(%p)->(%d %d %p %p)\n", This, cmdID, cmdexecopt, pvaIn, pvaOut);
768 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
769 VARIANT *pvarShow, VARIANT *pvarSize)
771 WebBrowser *This = WEBBROWSER_THIS(iface);
772 FIXME("(%p)->(%p %p %p)\n", This, pvaClsid, pvarShow, pvarSize);
776 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
778 WebBrowser *This = WEBBROWSER_THIS(iface);
780 TRACE("(%p)->(%p)\n", This, lpReadyState);
782 *lpReadyState = This->doc_host.ready_state;
786 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
788 WebBrowser *This = WEBBROWSER_THIS(iface);
790 TRACE("(%p)->(%p)\n", This, pbOffline);
792 *pbOffline = This->doc_host.offline;
796 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
798 WebBrowser *This = WEBBROWSER_THIS(iface);
800 TRACE("(%p)->(%x)\n", This, bOffline);
802 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
806 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
808 WebBrowser *This = WEBBROWSER_THIS(iface);
810 TRACE("(%p)->(%p)\n", This, pbSilent);
812 *pbSilent = This->doc_host.silent;
816 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
818 WebBrowser *This = WEBBROWSER_THIS(iface);
820 TRACE("(%p)->(%x)\n", This, bSilent);
822 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
826 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
827 VARIANT_BOOL *pbRegister)
829 WebBrowser *This = WEBBROWSER_THIS(iface);
831 FIXME("(%p)->(%p)\n", This, pbRegister);
833 *pbRegister = This->register_browser;
837 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
838 VARIANT_BOOL bRegister)
840 WebBrowser *This = WEBBROWSER_THIS(iface);
842 FIXME("(%p)->(%x)\n", This, bRegister);
844 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
848 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
849 VARIANT_BOOL *pbRegister)
851 WebBrowser *This = WEBBROWSER_THIS(iface);
852 FIXME("(%p)->(%p)\n", This, pbRegister);
857 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
858 VARIANT_BOOL bRegister)
860 WebBrowser *This = WEBBROWSER_THIS(iface);
861 FIXME("(%p)->(%x)\n", This, bRegister);
865 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
867 WebBrowser *This = WEBBROWSER_THIS(iface);
869 TRACE("(%p)->(%p)\n", This, pbRegister);
871 *pbRegister = This->theater_mode;
875 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
877 WebBrowser *This = WEBBROWSER_THIS(iface);
879 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
881 TRACE("(%p)->(%x)\n", This, bRegister);
883 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
885 /* In opposition to InternetExplorer, all we should do here is
886 * inform the embedder about the theater mode change. */
888 V_VT(&arg) = VT_BOOL;
889 V_BOOL(&arg) = bRegister;
890 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
895 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
897 WebBrowser *This = WEBBROWSER_THIS(iface);
899 TRACE("(%p)->(%p)\n", This, Value);
901 *Value = This->address_bar;
905 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
907 WebBrowser *This = WEBBROWSER_THIS(iface);
909 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
911 TRACE("(%p)->(%x)\n", This, Value);
913 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
915 /* In opposition to InternetExplorer, all we should do here is
916 * inform the embedder about the address bar change. */
918 V_VT(&arg) = VT_BOOL;
919 V_BOOL(&arg) = Value;
920 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
925 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
927 WebBrowser *This = WEBBROWSER_THIS(iface);
929 TRACE("(%p)->(%p)\n", This, Value);
931 /* It's InternetExplorer object's method. We have nothing to do here. */
935 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
937 WebBrowser *This = WEBBROWSER_THIS(iface);
939 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
941 TRACE("(%p)->(%x)\n", This, Value);
943 /* In opposition to InternetExplorer, all we should do here is
944 * inform the embedder about the resizable change. */
946 V_VT(&arg) = VT_BOOL;
947 V_BOOL(&arg) = Value;
948 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
953 #undef WEBBROWSER_THIS
955 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
957 WebBrowser_QueryInterface,
960 WebBrowser_GetTypeInfoCount,
961 WebBrowser_GetTypeInfo,
962 WebBrowser_GetIDsOfNames,
965 WebBrowser_GoForward,
972 WebBrowser_get_Application,
973 WebBrowser_get_Parent,
974 WebBrowser_get_Container,
975 WebBrowser_get_Document,
976 WebBrowser_get_TopLevelContainer,
982 WebBrowser_get_Width,
983 WebBrowser_put_Width,
984 WebBrowser_get_Height,
985 WebBrowser_put_Height,
986 WebBrowser_get_LocationName,
987 WebBrowser_get_LocationURL,
990 WebBrowser_ClientToWindow,
991 WebBrowser_PutProperty,
992 WebBrowser_GetProperty,
995 WebBrowser_get_FullName,
997 WebBrowser_get_Visible,
998 WebBrowser_put_Visible,
999 WebBrowser_get_StatusBar,
1000 WebBrowser_put_StatusBar,
1001 WebBrowser_get_StatusText,
1002 WebBrowser_put_StatusText,
1003 WebBrowser_get_ToolBar,
1004 WebBrowser_put_ToolBar,
1005 WebBrowser_get_MenuBar,
1006 WebBrowser_put_MenuBar,
1007 WebBrowser_get_FullScreen,
1008 WebBrowser_put_FullScreen,
1009 WebBrowser_Navigate2,
1010 WebBrowser_QueryStatusWB,
1012 WebBrowser_ShowBrowserBar,
1013 WebBrowser_get_ReadyState,
1014 WebBrowser_get_Offline,
1015 WebBrowser_put_Offline,
1016 WebBrowser_get_Silent,
1017 WebBrowser_put_Silent,
1018 WebBrowser_get_RegisterAsBrowser,
1019 WebBrowser_put_RegisterAsBrowser,
1020 WebBrowser_get_RegisterAsDropTarget,
1021 WebBrowser_put_RegisterAsDropTarget,
1022 WebBrowser_get_TheaterMode,
1023 WebBrowser_put_TheaterMode,
1024 WebBrowser_get_AddressBar,
1025 WebBrowser_put_AddressBar,
1026 WebBrowser_get_Resizable,
1027 WebBrowser_put_Resizable
1030 #define SERVPROV_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
1032 * IServiceProvider interface.
1034 static HRESULT WINAPI WebBrowser_IServiceProvider_QueryInterface(IServiceProvider *iface,
1035 REFIID riid, LPVOID *ppv)
1037 WebBrowser *This = SERVPROV_THIS(iface);
1043 if(IsEqualGUID(&IID_IUnknown, riid)) {
1044 *ppv = WEBBROWSER(This);
1045 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1046 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1047 *ppv = WEBBROWSER(This);
1048 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
1052 IUnknown_AddRef((IUnknown*)*ppv);
1056 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
1057 return E_NOINTERFACE;
1060 static ULONG WINAPI WebBrowser_IServiceProvider_AddRef(IServiceProvider *iface)
1062 WebBrowser *This = SERVPROV_THIS(iface);
1063 return IWebBrowser_AddRef(WEBBROWSER(This));
1066 static ULONG WINAPI WebBrowser_IServiceProvider_Release(IServiceProvider *iface)
1068 WebBrowser *This = SERVPROV_THIS(iface);
1069 return IWebBrowser_Release(WEBBROWSER(This));
1072 static HRESULT STDMETHODCALLTYPE WebBrowser_IServiceProvider_QueryService(IServiceProvider *iface,
1073 REFGUID guidService, REFIID riid, void **ppv)
1075 WebBrowser *This = SERVPROV_THIS(iface);
1076 static const IID IID_IBrowserService2 =
1077 {0x68BD21CC,0x438B,0x11d2,{0xA5,0x60,0x00,0xA0,0xC,0x2D,0xBF,0xE8}};
1082 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1083 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1087 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1089 return E_NOINTERFACE;
1092 #undef SERVPROV_THIS
1094 static const IServiceProviderVtbl ServiceProviderVtbl =
1096 WebBrowser_IServiceProvider_QueryInterface,
1097 WebBrowser_IServiceProvider_AddRef,
1098 WebBrowser_IServiceProvider_Release,
1099 WebBrowser_IServiceProvider_QueryService
1102 static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, void **ppv)
1107 TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
1109 ret = heap_alloc(sizeof(WebBrowser));
1111 ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
1112 ret->lpServiceProviderVtbl = &ServiceProviderVtbl;
1114 ret->version = version;
1116 DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
1118 ret->register_browser = VARIANT_FALSE;
1119 ret->visible = VARIANT_TRUE;
1120 ret->menu_bar = VARIANT_TRUE;
1121 ret->address_bar = VARIANT_TRUE;
1122 ret->status_bar = VARIANT_TRUE;
1123 ret->tool_bar = VARIANT_TRUE;
1124 ret->full_screen = VARIANT_FALSE;
1125 ret->theater_mode = VARIANT_FALSE;
1127 WebBrowser_OleObject_Init(ret);
1128 WebBrowser_ViewObject_Init(ret);
1129 WebBrowser_Persist_Init(ret);
1130 WebBrowser_ClassInfo_Init(ret);
1131 WebBrowser_HlinkFrame_Init(ret);
1133 hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
1134 if(SUCCEEDED(hres)) {
1135 SHDOCVW_LockModule();
1144 HRESULT WebBrowserV1_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1146 return WebBrowser_Create(1, pOuter, riid, ppv);
1149 HRESULT WebBrowserV2_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1151 return WebBrowser_Create(2, pOuter, riid, ppv);