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"
27 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw
);
29 /**********************************************************************
30 * Implement the IWebBrowser interface
33 #define WEBBROWSER_THIS(iface) DEFINE_THIS(WebBrowser, WebBrowser2, iface)
35 static HRESULT WINAPI
WebBrowser_QueryInterface(IWebBrowser2
*iface
, REFIID riid
, LPVOID
*ppv
)
37 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
43 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
44 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
45 *ppv
= WEBBROWSER(This
);
46 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
47 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
48 *ppv
= WEBBROWSER(This
);
49 }else if(IsEqualGUID(&IID_IWebBrowser
, riid
)) {
50 TRACE("(%p)->(IID_IWebBrowser %p)\n", This
, ppv
);
51 *ppv
= WEBBROWSER(This
);
52 }else if(IsEqualGUID(&IID_IWebBrowserApp
, riid
)) {
53 TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This
, ppv
);
54 *ppv
= WEBBROWSER(This
);
55 }else if(IsEqualGUID(&IID_IWebBrowser2
, riid
)) {
56 TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This
, ppv
);
57 *ppv
= WEBBROWSER(This
);
58 }else if(IsEqualGUID(&IID_IOleObject
, riid
)) {
59 TRACE("(%p)->(IID_IOleObject %p)\n", This
, ppv
);
61 }else if(IsEqualGUID(&IID_IOleWindow
, riid
)) {
62 TRACE("(%p)->(IID_IOleWindow %p)\n", This
, ppv
);
63 *ppv
= INPLACEOBJ(This
);
64 }else if(IsEqualGUID (&IID_IOleInPlaceObject
, riid
)) {
65 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This
, ppv
);
66 *ppv
= INPLACEOBJ(This
);
67 }else if(IsEqualGUID(&IID_IOleControl
, riid
)) {
68 TRACE("(%p)->(IID_IOleControl %p)\n", This
, ppv
);
70 }else if(IsEqualGUID(&IID_IPersist
, riid
)) {
71 TRACE("(%p)->(IID_IPersist %p)\n", This
, ppv
);
72 *ppv
= PERSTORAGE(This
);
73 }else if(IsEqualGUID(&IID_IPersistStorage
, riid
)) {
74 TRACE("(%p)->(IID_IPersistStorage %p)\n", This
, ppv
);
75 *ppv
= PERSTORAGE(This
);
76 }else if(IsEqualGUID(&IID_IPersistMemory
, riid
)) {
77 TRACE("(%p)->(IID_IPersistStorage %p)\n", This
, ppv
);
78 *ppv
= PERMEMORY(This
);
79 }else if(IsEqualGUID (&IID_IPersistStreamInit
, riid
)) {
80 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This
, ppv
);
81 *ppv
= PERSTRINIT(This
);
82 }else if(IsEqualGUID(&IID_IProvideClassInfo
, riid
)) {
83 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This
, ppv
);
84 *ppv
= CLASSINFO(This
);
85 }else if(IsEqualGUID(&IID_IProvideClassInfo2
, riid
)) {
86 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This
, ppv
);
87 *ppv
= CLASSINFO(This
);
88 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
89 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
90 *ppv
= CONPTCONT(&This
->doc_host
.cps
);
91 }else if(IsEqualGUID(&IID_IViewObject
, riid
)) {
92 TRACE("(%p)->(IID_IViewObject %p)\n", This
, ppv
);
94 }else if(IsEqualGUID(&IID_IViewObject2
, riid
)) {
95 TRACE("(%p)->(IID_IViewObject2 %p)\n", This
, ppv
);
96 *ppv
= VIEWOBJ2(This
);
97 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject
, riid
)) {
98 TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This
, ppv
);
99 *ppv
= ACTIVEOBJ(This
);
100 }else if(IsEqualGUID(&IID_IOleCommandTarget
, riid
)) {
101 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This
, ppv
);
103 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
104 *ppv
= SERVPROV(This
);
105 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
106 }else if(IsEqualGUID(&IID_IDataObject
, riid
)) {
107 *ppv
= DATAOBJECT(This
);
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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(iface
);
187 TRACE("(%p)->(%p)\n", This
, pctinfo
);
193 static HRESULT WINAPI
WebBrowser_GetTypeInfo(IWebBrowser2
*iface
, UINT iTInfo
, LCID lcid
,
196 WebBrowser
*This
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
, WEBBROWSER2(This
), dispIdMember
, wFlags
, pDispParams
,
246 pVarResult
, pExepInfo
, puArgErr
);
249 /* IWebBrowser methods */
250 static HRESULT WINAPI
WebBrowser_GoBack(IWebBrowser2
*iface
)
252 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
253 FIXME("(%p)\n", This
);
257 static HRESULT WINAPI
WebBrowser_GoForward(IWebBrowser2
*iface
)
259 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
260 FIXME("(%p)\n", This
);
264 static HRESULT WINAPI
WebBrowser_GoHome(IWebBrowser2
*iface
)
266 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
267 TRACE("(%p)\n", This
);
268 return go_home(&This
->doc_host
);
271 static HRESULT WINAPI
WebBrowser_GoSearch(IWebBrowser2
*iface
)
273 WebBrowser
*This
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(iface
);
294 FIXME("(%p)\n", This
);
298 static HRESULT WINAPI
WebBrowser_Refresh2(IWebBrowser2
*iface
, VARIANT
*Level
)
300 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
301 FIXME("(%p)->(%s)\n", This
, debugstr_variant(Level
));
305 static HRESULT WINAPI
WebBrowser_Stop(IWebBrowser2
*iface
)
307 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
308 FIXME("(%p)\n", This
);
312 static HRESULT WINAPI
WebBrowser_get_Application(IWebBrowser2
*iface
, IDispatch
**ppDisp
)
314 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
316 TRACE("(%p)->(%p)\n", This
, ppDisp
);
321 *ppDisp
= (IDispatch
*)WEBBROWSER2(This
);
322 IDispatch_AddRef(*ppDisp
);
326 static HRESULT WINAPI
WebBrowser_get_Parent(IWebBrowser2
*iface
, IDispatch
**ppDisp
)
328 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
329 FIXME("(%p)->(%p)\n", This
, ppDisp
);
333 static HRESULT WINAPI
WebBrowser_get_Container(IWebBrowser2
*iface
, IDispatch
**ppDisp
)
335 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
336 FIXME("(%p)->(%p)\n", This
, ppDisp
);
340 static HRESULT WINAPI
WebBrowser_get_Document(IWebBrowser2
*iface
, IDispatch
**ppDisp
)
342 WebBrowser
*This
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(iface
);
371 FIXME("(%p)->(%p)\n", This
, pBool
);
375 static HRESULT WINAPI
WebBrowser_get_Type(IWebBrowser2
*iface
, BSTR
*Type
)
377 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
378 FIXME("(%p)->(%p)\n", This
, Type
);
382 static HRESULT WINAPI
WebBrowser_get_Left(IWebBrowser2
*iface
, LONG
*pl
)
384 WebBrowser
*This
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(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
= WEBBROWSER_THIS(iface
);
497 FIXME("(%p)->(%p)\n", This
, LocationName
);
501 static HRESULT WINAPI
WebBrowser_get_LocationURL(IWebBrowser2
*iface
, BSTR
*LocationURL
)
503 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
505 FIXME("(%p)->(%p)\n", This
, LocationURL
);
507 if(!This
->doc_host
.url
) {
508 static const WCHAR null_char
= 0;
509 *LocationURL
= SysAllocString(&null_char
);
513 *LocationURL
= SysAllocString(This
->doc_host
.url
);
517 static HRESULT WINAPI
WebBrowser_get_Busy(IWebBrowser2
*iface
, VARIANT_BOOL
*pBool
)
519 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
521 TRACE("(%p)->(%p)\n", This
, pBool
);
523 *pBool
= This
->doc_host
.busy
;
527 static HRESULT WINAPI
WebBrowser_Quit(IWebBrowser2
*iface
)
529 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
531 TRACE("(%p)\n", This
);
533 /* It's a InternetExplorer specific method, we have nothing to do here. */
537 static HRESULT WINAPI
WebBrowser_ClientToWindow(IWebBrowser2
*iface
, int *pcx
, int *pcy
)
539 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
540 FIXME("(%p)->(%p %p)\n", This
, pcx
, pcy
);
544 static HRESULT WINAPI
WebBrowser_PutProperty(IWebBrowser2
*iface
, BSTR szProperty
, VARIANT vtValue
)
546 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
547 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(szProperty
), debugstr_variant(&vtValue
));
551 static HRESULT WINAPI
WebBrowser_GetProperty(IWebBrowser2
*iface
, BSTR szProperty
, VARIANT
*pvtValue
)
553 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
554 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(szProperty
), debugstr_variant(pvtValue
));
558 static HRESULT WINAPI
WebBrowser_get_Name(IWebBrowser2
*iface
, BSTR
*Name
)
560 static const WCHAR sName
[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
561 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
562 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
564 TRACE("(%p)->(%p)\n", This
, Name
);
566 *Name
= SysAllocString(sName
);
571 static HRESULT WINAPI
WebBrowser_get_HWND(IWebBrowser2
*iface
, LONG
*pHWND
)
573 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
575 TRACE("(%p)->(%p)\n", This
, pHWND
);
577 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
582 static HRESULT WINAPI
WebBrowser_get_FullName(IWebBrowser2
*iface
, BSTR
*FullName
)
584 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
585 FIXME("(%p)->(%p)\n", This
, FullName
);
589 static HRESULT WINAPI
WebBrowser_get_Path(IWebBrowser2
*iface
, BSTR
*Path
)
591 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
592 FIXME("(%p)->(%p)\n", This
, Path
);
596 static HRESULT WINAPI
WebBrowser_get_Visible(IWebBrowser2
*iface
, VARIANT_BOOL
*pBool
)
598 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
600 TRACE("(%p)->(%p)\n", This
, pBool
);
602 *pBool
= This
->visible
;
606 static HRESULT WINAPI
WebBrowser_put_Visible(IWebBrowser2
*iface
, VARIANT_BOOL Value
)
608 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
610 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
612 TRACE("(%p)->(%x)\n", This
, Value
);
614 This
->visible
= Value
;
616 V_VT(&arg
) = VT_BOOL
;
617 V_BOOL(&arg
) = Value
;
618 call_sink(This
->doc_host
.cps
.wbe2
, DISPID_ONVISIBLE
, &dispparams
);
623 static HRESULT WINAPI
WebBrowser_get_StatusBar(IWebBrowser2
*iface
, VARIANT_BOOL
*pBool
)
625 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
627 TRACE("(%p)->(%p)\n", This
, pBool
);
629 *pBool
= This
->status_bar
;
633 static HRESULT WINAPI
WebBrowser_put_StatusBar(IWebBrowser2
*iface
, VARIANT_BOOL Value
)
635 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
637 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
639 TRACE("(%p)->(%x)\n", This
, Value
);
641 This
->status_bar
= Value
? VARIANT_TRUE
: VARIANT_FALSE
;
643 /* In opposition to InternetExplorer, all we should do here is
644 * inform the embedder about the status bar change. */
646 V_VT(&arg
) = VT_BOOL
;
647 V_BOOL(&arg
) = Value
;
648 call_sink(This
->doc_host
.cps
.wbe2
, DISPID_ONSTATUSBAR
, &dispparams
);
653 static HRESULT WINAPI
WebBrowser_get_StatusText(IWebBrowser2
*iface
, BSTR
*StatusText
)
655 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
656 FIXME("(%p)->(%p)\n", This
, StatusText
);
660 static HRESULT WINAPI
WebBrowser_put_StatusText(IWebBrowser2
*iface
, BSTR StatusText
)
662 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
663 FIXME("(%p)->(%s)\n", This
, debugstr_w(StatusText
));
667 static HRESULT WINAPI
WebBrowser_get_ToolBar(IWebBrowser2
*iface
, int *Value
)
669 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
671 TRACE("(%p)->(%p)\n", This
, Value
);
673 *Value
= This
->tool_bar
;
677 static HRESULT WINAPI
WebBrowser_put_ToolBar(IWebBrowser2
*iface
, int Value
)
679 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
681 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
683 TRACE("(%p)->(%x)\n", This
, Value
);
685 This
->tool_bar
= Value
? VARIANT_TRUE
: VARIANT_FALSE
;
687 /* In opposition to InternetExplorer, all we should do here is
688 * inform the embedder about the tool bar change. */
690 V_VT(&arg
) = VT_BOOL
;
691 V_BOOL(&arg
) = This
->tool_bar
;
692 call_sink(This
->doc_host
.cps
.wbe2
, DISPID_ONTOOLBAR
, &dispparams
);
697 static HRESULT WINAPI
WebBrowser_get_MenuBar(IWebBrowser2
*iface
, VARIANT_BOOL
*Value
)
699 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
701 TRACE("(%p)->(%p)\n", This
, Value
);
703 *Value
= This
->menu_bar
;
707 static HRESULT WINAPI
WebBrowser_put_MenuBar(IWebBrowser2
*iface
, VARIANT_BOOL Value
)
709 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
711 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
713 TRACE("(%p)->(%x)\n", This
, Value
);
715 This
->menu_bar
= Value
? VARIANT_TRUE
: VARIANT_FALSE
;
717 /* In opposition to InternetExplorer, all we should do here is
718 * inform the embedder about the menu bar change. */
720 V_VT(&arg
) = VT_BOOL
;
721 V_BOOL(&arg
) = Value
;
722 call_sink(This
->doc_host
.cps
.wbe2
, DISPID_ONMENUBAR
, &dispparams
);
727 static HRESULT WINAPI
WebBrowser_get_FullScreen(IWebBrowser2
*iface
, VARIANT_BOOL
*pbFullScreen
)
729 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
731 TRACE("(%p)->(%p)\n", This
, pbFullScreen
);
733 *pbFullScreen
= This
->full_screen
;
737 static HRESULT WINAPI
WebBrowser_put_FullScreen(IWebBrowser2
*iface
, VARIANT_BOOL bFullScreen
)
739 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
741 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
743 /* In opposition to InternetExplorer, all we should do here is
744 * inform the embedder about the fullscreen change. */
746 TRACE("(%p)->(%x)\n", This
, bFullScreen
);
748 This
->full_screen
= bFullScreen
? VARIANT_TRUE
: VARIANT_FALSE
;
750 V_VT(&arg
) = VT_BOOL
;
751 V_BOOL(&arg
) = bFullScreen
;
752 call_sink(This
->doc_host
.cps
.wbe2
, DISPID_ONFULLSCREEN
, &dispparams
);
757 static HRESULT WINAPI
WebBrowser_Navigate2(IWebBrowser2
*iface
, VARIANT
*URL
, VARIANT
*Flags
,
758 VARIANT
*TargetFrameName
, VARIANT
*PostData
, VARIANT
*Headers
)
760 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
763 TRACE("(%p)->(%s %s %s %s %s)\n", This
, debugstr_variant(URL
), debugstr_variant(Flags
),
764 debugstr_variant(TargetFrameName
), debugstr_variant(PostData
), debugstr_variant(Headers
));
777 case VT_BSTR
|VT_BYREF
:
778 url
= *V_BSTRREF(URL
);
781 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL
));
785 return navigate_url(&This
->doc_host
, url
, Flags
, TargetFrameName
, PostData
, Headers
);
788 static HRESULT WINAPI
WebBrowser_QueryStatusWB(IWebBrowser2
*iface
, OLECMDID cmdID
, OLECMDF
*pcmdf
)
790 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
791 FIXME("(%p)->(%d %p)\n", This
, cmdID
, pcmdf
);
795 static HRESULT WINAPI
WebBrowser_ExecWB(IWebBrowser2
*iface
, OLECMDID cmdID
,
796 OLECMDEXECOPT cmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
798 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
799 FIXME("(%p)->(%d %d %s %p)\n", This
, cmdID
, cmdexecopt
, debugstr_variant(pvaIn
), pvaOut
);
803 static HRESULT WINAPI
WebBrowser_ShowBrowserBar(IWebBrowser2
*iface
, VARIANT
*pvaClsid
,
804 VARIANT
*pvarShow
, VARIANT
*pvarSize
)
806 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
807 FIXME("(%p)->(%s %s %s)\n", This
, debugstr_variant(pvaClsid
), debugstr_variant(pvarShow
),
808 debugstr_variant(pvarSize
));
812 static HRESULT WINAPI
WebBrowser_get_ReadyState(IWebBrowser2
*iface
, READYSTATE
*lpReadyState
)
814 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
816 TRACE("(%p)->(%p)\n", This
, lpReadyState
);
818 *lpReadyState
= This
->doc_host
.ready_state
;
822 static HRESULT WINAPI
WebBrowser_get_Offline(IWebBrowser2
*iface
, VARIANT_BOOL
*pbOffline
)
824 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
826 TRACE("(%p)->(%p)\n", This
, pbOffline
);
828 *pbOffline
= This
->doc_host
.offline
;
832 static HRESULT WINAPI
WebBrowser_put_Offline(IWebBrowser2
*iface
, VARIANT_BOOL bOffline
)
834 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
836 TRACE("(%p)->(%x)\n", This
, bOffline
);
838 This
->doc_host
.offline
= bOffline
? VARIANT_TRUE
: VARIANT_FALSE
;
842 static HRESULT WINAPI
WebBrowser_get_Silent(IWebBrowser2
*iface
, VARIANT_BOOL
*pbSilent
)
844 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
846 TRACE("(%p)->(%p)\n", This
, pbSilent
);
848 *pbSilent
= This
->doc_host
.silent
;
852 static HRESULT WINAPI
WebBrowser_put_Silent(IWebBrowser2
*iface
, VARIANT_BOOL bSilent
)
854 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
856 TRACE("(%p)->(%x)\n", This
, bSilent
);
858 This
->doc_host
.silent
= bSilent
? VARIANT_TRUE
: VARIANT_FALSE
;
862 static HRESULT WINAPI
WebBrowser_get_RegisterAsBrowser(IWebBrowser2
*iface
,
863 VARIANT_BOOL
*pbRegister
)
865 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
867 FIXME("(%p)->(%p)\n", This
, pbRegister
);
869 *pbRegister
= This
->register_browser
;
873 static HRESULT WINAPI
WebBrowser_put_RegisterAsBrowser(IWebBrowser2
*iface
,
874 VARIANT_BOOL bRegister
)
876 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
878 FIXME("(%p)->(%x)\n", This
, bRegister
);
880 This
->register_browser
= bRegister
? VARIANT_TRUE
: VARIANT_FALSE
;
884 static HRESULT WINAPI
WebBrowser_get_RegisterAsDropTarget(IWebBrowser2
*iface
,
885 VARIANT_BOOL
*pbRegister
)
887 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
888 FIXME("(%p)->(%p)\n", This
, pbRegister
);
893 static HRESULT WINAPI
WebBrowser_put_RegisterAsDropTarget(IWebBrowser2
*iface
,
894 VARIANT_BOOL bRegister
)
896 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
897 FIXME("(%p)->(%x)\n", This
, bRegister
);
901 static HRESULT WINAPI
WebBrowser_get_TheaterMode(IWebBrowser2
*iface
, VARIANT_BOOL
*pbRegister
)
903 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
905 TRACE("(%p)->(%p)\n", This
, pbRegister
);
907 *pbRegister
= This
->theater_mode
;
911 static HRESULT WINAPI
WebBrowser_put_TheaterMode(IWebBrowser2
*iface
, VARIANT_BOOL bRegister
)
913 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
915 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
917 TRACE("(%p)->(%x)\n", This
, bRegister
);
919 This
->theater_mode
= bRegister
? VARIANT_TRUE
: VARIANT_FALSE
;
921 /* In opposition to InternetExplorer, all we should do here is
922 * inform the embedder about the theater mode change. */
924 V_VT(&arg
) = VT_BOOL
;
925 V_BOOL(&arg
) = bRegister
;
926 call_sink(This
->doc_host
.cps
.wbe2
, DISPID_ONTHEATERMODE
, &dispparams
);
931 static HRESULT WINAPI
WebBrowser_get_AddressBar(IWebBrowser2
*iface
, VARIANT_BOOL
*Value
)
933 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
935 TRACE("(%p)->(%p)\n", This
, Value
);
937 *Value
= This
->address_bar
;
941 static HRESULT WINAPI
WebBrowser_put_AddressBar(IWebBrowser2
*iface
, VARIANT_BOOL Value
)
943 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
945 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
947 TRACE("(%p)->(%x)\n", This
, Value
);
949 This
->address_bar
= Value
? VARIANT_TRUE
: VARIANT_FALSE
;
951 /* In opposition to InternetExplorer, all we should do here is
952 * inform the embedder about the address bar change. */
954 V_VT(&arg
) = VT_BOOL
;
955 V_BOOL(&arg
) = Value
;
956 call_sink(This
->doc_host
.cps
.wbe2
, DISPID_ONADDRESSBAR
, &dispparams
);
961 static HRESULT WINAPI
WebBrowser_get_Resizable(IWebBrowser2
*iface
, VARIANT_BOOL
*Value
)
963 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
965 TRACE("(%p)->(%p)\n", This
, Value
);
967 /* It's InternetExplorer object's method. We have nothing to do here. */
971 static HRESULT WINAPI
WebBrowser_put_Resizable(IWebBrowser2
*iface
, VARIANT_BOOL Value
)
973 WebBrowser
*This
= WEBBROWSER_THIS(iface
);
975 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
977 TRACE("(%p)->(%x)\n", This
, Value
);
979 /* In opposition to InternetExplorer, all we should do here is
980 * inform the embedder about the resizable change. */
982 V_VT(&arg
) = VT_BOOL
;
983 V_BOOL(&arg
) = Value
;
984 call_sink(This
->doc_host
.cps
.wbe2
, DISPID_WINDOWSETRESIZABLE
, &dispparams
);
989 #undef WEBBROWSER_THIS
991 static const IWebBrowser2Vtbl WebBrowser2Vtbl
=
993 WebBrowser_QueryInterface
,
996 WebBrowser_GetTypeInfoCount
,
997 WebBrowser_GetTypeInfo
,
998 WebBrowser_GetIDsOfNames
,
1001 WebBrowser_GoForward
,
1003 WebBrowser_GoSearch
,
1004 WebBrowser_Navigate
,
1006 WebBrowser_Refresh2
,
1008 WebBrowser_get_Application
,
1009 WebBrowser_get_Parent
,
1010 WebBrowser_get_Container
,
1011 WebBrowser_get_Document
,
1012 WebBrowser_get_TopLevelContainer
,
1013 WebBrowser_get_Type
,
1014 WebBrowser_get_Left
,
1015 WebBrowser_put_Left
,
1018 WebBrowser_get_Width
,
1019 WebBrowser_put_Width
,
1020 WebBrowser_get_Height
,
1021 WebBrowser_put_Height
,
1022 WebBrowser_get_LocationName
,
1023 WebBrowser_get_LocationURL
,
1024 WebBrowser_get_Busy
,
1026 WebBrowser_ClientToWindow
,
1027 WebBrowser_PutProperty
,
1028 WebBrowser_GetProperty
,
1029 WebBrowser_get_Name
,
1030 WebBrowser_get_HWND
,
1031 WebBrowser_get_FullName
,
1032 WebBrowser_get_Path
,
1033 WebBrowser_get_Visible
,
1034 WebBrowser_put_Visible
,
1035 WebBrowser_get_StatusBar
,
1036 WebBrowser_put_StatusBar
,
1037 WebBrowser_get_StatusText
,
1038 WebBrowser_put_StatusText
,
1039 WebBrowser_get_ToolBar
,
1040 WebBrowser_put_ToolBar
,
1041 WebBrowser_get_MenuBar
,
1042 WebBrowser_put_MenuBar
,
1043 WebBrowser_get_FullScreen
,
1044 WebBrowser_put_FullScreen
,
1045 WebBrowser_Navigate2
,
1046 WebBrowser_QueryStatusWB
,
1048 WebBrowser_ShowBrowserBar
,
1049 WebBrowser_get_ReadyState
,
1050 WebBrowser_get_Offline
,
1051 WebBrowser_put_Offline
,
1052 WebBrowser_get_Silent
,
1053 WebBrowser_put_Silent
,
1054 WebBrowser_get_RegisterAsBrowser
,
1055 WebBrowser_put_RegisterAsBrowser
,
1056 WebBrowser_get_RegisterAsDropTarget
,
1057 WebBrowser_put_RegisterAsDropTarget
,
1058 WebBrowser_get_TheaterMode
,
1059 WebBrowser_put_TheaterMode
,
1060 WebBrowser_get_AddressBar
,
1061 WebBrowser_put_AddressBar
,
1062 WebBrowser_get_Resizable
,
1063 WebBrowser_put_Resizable
1066 #define SERVPROV_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
1068 * IServiceProvider interface.
1070 static HRESULT WINAPI
WebBrowser_IServiceProvider_QueryInterface(IServiceProvider
*iface
,
1071 REFIID riid
, LPVOID
*ppv
)
1073 WebBrowser
*This
= SERVPROV_THIS(iface
);
1079 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1080 *ppv
= WEBBROWSER(This
);
1081 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1082 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
1083 *ppv
= WEBBROWSER(This
);
1084 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
1088 IUnknown_AddRef((IUnknown
*)*ppv
);
1092 FIXME("(%p)->(%s %p) interface not supported\n", This
, debugstr_guid(riid
), ppv
);
1093 return E_NOINTERFACE
;
1096 static ULONG WINAPI
WebBrowser_IServiceProvider_AddRef(IServiceProvider
*iface
)
1098 WebBrowser
*This
= SERVPROV_THIS(iface
);
1099 return IWebBrowser_AddRef(WEBBROWSER(This
));
1102 static ULONG WINAPI
WebBrowser_IServiceProvider_Release(IServiceProvider
*iface
)
1104 WebBrowser
*This
= SERVPROV_THIS(iface
);
1105 return IWebBrowser_Release(WEBBROWSER(This
));
1108 static HRESULT STDMETHODCALLTYPE
WebBrowser_IServiceProvider_QueryService(IServiceProvider
*iface
,
1109 REFGUID guidService
, REFIID riid
, void **ppv
)
1111 WebBrowser
*This
= SERVPROV_THIS(iface
);
1112 static const IID IID_IBrowserService2
=
1113 {0x68BD21CC,0x438B,0x11d2,{0xA5,0x60,0x00,0xA0,0xC,0x2D,0xBF,0xE8}};
1118 if(IsEqualGUID(&IID_IBrowserService2
, riid
)) {
1119 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This
);
1123 FIXME("(%p)->(%s, %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
1125 return E_NOINTERFACE
;
1128 #undef SERVPROV_THIS
1130 static const IServiceProviderVtbl ServiceProviderVtbl
=
1132 WebBrowser_IServiceProvider_QueryInterface
,
1133 WebBrowser_IServiceProvider_AddRef
,
1134 WebBrowser_IServiceProvider_Release
,
1135 WebBrowser_IServiceProvider_QueryService
1138 #define DOCHOST_THIS(iface) DEFINE_THIS2(WebBrowser,doc_host,iface)
1140 static void WINAPI
DocHostContainer_GetDocObjRect(DocHost
* This
, RECT
* rc
)
1142 GetClientRect(This
->frame_hwnd
, rc
);
1145 static HRESULT WINAPI
DocHostContainer_SetStatusText(DocHost
* This
, LPCWSTR text
)
1150 static void WINAPI
DocHostContainer_SetURL(DocHost
* This
, LPCWSTR url
)
1155 static HRESULT
DocHostContainer_exec(DocHost
*doc_host
, const GUID
*cmd_group
, DWORD cmdid
, DWORD execopt
, VARIANT
*in
,
1158 WebBrowser
*This
= DOCHOST_THIS(doc_host
);
1159 IOleCommandTarget
*cmdtrg
= NULL
;
1163 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1168 if(!cmdtrg
&& This
->container
) {
1169 hres
= IOleContainer_QueryInterface(This
->container
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1177 hres
= IOleCommandTarget_Exec(cmdtrg
, cmd_group
, cmdid
, execopt
, in
, out
);
1178 IOleCommandTarget_Release(cmdtrg
);
1180 FIXME("Exec failed\n");
1187 static const IDocHostContainerVtbl DocHostContainerVtbl
= {
1188 DocHostContainer_GetDocObjRect
,
1189 DocHostContainer_SetStatusText
,
1190 DocHostContainer_SetURL
,
1191 DocHostContainer_exec
1194 static HRESULT
WebBrowser_Create(INT version
, IUnknown
*pOuter
, REFIID riid
, void **ppv
)
1199 TRACE("(%p %s %p) version=%d\n", pOuter
, debugstr_guid(riid
), ppv
, version
);
1201 ret
= heap_alloc_zero(sizeof(WebBrowser
));
1203 ret
->lpWebBrowser2Vtbl
= &WebBrowser2Vtbl
;
1204 ret
->lpServiceProviderVtbl
= &ServiceProviderVtbl
;
1206 ret
->version
= version
;
1208 DocHost_Init(&ret
->doc_host
, (IDispatch
*)WEBBROWSER2(ret
), &DocHostContainerVtbl
);
1210 ret
->visible
= VARIANT_TRUE
;
1211 ret
->menu_bar
= VARIANT_TRUE
;
1212 ret
->address_bar
= VARIANT_TRUE
;
1213 ret
->status_bar
= VARIANT_TRUE
;
1214 ret
->tool_bar
= VARIANT_TRUE
;
1216 WebBrowser_OleObject_Init(ret
);
1217 WebBrowser_ViewObject_Init(ret
);
1218 WebBrowser_DataObject_Init(ret
);
1219 WebBrowser_Persist_Init(ret
);
1220 WebBrowser_ClassInfo_Init(ret
);
1222 HlinkFrame_Init(&ret
->hlink_frame
, (IUnknown
*)WEBBROWSER2(ret
), &ret
->doc_host
);
1224 SHDOCVW_LockModule();
1226 hres
= IWebBrowser_QueryInterface(WEBBROWSER(ret
), riid
, ppv
);
1228 IWebBrowser2_Release(WEBBROWSER(ret
));
1232 HRESULT
WebBrowserV1_Create(IUnknown
*pOuter
, REFIID riid
, void **ppv
)
1234 return WebBrowser_Create(1, pOuter
, riid
, ppv
);
1237 HRESULT
WebBrowserV2_Create(IUnknown
*pOuter
, REFIID riid
, void **ppv
)
1239 return WebBrowser_Create(2, pOuter
, riid
, ppv
);