advapi32: Make rpcrt4 a delayed import to work around circular dependencies with...
[wine/testsucceed.git] / dlls / shdocvw / webbrowser.c
blob20d39bb3764b74ce568ef74406fde90368e7f4d1
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"
25 #include "mshtml.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);
39 if (ppv == NULL)
40 return E_POINTER;
41 *ppv = NULL;
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);
60 *ppv = OLEOBJ(This);
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);
69 *ppv = CONTROL(This);
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);
93 *ppv = VIEWOBJ(This);
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);
102 *ppv = OLECMD(This);
103 }else if(IsEqualGUID(&IID_IHlinkFrame, riid)) {
104 TRACE("(%p)->(IID_IHlinkFrame %p)\n", This, ppv);
105 *ppv = HLINKFRAME(This);
106 }else if(IsEqualGUID(&IID_ITargetFrame2, riid)) {
107 TRACE("(%p)->(IID_ITargetFrame2 %p)\n", This, ppv);
108 *ppv = TARGETFRAME2(This);
109 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
110 *ppv = SERVPROV(This);
111 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
112 }else if(IsEqualGUID(&IID_IDataObject, riid)) {
113 *ppv = DATAOBJECT(This);
114 TRACE("(%p)->(IID_IDataObject %p)\n", This, ppv);
115 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
116 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
117 return E_NOINTERFACE;
118 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
119 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
120 return E_NOINTERFACE;
121 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
122 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
123 return E_NOINTERFACE;
124 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
125 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
126 return E_NOINTERFACE;
127 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
128 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
129 return E_NOINTERFACE;
130 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
131 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
132 return E_NOINTERFACE;
133 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
134 TRACE("(%p)->(IID_IViewObjectEx %p) returning NULL\n", This, ppv);
135 return E_NOINTERFACE;
138 if(*ppv) {
139 IUnknown_AddRef((IUnknown*)*ppv);
140 return S_OK;
143 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
144 return E_NOINTERFACE;
147 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
149 WebBrowser *This = WEBBROWSER_THIS(iface);
150 LONG ref = InterlockedIncrement(&This->ref);
151 TRACE("(%p) ref=%d\n", This, ref);
152 return ref;
155 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
157 WebBrowser *This = WEBBROWSER_THIS(iface);
158 LONG ref = InterlockedDecrement(&This->ref);
160 TRACE("(%p) ref=%d\n", This, ref);
162 if(!ref) {
163 if(This->doc_host.document)
164 IUnknown_Release(This->doc_host.document);
166 DocHost_Release(&This->doc_host);
168 WebBrowser_OleObject_Destroy(This);
170 heap_free(This);
171 SHDOCVW_UnlockModule();
174 return ref;
177 /* IDispatch methods */
178 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
180 WebBrowser *This = WEBBROWSER_THIS(iface);
182 TRACE("(%p)->(%p)\n", This, pctinfo);
184 *pctinfo = 1;
185 return S_OK;
188 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
189 LPTYPEINFO *ppTInfo)
191 WebBrowser *This = WEBBROWSER_THIS(iface);
192 ITypeInfo *typeinfo;
193 HRESULT hres;
195 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
197 hres = get_typeinfo(&typeinfo);
198 if(FAILED(hres))
199 return hres;
201 ITypeInfo_AddRef(typeinfo);
202 *ppTInfo = typeinfo;
203 return S_OK;
206 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
207 LPOLESTR *rgszNames, UINT cNames,
208 LCID lcid, DISPID *rgDispId)
210 WebBrowser *This = WEBBROWSER_THIS(iface);
211 ITypeInfo *typeinfo;
212 HRESULT hres;
214 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
215 lcid, rgDispId);
217 hres = get_typeinfo(&typeinfo);
218 if(FAILED(hres))
219 return hres;
221 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
224 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
225 REFIID riid, LCID lcid, WORD wFlags,
226 DISPPARAMS *pDispParams, VARIANT *pVarResult,
227 EXCEPINFO *pExepInfo, UINT *puArgErr)
229 WebBrowser *This = WEBBROWSER_THIS(iface);
230 ITypeInfo *typeinfo;
231 HRESULT hres;
233 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
234 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
236 hres = get_typeinfo(&typeinfo);
237 if(FAILED(hres))
238 return hres;
240 return ITypeInfo_Invoke(typeinfo, WEBBROWSER2(This), dispIdMember, wFlags, pDispParams,
241 pVarResult, pExepInfo, puArgErr);
244 /* IWebBrowser methods */
245 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
247 WebBrowser *This = WEBBROWSER_THIS(iface);
248 FIXME("(%p)\n", This);
249 return E_NOTIMPL;
252 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
254 WebBrowser *This = WEBBROWSER_THIS(iface);
255 FIXME("(%p)\n", This);
256 return E_NOTIMPL;
259 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
261 WebBrowser *This = WEBBROWSER_THIS(iface);
262 TRACE("(%p)\n", This);
263 return go_home(&This->doc_host);
266 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
268 WebBrowser *This = WEBBROWSER_THIS(iface);
269 FIXME("(%p)\n", This);
270 return E_NOTIMPL;
273 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
274 VARIANT *Flags, VARIANT *TargetFrameName,
275 VARIANT *PostData, VARIANT *Headers)
277 WebBrowser *This = WEBBROWSER_THIS(iface);
279 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
280 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
281 debugstr_variant(Headers));
283 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
286 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
288 WebBrowser *This = WEBBROWSER_THIS(iface);
289 FIXME("(%p)\n", This);
290 return E_NOTIMPL;
293 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
295 WebBrowser *This = WEBBROWSER_THIS(iface);
296 FIXME("(%p)->(%s)\n", This, debugstr_variant(Level));
297 return E_NOTIMPL;
300 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
302 WebBrowser *This = WEBBROWSER_THIS(iface);
303 FIXME("(%p)\n", This);
304 return E_NOTIMPL;
307 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
309 WebBrowser *This = WEBBROWSER_THIS(iface);
311 TRACE("(%p)->(%p)\n", This, ppDisp);
313 if(!ppDisp)
314 return E_POINTER;
316 *ppDisp = (IDispatch*)WEBBROWSER2(This);
317 IDispatch_AddRef(*ppDisp);
318 return S_OK;
321 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
323 WebBrowser *This = WEBBROWSER_THIS(iface);
324 FIXME("(%p)->(%p)\n", This, ppDisp);
325 return E_NOTIMPL;
328 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
330 WebBrowser *This = WEBBROWSER_THIS(iface);
331 FIXME("(%p)->(%p)\n", This, ppDisp);
332 return E_NOTIMPL;
335 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
337 WebBrowser *This = WEBBROWSER_THIS(iface);
338 IDispatch *disp = NULL;
340 TRACE("(%p)->(%p)\n", This, ppDisp);
342 if(This->doc_host.document) {
343 HRESULT hres;
345 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
346 if(SUCCEEDED(hres)) {
347 IDispatch *html_doc;
349 /* Some broken apps cast returned IDispatch to IHTMLDocument2
350 * without QueryInterface call */
351 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
352 if(SUCCEEDED(hres)) {
353 IDispatch_Release(disp);
354 disp = html_doc;
359 *ppDisp = disp;
360 return S_OK;
363 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
365 WebBrowser *This = WEBBROWSER_THIS(iface);
366 FIXME("(%p)->(%p)\n", This, pBool);
367 return E_NOTIMPL;
370 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
372 WebBrowser *This = WEBBROWSER_THIS(iface);
373 FIXME("(%p)->(%p)\n", This, Type);
374 return E_NOTIMPL;
377 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
379 WebBrowser *This = WEBBROWSER_THIS(iface);
381 TRACE("(%p)->(%p)\n", This, pl);
383 *pl = This->pos_rect.left;
384 return S_OK;
387 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
389 WebBrowser *This = WEBBROWSER_THIS(iface);
390 RECT rect;
392 TRACE("(%p)->(%d)\n", This, Left);
394 if(!This->inplace)
395 return E_UNEXPECTED;
397 rect = This->pos_rect;
398 rect.left = Left;
400 /* We don't really change the window position here.
401 * We just notify the embedder that he should do so. */
402 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
405 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
407 WebBrowser *This = WEBBROWSER_THIS(iface);
409 TRACE("(%p)->(%p)\n", This, pl);
411 *pl = This->pos_rect.top;
412 return S_OK;
415 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
417 WebBrowser *This = WEBBROWSER_THIS(iface);
418 RECT rect;
420 TRACE("(%p)->(%d)\n", This, Top);
422 if(!This->inplace)
423 return E_UNEXPECTED;
425 rect = This->pos_rect;
426 rect.top = Top;
428 /* We don't really change the window position here.
429 * We just notify the embedder that he should do so. */
430 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
433 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
435 WebBrowser *This = WEBBROWSER_THIS(iface);
437 TRACE("(%p)->(%p)\n", This, pl);
439 *pl = This->pos_rect.right - This->pos_rect.left;
440 return S_OK;
443 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
445 WebBrowser *This = WEBBROWSER_THIS(iface);
446 RECT rect;
448 TRACE("(%p)->(%d)\n", This, Width);
450 if(!This->inplace)
451 return E_UNEXPECTED;
453 rect = This->pos_rect;
454 rect.right = rect.left+Width;
456 /* We don't really change the window size here.
457 * We just notify the embedder that he should do so. */
458 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
461 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
463 WebBrowser *This = WEBBROWSER_THIS(iface);
465 TRACE("(%p)->(%p)\n", This, pl);
467 *pl = This->pos_rect.bottom - This->pos_rect.top;
468 return S_OK;
471 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
473 WebBrowser *This = WEBBROWSER_THIS(iface);
474 RECT rect;
476 TRACE("(%p)->(%d)\n", This, Height);
478 if(!This->inplace)
479 return E_UNEXPECTED;
481 rect = This->pos_rect;
482 rect.bottom = rect.top+Height;
484 /* We don't really change the window size here.
485 * We just notify the embedder that he should do so. */
486 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
489 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
491 WebBrowser *This = WEBBROWSER_THIS(iface);
492 FIXME("(%p)->(%p)\n", This, LocationName);
493 return E_NOTIMPL;
496 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
498 WebBrowser *This = WEBBROWSER_THIS(iface);
500 FIXME("(%p)->(%p)\n", This, LocationURL);
502 if(!This->doc_host.url) {
503 static const WCHAR null_char = 0;
504 *LocationURL = SysAllocString(&null_char);
505 return S_FALSE;
508 *LocationURL = SysAllocString(This->doc_host.url);
509 return S_OK;
512 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
514 WebBrowser *This = WEBBROWSER_THIS(iface);
516 TRACE("(%p)->(%p)\n", This, pBool);
518 *pBool = This->doc_host.busy;
519 return S_OK;
522 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
524 WebBrowser *This = WEBBROWSER_THIS(iface);
526 TRACE("(%p)\n", This);
528 /* It's a InternetExplorer specific method, we have nothing to do here. */
529 return E_FAIL;
532 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
534 WebBrowser *This = WEBBROWSER_THIS(iface);
535 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
536 return E_NOTIMPL;
539 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
541 WebBrowser *This = WEBBROWSER_THIS(iface);
542 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
543 return E_NOTIMPL;
546 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
548 WebBrowser *This = WEBBROWSER_THIS(iface);
549 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
550 return E_NOTIMPL;
553 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
555 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
556 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
557 WebBrowser *This = WEBBROWSER_THIS(iface);
559 TRACE("(%p)->(%p)\n", This, Name);
561 *Name = SysAllocString(sName);
563 return S_OK;
566 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND)
568 WebBrowser *This = WEBBROWSER_THIS(iface);
570 TRACE("(%p)->(%p)\n", This, pHWND);
572 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
573 *pHWND = 0;
574 return E_FAIL;
577 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
579 WebBrowser *This = WEBBROWSER_THIS(iface);
580 FIXME("(%p)->(%p)\n", This, FullName);
581 return E_NOTIMPL;
584 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
586 WebBrowser *This = WEBBROWSER_THIS(iface);
587 FIXME("(%p)->(%p)\n", This, Path);
588 return E_NOTIMPL;
591 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
593 WebBrowser *This = WEBBROWSER_THIS(iface);
595 TRACE("(%p)->(%p)\n", This, pBool);
597 *pBool = This->visible;
598 return S_OK;
601 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
603 WebBrowser *This = WEBBROWSER_THIS(iface);
604 VARIANTARG arg;
605 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
607 TRACE("(%p)->(%x)\n", This, Value);
609 This->visible = Value;
611 V_VT(&arg) = VT_BOOL;
612 V_BOOL(&arg) = Value;
613 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
615 return S_OK;
618 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
620 WebBrowser *This = WEBBROWSER_THIS(iface);
622 TRACE("(%p)->(%p)\n", This, pBool);
624 *pBool = This->status_bar;
625 return S_OK;
628 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
630 WebBrowser *This = WEBBROWSER_THIS(iface);
631 VARIANTARG arg;
632 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
634 TRACE("(%p)->(%x)\n", This, Value);
636 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
638 /* In opposition to InternetExplorer, all we should do here is
639 * inform the embedder about the status bar change. */
641 V_VT(&arg) = VT_BOOL;
642 V_BOOL(&arg) = Value;
643 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
645 return S_OK;
648 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
650 WebBrowser *This = WEBBROWSER_THIS(iface);
651 FIXME("(%p)->(%p)\n", This, StatusText);
652 return E_NOTIMPL;
655 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
657 WebBrowser *This = WEBBROWSER_THIS(iface);
658 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
659 return E_NOTIMPL;
662 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
664 WebBrowser *This = WEBBROWSER_THIS(iface);
666 TRACE("(%p)->(%p)\n", This, Value);
668 *Value = This->tool_bar;
669 return S_OK;
672 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
674 WebBrowser *This = WEBBROWSER_THIS(iface);
675 VARIANTARG arg;
676 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
678 TRACE("(%p)->(%x)\n", This, Value);
680 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
682 /* In opposition to InternetExplorer, all we should do here is
683 * inform the embedder about the tool bar change. */
685 V_VT(&arg) = VT_BOOL;
686 V_BOOL(&arg) = This->tool_bar;
687 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
689 return S_OK;
692 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
694 WebBrowser *This = WEBBROWSER_THIS(iface);
696 TRACE("(%p)->(%p)\n", This, Value);
698 *Value = This->menu_bar;
699 return S_OK;
702 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
704 WebBrowser *This = WEBBROWSER_THIS(iface);
705 VARIANTARG arg;
706 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
708 TRACE("(%p)->(%x)\n", This, Value);
710 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
712 /* In opposition to InternetExplorer, all we should do here is
713 * inform the embedder about the menu bar change. */
715 V_VT(&arg) = VT_BOOL;
716 V_BOOL(&arg) = Value;
717 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
719 return S_OK;
722 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
724 WebBrowser *This = WEBBROWSER_THIS(iface);
726 TRACE("(%p)->(%p)\n", This, pbFullScreen);
728 *pbFullScreen = This->full_screen;
729 return S_OK;
732 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
734 WebBrowser *This = WEBBROWSER_THIS(iface);
735 VARIANTARG arg;
736 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
738 /* In opposition to InternetExplorer, all we should do here is
739 * inform the embedder about the fullscreen change. */
741 TRACE("(%p)->(%x)\n", This, bFullScreen);
743 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
745 V_VT(&arg) = VT_BOOL;
746 V_BOOL(&arg) = bFullScreen;
747 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
749 return S_OK;
752 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
753 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
755 WebBrowser *This = WEBBROWSER_THIS(iface);
756 LPCWSTR url;
758 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
759 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
761 if(!This->client)
762 return E_FAIL;
764 if(!URL)
765 return S_OK;
767 switch (V_VT(URL))
769 case VT_BSTR:
770 url = V_BSTR(URL);
771 break;
772 case VT_BSTR|VT_BYREF:
773 url = *V_BSTRREF(URL);
774 break;
775 default:
776 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
777 return E_INVALIDARG;
780 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
783 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
785 WebBrowser *This = WEBBROWSER_THIS(iface);
786 FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
787 return E_NOTIMPL;
790 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
791 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
793 WebBrowser *This = WEBBROWSER_THIS(iface);
794 FIXME("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
795 return E_NOTIMPL;
798 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
799 VARIANT *pvarShow, VARIANT *pvarSize)
801 WebBrowser *This = WEBBROWSER_THIS(iface);
802 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
803 debugstr_variant(pvarSize));
804 return E_NOTIMPL;
807 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
809 WebBrowser *This = WEBBROWSER_THIS(iface);
811 TRACE("(%p)->(%p)\n", This, lpReadyState);
813 *lpReadyState = This->doc_host.ready_state;
814 return S_OK;
817 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
819 WebBrowser *This = WEBBROWSER_THIS(iface);
821 TRACE("(%p)->(%p)\n", This, pbOffline);
823 *pbOffline = This->doc_host.offline;
824 return S_OK;
827 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
829 WebBrowser *This = WEBBROWSER_THIS(iface);
831 TRACE("(%p)->(%x)\n", This, bOffline);
833 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
834 return S_OK;
837 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
839 WebBrowser *This = WEBBROWSER_THIS(iface);
841 TRACE("(%p)->(%p)\n", This, pbSilent);
843 *pbSilent = This->doc_host.silent;
844 return S_OK;
847 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
849 WebBrowser *This = WEBBROWSER_THIS(iface);
851 TRACE("(%p)->(%x)\n", This, bSilent);
853 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
854 return S_OK;
857 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
858 VARIANT_BOOL *pbRegister)
860 WebBrowser *This = WEBBROWSER_THIS(iface);
862 FIXME("(%p)->(%p)\n", This, pbRegister);
864 *pbRegister = This->register_browser;
865 return S_OK;
868 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
869 VARIANT_BOOL bRegister)
871 WebBrowser *This = WEBBROWSER_THIS(iface);
873 FIXME("(%p)->(%x)\n", This, bRegister);
875 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
876 return S_OK;
879 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
880 VARIANT_BOOL *pbRegister)
882 WebBrowser *This = WEBBROWSER_THIS(iface);
883 FIXME("(%p)->(%p)\n", This, pbRegister);
884 *pbRegister=0;
885 return S_OK;
888 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
889 VARIANT_BOOL bRegister)
891 WebBrowser *This = WEBBROWSER_THIS(iface);
892 FIXME("(%p)->(%x)\n", This, bRegister);
893 return S_OK;
896 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
898 WebBrowser *This = WEBBROWSER_THIS(iface);
900 TRACE("(%p)->(%p)\n", This, pbRegister);
902 *pbRegister = This->theater_mode;
903 return S_OK;
906 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
908 WebBrowser *This = WEBBROWSER_THIS(iface);
909 VARIANTARG arg;
910 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
912 TRACE("(%p)->(%x)\n", This, bRegister);
914 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
916 /* In opposition to InternetExplorer, all we should do here is
917 * inform the embedder about the theater mode change. */
919 V_VT(&arg) = VT_BOOL;
920 V_BOOL(&arg) = bRegister;
921 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
923 return S_OK;
926 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
928 WebBrowser *This = WEBBROWSER_THIS(iface);
930 TRACE("(%p)->(%p)\n", This, Value);
932 *Value = This->address_bar;
933 return S_OK;
936 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
938 WebBrowser *This = WEBBROWSER_THIS(iface);
939 VARIANTARG arg;
940 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
942 TRACE("(%p)->(%x)\n", This, Value);
944 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
946 /* In opposition to InternetExplorer, all we should do here is
947 * inform the embedder about the address bar change. */
949 V_VT(&arg) = VT_BOOL;
950 V_BOOL(&arg) = Value;
951 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
953 return S_OK;
956 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
958 WebBrowser *This = WEBBROWSER_THIS(iface);
960 TRACE("(%p)->(%p)\n", This, Value);
962 /* It's InternetExplorer object's method. We have nothing to do here. */
963 return E_NOTIMPL;
966 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
968 WebBrowser *This = WEBBROWSER_THIS(iface);
969 VARIANTARG arg;
970 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
972 TRACE("(%p)->(%x)\n", This, Value);
974 /* In opposition to InternetExplorer, all we should do here is
975 * inform the embedder about the resizable change. */
977 V_VT(&arg) = VT_BOOL;
978 V_BOOL(&arg) = Value;
979 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
981 return S_OK;
984 #undef WEBBROWSER_THIS
986 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
988 WebBrowser_QueryInterface,
989 WebBrowser_AddRef,
990 WebBrowser_Release,
991 WebBrowser_GetTypeInfoCount,
992 WebBrowser_GetTypeInfo,
993 WebBrowser_GetIDsOfNames,
994 WebBrowser_Invoke,
995 WebBrowser_GoBack,
996 WebBrowser_GoForward,
997 WebBrowser_GoHome,
998 WebBrowser_GoSearch,
999 WebBrowser_Navigate,
1000 WebBrowser_Refresh,
1001 WebBrowser_Refresh2,
1002 WebBrowser_Stop,
1003 WebBrowser_get_Application,
1004 WebBrowser_get_Parent,
1005 WebBrowser_get_Container,
1006 WebBrowser_get_Document,
1007 WebBrowser_get_TopLevelContainer,
1008 WebBrowser_get_Type,
1009 WebBrowser_get_Left,
1010 WebBrowser_put_Left,
1011 WebBrowser_get_Top,
1012 WebBrowser_put_Top,
1013 WebBrowser_get_Width,
1014 WebBrowser_put_Width,
1015 WebBrowser_get_Height,
1016 WebBrowser_put_Height,
1017 WebBrowser_get_LocationName,
1018 WebBrowser_get_LocationURL,
1019 WebBrowser_get_Busy,
1020 WebBrowser_Quit,
1021 WebBrowser_ClientToWindow,
1022 WebBrowser_PutProperty,
1023 WebBrowser_GetProperty,
1024 WebBrowser_get_Name,
1025 WebBrowser_get_HWND,
1026 WebBrowser_get_FullName,
1027 WebBrowser_get_Path,
1028 WebBrowser_get_Visible,
1029 WebBrowser_put_Visible,
1030 WebBrowser_get_StatusBar,
1031 WebBrowser_put_StatusBar,
1032 WebBrowser_get_StatusText,
1033 WebBrowser_put_StatusText,
1034 WebBrowser_get_ToolBar,
1035 WebBrowser_put_ToolBar,
1036 WebBrowser_get_MenuBar,
1037 WebBrowser_put_MenuBar,
1038 WebBrowser_get_FullScreen,
1039 WebBrowser_put_FullScreen,
1040 WebBrowser_Navigate2,
1041 WebBrowser_QueryStatusWB,
1042 WebBrowser_ExecWB,
1043 WebBrowser_ShowBrowserBar,
1044 WebBrowser_get_ReadyState,
1045 WebBrowser_get_Offline,
1046 WebBrowser_put_Offline,
1047 WebBrowser_get_Silent,
1048 WebBrowser_put_Silent,
1049 WebBrowser_get_RegisterAsBrowser,
1050 WebBrowser_put_RegisterAsBrowser,
1051 WebBrowser_get_RegisterAsDropTarget,
1052 WebBrowser_put_RegisterAsDropTarget,
1053 WebBrowser_get_TheaterMode,
1054 WebBrowser_put_TheaterMode,
1055 WebBrowser_get_AddressBar,
1056 WebBrowser_put_AddressBar,
1057 WebBrowser_get_Resizable,
1058 WebBrowser_put_Resizable
1061 #define SERVPROV_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
1063 * IServiceProvider interface.
1065 static HRESULT WINAPI WebBrowser_IServiceProvider_QueryInterface(IServiceProvider *iface,
1066 REFIID riid, LPVOID *ppv)
1068 WebBrowser *This = SERVPROV_THIS(iface);
1070 if (ppv == NULL)
1071 return E_POINTER;
1072 *ppv = NULL;
1074 if(IsEqualGUID(&IID_IUnknown, riid)) {
1075 *ppv = WEBBROWSER(This);
1076 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1077 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1078 *ppv = WEBBROWSER(This);
1079 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
1082 if(*ppv) {
1083 IUnknown_AddRef((IUnknown*)*ppv);
1084 return S_OK;
1087 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
1088 return E_NOINTERFACE;
1091 static ULONG WINAPI WebBrowser_IServiceProvider_AddRef(IServiceProvider *iface)
1093 WebBrowser *This = SERVPROV_THIS(iface);
1094 return IWebBrowser_AddRef(WEBBROWSER(This));
1097 static ULONG WINAPI WebBrowser_IServiceProvider_Release(IServiceProvider *iface)
1099 WebBrowser *This = SERVPROV_THIS(iface);
1100 return IWebBrowser_Release(WEBBROWSER(This));
1103 static HRESULT STDMETHODCALLTYPE WebBrowser_IServiceProvider_QueryService(IServiceProvider *iface,
1104 REFGUID guidService, REFIID riid, void **ppv)
1106 WebBrowser *This = SERVPROV_THIS(iface);
1107 static const IID IID_IBrowserService2 =
1108 {0x68BD21CC,0x438B,0x11d2,{0xA5,0x60,0x00,0xA0,0xC,0x2D,0xBF,0xE8}};
1110 if(*ppv)
1111 ppv = NULL;
1113 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1114 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1115 return E_FAIL;
1118 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1120 return E_NOINTERFACE;
1123 #undef SERVPROV_THIS
1125 static const IServiceProviderVtbl ServiceProviderVtbl =
1127 WebBrowser_IServiceProvider_QueryInterface,
1128 WebBrowser_IServiceProvider_AddRef,
1129 WebBrowser_IServiceProvider_Release,
1130 WebBrowser_IServiceProvider_QueryService
1133 static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, void **ppv)
1135 WebBrowser *ret;
1136 HRESULT hres;
1138 TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
1140 ret = heap_alloc_zero(sizeof(WebBrowser));
1142 ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
1143 ret->lpServiceProviderVtbl = &ServiceProviderVtbl;
1144 ret->ref = 1;
1145 ret->version = version;
1147 DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
1149 ret->visible = VARIANT_TRUE;
1150 ret->menu_bar = VARIANT_TRUE;
1151 ret->address_bar = VARIANT_TRUE;
1152 ret->status_bar = VARIANT_TRUE;
1153 ret->tool_bar = VARIANT_TRUE;
1155 WebBrowser_OleObject_Init(ret);
1156 WebBrowser_ViewObject_Init(ret);
1157 WebBrowser_DataObject_Init(ret);
1158 WebBrowser_Persist_Init(ret);
1159 WebBrowser_ClassInfo_Init(ret);
1160 WebBrowser_HlinkFrame_Init(ret);
1162 SHDOCVW_LockModule();
1164 hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
1166 IWebBrowser2_Release(WEBBROWSER(ret));
1167 return hres;
1170 HRESULT WebBrowserV1_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1172 return WebBrowser_Create(1, pOuter, riid, ppv);
1175 HRESULT WebBrowserV2_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1177 return WebBrowser_Create(2, pOuter, riid, ppv);