2 * Implementation of IWebBrowser interface for WebBrowser control
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
5 * Copyright 2005 Jacek Caban
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
31 static inline WebBrowser *impl_from_IWebBrowser2(IWebBrowser2 *iface)
33 return CONTAINING_RECORD(iface, WebBrowser, IWebBrowser2_iface);
36 static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
38 WebBrowser *This = impl_from_IWebBrowser2(iface);
44 if(IsEqualGUID(&IID_IUnknown, riid)) {
45 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
46 *ppv = &This->IWebBrowser2_iface;
47 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
48 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
49 *ppv = &This->IWebBrowser2_iface;
50 }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
51 TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
52 *ppv = &This->IWebBrowser2_iface;
53 }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
54 TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
55 *ppv = &This->IWebBrowser2_iface;
56 }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
57 TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
58 *ppv = &This->IWebBrowser2_iface;
59 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
60 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
61 *ppv = &This->IOleObject_iface;
62 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
63 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
64 *ppv = &This->IOleInPlaceObject_iface;
65 }else if(IsEqualGUID (&IID_IOleInPlaceObject, riid)) {
66 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
67 *ppv = &This->IOleInPlaceObject_iface;
68 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
69 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
70 *ppv = &This->IOleControl_iface;
71 }else if(IsEqualGUID(&IID_IPersist, riid)) {
72 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
73 *ppv = &This->IPersistStorage_iface;
74 }else if(IsEqualGUID(&IID_IPersistStorage, riid)) {
75 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
76 *ppv = &This->IPersistStorage_iface;
77 }else if(IsEqualGUID(&IID_IPersistMemory, riid)) {
78 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
79 *ppv = &This->IPersistMemory_iface;
80 }else if(IsEqualGUID (&IID_IPersistStreamInit, riid)) {
81 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
82 *ppv = &This->IPersistStreamInit_iface;
83 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
84 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
85 *ppv = &This->IProvideClassInfo2_iface;
86 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
87 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
88 *ppv = &This->IProvideClassInfo2_iface;
89 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
90 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
91 *ppv = &This->doc_host.cps.IConnectionPointContainer_iface;
92 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
93 TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
94 *ppv = &This->IViewObject2_iface;
95 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
96 TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
97 *ppv = &This->IViewObject2_iface;
98 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
99 TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
100 *ppv = &This->IOleInPlaceActiveObject_iface;
101 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
102 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
103 *ppv = &This->IOleCommandTarget_iface;
104 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
105 *ppv = &This->IServiceProvider_iface;
106 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
107 }else if(IsEqualGUID(&IID_IDataObject, riid)) {
108 *ppv = &This->IDataObject_iface;
109 TRACE("(%p)->(IID_IDataObject %p)\n", This, ppv);
110 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
111 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
112 return E_NOINTERFACE;
113 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
114 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
115 return E_NOINTERFACE;
116 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
117 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
118 return E_NOINTERFACE;
119 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
120 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
121 return E_NOINTERFACE;
122 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
123 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
124 return E_NOINTERFACE;
125 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
126 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
127 return E_NOINTERFACE;
128 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
129 TRACE("(%p)->(IID_IViewObjectEx %p) returning NULL\n", This, ppv);
130 return E_NOINTERFACE;
131 }else if(IsEqualGUID(&IID_IOleLink, riid)) {
132 TRACE("(%p)->(IID_IOleLink %p) returning NULL\n", This, ppv);
133 return E_NOINTERFACE;
134 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
135 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
136 return E_NOINTERFACE;
137 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
138 TRACE("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
139 return E_NOINTERFACE;
140 }else if(HlinkFrame_QI(&This->hlink_frame, riid, ppv)) {
145 IUnknown_AddRef((IUnknown*)*ppv);
149 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
150 return E_NOINTERFACE;
153 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
155 WebBrowser *This = impl_from_IWebBrowser2(iface);
156 LONG ref = InterlockedIncrement(&This->ref);
157 TRACE("(%p) ref=%d\n", This, ref);
161 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
163 WebBrowser *This = impl_from_IWebBrowser2(iface);
164 LONG ref = InterlockedDecrement(&This->ref);
166 TRACE("(%p) ref=%d\n", This, ref);
169 if(This->doc_host.document)
170 IUnknown_Release(This->doc_host.document);
172 DocHost_Release(&This->doc_host);
174 WebBrowser_OleObject_Destroy(This);
183 /* IDispatch methods */
184 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
186 WebBrowser *This = impl_from_IWebBrowser2(iface);
188 TRACE("(%p)->(%p)\n", This, pctinfo);
194 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
197 WebBrowser *This = impl_from_IWebBrowser2(iface);
201 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
203 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
207 ITypeInfo_AddRef(typeinfo);
212 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
213 LPOLESTR *rgszNames, UINT cNames,
214 LCID lcid, DISPID *rgDispId)
216 WebBrowser *This = impl_from_IWebBrowser2(iface);
220 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
223 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
227 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
230 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
231 REFIID riid, LCID lcid, WORD wFlags,
232 DISPPARAMS *pDispParams, VARIANT *pVarResult,
233 EXCEPINFO *pExepInfo, UINT *puArgErr)
235 WebBrowser *This = impl_from_IWebBrowser2(iface);
239 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
240 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
242 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
246 return ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags, pDispParams,
247 pVarResult, pExepInfo, puArgErr);
250 /* IWebBrowser methods */
251 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
253 WebBrowser *This = impl_from_IWebBrowser2(iface);
254 TRACE("(%p)\n", This);
255 return go_back(&This->doc_host);
258 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
260 WebBrowser *This = impl_from_IWebBrowser2(iface);
261 FIXME("(%p)\n", This);
265 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
267 WebBrowser *This = impl_from_IWebBrowser2(iface);
268 TRACE("(%p)\n", This);
269 return go_home(&This->doc_host);
272 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
274 WebBrowser *This = impl_from_IWebBrowser2(iface);
275 FIXME("(%p)\n", This);
279 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
280 VARIANT *Flags, VARIANT *TargetFrameName,
281 VARIANT *PostData, VARIANT *Headers)
283 WebBrowser *This = impl_from_IWebBrowser2(iface);
285 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
286 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
287 debugstr_variant(Headers));
289 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
292 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
294 WebBrowser *This = impl_from_IWebBrowser2(iface);
295 FIXME("(%p)\n", This);
299 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
301 WebBrowser *This = impl_from_IWebBrowser2(iface);
302 FIXME("(%p)->(%s)\n", This, debugstr_variant(Level));
306 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
308 WebBrowser *This = impl_from_IWebBrowser2(iface);
309 FIXME("(%p)\n", This);
313 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
315 WebBrowser *This = impl_from_IWebBrowser2(iface);
317 TRACE("(%p)->(%p)\n", This, ppDisp);
322 *ppDisp = (IDispatch*)&This->IWebBrowser2_iface;
323 IDispatch_AddRef(*ppDisp);
327 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
329 WebBrowser *This = impl_from_IWebBrowser2(iface);
330 FIXME("(%p)->(%p)\n", This, ppDisp);
334 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
336 WebBrowser *This = impl_from_IWebBrowser2(iface);
337 FIXME("(%p)->(%p)\n", This, ppDisp);
341 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
343 WebBrowser *This = impl_from_IWebBrowser2(iface);
344 IDispatch *disp = NULL;
346 TRACE("(%p)->(%p)\n", This, ppDisp);
348 if(This->doc_host.document) {
351 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
352 if(SUCCEEDED(hres)) {
355 /* Some broken apps cast returned IDispatch to IHTMLDocument2
356 * without QueryInterface call */
357 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
358 if(SUCCEEDED(hres)) {
359 IDispatch_Release(disp);
369 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
371 WebBrowser *This = impl_from_IWebBrowser2(iface);
372 FIXME("(%p)->(%p)\n", This, pBool);
376 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
378 WebBrowser *This = impl_from_IWebBrowser2(iface);
379 FIXME("(%p)->(%p)\n", This, Type);
383 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
385 WebBrowser *This = impl_from_IWebBrowser2(iface);
387 TRACE("(%p)->(%p)\n", This, pl);
389 *pl = This->pos_rect.left;
393 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
395 WebBrowser *This = impl_from_IWebBrowser2(iface);
398 TRACE("(%p)->(%d)\n", This, Left);
403 rect = This->pos_rect;
406 /* We don't really change the window position here.
407 * We just notify the embedder that he should do so. */
408 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
411 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
413 WebBrowser *This = impl_from_IWebBrowser2(iface);
415 TRACE("(%p)->(%p)\n", This, pl);
417 *pl = This->pos_rect.top;
421 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
423 WebBrowser *This = impl_from_IWebBrowser2(iface);
426 TRACE("(%p)->(%d)\n", This, Top);
431 rect = This->pos_rect;
434 /* We don't really change the window position here.
435 * We just notify the embedder that he should do so. */
436 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
439 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
441 WebBrowser *This = impl_from_IWebBrowser2(iface);
443 TRACE("(%p)->(%p)\n", This, pl);
445 *pl = This->pos_rect.right - This->pos_rect.left;
449 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
451 WebBrowser *This = impl_from_IWebBrowser2(iface);
454 TRACE("(%p)->(%d)\n", This, Width);
459 rect = This->pos_rect;
460 rect.right = rect.left+Width;
462 /* We don't really change the window size here.
463 * We just notify the embedder that he should do so. */
464 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
467 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
469 WebBrowser *This = impl_from_IWebBrowser2(iface);
471 TRACE("(%p)->(%p)\n", This, pl);
473 *pl = This->pos_rect.bottom - This->pos_rect.top;
477 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
479 WebBrowser *This = impl_from_IWebBrowser2(iface);
482 TRACE("(%p)->(%d)\n", This, Height);
487 rect = This->pos_rect;
488 rect.bottom = rect.top+Height;
490 /* We don't really change the window size here.
491 * We just notify the embedder that he should do so. */
492 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
495 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
497 WebBrowser *This = impl_from_IWebBrowser2(iface);
498 FIXME("(%p)->(%p)\n", This, LocationName);
502 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
504 WebBrowser *This = impl_from_IWebBrowser2(iface);
506 TRACE("(%p)->(%p)\n", This, LocationURL);
508 return get_location_url(&This->doc_host, LocationURL);
511 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
513 WebBrowser *This = impl_from_IWebBrowser2(iface);
515 TRACE("(%p)->(%p)\n", This, pBool);
517 *pBool = This->doc_host.busy;
521 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
523 WebBrowser *This = impl_from_IWebBrowser2(iface);
525 TRACE("(%p)\n", This);
527 /* It's a InternetExplorer specific method, we have nothing to do here. */
531 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
533 WebBrowser *This = impl_from_IWebBrowser2(iface);
534 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
538 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
540 WebBrowser *This = impl_from_IWebBrowser2(iface);
541 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
545 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
547 WebBrowser *This = impl_from_IWebBrowser2(iface);
548 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
552 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
554 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
555 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
556 WebBrowser *This = impl_from_IWebBrowser2(iface);
558 TRACE("(%p)->(%p)\n", This, Name);
560 *Name = SysAllocString(sName);
565 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND)
567 WebBrowser *This = impl_from_IWebBrowser2(iface);
569 TRACE("(%p)->(%p)\n", This, pHWND);
571 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
576 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
578 WebBrowser *This = impl_from_IWebBrowser2(iface);
579 FIXME("(%p)->(%p)\n", This, FullName);
583 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
585 WebBrowser *This = impl_from_IWebBrowser2(iface);
586 FIXME("(%p)->(%p)\n", This, Path);
590 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
592 WebBrowser *This = impl_from_IWebBrowser2(iface);
594 TRACE("(%p)->(%p)\n", This, pBool);
596 *pBool = This->visible;
600 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
602 WebBrowser *This = impl_from_IWebBrowser2(iface);
604 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
606 TRACE("(%p)->(%x)\n", This, Value);
608 This->visible = Value;
610 V_VT(&arg) = VT_BOOL;
611 V_BOOL(&arg) = Value;
612 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
617 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
619 WebBrowser *This = impl_from_IWebBrowser2(iface);
621 TRACE("(%p)->(%p)\n", This, pBool);
623 *pBool = This->status_bar;
627 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
629 WebBrowser *This = impl_from_IWebBrowser2(iface);
631 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
633 TRACE("(%p)->(%x)\n", This, Value);
635 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
637 /* In opposition to InternetExplorer, all we should do here is
638 * inform the embedder about the status bar change. */
640 V_VT(&arg) = VT_BOOL;
641 V_BOOL(&arg) = Value;
642 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
647 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
649 WebBrowser *This = impl_from_IWebBrowser2(iface);
650 FIXME("(%p)->(%p)\n", This, StatusText);
654 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
656 WebBrowser *This = impl_from_IWebBrowser2(iface);
657 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
661 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
663 WebBrowser *This = impl_from_IWebBrowser2(iface);
665 TRACE("(%p)->(%p)\n", This, Value);
667 *Value = This->tool_bar;
671 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
673 WebBrowser *This = impl_from_IWebBrowser2(iface);
675 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
677 TRACE("(%p)->(%x)\n", This, Value);
679 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
681 /* In opposition to InternetExplorer, all we should do here is
682 * inform the embedder about the tool bar change. */
684 V_VT(&arg) = VT_BOOL;
685 V_BOOL(&arg) = This->tool_bar;
686 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
691 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
693 WebBrowser *This = impl_from_IWebBrowser2(iface);
695 TRACE("(%p)->(%p)\n", This, Value);
697 *Value = This->menu_bar;
701 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
703 WebBrowser *This = impl_from_IWebBrowser2(iface);
705 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
707 TRACE("(%p)->(%x)\n", This, Value);
709 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
711 /* In opposition to InternetExplorer, all we should do here is
712 * inform the embedder about the menu bar change. */
714 V_VT(&arg) = VT_BOOL;
715 V_BOOL(&arg) = Value;
716 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
721 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
723 WebBrowser *This = impl_from_IWebBrowser2(iface);
725 TRACE("(%p)->(%p)\n", This, pbFullScreen);
727 *pbFullScreen = This->full_screen;
731 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
733 WebBrowser *This = impl_from_IWebBrowser2(iface);
735 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
737 /* In opposition to InternetExplorer, all we should do here is
738 * inform the embedder about the fullscreen change. */
740 TRACE("(%p)->(%x)\n", This, bFullScreen);
742 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
744 V_VT(&arg) = VT_BOOL;
745 V_BOOL(&arg) = bFullScreen;
746 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
751 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
752 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
754 WebBrowser *This = impl_from_IWebBrowser2(iface);
757 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
758 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
771 case VT_BSTR|VT_BYREF:
772 url = *V_BSTRREF(URL);
775 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
779 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
782 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
784 WebBrowser *This = impl_from_IWebBrowser2(iface);
785 IOleCommandTarget *target = NULL;
786 OLECMD ole_command[1];
789 TRACE("(%p)->(%d %p)\n", This, cmdID, pcmdf);
793 ole_command[0].cmdID = cmdID;
794 ole_command[0].cmdf = *pcmdf;
798 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
802 if (!target && This->doc_host.document)
804 hres = IOleContainer_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
812 hres = IOleCommandTarget_QueryStatus(target, NULL, 1, ole_command, NULL);
814 *pcmdf = ole_command[0].cmdf;
815 if (hres == OLECMDERR_E_NOTSUPPORTED)
820 IOleCommandTarget_Release(target);
825 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
826 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
828 WebBrowser *This = impl_from_IWebBrowser2(iface);
829 IOleCommandTarget *target = NULL;
832 TRACE("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
836 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
840 if(!target && This->doc_host.document)
842 hres = IOleContainer_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
850 hres = IOleCommandTarget_Exec(target, NULL, cmdID, cmdexecopt, pvaIn, pvaOut);
851 IOleCommandTarget_Release(target);
856 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
857 VARIANT *pvarShow, VARIANT *pvarSize)
859 WebBrowser *This = impl_from_IWebBrowser2(iface);
860 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
861 debugstr_variant(pvarSize));
865 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
867 WebBrowser *This = impl_from_IWebBrowser2(iface);
869 TRACE("(%p)->(%p)\n", This, lpReadyState);
871 *lpReadyState = This->doc_host.ready_state;
875 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
877 WebBrowser *This = impl_from_IWebBrowser2(iface);
879 TRACE("(%p)->(%p)\n", This, pbOffline);
881 *pbOffline = This->doc_host.offline;
885 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
887 WebBrowser *This = impl_from_IWebBrowser2(iface);
889 TRACE("(%p)->(%x)\n", This, bOffline);
891 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
895 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
897 WebBrowser *This = impl_from_IWebBrowser2(iface);
899 TRACE("(%p)->(%p)\n", This, pbSilent);
901 *pbSilent = This->doc_host.silent;
905 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
907 WebBrowser *This = impl_from_IWebBrowser2(iface);
909 TRACE("(%p)->(%x)\n", This, bSilent);
911 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
915 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
916 VARIANT_BOOL *pbRegister)
918 WebBrowser *This = impl_from_IWebBrowser2(iface);
920 FIXME("(%p)->(%p)\n", This, pbRegister);
922 *pbRegister = This->register_browser;
926 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
927 VARIANT_BOOL bRegister)
929 WebBrowser *This = impl_from_IWebBrowser2(iface);
931 FIXME("(%p)->(%x)\n", This, bRegister);
933 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
937 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
938 VARIANT_BOOL *pbRegister)
940 WebBrowser *This = impl_from_IWebBrowser2(iface);
941 FIXME("(%p)->(%p)\n", This, pbRegister);
946 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
947 VARIANT_BOOL bRegister)
949 WebBrowser *This = impl_from_IWebBrowser2(iface);
950 FIXME("(%p)->(%x)\n", This, bRegister);
954 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
956 WebBrowser *This = impl_from_IWebBrowser2(iface);
958 TRACE("(%p)->(%p)\n", This, pbRegister);
960 *pbRegister = This->theater_mode;
964 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
966 WebBrowser *This = impl_from_IWebBrowser2(iface);
968 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
970 TRACE("(%p)->(%x)\n", This, bRegister);
972 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
974 /* In opposition to InternetExplorer, all we should do here is
975 * inform the embedder about the theater mode change. */
977 V_VT(&arg) = VT_BOOL;
978 V_BOOL(&arg) = bRegister;
979 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
984 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
986 WebBrowser *This = impl_from_IWebBrowser2(iface);
988 TRACE("(%p)->(%p)\n", This, Value);
990 *Value = This->address_bar;
994 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
996 WebBrowser *This = impl_from_IWebBrowser2(iface);
998 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1000 TRACE("(%p)->(%x)\n", This, Value);
1002 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
1004 /* In opposition to InternetExplorer, all we should do here is
1005 * inform the embedder about the address bar change. */
1007 V_VT(&arg) = VT_BOOL;
1008 V_BOOL(&arg) = Value;
1009 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
1014 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1016 WebBrowser *This = impl_from_IWebBrowser2(iface);
1018 TRACE("(%p)->(%p)\n", This, Value);
1020 /* It's InternetExplorer object's method. We have nothing to do here. */
1024 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
1026 WebBrowser *This = impl_from_IWebBrowser2(iface);
1028 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1030 TRACE("(%p)->(%x)\n", This, Value);
1032 /* In opposition to InternetExplorer, all we should do here is
1033 * inform the embedder about the resizable change. */
1035 V_VT(&arg) = VT_BOOL;
1036 V_BOOL(&arg) = Value;
1037 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
1042 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
1044 WebBrowser_QueryInterface,
1047 WebBrowser_GetTypeInfoCount,
1048 WebBrowser_GetTypeInfo,
1049 WebBrowser_GetIDsOfNames,
1052 WebBrowser_GoForward,
1054 WebBrowser_GoSearch,
1055 WebBrowser_Navigate,
1057 WebBrowser_Refresh2,
1059 WebBrowser_get_Application,
1060 WebBrowser_get_Parent,
1061 WebBrowser_get_Container,
1062 WebBrowser_get_Document,
1063 WebBrowser_get_TopLevelContainer,
1064 WebBrowser_get_Type,
1065 WebBrowser_get_Left,
1066 WebBrowser_put_Left,
1069 WebBrowser_get_Width,
1070 WebBrowser_put_Width,
1071 WebBrowser_get_Height,
1072 WebBrowser_put_Height,
1073 WebBrowser_get_LocationName,
1074 WebBrowser_get_LocationURL,
1075 WebBrowser_get_Busy,
1077 WebBrowser_ClientToWindow,
1078 WebBrowser_PutProperty,
1079 WebBrowser_GetProperty,
1080 WebBrowser_get_Name,
1081 WebBrowser_get_HWND,
1082 WebBrowser_get_FullName,
1083 WebBrowser_get_Path,
1084 WebBrowser_get_Visible,
1085 WebBrowser_put_Visible,
1086 WebBrowser_get_StatusBar,
1087 WebBrowser_put_StatusBar,
1088 WebBrowser_get_StatusText,
1089 WebBrowser_put_StatusText,
1090 WebBrowser_get_ToolBar,
1091 WebBrowser_put_ToolBar,
1092 WebBrowser_get_MenuBar,
1093 WebBrowser_put_MenuBar,
1094 WebBrowser_get_FullScreen,
1095 WebBrowser_put_FullScreen,
1096 WebBrowser_Navigate2,
1097 WebBrowser_QueryStatusWB,
1099 WebBrowser_ShowBrowserBar,
1100 WebBrowser_get_ReadyState,
1101 WebBrowser_get_Offline,
1102 WebBrowser_put_Offline,
1103 WebBrowser_get_Silent,
1104 WebBrowser_put_Silent,
1105 WebBrowser_get_RegisterAsBrowser,
1106 WebBrowser_put_RegisterAsBrowser,
1107 WebBrowser_get_RegisterAsDropTarget,
1108 WebBrowser_put_RegisterAsDropTarget,
1109 WebBrowser_get_TheaterMode,
1110 WebBrowser_put_TheaterMode,
1111 WebBrowser_get_AddressBar,
1112 WebBrowser_put_AddressBar,
1113 WebBrowser_get_Resizable,
1114 WebBrowser_put_Resizable
1117 static inline WebBrowser *impl_from_IServiceProvider(IServiceProvider *iface)
1119 return CONTAINING_RECORD(iface, WebBrowser, IServiceProvider_iface);
1122 static HRESULT WINAPI WBServiceProvider_QueryInterface(IServiceProvider *iface,
1123 REFIID riid, LPVOID *ppv)
1125 WebBrowser *This = impl_from_IServiceProvider(iface);
1126 return IWebBrowser_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
1129 static ULONG WINAPI WBServiceProvider_AddRef(IServiceProvider *iface)
1131 WebBrowser *This = impl_from_IServiceProvider(iface);
1132 return IWebBrowser_AddRef(&This->IWebBrowser2_iface);
1135 static ULONG WINAPI WBServiceProvider_Release(IServiceProvider *iface)
1137 WebBrowser *This = impl_from_IServiceProvider(iface);
1138 return IWebBrowser_Release(&This->IWebBrowser2_iface);
1141 static HRESULT STDMETHODCALLTYPE WBServiceProvider_QueryService(IServiceProvider *iface,
1142 REFGUID guidService, REFIID riid, void **ppv)
1144 WebBrowser *This = impl_from_IServiceProvider(iface);
1146 if(IsEqualGUID(&SID_SHTMLWindow, riid)) {
1147 TRACE("(%p)->(SID_SHTMLWindow)\n", This);
1148 return IHTMLWindow2_QueryInterface(&This->doc_host.html_window.IHTMLWindow2_iface, riid, ppv);
1151 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1152 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1157 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1159 return E_NOINTERFACE;
1162 static const IServiceProviderVtbl ServiceProviderVtbl =
1164 WBServiceProvider_QueryInterface,
1165 WBServiceProvider_AddRef,
1166 WBServiceProvider_Release,
1167 WBServiceProvider_QueryService
1170 static inline WebBrowser *impl_from_DocHost(DocHost *iface)
1172 return CONTAINING_RECORD(iface, WebBrowser, doc_host);
1175 static ULONG WebBrowser_addref(DocHost *iface)
1177 WebBrowser *This = impl_from_DocHost(iface);
1178 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
1181 static ULONG WebBrowser_release(DocHost *iface)
1183 WebBrowser *This = impl_from_DocHost(iface);
1184 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
1187 static void WINAPI DocHostContainer_GetDocObjRect(DocHost* This, RECT* rc)
1189 GetClientRect(This->frame_hwnd, rc);
1192 static HRESULT WINAPI DocHostContainer_SetStatusText(DocHost* This, LPCWSTR text)
1197 static void WINAPI DocHostContainer_SetURL(DocHost* This, LPCWSTR url)
1202 static HRESULT DocHostContainer_exec(DocHost *doc_host, const GUID *cmd_group, DWORD cmdid, DWORD execopt, VARIANT *in,
1205 WebBrowser *This = impl_from_DocHost(doc_host);
1206 IOleCommandTarget *cmdtrg = NULL;
1210 hres = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
1215 if(!cmdtrg && This->container) {
1216 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (void**)&cmdtrg);
1224 hres = IOleCommandTarget_Exec(cmdtrg, cmd_group, cmdid, execopt, in, out);
1225 IOleCommandTarget_Release(cmdtrg);
1227 FIXME("Exec failed\n");
1232 static const IDocHostContainerVtbl DocHostContainerVtbl = {
1235 DocHostContainer_GetDocObjRect,
1236 DocHostContainer_SetStatusText,
1237 DocHostContainer_SetURL,
1238 DocHostContainer_exec
1241 static HRESULT create_webbrowser(int version, IUnknown *outer, REFIID riid, void **ppv)
1246 TRACE("(%p %s %p) version=%d\n", outer, debugstr_guid(riid), ppv, version);
1248 ret = heap_alloc_zero(sizeof(WebBrowser));
1250 ret->IWebBrowser2_iface.lpVtbl = &WebBrowser2Vtbl;
1251 ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
1253 ret->version = version;
1255 DocHost_Init(&ret->doc_host, &ret->IWebBrowser2_iface, &DocHostContainerVtbl);
1257 ret->visible = VARIANT_TRUE;
1258 ret->menu_bar = VARIANT_TRUE;
1259 ret->address_bar = VARIANT_TRUE;
1260 ret->status_bar = VARIANT_TRUE;
1261 ret->tool_bar = VARIANT_TRUE;
1263 WebBrowser_OleObject_Init(ret);
1264 WebBrowser_ViewObject_Init(ret);
1265 WebBrowser_Persist_Init(ret);
1266 WebBrowser_ClassInfo_Init(ret);
1268 HlinkFrame_Init(&ret->hlink_frame, (IUnknown*)&ret->IWebBrowser2_iface, &ret->doc_host);
1272 hres = IWebBrowser_QueryInterface(&ret->IWebBrowser2_iface, riid, ppv);
1274 IWebBrowser2_Release(&ret->IWebBrowser2_iface);
1278 HRESULT WINAPI WebBrowserV1_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1280 return create_webbrowser(1, pOuter, riid, ppv);
1283 HRESULT WINAPI WebBrowser_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1285 return create_webbrowser(2, pOuter, riid, ppv);