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);
728 TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers);
736 if(V_VT(URL) != VT_BSTR) {
737 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
741 return navigate_url(&This->doc_host, V_BSTR(URL), Flags, TargetFrameName, PostData, Headers);
744 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
746 WebBrowser *This = WEBBROWSER_THIS(iface);
747 FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
751 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
752 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
754 WebBrowser *This = WEBBROWSER_THIS(iface);
755 FIXME("(%p)->(%d %d %p %p)\n", This, cmdID, cmdexecopt, pvaIn, pvaOut);
759 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
760 VARIANT *pvarShow, VARIANT *pvarSize)
762 WebBrowser *This = WEBBROWSER_THIS(iface);
763 FIXME("(%p)->(%p %p %p)\n", This, pvaClsid, pvarShow, pvarSize);
767 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
769 WebBrowser *This = WEBBROWSER_THIS(iface);
770 FIXME("(%p)->(%p)\n", This, lpReadyState);
772 *lpReadyState = READYSTATE_COMPLETE;
776 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
778 WebBrowser *This = WEBBROWSER_THIS(iface);
780 TRACE("(%p)->(%p)\n", This, pbOffline);
782 *pbOffline = This->doc_host.offline;
786 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
788 WebBrowser *This = WEBBROWSER_THIS(iface);
790 TRACE("(%p)->(%x)\n", This, bOffline);
792 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
796 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
798 WebBrowser *This = WEBBROWSER_THIS(iface);
800 TRACE("(%p)->(%p)\n", This, pbSilent);
802 *pbSilent = This->doc_host.silent;
806 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
808 WebBrowser *This = WEBBROWSER_THIS(iface);
810 TRACE("(%p)->(%x)\n", This, bSilent);
812 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
816 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
817 VARIANT_BOOL *pbRegister)
819 WebBrowser *This = WEBBROWSER_THIS(iface);
821 FIXME("(%p)->(%p)\n", This, pbRegister);
823 *pbRegister = This->register_browser;
827 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
828 VARIANT_BOOL bRegister)
830 WebBrowser *This = WEBBROWSER_THIS(iface);
832 FIXME("(%p)->(%x)\n", This, bRegister);
834 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
838 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
839 VARIANT_BOOL *pbRegister)
841 WebBrowser *This = WEBBROWSER_THIS(iface);
842 FIXME("(%p)->(%p)\n", This, pbRegister);
847 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
848 VARIANT_BOOL bRegister)
850 WebBrowser *This = WEBBROWSER_THIS(iface);
851 FIXME("(%p)->(%x)\n", This, bRegister);
855 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
857 WebBrowser *This = WEBBROWSER_THIS(iface);
859 TRACE("(%p)->(%p)\n", This, pbRegister);
861 *pbRegister = This->theater_mode;
865 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
867 WebBrowser *This = WEBBROWSER_THIS(iface);
869 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
871 TRACE("(%p)->(%x)\n", This, bRegister);
873 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
875 /* In opposition to InternetExplorer, all we should do here is
876 * inform the embedder about the theater mode change. */
878 V_VT(&arg) = VT_BOOL;
879 V_BOOL(&arg) = bRegister;
880 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
885 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
887 WebBrowser *This = WEBBROWSER_THIS(iface);
889 TRACE("(%p)->(%p)\n", This, Value);
891 *Value = This->address_bar;
895 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
897 WebBrowser *This = WEBBROWSER_THIS(iface);
899 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
901 TRACE("(%p)->(%x)\n", This, Value);
903 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
905 /* In opposition to InternetExplorer, all we should do here is
906 * inform the embedder about the address bar change. */
908 V_VT(&arg) = VT_BOOL;
909 V_BOOL(&arg) = Value;
910 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
915 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
917 WebBrowser *This = WEBBROWSER_THIS(iface);
919 TRACE("(%p)->(%p)\n", This, Value);
921 /* It's InternetExplorer object's method. We have nothing to do here. */
925 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
927 WebBrowser *This = WEBBROWSER_THIS(iface);
929 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
931 TRACE("(%p)->(%x)\n", This, Value);
933 /* In opposition to InternetExplorer, all we should do here is
934 * inform the embedder about the resizable change. */
936 V_VT(&arg) = VT_BOOL;
937 V_BOOL(&arg) = Value;
938 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
943 #undef WEBBROWSER_THIS
945 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
947 WebBrowser_QueryInterface,
950 WebBrowser_GetTypeInfoCount,
951 WebBrowser_GetTypeInfo,
952 WebBrowser_GetIDsOfNames,
955 WebBrowser_GoForward,
962 WebBrowser_get_Application,
963 WebBrowser_get_Parent,
964 WebBrowser_get_Container,
965 WebBrowser_get_Document,
966 WebBrowser_get_TopLevelContainer,
972 WebBrowser_get_Width,
973 WebBrowser_put_Width,
974 WebBrowser_get_Height,
975 WebBrowser_put_Height,
976 WebBrowser_get_LocationName,
977 WebBrowser_get_LocationURL,
980 WebBrowser_ClientToWindow,
981 WebBrowser_PutProperty,
982 WebBrowser_GetProperty,
985 WebBrowser_get_FullName,
987 WebBrowser_get_Visible,
988 WebBrowser_put_Visible,
989 WebBrowser_get_StatusBar,
990 WebBrowser_put_StatusBar,
991 WebBrowser_get_StatusText,
992 WebBrowser_put_StatusText,
993 WebBrowser_get_ToolBar,
994 WebBrowser_put_ToolBar,
995 WebBrowser_get_MenuBar,
996 WebBrowser_put_MenuBar,
997 WebBrowser_get_FullScreen,
998 WebBrowser_put_FullScreen,
999 WebBrowser_Navigate2,
1000 WebBrowser_QueryStatusWB,
1002 WebBrowser_ShowBrowserBar,
1003 WebBrowser_get_ReadyState,
1004 WebBrowser_get_Offline,
1005 WebBrowser_put_Offline,
1006 WebBrowser_get_Silent,
1007 WebBrowser_put_Silent,
1008 WebBrowser_get_RegisterAsBrowser,
1009 WebBrowser_put_RegisterAsBrowser,
1010 WebBrowser_get_RegisterAsDropTarget,
1011 WebBrowser_put_RegisterAsDropTarget,
1012 WebBrowser_get_TheaterMode,
1013 WebBrowser_put_TheaterMode,
1014 WebBrowser_get_AddressBar,
1015 WebBrowser_put_AddressBar,
1016 WebBrowser_get_Resizable,
1017 WebBrowser_put_Resizable
1020 #define SERVPROV_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
1022 * IServiceProvider interface.
1024 static HRESULT WINAPI WebBrowser_IServiceProvider_QueryInterface(IServiceProvider *iface,
1025 REFIID riid, LPVOID *ppv)
1027 WebBrowser *This = SERVPROV_THIS(iface);
1033 if(IsEqualGUID(&IID_IUnknown, riid)) {
1034 *ppv = WEBBROWSER(This);
1035 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1036 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1037 *ppv = WEBBROWSER(This);
1038 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
1042 IUnknown_AddRef((IUnknown*)*ppv);
1046 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
1047 return E_NOINTERFACE;
1050 static ULONG WINAPI WebBrowser_IServiceProvider_AddRef(IServiceProvider *iface)
1052 WebBrowser *This = SERVPROV_THIS(iface);
1053 return IWebBrowser_AddRef(WEBBROWSER(This));
1056 static ULONG WINAPI WebBrowser_IServiceProvider_Release(IServiceProvider *iface)
1058 WebBrowser *This = SERVPROV_THIS(iface);
1059 return IWebBrowser_Release(WEBBROWSER(This));
1062 static HRESULT STDMETHODCALLTYPE WebBrowser_IServiceProvider_QueryService(IServiceProvider *iface,
1063 REFGUID guidService, REFIID riid, void **ppv)
1065 WebBrowser *This = SERVPROV_THIS(iface);
1066 static const IID IID_IBrowserService2 =
1067 {0x68BD21CC,0x438B,0x11d2,{0xA5,0x60,0x00,0xA0,0xC,0x2D,0xBF,0xE8}};
1072 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1073 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1077 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1079 return E_NOINTERFACE;
1082 #undef SERVPROV_THIS
1084 static const IServiceProviderVtbl ServiceProviderVtbl =
1086 WebBrowser_IServiceProvider_QueryInterface,
1087 WebBrowser_IServiceProvider_AddRef,
1088 WebBrowser_IServiceProvider_Release,
1089 WebBrowser_IServiceProvider_QueryService
1092 static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, void **ppv)
1097 TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
1099 ret = heap_alloc(sizeof(WebBrowser));
1101 ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
1102 ret->lpServiceProviderVtbl = &ServiceProviderVtbl;
1104 ret->version = version;
1106 DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
1108 ret->register_browser = VARIANT_FALSE;
1109 ret->visible = VARIANT_TRUE;
1110 ret->menu_bar = VARIANT_TRUE;
1111 ret->address_bar = VARIANT_TRUE;
1112 ret->status_bar = VARIANT_TRUE;
1113 ret->tool_bar = VARIANT_TRUE;
1114 ret->full_screen = VARIANT_FALSE;
1115 ret->theater_mode = VARIANT_FALSE;
1117 WebBrowser_OleObject_Init(ret);
1118 WebBrowser_ViewObject_Init(ret);
1119 WebBrowser_Persist_Init(ret);
1120 WebBrowser_ClassInfo_Init(ret);
1121 WebBrowser_HlinkFrame_Init(ret);
1123 hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
1124 if(SUCCEEDED(hres)) {
1125 SHDOCVW_LockModule();
1134 HRESULT WebBrowserV1_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1136 return WebBrowser_Create(1, pOuter, riid, ppv);
1139 HRESULT WebBrowserV2_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1141 return WebBrowser_Create(2, pOuter, riid, ppv);