push 378fe7a60681a28e8b22f62dcfe122d585b92570
[wine/hacks.git] / dlls / shdocvw / webbrowser.c
blob9fdbde8eee8f78ce97fb8b51cc10dcdc721c8c27
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_IServiceProvider, riid)) {
106 *ppv = SERVPROV(This);
107 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
108 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
109 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
110 return E_NOINTERFACE;
111 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
112 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
113 return E_NOINTERFACE;
114 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
115 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
116 return E_NOINTERFACE;
117 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
118 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
119 return E_NOINTERFACE;
120 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
121 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
122 return E_NOINTERFACE;
123 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
124 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
125 return E_NOINTERFACE;
126 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
127 TRACE("(%p)->(IID_IViewObjectEx %p) returning NULL\n", This, ppv);
128 return E_NOINTERFACE;
131 if(*ppv) {
132 IUnknown_AddRef((IUnknown*)*ppv);
133 return S_OK;
136 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
137 return E_NOINTERFACE;
140 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
142 WebBrowser *This = WEBBROWSER_THIS(iface);
143 LONG ref = InterlockedIncrement(&This->ref);
144 TRACE("(%p) ref=%d\n", This, ref);
145 return ref;
148 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
150 WebBrowser *This = WEBBROWSER_THIS(iface);
151 LONG ref = InterlockedDecrement(&This->ref);
153 TRACE("(%p) ref=%d\n", This, ref);
155 if(!ref) {
156 if(This->doc_host.document)
157 IUnknown_Release(This->doc_host.document);
159 DocHost_Release(&This->doc_host);
161 WebBrowser_OleObject_Destroy(This);
163 heap_free(This);
164 SHDOCVW_UnlockModule();
167 return ref;
170 /* IDispatch methods */
171 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
173 WebBrowser *This = WEBBROWSER_THIS(iface);
175 TRACE("(%p)->(%p)\n", This, pctinfo);
177 *pctinfo = 1;
178 return S_OK;
181 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
182 LPTYPEINFO *ppTInfo)
184 WebBrowser *This = WEBBROWSER_THIS(iface);
185 ITypeInfo *typeinfo;
186 HRESULT hres;
188 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
190 hres = get_typeinfo(&typeinfo);
191 if(FAILED(hres))
192 return hres;
194 ITypeInfo_AddRef(typeinfo);
195 *ppTInfo = typeinfo;
196 return S_OK;
199 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
200 LPOLESTR *rgszNames, UINT cNames,
201 LCID lcid, DISPID *rgDispId)
203 WebBrowser *This = WEBBROWSER_THIS(iface);
204 ITypeInfo *typeinfo;
205 HRESULT hres;
207 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
208 lcid, rgDispId);
210 hres = get_typeinfo(&typeinfo);
211 if(FAILED(hres))
212 return hres;
214 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
217 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
218 REFIID riid, LCID lcid, WORD wFlags,
219 DISPPARAMS *pDispParams, VARIANT *pVarResult,
220 EXCEPINFO *pExepInfo, UINT *puArgErr)
222 WebBrowser *This = WEBBROWSER_THIS(iface);
223 ITypeInfo *typeinfo;
224 HRESULT hres;
226 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
227 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
229 hres = get_typeinfo(&typeinfo);
230 if(FAILED(hres))
231 return hres;
233 return ITypeInfo_Invoke(typeinfo, WEBBROWSER2(This), dispIdMember, wFlags, pDispParams,
234 pVarResult, pExepInfo, puArgErr);
237 /* IWebBrowser methods */
238 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
240 WebBrowser *This = WEBBROWSER_THIS(iface);
241 FIXME("(%p)\n", This);
242 return E_NOTIMPL;
245 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
247 WebBrowser *This = WEBBROWSER_THIS(iface);
248 FIXME("(%p)\n", This);
249 return E_NOTIMPL;
252 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
254 WebBrowser *This = WEBBROWSER_THIS(iface);
255 TRACE("(%p)\n", This);
256 return go_home(&This->doc_host);
259 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
261 WebBrowser *This = WEBBROWSER_THIS(iface);
262 FIXME("(%p)\n", This);
263 return E_NOTIMPL;
266 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
267 VARIANT *Flags, VARIANT *TargetFrameName,
268 VARIANT *PostData, VARIANT *Headers)
270 WebBrowser *This = WEBBROWSER_THIS(iface);
272 TRACE("(%p)->(%s %p %p %p %p)\n", This, debugstr_w(szUrl), Flags, TargetFrameName,
273 PostData, Headers);
275 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
278 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
280 WebBrowser *This = WEBBROWSER_THIS(iface);
281 FIXME("(%p)\n", This);
282 return E_NOTIMPL;
285 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
287 WebBrowser *This = WEBBROWSER_THIS(iface);
288 FIXME("(%p)->(%p)\n", This, Level);
289 return E_NOTIMPL;
292 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
294 WebBrowser *This = WEBBROWSER_THIS(iface);
295 FIXME("(%p)\n", This);
296 return E_NOTIMPL;
299 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
301 WebBrowser *This = WEBBROWSER_THIS(iface);
303 TRACE("(%p)->(%p)\n", This, ppDisp);
305 if(!ppDisp)
306 return E_POINTER;
308 *ppDisp = (IDispatch*)WEBBROWSER2(This);
309 IDispatch_AddRef(*ppDisp);
310 return S_OK;
313 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
315 WebBrowser *This = WEBBROWSER_THIS(iface);
316 FIXME("(%p)->(%p)\n", This, ppDisp);
317 return E_NOTIMPL;
320 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
322 WebBrowser *This = WEBBROWSER_THIS(iface);
323 FIXME("(%p)->(%p)\n", This, ppDisp);
324 return E_NOTIMPL;
327 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
329 WebBrowser *This = WEBBROWSER_THIS(iface);
331 TRACE("(%p)->(%p)\n", This, ppDisp);
333 *ppDisp = NULL;
334 if(This->doc_host.document)
335 IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)ppDisp);
337 return S_OK;
340 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
342 WebBrowser *This = WEBBROWSER_THIS(iface);
343 FIXME("(%p)->(%p)\n", This, pBool);
344 return E_NOTIMPL;
347 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
349 WebBrowser *This = WEBBROWSER_THIS(iface);
350 FIXME("(%p)->(%p)\n", This, Type);
351 return E_NOTIMPL;
354 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, long *pl)
356 WebBrowser *This = WEBBROWSER_THIS(iface);
358 TRACE("(%p)->(%p)\n", This, pl);
360 *pl = This->pos_rect.left;
361 return S_OK;
364 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, long Left)
366 WebBrowser *This = WEBBROWSER_THIS(iface);
367 RECT rect;
369 TRACE("(%p)->(%ld)\n", This, Left);
371 if(!This->inplace)
372 return E_UNEXPECTED;
374 rect = This->pos_rect;
375 rect.left = Left;
377 /* We don't really change the window position here.
378 * We just notify the embedder that he should do so. */
379 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
382 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, long *pl)
384 WebBrowser *This = WEBBROWSER_THIS(iface);
386 TRACE("(%p)->(%p)\n", This, pl);
388 *pl = This->pos_rect.top;
389 return S_OK;
392 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, long Top)
394 WebBrowser *This = WEBBROWSER_THIS(iface);
395 RECT rect;
397 TRACE("(%p)->(%ld)\n", This, Top);
399 if(!This->inplace)
400 return E_UNEXPECTED;
402 rect = This->pos_rect;
403 rect.top = Top;
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_Width(IWebBrowser2 *iface, long *pl)
412 WebBrowser *This = WEBBROWSER_THIS(iface);
414 TRACE("(%p)->(%p)\n", This, pl);
416 *pl = This->pos_rect.right - This->pos_rect.left;
417 return S_OK;
420 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, long Width)
422 WebBrowser *This = WEBBROWSER_THIS(iface);
423 RECT rect;
425 TRACE("(%p)->(%ld)\n", This, Width);
427 if(!This->inplace)
428 return E_UNEXPECTED;
430 rect = This->pos_rect;
431 rect.right = rect.left+Width;
433 /* We don't really change the window size 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_Height(IWebBrowser2 *iface, long *pl)
440 WebBrowser *This = WEBBROWSER_THIS(iface);
442 TRACE("(%p)->(%p)\n", This, pl);
444 *pl = This->pos_rect.bottom - This->pos_rect.top;
445 return S_OK;
448 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, long Height)
450 WebBrowser *This = WEBBROWSER_THIS(iface);
451 RECT rect;
453 TRACE("(%p)->(%ld)\n", This, Height);
455 if(!This->inplace)
456 return E_UNEXPECTED;
458 rect = This->pos_rect;
459 rect.bottom = rect.top+Height;
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_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
468 WebBrowser *This = WEBBROWSER_THIS(iface);
469 FIXME("(%p)->(%p)\n", This, LocationName);
470 return E_NOTIMPL;
473 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
475 WebBrowser *This = WEBBROWSER_THIS(iface);
477 FIXME("(%p)->(%p)\n", This, LocationURL);
479 if(!This->doc_host.url) {
480 static const WCHAR null_char = 0;
481 *LocationURL = SysAllocString(&null_char);
482 return S_FALSE;
485 *LocationURL = SysAllocString(This->doc_host.url);
486 return S_OK;
489 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
491 WebBrowser *This = WEBBROWSER_THIS(iface);
493 TRACE("(%p)->(%p)\n", This, pBool);
495 *pBool = This->doc_host.busy;
496 return S_OK;
499 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
501 WebBrowser *This = WEBBROWSER_THIS(iface);
503 TRACE("(%p)\n", This);
505 /* It's a InternetExplorer specific method, we have nothing to do here. */
506 return E_FAIL;
509 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
511 WebBrowser *This = WEBBROWSER_THIS(iface);
512 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
513 return E_NOTIMPL;
516 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
518 WebBrowser *This = WEBBROWSER_THIS(iface);
519 FIXME("(%p)->(%s)\n", This, debugstr_w(szProperty));
520 return E_NOTIMPL;
523 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
525 WebBrowser *This = WEBBROWSER_THIS(iface);
526 FIXME("(%p)->(%s %p)\n", This, debugstr_w(szProperty), pvtValue);
527 return E_NOTIMPL;
530 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
532 WebBrowser *This = WEBBROWSER_THIS(iface);
533 FIXME("(%p)->(%p)\n", This, Name);
534 return E_NOTIMPL;
537 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, long *pHWND)
539 WebBrowser *This = WEBBROWSER_THIS(iface);
541 TRACE("(%p)->(%p)\n", This, pHWND);
543 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
544 *pHWND = 0;
545 return E_FAIL;
548 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
550 WebBrowser *This = WEBBROWSER_THIS(iface);
551 FIXME("(%p)->(%p)\n", This, FullName);
552 return E_NOTIMPL;
555 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
557 WebBrowser *This = WEBBROWSER_THIS(iface);
558 FIXME("(%p)->(%p)\n", This, Path);
559 return E_NOTIMPL;
562 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
564 WebBrowser *This = WEBBROWSER_THIS(iface);
566 TRACE("(%p)->(%p)\n", This, pBool);
568 *pBool = This->visible;
569 return S_OK;
572 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
574 WebBrowser *This = WEBBROWSER_THIS(iface);
575 VARIANTARG arg;
576 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
578 TRACE("(%p)->(%x)\n", This, Value);
580 This->visible = Value;
582 V_VT(&arg) = VT_BOOL;
583 V_BOOL(&arg) = Value;
584 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
586 return S_OK;
589 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
591 WebBrowser *This = WEBBROWSER_THIS(iface);
593 TRACE("(%p)->(%p)\n", This, pBool);
595 *pBool = This->status_bar;
596 return S_OK;
599 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
601 WebBrowser *This = WEBBROWSER_THIS(iface);
602 VARIANTARG arg;
603 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
605 TRACE("(%p)->(%x)\n", This, Value);
607 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
609 /* In opposition to InternetExplorer, all we should do here is
610 * inform the embedder about the status bar change. */
612 V_VT(&arg) = VT_BOOL;
613 V_BOOL(&arg) = Value;
614 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
616 return S_OK;
619 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
621 WebBrowser *This = WEBBROWSER_THIS(iface);
622 FIXME("(%p)->(%p)\n", This, StatusText);
623 return E_NOTIMPL;
626 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
628 WebBrowser *This = WEBBROWSER_THIS(iface);
629 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
630 return E_NOTIMPL;
633 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
635 WebBrowser *This = WEBBROWSER_THIS(iface);
637 TRACE("(%p)->(%p)\n", This, Value);
639 *Value = This->tool_bar;
640 return S_OK;
643 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
645 WebBrowser *This = WEBBROWSER_THIS(iface);
646 VARIANTARG arg;
647 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
649 TRACE("(%p)->(%x)\n", This, Value);
651 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
653 /* In opposition to InternetExplorer, all we should do here is
654 * inform the embedder about the tool bar change. */
656 V_VT(&arg) = VT_BOOL;
657 V_BOOL(&arg) = This->tool_bar;
658 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
660 return S_OK;
663 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
665 WebBrowser *This = WEBBROWSER_THIS(iface);
667 TRACE("(%p)->(%p)\n", This, Value);
669 *Value = This->menu_bar;
670 return S_OK;
673 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
675 WebBrowser *This = WEBBROWSER_THIS(iface);
676 VARIANTARG arg;
677 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
679 TRACE("(%p)->(%x)\n", This, Value);
681 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
683 /* In opposition to InternetExplorer, all we should do here is
684 * inform the embedder about the menu bar change. */
686 V_VT(&arg) = VT_BOOL;
687 V_BOOL(&arg) = Value;
688 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
690 return S_OK;
693 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
695 WebBrowser *This = WEBBROWSER_THIS(iface);
697 TRACE("(%p)->(%p)\n", This, pbFullScreen);
699 *pbFullScreen = This->full_screen;
700 return S_OK;
703 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
705 WebBrowser *This = WEBBROWSER_THIS(iface);
706 VARIANTARG arg;
707 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
709 /* In opposition to InternetExplorer, all we should do here is
710 * inform the embedder about the fullscreen change. */
712 TRACE("(%p)->(%x)\n", This, bFullScreen);
714 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
716 V_VT(&arg) = VT_BOOL;
717 V_BOOL(&arg) = bFullScreen;
718 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
720 return S_OK;
723 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
724 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
726 WebBrowser *This = WEBBROWSER_THIS(iface);
728 TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers);
730 if(!This->client)
731 return E_FAIL;
733 if(!URL)
734 return S_OK;
736 if(V_VT(URL) != VT_BSTR) {
737 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
738 return E_INVALIDARG;
741 return navigate_url(&This->doc_host, V_BSTR(URL), Flags, TargetFrameName, PostData, Headers);
744 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
746 WebBrowser *This = WEBBROWSER_THIS(iface);
747 FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
748 return E_NOTIMPL;
751 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
752 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
754 WebBrowser *This = WEBBROWSER_THIS(iface);
755 FIXME("(%p)->(%d %d %p %p)\n", This, cmdID, cmdexecopt, pvaIn, pvaOut);
756 return E_NOTIMPL;
759 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
760 VARIANT *pvarShow, VARIANT *pvarSize)
762 WebBrowser *This = WEBBROWSER_THIS(iface);
763 FIXME("(%p)->(%p %p %p)\n", This, pvaClsid, pvarShow, pvarSize);
764 return E_NOTIMPL;
767 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
769 WebBrowser *This = WEBBROWSER_THIS(iface);
770 FIXME("(%p)->(%p)\n", This, lpReadyState);
772 *lpReadyState = READYSTATE_COMPLETE;
773 return S_OK;
776 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
778 WebBrowser *This = WEBBROWSER_THIS(iface);
780 TRACE("(%p)->(%p)\n", This, pbOffline);
782 *pbOffline = This->doc_host.offline;
783 return S_OK;
786 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
788 WebBrowser *This = WEBBROWSER_THIS(iface);
790 TRACE("(%p)->(%x)\n", This, bOffline);
792 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
793 return S_OK;
796 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
798 WebBrowser *This = WEBBROWSER_THIS(iface);
800 TRACE("(%p)->(%p)\n", This, pbSilent);
802 *pbSilent = This->doc_host.silent;
803 return S_OK;
806 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
808 WebBrowser *This = WEBBROWSER_THIS(iface);
810 TRACE("(%p)->(%x)\n", This, bSilent);
812 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
813 return S_OK;
816 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
817 VARIANT_BOOL *pbRegister)
819 WebBrowser *This = WEBBROWSER_THIS(iface);
821 FIXME("(%p)->(%p)\n", This, pbRegister);
823 *pbRegister = This->register_browser;
824 return S_OK;
827 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
828 VARIANT_BOOL bRegister)
830 WebBrowser *This = WEBBROWSER_THIS(iface);
832 FIXME("(%p)->(%x)\n", This, bRegister);
834 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
835 return S_OK;
838 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
839 VARIANT_BOOL *pbRegister)
841 WebBrowser *This = WEBBROWSER_THIS(iface);
842 FIXME("(%p)->(%p)\n", This, pbRegister);
843 *pbRegister=0;
844 return S_OK;
847 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
848 VARIANT_BOOL bRegister)
850 WebBrowser *This = WEBBROWSER_THIS(iface);
851 FIXME("(%p)->(%x)\n", This, bRegister);
852 return S_OK;
855 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
857 WebBrowser *This = WEBBROWSER_THIS(iface);
859 TRACE("(%p)->(%p)\n", This, pbRegister);
861 *pbRegister = This->theater_mode;
862 return S_OK;
865 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
867 WebBrowser *This = WEBBROWSER_THIS(iface);
868 VARIANTARG arg;
869 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
871 TRACE("(%p)->(%x)\n", This, bRegister);
873 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
875 /* In opposition to InternetExplorer, all we should do here is
876 * inform the embedder about the theater mode change. */
878 V_VT(&arg) = VT_BOOL;
879 V_BOOL(&arg) = bRegister;
880 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
882 return S_OK;
885 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
887 WebBrowser *This = WEBBROWSER_THIS(iface);
889 TRACE("(%p)->(%p)\n", This, Value);
891 *Value = This->address_bar;
892 return S_OK;
895 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
897 WebBrowser *This = WEBBROWSER_THIS(iface);
898 VARIANTARG arg;
899 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
901 TRACE("(%p)->(%x)\n", This, Value);
903 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
905 /* In opposition to InternetExplorer, all we should do here is
906 * inform the embedder about the address bar change. */
908 V_VT(&arg) = VT_BOOL;
909 V_BOOL(&arg) = Value;
910 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
912 return S_OK;
915 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
917 WebBrowser *This = WEBBROWSER_THIS(iface);
919 TRACE("(%p)->(%p)\n", This, Value);
921 /* It's InternetExplorer object's method. We have nothing to do here. */
922 return E_NOTIMPL;
925 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
927 WebBrowser *This = WEBBROWSER_THIS(iface);
928 VARIANTARG arg;
929 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
931 TRACE("(%p)->(%x)\n", This, Value);
933 /* In opposition to InternetExplorer, all we should do here is
934 * inform the embedder about the resizable change. */
936 V_VT(&arg) = VT_BOOL;
937 V_BOOL(&arg) = Value;
938 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
940 return S_OK;
943 #undef WEBBROWSER_THIS
945 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
947 WebBrowser_QueryInterface,
948 WebBrowser_AddRef,
949 WebBrowser_Release,
950 WebBrowser_GetTypeInfoCount,
951 WebBrowser_GetTypeInfo,
952 WebBrowser_GetIDsOfNames,
953 WebBrowser_Invoke,
954 WebBrowser_GoBack,
955 WebBrowser_GoForward,
956 WebBrowser_GoHome,
957 WebBrowser_GoSearch,
958 WebBrowser_Navigate,
959 WebBrowser_Refresh,
960 WebBrowser_Refresh2,
961 WebBrowser_Stop,
962 WebBrowser_get_Application,
963 WebBrowser_get_Parent,
964 WebBrowser_get_Container,
965 WebBrowser_get_Document,
966 WebBrowser_get_TopLevelContainer,
967 WebBrowser_get_Type,
968 WebBrowser_get_Left,
969 WebBrowser_put_Left,
970 WebBrowser_get_Top,
971 WebBrowser_put_Top,
972 WebBrowser_get_Width,
973 WebBrowser_put_Width,
974 WebBrowser_get_Height,
975 WebBrowser_put_Height,
976 WebBrowser_get_LocationName,
977 WebBrowser_get_LocationURL,
978 WebBrowser_get_Busy,
979 WebBrowser_Quit,
980 WebBrowser_ClientToWindow,
981 WebBrowser_PutProperty,
982 WebBrowser_GetProperty,
983 WebBrowser_get_Name,
984 WebBrowser_get_HWND,
985 WebBrowser_get_FullName,
986 WebBrowser_get_Path,
987 WebBrowser_get_Visible,
988 WebBrowser_put_Visible,
989 WebBrowser_get_StatusBar,
990 WebBrowser_put_StatusBar,
991 WebBrowser_get_StatusText,
992 WebBrowser_put_StatusText,
993 WebBrowser_get_ToolBar,
994 WebBrowser_put_ToolBar,
995 WebBrowser_get_MenuBar,
996 WebBrowser_put_MenuBar,
997 WebBrowser_get_FullScreen,
998 WebBrowser_put_FullScreen,
999 WebBrowser_Navigate2,
1000 WebBrowser_QueryStatusWB,
1001 WebBrowser_ExecWB,
1002 WebBrowser_ShowBrowserBar,
1003 WebBrowser_get_ReadyState,
1004 WebBrowser_get_Offline,
1005 WebBrowser_put_Offline,
1006 WebBrowser_get_Silent,
1007 WebBrowser_put_Silent,
1008 WebBrowser_get_RegisterAsBrowser,
1009 WebBrowser_put_RegisterAsBrowser,
1010 WebBrowser_get_RegisterAsDropTarget,
1011 WebBrowser_put_RegisterAsDropTarget,
1012 WebBrowser_get_TheaterMode,
1013 WebBrowser_put_TheaterMode,
1014 WebBrowser_get_AddressBar,
1015 WebBrowser_put_AddressBar,
1016 WebBrowser_get_Resizable,
1017 WebBrowser_put_Resizable
1020 #define SERVPROV_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
1022 * IServiceProvider interface.
1024 static HRESULT WINAPI WebBrowser_IServiceProvider_QueryInterface(IServiceProvider *iface,
1025 REFIID riid, LPVOID *ppv)
1027 WebBrowser *This = SERVPROV_THIS(iface);
1029 if (ppv == NULL)
1030 return E_POINTER;
1031 *ppv = NULL;
1033 if(IsEqualGUID(&IID_IUnknown, riid)) {
1034 *ppv = WEBBROWSER(This);
1035 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1036 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1037 *ppv = WEBBROWSER(This);
1038 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
1041 if(*ppv) {
1042 IUnknown_AddRef((IUnknown*)*ppv);
1043 return S_OK;
1046 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
1047 return E_NOINTERFACE;
1050 static ULONG WINAPI WebBrowser_IServiceProvider_AddRef(IServiceProvider *iface)
1052 WebBrowser *This = SERVPROV_THIS(iface);
1053 return IWebBrowser_AddRef(WEBBROWSER(This));
1056 static ULONG WINAPI WebBrowser_IServiceProvider_Release(IServiceProvider *iface)
1058 WebBrowser *This = SERVPROV_THIS(iface);
1059 return IWebBrowser_Release(WEBBROWSER(This));
1062 static HRESULT STDMETHODCALLTYPE WebBrowser_IServiceProvider_QueryService(IServiceProvider *iface,
1063 REFGUID guidService, REFIID riid, void **ppv)
1065 WebBrowser *This = SERVPROV_THIS(iface);
1066 static const IID IID_IBrowserService2 =
1067 {0x68BD21CC,0x438B,0x11d2,{0xA5,0x60,0x00,0xA0,0xC,0x2D,0xBF,0xE8}};
1069 if(*ppv)
1070 ppv = NULL;
1072 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1073 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1074 return E_FAIL;
1077 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1079 return E_NOINTERFACE;
1082 #undef SERVPROV_THIS
1084 static const IServiceProviderVtbl ServiceProviderVtbl =
1086 WebBrowser_IServiceProvider_QueryInterface,
1087 WebBrowser_IServiceProvider_AddRef,
1088 WebBrowser_IServiceProvider_Release,
1089 WebBrowser_IServiceProvider_QueryService
1092 static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, void **ppv)
1094 WebBrowser *ret;
1095 HRESULT hres;
1097 TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
1099 ret = heap_alloc(sizeof(WebBrowser));
1101 ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
1102 ret->lpServiceProviderVtbl = &ServiceProviderVtbl;
1103 ret->ref = 0;
1104 ret->version = version;
1106 DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
1108 ret->register_browser = VARIANT_FALSE;
1109 ret->visible = VARIANT_TRUE;
1110 ret->menu_bar = VARIANT_TRUE;
1111 ret->address_bar = VARIANT_TRUE;
1112 ret->status_bar = VARIANT_TRUE;
1113 ret->tool_bar = VARIANT_TRUE;
1114 ret->full_screen = VARIANT_FALSE;
1115 ret->theater_mode = VARIANT_FALSE;
1117 WebBrowser_OleObject_Init(ret);
1118 WebBrowser_ViewObject_Init(ret);
1119 WebBrowser_Persist_Init(ret);
1120 WebBrowser_ClassInfo_Init(ret);
1121 WebBrowser_HlinkFrame_Init(ret);
1123 hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
1124 if(SUCCEEDED(hres)) {
1125 SHDOCVW_LockModule();
1126 }else {
1127 heap_free(ret);
1128 return hres;
1131 return hres;
1134 HRESULT WebBrowserV1_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1136 return WebBrowser_Create(1, pOuter, riid, ppv);
1139 HRESULT WebBrowserV2_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1141 return WebBrowser_Create(2, pOuter, riid, ppv);