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_IDataObject, riid)) {
109 *ppv = DATAOBJECT(This);
110 TRACE("(%p)->(IID_IDataObject %p)\n", This, ppv);
111 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
112 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
113 return E_NOINTERFACE;
114 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
115 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
116 return E_NOINTERFACE;
117 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
118 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
119 return E_NOINTERFACE;
120 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
121 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
122 return E_NOINTERFACE;
123 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
124 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
125 return E_NOINTERFACE;
126 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
127 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
128 return E_NOINTERFACE;
129 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
130 TRACE("(%p)->(IID_IViewObjectEx %p) returning NULL\n", This, ppv);
131 return E_NOINTERFACE;
135 IUnknown_AddRef((IUnknown*)*ppv);
139 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
140 return E_NOINTERFACE;
143 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
145 WebBrowser *This = WEBBROWSER_THIS(iface);
146 LONG ref = InterlockedIncrement(&This->ref);
147 TRACE("(%p) ref=%d\n", This, ref);
151 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
153 WebBrowser *This = WEBBROWSER_THIS(iface);
154 LONG ref = InterlockedDecrement(&This->ref);
156 TRACE("(%p) ref=%d\n", This, ref);
159 if(This->doc_host.document)
160 IUnknown_Release(This->doc_host.document);
162 DocHost_Release(&This->doc_host);
164 WebBrowser_OleObject_Destroy(This);
167 SHDOCVW_UnlockModule();
173 /* IDispatch methods */
174 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
176 WebBrowser *This = WEBBROWSER_THIS(iface);
178 TRACE("(%p)->(%p)\n", This, pctinfo);
184 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
187 WebBrowser *This = WEBBROWSER_THIS(iface);
191 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
193 hres = get_typeinfo(&typeinfo);
197 ITypeInfo_AddRef(typeinfo);
202 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
203 LPOLESTR *rgszNames, UINT cNames,
204 LCID lcid, DISPID *rgDispId)
206 WebBrowser *This = WEBBROWSER_THIS(iface);
210 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
213 hres = get_typeinfo(&typeinfo);
217 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
220 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
221 REFIID riid, LCID lcid, WORD wFlags,
222 DISPPARAMS *pDispParams, VARIANT *pVarResult,
223 EXCEPINFO *pExepInfo, UINT *puArgErr)
225 WebBrowser *This = WEBBROWSER_THIS(iface);
229 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
230 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
232 hres = get_typeinfo(&typeinfo);
236 return ITypeInfo_Invoke(typeinfo, WEBBROWSER2(This), dispIdMember, wFlags, pDispParams,
237 pVarResult, pExepInfo, puArgErr);
240 /* IWebBrowser methods */
241 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
243 WebBrowser *This = WEBBROWSER_THIS(iface);
244 FIXME("(%p)\n", This);
248 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
250 WebBrowser *This = WEBBROWSER_THIS(iface);
251 FIXME("(%p)\n", This);
255 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
257 WebBrowser *This = WEBBROWSER_THIS(iface);
258 TRACE("(%p)\n", This);
259 return go_home(&This->doc_host);
262 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
264 WebBrowser *This = WEBBROWSER_THIS(iface);
265 FIXME("(%p)\n", This);
269 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
270 VARIANT *Flags, VARIANT *TargetFrameName,
271 VARIANT *PostData, VARIANT *Headers)
273 WebBrowser *This = WEBBROWSER_THIS(iface);
275 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
276 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
277 debugstr_variant(Headers));
279 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
282 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
284 WebBrowser *This = WEBBROWSER_THIS(iface);
285 FIXME("(%p)\n", This);
289 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
291 WebBrowser *This = WEBBROWSER_THIS(iface);
292 FIXME("(%p)->(%s)\n", This, debugstr_variant(Level));
296 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
298 WebBrowser *This = WEBBROWSER_THIS(iface);
299 FIXME("(%p)\n", This);
303 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
305 WebBrowser *This = WEBBROWSER_THIS(iface);
307 TRACE("(%p)->(%p)\n", This, ppDisp);
312 *ppDisp = (IDispatch*)WEBBROWSER2(This);
313 IDispatch_AddRef(*ppDisp);
317 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
319 WebBrowser *This = WEBBROWSER_THIS(iface);
320 FIXME("(%p)->(%p)\n", This, ppDisp);
324 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
326 WebBrowser *This = WEBBROWSER_THIS(iface);
327 FIXME("(%p)->(%p)\n", This, ppDisp);
331 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
333 WebBrowser *This = WEBBROWSER_THIS(iface);
335 TRACE("(%p)->(%p)\n", This, ppDisp);
338 if(This->doc_host.document)
339 IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)ppDisp);
344 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
346 WebBrowser *This = WEBBROWSER_THIS(iface);
347 FIXME("(%p)->(%p)\n", This, pBool);
351 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
353 WebBrowser *This = WEBBROWSER_THIS(iface);
354 FIXME("(%p)->(%p)\n", This, Type);
358 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
360 WebBrowser *This = WEBBROWSER_THIS(iface);
362 TRACE("(%p)->(%p)\n", This, pl);
364 *pl = This->pos_rect.left;
368 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
370 WebBrowser *This = WEBBROWSER_THIS(iface);
373 TRACE("(%p)->(%d)\n", This, Left);
378 rect = This->pos_rect;
381 /* We don't really change the window position here.
382 * We just notify the embedder that he should do so. */
383 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
386 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
388 WebBrowser *This = WEBBROWSER_THIS(iface);
390 TRACE("(%p)->(%p)\n", This, pl);
392 *pl = This->pos_rect.top;
396 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
398 WebBrowser *This = WEBBROWSER_THIS(iface);
401 TRACE("(%p)->(%d)\n", This, Top);
406 rect = This->pos_rect;
409 /* We don't really change the window position here.
410 * We just notify the embedder that he should do so. */
411 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
414 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
416 WebBrowser *This = WEBBROWSER_THIS(iface);
418 TRACE("(%p)->(%p)\n", This, pl);
420 *pl = This->pos_rect.right - This->pos_rect.left;
424 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
426 WebBrowser *This = WEBBROWSER_THIS(iface);
429 TRACE("(%p)->(%d)\n", This, Width);
434 rect = This->pos_rect;
435 rect.right = rect.left+Width;
437 /* We don't really change the window size here.
438 * We just notify the embedder that he should do so. */
439 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
442 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
444 WebBrowser *This = WEBBROWSER_THIS(iface);
446 TRACE("(%p)->(%p)\n", This, pl);
448 *pl = This->pos_rect.bottom - This->pos_rect.top;
452 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
454 WebBrowser *This = WEBBROWSER_THIS(iface);
457 TRACE("(%p)->(%d)\n", This, Height);
462 rect = This->pos_rect;
463 rect.bottom = rect.top+Height;
465 /* We don't really change the window size here.
466 * We just notify the embedder that he should do so. */
467 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
470 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
472 WebBrowser *This = WEBBROWSER_THIS(iface);
473 FIXME("(%p)->(%p)\n", This, LocationName);
477 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
479 WebBrowser *This = WEBBROWSER_THIS(iface);
481 FIXME("(%p)->(%p)\n", This, LocationURL);
483 if(!This->doc_host.url) {
484 static const WCHAR null_char = 0;
485 *LocationURL = SysAllocString(&null_char);
489 *LocationURL = SysAllocString(This->doc_host.url);
493 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
495 WebBrowser *This = WEBBROWSER_THIS(iface);
497 TRACE("(%p)->(%p)\n", This, pBool);
499 *pBool = This->doc_host.busy;
503 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
505 WebBrowser *This = WEBBROWSER_THIS(iface);
507 TRACE("(%p)\n", This);
509 /* It's a InternetExplorer specific method, we have nothing to do here. */
513 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
515 WebBrowser *This = WEBBROWSER_THIS(iface);
516 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
520 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
522 WebBrowser *This = WEBBROWSER_THIS(iface);
523 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
527 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
529 WebBrowser *This = WEBBROWSER_THIS(iface);
530 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
534 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
536 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
537 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
538 WebBrowser *This = WEBBROWSER_THIS(iface);
540 TRACE("(%p)->(%p)\n", This, Name);
542 *Name = SysAllocString(sName);
547 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND)
549 WebBrowser *This = WEBBROWSER_THIS(iface);
551 TRACE("(%p)->(%p)\n", This, pHWND);
553 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
558 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
560 WebBrowser *This = WEBBROWSER_THIS(iface);
561 FIXME("(%p)->(%p)\n", This, FullName);
565 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
567 WebBrowser *This = WEBBROWSER_THIS(iface);
568 FIXME("(%p)->(%p)\n", This, Path);
572 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
574 WebBrowser *This = WEBBROWSER_THIS(iface);
576 TRACE("(%p)->(%p)\n", This, pBool);
578 *pBool = This->visible;
582 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
584 WebBrowser *This = WEBBROWSER_THIS(iface);
586 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
588 TRACE("(%p)->(%x)\n", This, Value);
590 This->visible = Value;
592 V_VT(&arg) = VT_BOOL;
593 V_BOOL(&arg) = Value;
594 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
599 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
601 WebBrowser *This = WEBBROWSER_THIS(iface);
603 TRACE("(%p)->(%p)\n", This, pBool);
605 *pBool = This->status_bar;
609 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
611 WebBrowser *This = WEBBROWSER_THIS(iface);
613 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
615 TRACE("(%p)->(%x)\n", This, Value);
617 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
619 /* In opposition to InternetExplorer, all we should do here is
620 * inform the embedder about the status bar change. */
622 V_VT(&arg) = VT_BOOL;
623 V_BOOL(&arg) = Value;
624 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
629 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
631 WebBrowser *This = WEBBROWSER_THIS(iface);
632 FIXME("(%p)->(%p)\n", This, StatusText);
636 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
638 WebBrowser *This = WEBBROWSER_THIS(iface);
639 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
643 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
645 WebBrowser *This = WEBBROWSER_THIS(iface);
647 TRACE("(%p)->(%p)\n", This, Value);
649 *Value = This->tool_bar;
653 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
655 WebBrowser *This = WEBBROWSER_THIS(iface);
657 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
659 TRACE("(%p)->(%x)\n", This, Value);
661 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
663 /* In opposition to InternetExplorer, all we should do here is
664 * inform the embedder about the tool bar change. */
666 V_VT(&arg) = VT_BOOL;
667 V_BOOL(&arg) = This->tool_bar;
668 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
673 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
675 WebBrowser *This = WEBBROWSER_THIS(iface);
677 TRACE("(%p)->(%p)\n", This, Value);
679 *Value = This->menu_bar;
683 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
685 WebBrowser *This = WEBBROWSER_THIS(iface);
687 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
689 TRACE("(%p)->(%x)\n", This, Value);
691 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
693 /* In opposition to InternetExplorer, all we should do here is
694 * inform the embedder about the menu bar change. */
696 V_VT(&arg) = VT_BOOL;
697 V_BOOL(&arg) = Value;
698 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
703 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
705 WebBrowser *This = WEBBROWSER_THIS(iface);
707 TRACE("(%p)->(%p)\n", This, pbFullScreen);
709 *pbFullScreen = This->full_screen;
713 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
715 WebBrowser *This = WEBBROWSER_THIS(iface);
717 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
719 /* In opposition to InternetExplorer, all we should do here is
720 * inform the embedder about the fullscreen change. */
722 TRACE("(%p)->(%x)\n", This, bFullScreen);
724 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
726 V_VT(&arg) = VT_BOOL;
727 V_BOOL(&arg) = bFullScreen;
728 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
733 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
734 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
736 WebBrowser *This = WEBBROWSER_THIS(iface);
739 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
740 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
753 case VT_BSTR|VT_BYREF:
754 url = *V_BSTRREF(URL);
757 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
761 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
764 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
766 WebBrowser *This = WEBBROWSER_THIS(iface);
767 FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
771 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
772 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
774 WebBrowser *This = WEBBROWSER_THIS(iface);
775 FIXME("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
779 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
780 VARIANT *pvarShow, VARIANT *pvarSize)
782 WebBrowser *This = WEBBROWSER_THIS(iface);
783 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
784 debugstr_variant(pvarSize));
788 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
790 WebBrowser *This = WEBBROWSER_THIS(iface);
792 TRACE("(%p)->(%p)\n", This, lpReadyState);
794 *lpReadyState = This->doc_host.ready_state;
798 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
800 WebBrowser *This = WEBBROWSER_THIS(iface);
802 TRACE("(%p)->(%p)\n", This, pbOffline);
804 *pbOffline = This->doc_host.offline;
808 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
810 WebBrowser *This = WEBBROWSER_THIS(iface);
812 TRACE("(%p)->(%x)\n", This, bOffline);
814 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
818 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
820 WebBrowser *This = WEBBROWSER_THIS(iface);
822 TRACE("(%p)->(%p)\n", This, pbSilent);
824 *pbSilent = This->doc_host.silent;
828 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
830 WebBrowser *This = WEBBROWSER_THIS(iface);
832 TRACE("(%p)->(%x)\n", This, bSilent);
834 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
838 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
839 VARIANT_BOOL *pbRegister)
841 WebBrowser *This = WEBBROWSER_THIS(iface);
843 FIXME("(%p)->(%p)\n", This, pbRegister);
845 *pbRegister = This->register_browser;
849 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
850 VARIANT_BOOL bRegister)
852 WebBrowser *This = WEBBROWSER_THIS(iface);
854 FIXME("(%p)->(%x)\n", This, bRegister);
856 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
860 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
861 VARIANT_BOOL *pbRegister)
863 WebBrowser *This = WEBBROWSER_THIS(iface);
864 FIXME("(%p)->(%p)\n", This, pbRegister);
869 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
870 VARIANT_BOOL bRegister)
872 WebBrowser *This = WEBBROWSER_THIS(iface);
873 FIXME("(%p)->(%x)\n", This, bRegister);
877 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
879 WebBrowser *This = WEBBROWSER_THIS(iface);
881 TRACE("(%p)->(%p)\n", This, pbRegister);
883 *pbRegister = This->theater_mode;
887 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
889 WebBrowser *This = WEBBROWSER_THIS(iface);
891 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
893 TRACE("(%p)->(%x)\n", This, bRegister);
895 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
897 /* In opposition to InternetExplorer, all we should do here is
898 * inform the embedder about the theater mode change. */
900 V_VT(&arg) = VT_BOOL;
901 V_BOOL(&arg) = bRegister;
902 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
907 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
909 WebBrowser *This = WEBBROWSER_THIS(iface);
911 TRACE("(%p)->(%p)\n", This, Value);
913 *Value = This->address_bar;
917 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
919 WebBrowser *This = WEBBROWSER_THIS(iface);
921 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
923 TRACE("(%p)->(%x)\n", This, Value);
925 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
927 /* In opposition to InternetExplorer, all we should do here is
928 * inform the embedder about the address bar change. */
930 V_VT(&arg) = VT_BOOL;
931 V_BOOL(&arg) = Value;
932 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
937 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
939 WebBrowser *This = WEBBROWSER_THIS(iface);
941 TRACE("(%p)->(%p)\n", This, Value);
943 /* It's InternetExplorer object's method. We have nothing to do here. */
947 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
949 WebBrowser *This = WEBBROWSER_THIS(iface);
951 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
953 TRACE("(%p)->(%x)\n", This, Value);
955 /* In opposition to InternetExplorer, all we should do here is
956 * inform the embedder about the resizable change. */
958 V_VT(&arg) = VT_BOOL;
959 V_BOOL(&arg) = Value;
960 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
965 #undef WEBBROWSER_THIS
967 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
969 WebBrowser_QueryInterface,
972 WebBrowser_GetTypeInfoCount,
973 WebBrowser_GetTypeInfo,
974 WebBrowser_GetIDsOfNames,
977 WebBrowser_GoForward,
984 WebBrowser_get_Application,
985 WebBrowser_get_Parent,
986 WebBrowser_get_Container,
987 WebBrowser_get_Document,
988 WebBrowser_get_TopLevelContainer,
994 WebBrowser_get_Width,
995 WebBrowser_put_Width,
996 WebBrowser_get_Height,
997 WebBrowser_put_Height,
998 WebBrowser_get_LocationName,
999 WebBrowser_get_LocationURL,
1000 WebBrowser_get_Busy,
1002 WebBrowser_ClientToWindow,
1003 WebBrowser_PutProperty,
1004 WebBrowser_GetProperty,
1005 WebBrowser_get_Name,
1006 WebBrowser_get_HWND,
1007 WebBrowser_get_FullName,
1008 WebBrowser_get_Path,
1009 WebBrowser_get_Visible,
1010 WebBrowser_put_Visible,
1011 WebBrowser_get_StatusBar,
1012 WebBrowser_put_StatusBar,
1013 WebBrowser_get_StatusText,
1014 WebBrowser_put_StatusText,
1015 WebBrowser_get_ToolBar,
1016 WebBrowser_put_ToolBar,
1017 WebBrowser_get_MenuBar,
1018 WebBrowser_put_MenuBar,
1019 WebBrowser_get_FullScreen,
1020 WebBrowser_put_FullScreen,
1021 WebBrowser_Navigate2,
1022 WebBrowser_QueryStatusWB,
1024 WebBrowser_ShowBrowserBar,
1025 WebBrowser_get_ReadyState,
1026 WebBrowser_get_Offline,
1027 WebBrowser_put_Offline,
1028 WebBrowser_get_Silent,
1029 WebBrowser_put_Silent,
1030 WebBrowser_get_RegisterAsBrowser,
1031 WebBrowser_put_RegisterAsBrowser,
1032 WebBrowser_get_RegisterAsDropTarget,
1033 WebBrowser_put_RegisterAsDropTarget,
1034 WebBrowser_get_TheaterMode,
1035 WebBrowser_put_TheaterMode,
1036 WebBrowser_get_AddressBar,
1037 WebBrowser_put_AddressBar,
1038 WebBrowser_get_Resizable,
1039 WebBrowser_put_Resizable
1042 #define SERVPROV_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
1044 * IServiceProvider interface.
1046 static HRESULT WINAPI WebBrowser_IServiceProvider_QueryInterface(IServiceProvider *iface,
1047 REFIID riid, LPVOID *ppv)
1049 WebBrowser *This = SERVPROV_THIS(iface);
1055 if(IsEqualGUID(&IID_IUnknown, riid)) {
1056 *ppv = WEBBROWSER(This);
1057 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1058 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1059 *ppv = WEBBROWSER(This);
1060 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
1064 IUnknown_AddRef((IUnknown*)*ppv);
1068 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
1069 return E_NOINTERFACE;
1072 static ULONG WINAPI WebBrowser_IServiceProvider_AddRef(IServiceProvider *iface)
1074 WebBrowser *This = SERVPROV_THIS(iface);
1075 return IWebBrowser_AddRef(WEBBROWSER(This));
1078 static ULONG WINAPI WebBrowser_IServiceProvider_Release(IServiceProvider *iface)
1080 WebBrowser *This = SERVPROV_THIS(iface);
1081 return IWebBrowser_Release(WEBBROWSER(This));
1084 static HRESULT STDMETHODCALLTYPE WebBrowser_IServiceProvider_QueryService(IServiceProvider *iface,
1085 REFGUID guidService, REFIID riid, void **ppv)
1087 WebBrowser *This = SERVPROV_THIS(iface);
1088 static const IID IID_IBrowserService2 =
1089 {0x68BD21CC,0x438B,0x11d2,{0xA5,0x60,0x00,0xA0,0xC,0x2D,0xBF,0xE8}};
1094 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1095 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1099 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1101 return E_NOINTERFACE;
1104 #undef SERVPROV_THIS
1106 static const IServiceProviderVtbl ServiceProviderVtbl =
1108 WebBrowser_IServiceProvider_QueryInterface,
1109 WebBrowser_IServiceProvider_AddRef,
1110 WebBrowser_IServiceProvider_Release,
1111 WebBrowser_IServiceProvider_QueryService
1114 static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, void **ppv)
1119 TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
1121 ret = heap_alloc_zero(sizeof(WebBrowser));
1123 ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
1124 ret->lpServiceProviderVtbl = &ServiceProviderVtbl;
1126 ret->version = version;
1128 DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
1130 ret->visible = VARIANT_TRUE;
1131 ret->menu_bar = VARIANT_TRUE;
1132 ret->address_bar = VARIANT_TRUE;
1133 ret->status_bar = VARIANT_TRUE;
1134 ret->tool_bar = VARIANT_TRUE;
1136 WebBrowser_OleObject_Init(ret);
1137 WebBrowser_ViewObject_Init(ret);
1138 WebBrowser_DataObject_Init(ret);
1139 WebBrowser_Persist_Init(ret);
1140 WebBrowser_ClassInfo_Init(ret);
1141 WebBrowser_HlinkFrame_Init(ret);
1143 SHDOCVW_LockModule();
1145 hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
1147 IWebBrowser2_Release(WEBBROWSER(ret));
1151 HRESULT WebBrowserV1_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1153 return WebBrowser_Create(1, pOuter, riid, ppv);
1156 HRESULT WebBrowserV2_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1158 return WebBrowser_Create(2, pOuter, riid, ppv);