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 #include "shdeprecated.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
30 static inline WebBrowser *impl_from_IWebBrowser2(IWebBrowser2 *iface)
32 return CONTAINING_RECORD(iface, WebBrowser, IWebBrowser2_iface);
35 static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
37 WebBrowser *This = impl_from_IWebBrowser2(iface);
43 if(IsEqualGUID(&IID_IUnknown, riid)) {
44 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
45 *ppv = &This->IWebBrowser2_iface;
46 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
47 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
48 *ppv = &This->IWebBrowser2_iface;
49 }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
50 TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
51 *ppv = &This->IWebBrowser2_iface;
52 }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
53 TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
54 *ppv = &This->IWebBrowser2_iface;
55 }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
56 TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
57 *ppv = &This->IWebBrowser2_iface;
58 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
59 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
60 *ppv = &This->IOleObject_iface;
61 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
62 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
63 *ppv = &This->IOleInPlaceObject_iface;
64 }else if(IsEqualGUID (&IID_IOleInPlaceObject, riid)) {
65 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
66 *ppv = &This->IOleInPlaceObject_iface;
67 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
68 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
69 *ppv = &This->IOleControl_iface;
70 }else if(IsEqualGUID(&IID_IPersist, riid)) {
71 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
72 *ppv = &This->IPersistStorage_iface;
73 }else if(IsEqualGUID(&IID_IPersistStorage, riid)) {
74 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
75 *ppv = &This->IPersistStorage_iface;
76 }else if(IsEqualGUID(&IID_IPersistMemory, riid)) {
77 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
78 *ppv = &This->IPersistMemory_iface;
79 }else if(IsEqualGUID (&IID_IPersistStreamInit, riid)) {
80 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
81 *ppv = &This->IPersistStreamInit_iface;
82 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
83 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
84 *ppv = &This->IProvideClassInfo2_iface;
85 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
86 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
87 *ppv = &This->IProvideClassInfo2_iface;
88 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
89 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
90 *ppv = &This->doc_host.cps.IConnectionPointContainer_iface;
91 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
92 TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
93 *ppv = &This->IViewObject2_iface;
94 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
95 TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
96 *ppv = &This->IViewObject2_iface;
97 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
98 TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
99 *ppv = &This->IOleInPlaceActiveObject_iface;
100 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
101 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
102 *ppv = &This->IOleCommandTarget_iface;
103 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
104 *ppv = &This->IServiceProvider_iface;
105 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
106 }else if(IsEqualGUID(&IID_IDataObject, riid)) {
107 *ppv = &This->IDataObject_iface;
108 TRACE("(%p)->(IID_IDataObject %p)\n", This, ppv);
109 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
110 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
111 return E_NOINTERFACE;
112 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
113 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
114 return E_NOINTERFACE;
115 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
116 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
117 return E_NOINTERFACE;
118 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
119 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
120 return E_NOINTERFACE;
121 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
122 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
123 return E_NOINTERFACE;
124 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
125 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
126 return E_NOINTERFACE;
127 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
128 TRACE("(%p)->(IID_IViewObjectEx %p) returning NULL\n", This, ppv);
129 return E_NOINTERFACE;
130 }else if(IsEqualGUID(&IID_IOleLink, riid)) {
131 TRACE("(%p)->(IID_IOleLink %p) returning NULL\n", This, ppv);
132 return E_NOINTERFACE;
133 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
134 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
135 return E_NOINTERFACE;
136 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
137 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
138 return E_NOINTERFACE;
139 }else if(HlinkFrame_QI(&This->hlink_frame, riid, ppv)) {
144 IUnknown_AddRef((IUnknown*)*ppv);
148 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
149 return E_NOINTERFACE;
152 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
154 WebBrowser *This = impl_from_IWebBrowser2(iface);
155 LONG ref = InterlockedIncrement(&This->ref);
156 TRACE("(%p) ref=%d\n", This, ref);
160 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
162 WebBrowser *This = impl_from_IWebBrowser2(iface);
163 LONG ref = InterlockedDecrement(&This->ref);
165 TRACE("(%p) ref=%d\n", This, ref);
168 if(This->doc_host.document)
169 IUnknown_Release(This->doc_host.document);
171 DocHost_Release(&This->doc_host);
173 WebBrowser_OleObject_Destroy(This);
176 SHDOCVW_UnlockModule();
182 /* IDispatch methods */
183 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
185 WebBrowser *This = impl_from_IWebBrowser2(iface);
187 TRACE("(%p)->(%p)\n", This, pctinfo);
193 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
196 WebBrowser *This = impl_from_IWebBrowser2(iface);
200 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
202 hres = get_typeinfo(&typeinfo);
206 ITypeInfo_AddRef(typeinfo);
211 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
212 LPOLESTR *rgszNames, UINT cNames,
213 LCID lcid, DISPID *rgDispId)
215 WebBrowser *This = impl_from_IWebBrowser2(iface);
219 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
222 hres = get_typeinfo(&typeinfo);
226 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
229 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
230 REFIID riid, LCID lcid, WORD wFlags,
231 DISPPARAMS *pDispParams, VARIANT *pVarResult,
232 EXCEPINFO *pExepInfo, UINT *puArgErr)
234 WebBrowser *This = impl_from_IWebBrowser2(iface);
238 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
239 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
241 hres = get_typeinfo(&typeinfo);
245 return ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags, pDispParams,
246 pVarResult, pExepInfo, puArgErr);
249 /* IWebBrowser methods */
250 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
252 WebBrowser *This = impl_from_IWebBrowser2(iface);
253 FIXME("(%p)\n", This);
257 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
259 WebBrowser *This = impl_from_IWebBrowser2(iface);
260 FIXME("(%p)\n", This);
264 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
266 WebBrowser *This = impl_from_IWebBrowser2(iface);
267 TRACE("(%p)\n", This);
268 return go_home(&This->doc_host);
271 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
273 WebBrowser *This = impl_from_IWebBrowser2(iface);
274 FIXME("(%p)\n", This);
278 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
279 VARIANT *Flags, VARIANT *TargetFrameName,
280 VARIANT *PostData, VARIANT *Headers)
282 WebBrowser *This = impl_from_IWebBrowser2(iface);
284 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
285 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
286 debugstr_variant(Headers));
288 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
291 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
293 WebBrowser *This = impl_from_IWebBrowser2(iface);
294 FIXME("(%p)\n", This);
298 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
300 WebBrowser *This = impl_from_IWebBrowser2(iface);
301 FIXME("(%p)->(%s)\n", This, debugstr_variant(Level));
305 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
307 WebBrowser *This = impl_from_IWebBrowser2(iface);
308 FIXME("(%p)\n", This);
312 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
314 WebBrowser *This = impl_from_IWebBrowser2(iface);
316 TRACE("(%p)->(%p)\n", This, ppDisp);
321 *ppDisp = (IDispatch*)&This->IWebBrowser2_iface;
322 IDispatch_AddRef(*ppDisp);
326 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
328 WebBrowser *This = impl_from_IWebBrowser2(iface);
329 FIXME("(%p)->(%p)\n", This, ppDisp);
333 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
335 WebBrowser *This = impl_from_IWebBrowser2(iface);
336 FIXME("(%p)->(%p)\n", This, ppDisp);
340 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
342 WebBrowser *This = impl_from_IWebBrowser2(iface);
343 IDispatch *disp = NULL;
345 TRACE("(%p)->(%p)\n", This, ppDisp);
347 if(This->doc_host.document) {
350 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
351 if(SUCCEEDED(hres)) {
354 /* Some broken apps cast returned IDispatch to IHTMLDocument2
355 * without QueryInterface call */
356 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
357 if(SUCCEEDED(hres)) {
358 IDispatch_Release(disp);
368 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
370 WebBrowser *This = impl_from_IWebBrowser2(iface);
371 FIXME("(%p)->(%p)\n", This, pBool);
375 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
377 WebBrowser *This = impl_from_IWebBrowser2(iface);
378 FIXME("(%p)->(%p)\n", This, Type);
382 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
384 WebBrowser *This = impl_from_IWebBrowser2(iface);
386 TRACE("(%p)->(%p)\n", This, pl);
388 *pl = This->pos_rect.left;
392 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
394 WebBrowser *This = impl_from_IWebBrowser2(iface);
397 TRACE("(%p)->(%d)\n", This, Left);
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_Top(IWebBrowser2 *iface, LONG *pl)
412 WebBrowser *This = impl_from_IWebBrowser2(iface);
414 TRACE("(%p)->(%p)\n", This, pl);
416 *pl = This->pos_rect.top;
420 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
422 WebBrowser *This = impl_from_IWebBrowser2(iface);
425 TRACE("(%p)->(%d)\n", This, Top);
430 rect = This->pos_rect;
433 /* We don't really change the window position 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_Width(IWebBrowser2 *iface, LONG *pl)
440 WebBrowser *This = impl_from_IWebBrowser2(iface);
442 TRACE("(%p)->(%p)\n", This, pl);
444 *pl = This->pos_rect.right - This->pos_rect.left;
448 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
450 WebBrowser *This = impl_from_IWebBrowser2(iface);
453 TRACE("(%p)->(%d)\n", This, Width);
458 rect = This->pos_rect;
459 rect.right = rect.left+Width;
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_Height(IWebBrowser2 *iface, LONG *pl)
468 WebBrowser *This = impl_from_IWebBrowser2(iface);
470 TRACE("(%p)->(%p)\n", This, pl);
472 *pl = This->pos_rect.bottom - This->pos_rect.top;
476 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
478 WebBrowser *This = impl_from_IWebBrowser2(iface);
481 TRACE("(%p)->(%d)\n", This, Height);
486 rect = This->pos_rect;
487 rect.bottom = rect.top+Height;
489 /* We don't really change the window size here.
490 * We just notify the embedder that he should do so. */
491 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
494 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
496 WebBrowser *This = impl_from_IWebBrowser2(iface);
497 FIXME("(%p)->(%p)\n", This, LocationName);
501 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
503 WebBrowser *This = impl_from_IWebBrowser2(iface);
505 TRACE("(%p)->(%p)\n", This, LocationURL);
507 return get_location_url(&This->doc_host, LocationURL);
510 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
512 WebBrowser *This = impl_from_IWebBrowser2(iface);
514 TRACE("(%p)->(%p)\n", This, pBool);
516 *pBool = This->doc_host.busy;
520 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
522 WebBrowser *This = impl_from_IWebBrowser2(iface);
524 TRACE("(%p)\n", This);
526 /* It's a InternetExplorer specific method, we have nothing to do here. */
530 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
532 WebBrowser *This = impl_from_IWebBrowser2(iface);
533 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
537 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
539 WebBrowser *This = impl_from_IWebBrowser2(iface);
540 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
544 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
546 WebBrowser *This = impl_from_IWebBrowser2(iface);
547 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
551 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
553 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
554 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
555 WebBrowser *This = impl_from_IWebBrowser2(iface);
557 TRACE("(%p)->(%p)\n", This, Name);
559 *Name = SysAllocString(sName);
564 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND)
566 WebBrowser *This = impl_from_IWebBrowser2(iface);
568 TRACE("(%p)->(%p)\n", This, pHWND);
570 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
575 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
577 WebBrowser *This = impl_from_IWebBrowser2(iface);
578 FIXME("(%p)->(%p)\n", This, FullName);
582 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
584 WebBrowser *This = impl_from_IWebBrowser2(iface);
585 FIXME("(%p)->(%p)\n", This, Path);
589 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
591 WebBrowser *This = impl_from_IWebBrowser2(iface);
593 TRACE("(%p)->(%p)\n", This, pBool);
595 *pBool = This->visible;
599 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
601 WebBrowser *This = impl_from_IWebBrowser2(iface);
603 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
605 TRACE("(%p)->(%x)\n", This, Value);
607 This->visible = Value;
609 V_VT(&arg) = VT_BOOL;
610 V_BOOL(&arg) = Value;
611 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
616 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
618 WebBrowser *This = impl_from_IWebBrowser2(iface);
620 TRACE("(%p)->(%p)\n", This, pBool);
622 *pBool = This->status_bar;
626 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
628 WebBrowser *This = impl_from_IWebBrowser2(iface);
630 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
632 TRACE("(%p)->(%x)\n", This, Value);
634 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
636 /* In opposition to InternetExplorer, all we should do here is
637 * inform the embedder about the status bar change. */
639 V_VT(&arg) = VT_BOOL;
640 V_BOOL(&arg) = Value;
641 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
646 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
648 WebBrowser *This = impl_from_IWebBrowser2(iface);
649 FIXME("(%p)->(%p)\n", This, StatusText);
653 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
655 WebBrowser *This = impl_from_IWebBrowser2(iface);
656 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
660 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
662 WebBrowser *This = impl_from_IWebBrowser2(iface);
664 TRACE("(%p)->(%p)\n", This, Value);
666 *Value = This->tool_bar;
670 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
672 WebBrowser *This = impl_from_IWebBrowser2(iface);
674 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
676 TRACE("(%p)->(%x)\n", This, Value);
678 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
680 /* In opposition to InternetExplorer, all we should do here is
681 * inform the embedder about the tool bar change. */
683 V_VT(&arg) = VT_BOOL;
684 V_BOOL(&arg) = This->tool_bar;
685 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
690 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
692 WebBrowser *This = impl_from_IWebBrowser2(iface);
694 TRACE("(%p)->(%p)\n", This, Value);
696 *Value = This->menu_bar;
700 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
702 WebBrowser *This = impl_from_IWebBrowser2(iface);
704 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
706 TRACE("(%p)->(%x)\n", This, Value);
708 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
710 /* In opposition to InternetExplorer, all we should do here is
711 * inform the embedder about the menu bar change. */
713 V_VT(&arg) = VT_BOOL;
714 V_BOOL(&arg) = Value;
715 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
720 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
722 WebBrowser *This = impl_from_IWebBrowser2(iface);
724 TRACE("(%p)->(%p)\n", This, pbFullScreen);
726 *pbFullScreen = This->full_screen;
730 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
732 WebBrowser *This = impl_from_IWebBrowser2(iface);
734 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
736 /* In opposition to InternetExplorer, all we should do here is
737 * inform the embedder about the fullscreen change. */
739 TRACE("(%p)->(%x)\n", This, bFullScreen);
741 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
743 V_VT(&arg) = VT_BOOL;
744 V_BOOL(&arg) = bFullScreen;
745 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
750 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
751 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
753 WebBrowser *This = impl_from_IWebBrowser2(iface);
756 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
757 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
770 case VT_BSTR|VT_BYREF:
771 url = *V_BSTRREF(URL);
774 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
778 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
781 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
783 WebBrowser *This = impl_from_IWebBrowser2(iface);
784 IOleCommandTarget *target = NULL;
785 OLECMD ole_command[1];
788 TRACE("(%p)->(%d %p)\n", This, cmdID, pcmdf);
792 ole_command[0].cmdID = cmdID;
793 ole_command[0].cmdf = *pcmdf;
797 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
801 if (!target && This->doc_host.document)
803 hres = IOleContainer_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
811 hres = IOleCommandTarget_QueryStatus(target, NULL, 1, ole_command, NULL);
813 *pcmdf = ole_command[0].cmdf;
814 if (hres == OLECMDERR_E_NOTSUPPORTED)
819 IOleCommandTarget_Release(target);
824 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
825 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
827 WebBrowser *This = impl_from_IWebBrowser2(iface);
828 IOleCommandTarget *target = NULL;
831 TRACE("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
835 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
839 if(!target && This->doc_host.document)
841 hres = IOleContainer_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
849 hres = IOleCommandTarget_Exec(target, NULL, cmdID, cmdexecopt, pvaIn, pvaOut);
850 IOleCommandTarget_Release(target);
855 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
856 VARIANT *pvarShow, VARIANT *pvarSize)
858 WebBrowser *This = impl_from_IWebBrowser2(iface);
859 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
860 debugstr_variant(pvarSize));
864 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
866 WebBrowser *This = impl_from_IWebBrowser2(iface);
868 TRACE("(%p)->(%p)\n", This, lpReadyState);
870 *lpReadyState = This->doc_host.ready_state;
874 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
876 WebBrowser *This = impl_from_IWebBrowser2(iface);
878 TRACE("(%p)->(%p)\n", This, pbOffline);
880 *pbOffline = This->doc_host.offline;
884 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
886 WebBrowser *This = impl_from_IWebBrowser2(iface);
888 TRACE("(%p)->(%x)\n", This, bOffline);
890 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
894 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
896 WebBrowser *This = impl_from_IWebBrowser2(iface);
898 TRACE("(%p)->(%p)\n", This, pbSilent);
900 *pbSilent = This->doc_host.silent;
904 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
906 WebBrowser *This = impl_from_IWebBrowser2(iface);
908 TRACE("(%p)->(%x)\n", This, bSilent);
910 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
914 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
915 VARIANT_BOOL *pbRegister)
917 WebBrowser *This = impl_from_IWebBrowser2(iface);
919 FIXME("(%p)->(%p)\n", This, pbRegister);
921 *pbRegister = This->register_browser;
925 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
926 VARIANT_BOOL bRegister)
928 WebBrowser *This = impl_from_IWebBrowser2(iface);
930 FIXME("(%p)->(%x)\n", This, bRegister);
932 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
936 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
937 VARIANT_BOOL *pbRegister)
939 WebBrowser *This = impl_from_IWebBrowser2(iface);
940 FIXME("(%p)->(%p)\n", This, pbRegister);
945 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
946 VARIANT_BOOL bRegister)
948 WebBrowser *This = impl_from_IWebBrowser2(iface);
949 FIXME("(%p)->(%x)\n", This, bRegister);
953 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
955 WebBrowser *This = impl_from_IWebBrowser2(iface);
957 TRACE("(%p)->(%p)\n", This, pbRegister);
959 *pbRegister = This->theater_mode;
963 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
965 WebBrowser *This = impl_from_IWebBrowser2(iface);
967 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
969 TRACE("(%p)->(%x)\n", This, bRegister);
971 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
973 /* In opposition to InternetExplorer, all we should do here is
974 * inform the embedder about the theater mode change. */
976 V_VT(&arg) = VT_BOOL;
977 V_BOOL(&arg) = bRegister;
978 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
983 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
985 WebBrowser *This = impl_from_IWebBrowser2(iface);
987 TRACE("(%p)->(%p)\n", This, Value);
989 *Value = This->address_bar;
993 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
995 WebBrowser *This = impl_from_IWebBrowser2(iface);
997 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
999 TRACE("(%p)->(%x)\n", This, Value);
1001 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
1003 /* In opposition to InternetExplorer, all we should do here is
1004 * inform the embedder about the address bar change. */
1006 V_VT(&arg) = VT_BOOL;
1007 V_BOOL(&arg) = Value;
1008 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
1013 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1015 WebBrowser *This = impl_from_IWebBrowser2(iface);
1017 TRACE("(%p)->(%p)\n", This, Value);
1019 /* It's InternetExplorer object's method. We have nothing to do here. */
1023 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
1025 WebBrowser *This = impl_from_IWebBrowser2(iface);
1027 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1029 TRACE("(%p)->(%x)\n", This, Value);
1031 /* In opposition to InternetExplorer, all we should do here is
1032 * inform the embedder about the resizable change. */
1034 V_VT(&arg) = VT_BOOL;
1035 V_BOOL(&arg) = Value;
1036 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
1041 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
1043 WebBrowser_QueryInterface,
1046 WebBrowser_GetTypeInfoCount,
1047 WebBrowser_GetTypeInfo,
1048 WebBrowser_GetIDsOfNames,
1051 WebBrowser_GoForward,
1053 WebBrowser_GoSearch,
1054 WebBrowser_Navigate,
1056 WebBrowser_Refresh2,
1058 WebBrowser_get_Application,
1059 WebBrowser_get_Parent,
1060 WebBrowser_get_Container,
1061 WebBrowser_get_Document,
1062 WebBrowser_get_TopLevelContainer,
1063 WebBrowser_get_Type,
1064 WebBrowser_get_Left,
1065 WebBrowser_put_Left,
1068 WebBrowser_get_Width,
1069 WebBrowser_put_Width,
1070 WebBrowser_get_Height,
1071 WebBrowser_put_Height,
1072 WebBrowser_get_LocationName,
1073 WebBrowser_get_LocationURL,
1074 WebBrowser_get_Busy,
1076 WebBrowser_ClientToWindow,
1077 WebBrowser_PutProperty,
1078 WebBrowser_GetProperty,
1079 WebBrowser_get_Name,
1080 WebBrowser_get_HWND,
1081 WebBrowser_get_FullName,
1082 WebBrowser_get_Path,
1083 WebBrowser_get_Visible,
1084 WebBrowser_put_Visible,
1085 WebBrowser_get_StatusBar,
1086 WebBrowser_put_StatusBar,
1087 WebBrowser_get_StatusText,
1088 WebBrowser_put_StatusText,
1089 WebBrowser_get_ToolBar,
1090 WebBrowser_put_ToolBar,
1091 WebBrowser_get_MenuBar,
1092 WebBrowser_put_MenuBar,
1093 WebBrowser_get_FullScreen,
1094 WebBrowser_put_FullScreen,
1095 WebBrowser_Navigate2,
1096 WebBrowser_QueryStatusWB,
1098 WebBrowser_ShowBrowserBar,
1099 WebBrowser_get_ReadyState,
1100 WebBrowser_get_Offline,
1101 WebBrowser_put_Offline,
1102 WebBrowser_get_Silent,
1103 WebBrowser_put_Silent,
1104 WebBrowser_get_RegisterAsBrowser,
1105 WebBrowser_put_RegisterAsBrowser,
1106 WebBrowser_get_RegisterAsDropTarget,
1107 WebBrowser_put_RegisterAsDropTarget,
1108 WebBrowser_get_TheaterMode,
1109 WebBrowser_put_TheaterMode,
1110 WebBrowser_get_AddressBar,
1111 WebBrowser_put_AddressBar,
1112 WebBrowser_get_Resizable,
1113 WebBrowser_put_Resizable
1116 static inline WebBrowser *impl_from_IServiceProvider(IServiceProvider *iface)
1118 return CONTAINING_RECORD(iface, WebBrowser, IServiceProvider_iface);
1121 static HRESULT WINAPI WBServiceProvider_QueryInterface(IServiceProvider *iface,
1122 REFIID riid, LPVOID *ppv)
1124 WebBrowser *This = impl_from_IServiceProvider(iface);
1125 return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
1128 static ULONG WINAPI WBServiceProvider_AddRef(IServiceProvider *iface)
1130 WebBrowser *This = impl_from_IServiceProvider(iface);
1131 return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
1134 static ULONG WINAPI WBServiceProvider_Release(IServiceProvider *iface)
1136 WebBrowser *This = impl_from_IServiceProvider(iface);
1137 return IWebBrowser_Release(&This->IWebBrowser2_iface);
1140 static HRESULT STDMETHODCALLTYPE WBServiceProvider_QueryService(IServiceProvider *iface,
1141 REFGUID guidService, REFIID riid, void **ppv)
1143 WebBrowser *This = impl_from_IServiceProvider(iface);
1148 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1149 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1153 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1155 return E_NOINTERFACE;
1158 static const IServiceProviderVtbl ServiceProviderVtbl =
1160 WBServiceProvider_QueryInterface,
1161 WBServiceProvider_AddRef,
1162 WBServiceProvider_Release,
1163 WBServiceProvider_QueryService
1166 static inline WebBrowser *impl_from_DocHost(DocHost *iface)
1168 return CONTAINING_RECORD(iface, WebBrowser, doc_host);
1171 static ULONG WebBrowser_addref(DocHost *iface)
1173 WebBrowser *This = impl_from_DocHost(iface);
1174 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
1177 static ULONG WebBrowser_release(DocHost *iface)
1179 WebBrowser *This = impl_from_DocHost(iface);
1180 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
1183 static void WINAPI DocHostContainer_GetDocObjRect(DocHost* This, RECT* rc)
1185 GetClientRect(This->frame_hwnd, rc);
1188 static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost* This, LPCWSTR text)
1193 static void WINAPI DocHostContainer_SetURL(DocHost* This, LPCWSTR url)
1198 static HRESULT DocHostContainer_exec(DocHost *doc_host, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in,
1201 WebBrowser *This = impl_from_DocHost(doc_host);
1202 IOleCommandTarget *cmdtrg = NULL;
1206 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
1211 if(!cmdtrg && This->container) {
1212 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (void**)&cmdtrg);
1220 hres = IOleCommandTarget_Exec(cmdtrg, cmd_group, cmdid, execopt, in, out);
1221 IOleCommandTarget_Release(cmdtrg);
1223 FIXME("Exec failed\n");
1228 static const IDocHostContainerVtbl DocHostContainerVtbl = {
1231 DocHostContainer_GetDocObjRect,
1232 DocHostContainer_SetStatusText,
1233 DocHostContainer_SetURL,
1234 DocHostContainer_exec
1237 static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, void **ppv)
1242 TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
1244 ret = heap_alloc_zero(sizeof(WebBrowser));
1246 ret->IWebBrowser2_iface.lpVtbl = &WebBrowser2Vtbl;
1247 ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
1249 ret->version = version;
1251 DocHost_Init(&ret->doc_host, (IDispatch*)&ret->IWebBrowser2_iface, &DocHostContainerVtbl);
1253 ret->visible = VARIANT_TRUE;
1254 ret->menu_bar = VARIANT_TRUE;
1255 ret->address_bar = VARIANT_TRUE;
1256 ret->status_bar = VARIANT_TRUE;
1257 ret->tool_bar = VARIANT_TRUE;
1259 WebBrowser_OleObject_Init(ret);
1260 WebBrowser_ViewObject_Init(ret);
1261 WebBrowser_Persist_Init(ret);
1262 WebBrowser_ClassInfo_Init(ret);
1264 HlinkFrame_Init(&ret->hlink_frame, (IUnknown*)&ret->IWebBrowser2_iface, &ret->doc_host);
1266 SHDOCVW_LockModule();
1268 hres = IWebBrowser_QueryInterface(&ret->IWebBrowser2_iface, riid, ppv);
1270 IWebBrowser2_Release(&ret->IWebBrowser2_iface);
1274 HRESULT WebBrowserV1_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1276 return WebBrowser_Create(1, pOuter, riid, ppv);
1279 HRESULT WebBrowserV2_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1281 return WebBrowser_Create(2, pOuter, riid, ppv);