advpack: Run the install test in a temporary directory.
[wine/multimedia.git] / dlls / shdocvw / webbrowser.c
blob3699239821d929826749728102245b16c3c1c197
1 /*
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"
23 #include "shdocvw.h"
24 #include "exdispid.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
28 /**********************************************************************
29 * Implement the IWebBrowser interface
32 #define WEBBROWSER_THIS(iface) DEFINE_THIS(WebBrowser, WebBrowser2, iface)
34 static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
36 WebBrowser *This = WEBBROWSER_THIS(iface);
38 if (ppv == NULL)
39 return E_POINTER;
40 *ppv = NULL;
42 if(IsEqualGUID(&IID_IUnknown, riid)) {
43 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
44 *ppv = WEBBROWSER(This);
45 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
46 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
47 *ppv = WEBBROWSER(This);
48 }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
49 TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
50 *ppv = WEBBROWSER(This);
51 }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
52 TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
53 *ppv = WEBBROWSER(This);
54 }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
55 TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
56 *ppv = WEBBROWSER(This);
57 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
58 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
59 *ppv = OLEOBJ(This);
60 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
61 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
62 *ppv = INPLACEOBJ(This);
63 }else if(IsEqualGUID (&IID_IOleInPlaceObject, riid)) {
64 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
65 *ppv = INPLACEOBJ(This);
66 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
67 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
68 *ppv = CONTROL(This);
69 }else if(IsEqualGUID(&IID_IPersist, riid)) {
70 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
71 *ppv = PERSTORAGE(This);
72 }else if(IsEqualGUID(&IID_IPersistStorage, riid)) {
73 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
74 *ppv = PERSTORAGE(This);
75 }else if(IsEqualGUID(&IID_IPersistMemory, riid)) {
76 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
77 *ppv = PERMEMORY(This);
78 }else if(IsEqualGUID (&IID_IPersistStreamInit, riid)) {
79 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
80 *ppv = PERSTRINIT(This);
81 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
82 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
83 *ppv = CLASSINFO(This);
84 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
85 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
86 *ppv = CLASSINFO(This);
87 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
88 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
89 *ppv = CONPTCONT(&This->doc_host.cps);
90 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
91 TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
92 *ppv = VIEWOBJ(This);
93 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
94 TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
95 *ppv = VIEWOBJ2(This);
96 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
97 TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
98 *ppv = ACTIVEOBJ(This);
99 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
100 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
101 *ppv = OLECMD(This);
102 }else if(IsEqualGUID(&IID_IHlinkFrame, riid)) {
103 TRACE("(%p)->(IID_IHlinkFrame %p)\n", This, ppv);
104 *ppv = HLINKFRAME(This);
105 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
106 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
107 return E_NOINTERFACE;
108 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
109 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
110 return E_NOINTERFACE;
111 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
112 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
113 return E_NOINTERFACE;
114 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
115 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
116 return E_NOINTERFACE;
117 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
118 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
119 return E_NOINTERFACE;
120 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
121 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
122 return E_NOINTERFACE;
125 if(*ppv) {
126 IUnknown_AddRef((IUnknown*)*ppv);
127 return S_OK;
130 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
131 return E_NOINTERFACE;
134 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
136 WebBrowser *This = WEBBROWSER_THIS(iface);
137 LONG ref = InterlockedIncrement(&This->ref);
138 TRACE("(%p) ref=%d\n", This, ref);
139 return ref;
142 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
144 WebBrowser *This = WEBBROWSER_THIS(iface);
145 LONG ref = InterlockedDecrement(&This->ref);
147 TRACE("(%p) ref=%d\n", This, ref);
149 if(!ref) {
150 if(This->doc_host.document)
151 IUnknown_Release(This->doc_host.document);
153 DocHost_Release(&This->doc_host);
155 WebBrowser_OleObject_Destroy(This);
157 heap_free(This);
158 SHDOCVW_UnlockModule();
161 return ref;
164 /* IDispatch methods */
165 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
167 WebBrowser *This = WEBBROWSER_THIS(iface);
169 TRACE("(%p)->(%p)\n", This, pctinfo);
171 *pctinfo = 1;
172 return S_OK;
175 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
176 LPTYPEINFO *ppTInfo)
178 WebBrowser *This = WEBBROWSER_THIS(iface);
179 ITypeInfo *typeinfo;
180 HRESULT hres;
182 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
184 hres = get_typeinfo(&typeinfo);
185 if(FAILED(hres))
186 return hres;
188 ITypeInfo_AddRef(typeinfo);
189 *ppTInfo = typeinfo;
190 return S_OK;
193 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
194 LPOLESTR *rgszNames, UINT cNames,
195 LCID lcid, DISPID *rgDispId)
197 WebBrowser *This = WEBBROWSER_THIS(iface);
198 ITypeInfo *typeinfo;
199 HRESULT hres;
201 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
202 lcid, rgDispId);
204 hres = get_typeinfo(&typeinfo);
205 if(FAILED(hres))
206 return hres;
208 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
211 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
212 REFIID riid, LCID lcid, WORD wFlags,
213 DISPPARAMS *pDispParams, VARIANT *pVarResult,
214 EXCEPINFO *pExepInfo, UINT *puArgErr)
216 WebBrowser *This = WEBBROWSER_THIS(iface);
217 ITypeInfo *typeinfo;
218 HRESULT hres;
220 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
221 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
223 hres = get_typeinfo(&typeinfo);
224 if(FAILED(hres))
225 return hres;
227 return ITypeInfo_Invoke(typeinfo, WEBBROWSER2(This), dispIdMember, wFlags, pDispParams,
228 pVarResult, pExepInfo, puArgErr);
231 /* IWebBrowser methods */
232 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
234 WebBrowser *This = WEBBROWSER_THIS(iface);
235 FIXME("(%p)\n", This);
236 return E_NOTIMPL;
239 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
241 WebBrowser *This = WEBBROWSER_THIS(iface);
242 FIXME("(%p)\n", This);
243 return E_NOTIMPL;
246 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
248 WebBrowser *This = WEBBROWSER_THIS(iface);
249 TRACE("(%p)\n", This);
250 return go_home(&This->doc_host);
253 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
255 WebBrowser *This = WEBBROWSER_THIS(iface);
256 FIXME("(%p)\n", This);
257 return E_NOTIMPL;
260 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
261 VARIANT *Flags, VARIANT *TargetFrameName,
262 VARIANT *PostData, VARIANT *Headers)
264 WebBrowser *This = WEBBROWSER_THIS(iface);
266 TRACE("(%p)->(%s %p %p %p %p)\n", This, debugstr_w(szUrl), Flags, TargetFrameName,
267 PostData, Headers);
269 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
272 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
274 WebBrowser *This = WEBBROWSER_THIS(iface);
275 FIXME("(%p)\n", This);
276 return E_NOTIMPL;
279 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
281 WebBrowser *This = WEBBROWSER_THIS(iface);
282 FIXME("(%p)->(%p)\n", This, Level);
283 return E_NOTIMPL;
286 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
288 WebBrowser *This = WEBBROWSER_THIS(iface);
289 FIXME("(%p)\n", This);
290 return E_NOTIMPL;
293 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
295 WebBrowser *This = WEBBROWSER_THIS(iface);
297 TRACE("(%p)->(%p)\n", This, ppDisp);
299 if(!ppDisp)
300 return E_POINTER;
302 *ppDisp = (IDispatch*)WEBBROWSER2(This);
303 IDispatch_AddRef(*ppDisp);
304 return S_OK;
307 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
309 WebBrowser *This = WEBBROWSER_THIS(iface);
310 FIXME("(%p)->(%p)\n", This, ppDisp);
311 return E_NOTIMPL;
314 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
316 WebBrowser *This = WEBBROWSER_THIS(iface);
317 FIXME("(%p)->(%p)\n", This, ppDisp);
318 return E_NOTIMPL;
321 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
323 WebBrowser *This = WEBBROWSER_THIS(iface);
325 TRACE("(%p)->(%p)\n", This, ppDisp);
327 *ppDisp = NULL;
328 if(This->doc_host.document)
329 IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)ppDisp);
331 return S_OK;
334 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
336 WebBrowser *This = WEBBROWSER_THIS(iface);
337 FIXME("(%p)->(%p)\n", This, pBool);
338 return E_NOTIMPL;
341 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
343 WebBrowser *This = WEBBROWSER_THIS(iface);
344 FIXME("(%p)->(%p)\n", This, Type);
345 return E_NOTIMPL;
348 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, long *pl)
350 WebBrowser *This = WEBBROWSER_THIS(iface);
352 TRACE("(%p)->(%p)\n", This, pl);
354 *pl = This->pos_rect.left;
355 return S_OK;
358 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, long Left)
360 WebBrowser *This = WEBBROWSER_THIS(iface);
361 RECT rect;
363 TRACE("(%p)->(%ld)\n", This, Left);
365 if(!This->inplace)
366 return E_UNEXPECTED;
368 rect = This->pos_rect;
369 rect.left = Left;
371 /* We don't really change the window position here.
372 * We just notify the embedder that he should do so. */
373 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
376 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, long *pl)
378 WebBrowser *This = WEBBROWSER_THIS(iface);
380 TRACE("(%p)->(%p)\n", This, pl);
382 *pl = This->pos_rect.top;
383 return S_OK;
386 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, long Top)
388 WebBrowser *This = WEBBROWSER_THIS(iface);
389 RECT rect;
391 TRACE("(%p)->(%ld)\n", This, Top);
393 if(!This->inplace)
394 return E_UNEXPECTED;
396 rect = This->pos_rect;
397 rect.top = Top;
399 /* We don't really change the window position here.
400 * We just notify the embedder that he should do so. */
401 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
404 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, long *pl)
406 WebBrowser *This = WEBBROWSER_THIS(iface);
408 TRACE("(%p)->(%p)\n", This, pl);
410 *pl = This->pos_rect.right - This->pos_rect.left;
411 return S_OK;
414 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, long Width)
416 WebBrowser *This = WEBBROWSER_THIS(iface);
417 RECT rect;
419 TRACE("(%p)->(%ld)\n", This, Width);
421 if(!This->inplace)
422 return E_UNEXPECTED;
424 rect = This->pos_rect;
425 rect.right = rect.left+Width;
427 /* We don't really change the window size here.
428 * We just notify the embedder that he should do so. */
429 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
432 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, long *pl)
434 WebBrowser *This = WEBBROWSER_THIS(iface);
436 TRACE("(%p)->(%p)\n", This, pl);
438 *pl = This->pos_rect.bottom - This->pos_rect.top;
439 return S_OK;
442 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, long Height)
444 WebBrowser *This = WEBBROWSER_THIS(iface);
445 RECT rect;
447 TRACE("(%p)->(%ld)\n", This, Height);
449 if(!This->inplace)
450 return E_UNEXPECTED;
452 rect = This->pos_rect;
453 rect.bottom = rect.top+Height;
455 /* We don't really change the window size here.
456 * We just notify the embedder that he should do so. */
457 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
460 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
462 WebBrowser *This = WEBBROWSER_THIS(iface);
463 FIXME("(%p)->(%p)\n", This, LocationName);
464 return E_NOTIMPL;
467 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
469 WebBrowser *This = WEBBROWSER_THIS(iface);
471 FIXME("(%p)->(%p)\n", This, LocationURL);
473 if(!This->doc_host.url) {
474 static const WCHAR null_char = 0;
475 *LocationURL = SysAllocString(&null_char);
476 return S_FALSE;
479 *LocationURL = SysAllocString(This->doc_host.url);
480 return S_OK;
483 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
485 WebBrowser *This = WEBBROWSER_THIS(iface);
487 TRACE("(%p)->(%p)\n", This, pBool);
489 *pBool = This->doc_host.busy;
490 return S_OK;
493 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
495 WebBrowser *This = WEBBROWSER_THIS(iface);
497 TRACE("(%p)\n", This);
499 /* It's a InternetExplorer specific method, we have nothing to do here. */
500 return E_FAIL;
503 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
505 WebBrowser *This = WEBBROWSER_THIS(iface);
506 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
507 return E_NOTIMPL;
510 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
512 WebBrowser *This = WEBBROWSER_THIS(iface);
513 FIXME("(%p)->(%s)\n", This, debugstr_w(szProperty));
514 return E_NOTIMPL;
517 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
519 WebBrowser *This = WEBBROWSER_THIS(iface);
520 FIXME("(%p)->(%s %p)\n", This, debugstr_w(szProperty), pvtValue);
521 return E_NOTIMPL;
524 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
526 WebBrowser *This = WEBBROWSER_THIS(iface);
527 FIXME("(%p)->(%p)\n", This, Name);
528 return E_NOTIMPL;
531 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, long *pHWND)
533 WebBrowser *This = WEBBROWSER_THIS(iface);
535 TRACE("(%p)->(%p)\n", This, pHWND);
537 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
538 *pHWND = 0;
539 return E_FAIL;
542 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
544 WebBrowser *This = WEBBROWSER_THIS(iface);
545 FIXME("(%p)->(%p)\n", This, FullName);
546 return E_NOTIMPL;
549 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
551 WebBrowser *This = WEBBROWSER_THIS(iface);
552 FIXME("(%p)->(%p)\n", This, Path);
553 return E_NOTIMPL;
556 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
558 WebBrowser *This = WEBBROWSER_THIS(iface);
560 TRACE("(%p)->(%p)\n", This, pBool);
562 *pBool = This->visible;
563 return S_OK;
566 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
568 WebBrowser *This = WEBBROWSER_THIS(iface);
569 VARIANTARG arg;
570 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
572 TRACE("(%p)->(%x)\n", This, Value);
574 This->visible = Value;
576 V_VT(&arg) = VT_BOOL;
577 V_BOOL(&arg) = Value;
578 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
580 return S_OK;
583 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
585 WebBrowser *This = WEBBROWSER_THIS(iface);
587 TRACE("(%p)->(%p)\n", This, pBool);
589 *pBool = This->status_bar;
590 return S_OK;
593 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
595 WebBrowser *This = WEBBROWSER_THIS(iface);
596 VARIANTARG arg;
597 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
599 TRACE("(%p)->(%x)\n", This, Value);
601 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
603 /* In opposition to InternetExplorer, all we should do here is
604 * inform the embedder about the status bar change. */
606 V_VT(&arg) = VT_BOOL;
607 V_BOOL(&arg) = Value;
608 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
610 return S_OK;
613 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
615 WebBrowser *This = WEBBROWSER_THIS(iface);
616 FIXME("(%p)->(%p)\n", This, StatusText);
617 return E_NOTIMPL;
620 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
622 WebBrowser *This = WEBBROWSER_THIS(iface);
623 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
624 return E_NOTIMPL;
627 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
629 WebBrowser *This = WEBBROWSER_THIS(iface);
631 TRACE("(%p)->(%p)\n", This, Value);
633 *Value = This->tool_bar;
634 return S_OK;
637 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
639 WebBrowser *This = WEBBROWSER_THIS(iface);
640 VARIANTARG arg;
641 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
643 TRACE("(%p)->(%x)\n", This, Value);
645 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
647 /* In opposition to InternetExplorer, all we should do here is
648 * inform the embedder about the tool bar change. */
650 V_VT(&arg) = VT_BOOL;
651 V_BOOL(&arg) = This->tool_bar;
652 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
654 return S_OK;
657 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
659 WebBrowser *This = WEBBROWSER_THIS(iface);
661 TRACE("(%p)->(%p)\n", This, Value);
663 *Value = This->menu_bar;
664 return S_OK;
667 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
669 WebBrowser *This = WEBBROWSER_THIS(iface);
670 VARIANTARG arg;
671 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
673 TRACE("(%p)->(%x)\n", This, Value);
675 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
677 /* In opposition to InternetExplorer, all we should do here is
678 * inform the embedder about the menu bar change. */
680 V_VT(&arg) = VT_BOOL;
681 V_BOOL(&arg) = Value;
682 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
684 return S_OK;
687 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
689 WebBrowser *This = WEBBROWSER_THIS(iface);
691 TRACE("(%p)->(%p)\n", This, pbFullScreen);
693 *pbFullScreen = This->full_screen;
694 return S_OK;
697 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
699 WebBrowser *This = WEBBROWSER_THIS(iface);
700 VARIANTARG arg;
701 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
703 /* In opposition to InternetExplorer, all we should do here is
704 * inform the embedder about the fullscreen change. */
706 TRACE("(%p)->(%x)\n", This, bFullScreen);
708 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
710 V_VT(&arg) = VT_BOOL;
711 V_BOOL(&arg) = bFullScreen;
712 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
714 return S_OK;
717 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
718 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
720 WebBrowser *This = WEBBROWSER_THIS(iface);
722 TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers);
724 if(!This->client)
725 return E_FAIL;
727 if(!URL)
728 return S_OK;
730 if(V_VT(URL) != VT_BSTR) {
731 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
732 return E_INVALIDARG;
735 return navigate_url(&This->doc_host, V_BSTR(URL), Flags, TargetFrameName, PostData, Headers);
738 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
740 WebBrowser *This = WEBBROWSER_THIS(iface);
741 FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
742 return E_NOTIMPL;
745 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
746 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
748 WebBrowser *This = WEBBROWSER_THIS(iface);
749 FIXME("(%p)->(%d %d %p %p)\n", This, cmdID, cmdexecopt, pvaIn, pvaOut);
750 return E_NOTIMPL;
753 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
754 VARIANT *pvarShow, VARIANT *pvarSize)
756 WebBrowser *This = WEBBROWSER_THIS(iface);
757 FIXME("(%p)->(%p %p %p)\n", This, pvaClsid, pvarShow, pvarSize);
758 return E_NOTIMPL;
761 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
763 WebBrowser *This = WEBBROWSER_THIS(iface);
764 FIXME("(%p)->(%p)\n", This, lpReadyState);
766 *lpReadyState = READYSTATE_COMPLETE;
767 return S_OK;
770 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
772 WebBrowser *This = WEBBROWSER_THIS(iface);
774 TRACE("(%p)->(%p)\n", This, pbOffline);
776 *pbOffline = This->doc_host.offline;
777 return S_OK;
780 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
782 WebBrowser *This = WEBBROWSER_THIS(iface);
784 TRACE("(%p)->(%x)\n", This, bOffline);
786 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
787 return S_OK;
790 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
792 WebBrowser *This = WEBBROWSER_THIS(iface);
794 TRACE("(%p)->(%p)\n", This, pbSilent);
796 *pbSilent = This->doc_host.silent;
797 return S_OK;
800 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
802 WebBrowser *This = WEBBROWSER_THIS(iface);
804 TRACE("(%p)->(%x)\n", This, bSilent);
806 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
807 return S_OK;
810 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
811 VARIANT_BOOL *pbRegister)
813 WebBrowser *This = WEBBROWSER_THIS(iface);
815 FIXME("(%p)->(%p)\n", This, pbRegister);
817 *pbRegister = This->register_browser;
818 return S_OK;
821 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
822 VARIANT_BOOL bRegister)
824 WebBrowser *This = WEBBROWSER_THIS(iface);
826 FIXME("(%p)->(%x)\n", This, bRegister);
828 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
829 return S_OK;
832 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
833 VARIANT_BOOL *pbRegister)
835 WebBrowser *This = WEBBROWSER_THIS(iface);
836 FIXME("(%p)->(%p)\n", This, pbRegister);
837 *pbRegister=0;
838 return S_OK;
841 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
842 VARIANT_BOOL bRegister)
844 WebBrowser *This = WEBBROWSER_THIS(iface);
845 FIXME("(%p)->(%x)\n", This, bRegister);
846 return S_OK;
849 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
851 WebBrowser *This = WEBBROWSER_THIS(iface);
853 TRACE("(%p)->(%p)\n", This, pbRegister);
855 *pbRegister = This->theater_mode;
856 return S_OK;
859 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
861 WebBrowser *This = WEBBROWSER_THIS(iface);
862 VARIANTARG arg;
863 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
865 TRACE("(%p)->(%x)\n", This, bRegister);
867 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
869 /* In opposition to InternetExplorer, all we should do here is
870 * inform the embedder about the theater mode change. */
872 V_VT(&arg) = VT_BOOL;
873 V_BOOL(&arg) = bRegister;
874 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
876 return S_OK;
879 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
881 WebBrowser *This = WEBBROWSER_THIS(iface);
883 TRACE("(%p)->(%p)\n", This, Value);
885 *Value = This->address_bar;
886 return S_OK;
889 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
891 WebBrowser *This = WEBBROWSER_THIS(iface);
892 VARIANTARG arg;
893 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
895 TRACE("(%p)->(%x)\n", This, Value);
897 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
899 /* In opposition to InternetExplorer, all we should do here is
900 * inform the embedder about the address bar change. */
902 V_VT(&arg) = VT_BOOL;
903 V_BOOL(&arg) = Value;
904 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
906 return S_OK;
909 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
911 WebBrowser *This = WEBBROWSER_THIS(iface);
913 TRACE("(%p)->(%p)\n", This, Value);
915 /* It's InternetExplorer object's method. We have nothing to do here. */
916 return E_NOTIMPL;
919 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
921 WebBrowser *This = WEBBROWSER_THIS(iface);
922 VARIANTARG arg;
923 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
925 TRACE("(%p)->(%x)\n", This, Value);
927 /* In opposition to InternetExplorer, all we should do here is
928 * inform the embedder about the resizable change. */
930 V_VT(&arg) = VT_BOOL;
931 V_BOOL(&arg) = Value;
932 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
934 return S_OK;
937 #undef WEBBROWSER_THIS
939 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
941 WebBrowser_QueryInterface,
942 WebBrowser_AddRef,
943 WebBrowser_Release,
944 WebBrowser_GetTypeInfoCount,
945 WebBrowser_GetTypeInfo,
946 WebBrowser_GetIDsOfNames,
947 WebBrowser_Invoke,
948 WebBrowser_GoBack,
949 WebBrowser_GoForward,
950 WebBrowser_GoHome,
951 WebBrowser_GoSearch,
952 WebBrowser_Navigate,
953 WebBrowser_Refresh,
954 WebBrowser_Refresh2,
955 WebBrowser_Stop,
956 WebBrowser_get_Application,
957 WebBrowser_get_Parent,
958 WebBrowser_get_Container,
959 WebBrowser_get_Document,
960 WebBrowser_get_TopLevelContainer,
961 WebBrowser_get_Type,
962 WebBrowser_get_Left,
963 WebBrowser_put_Left,
964 WebBrowser_get_Top,
965 WebBrowser_put_Top,
966 WebBrowser_get_Width,
967 WebBrowser_put_Width,
968 WebBrowser_get_Height,
969 WebBrowser_put_Height,
970 WebBrowser_get_LocationName,
971 WebBrowser_get_LocationURL,
972 WebBrowser_get_Busy,
973 WebBrowser_Quit,
974 WebBrowser_ClientToWindow,
975 WebBrowser_PutProperty,
976 WebBrowser_GetProperty,
977 WebBrowser_get_Name,
978 WebBrowser_get_HWND,
979 WebBrowser_get_FullName,
980 WebBrowser_get_Path,
981 WebBrowser_get_Visible,
982 WebBrowser_put_Visible,
983 WebBrowser_get_StatusBar,
984 WebBrowser_put_StatusBar,
985 WebBrowser_get_StatusText,
986 WebBrowser_put_StatusText,
987 WebBrowser_get_ToolBar,
988 WebBrowser_put_ToolBar,
989 WebBrowser_get_MenuBar,
990 WebBrowser_put_MenuBar,
991 WebBrowser_get_FullScreen,
992 WebBrowser_put_FullScreen,
993 WebBrowser_Navigate2,
994 WebBrowser_QueryStatusWB,
995 WebBrowser_ExecWB,
996 WebBrowser_ShowBrowserBar,
997 WebBrowser_get_ReadyState,
998 WebBrowser_get_Offline,
999 WebBrowser_put_Offline,
1000 WebBrowser_get_Silent,
1001 WebBrowser_put_Silent,
1002 WebBrowser_get_RegisterAsBrowser,
1003 WebBrowser_put_RegisterAsBrowser,
1004 WebBrowser_get_RegisterAsDropTarget,
1005 WebBrowser_put_RegisterAsDropTarget,
1006 WebBrowser_get_TheaterMode,
1007 WebBrowser_put_TheaterMode,
1008 WebBrowser_get_AddressBar,
1009 WebBrowser_put_AddressBar,
1010 WebBrowser_get_Resizable,
1011 WebBrowser_put_Resizable
1014 static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, void **ppv)
1016 WebBrowser *ret;
1017 HRESULT hres;
1019 TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
1021 ret = heap_alloc(sizeof(WebBrowser));
1023 ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
1024 ret->ref = 0;
1025 ret->version = version;
1027 DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
1029 ret->register_browser = VARIANT_FALSE;
1030 ret->visible = VARIANT_TRUE;
1031 ret->menu_bar = VARIANT_TRUE;
1032 ret->address_bar = VARIANT_TRUE;
1033 ret->status_bar = VARIANT_TRUE;
1034 ret->tool_bar = VARIANT_TRUE;
1035 ret->full_screen = VARIANT_FALSE;
1036 ret->theater_mode = VARIANT_FALSE;
1038 WebBrowser_OleObject_Init(ret);
1039 WebBrowser_ViewObject_Init(ret);
1040 WebBrowser_Persist_Init(ret);
1041 WebBrowser_ClassInfo_Init(ret);
1042 WebBrowser_HlinkFrame_Init(ret);
1044 hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
1045 if(SUCCEEDED(hres)) {
1046 SHDOCVW_LockModule();
1047 }else {
1048 heap_free(ret);
1049 return hres;
1052 return hres;
1055 HRESULT WebBrowserV1_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1057 return WebBrowser_Create(1, pOuter, riid, ppv);
1060 HRESULT WebBrowserV2_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1062 return WebBrowser_Create(2, pOuter, riid, ppv);