Release 1.1.37.
[wine/gsoc-2012-control.git] / dlls / shdocvw / webbrowser.c
blobb0633b03f194bd56aa1185af82eb2844b56e5925
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 %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
273 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
274 debugstr_variant(Headers));
276 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
279 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
281 WebBrowser *This = WEBBROWSER_THIS(iface);
282 FIXME("(%p)\n", This);
283 return E_NOTIMPL;
286 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
288 WebBrowser *This = WEBBROWSER_THIS(iface);
289 FIXME("(%p)->(%s)\n", This, debugstr_variant(Level));
290 return E_NOTIMPL;
293 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
295 WebBrowser *This = WEBBROWSER_THIS(iface);
296 FIXME("(%p)\n", This);
297 return E_NOTIMPL;
300 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
302 WebBrowser *This = WEBBROWSER_THIS(iface);
304 TRACE("(%p)->(%p)\n", This, ppDisp);
306 if(!ppDisp)
307 return E_POINTER;
309 *ppDisp = (IDispatch*)WEBBROWSER2(This);
310 IDispatch_AddRef(*ppDisp);
311 return S_OK;
314 static HRESULT WINAPI WebBrowser_get_Parent(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_Container(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_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
330 WebBrowser *This = WEBBROWSER_THIS(iface);
332 TRACE("(%p)->(%p)\n", This, ppDisp);
334 *ppDisp = NULL;
335 if(This->doc_host.document)
336 IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)ppDisp);
338 return S_OK;
341 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
343 WebBrowser *This = WEBBROWSER_THIS(iface);
344 FIXME("(%p)->(%p)\n", This, pBool);
345 return E_NOTIMPL;
348 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
350 WebBrowser *This = WEBBROWSER_THIS(iface);
351 FIXME("(%p)->(%p)\n", This, Type);
352 return E_NOTIMPL;
355 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
357 WebBrowser *This = WEBBROWSER_THIS(iface);
359 TRACE("(%p)->(%p)\n", This, pl);
361 *pl = This->pos_rect.left;
362 return S_OK;
365 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
367 WebBrowser *This = WEBBROWSER_THIS(iface);
368 RECT rect;
370 TRACE("(%p)->(%d)\n", This, Left);
372 if(!This->inplace)
373 return E_UNEXPECTED;
375 rect = This->pos_rect;
376 rect.left = Left;
378 /* We don't really change the window position here.
379 * We just notify the embedder that he should do so. */
380 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
383 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
385 WebBrowser *This = WEBBROWSER_THIS(iface);
387 TRACE("(%p)->(%p)\n", This, pl);
389 *pl = This->pos_rect.top;
390 return S_OK;
393 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
395 WebBrowser *This = WEBBROWSER_THIS(iface);
396 RECT rect;
398 TRACE("(%p)->(%d)\n", This, Top);
400 if(!This->inplace)
401 return E_UNEXPECTED;
403 rect = This->pos_rect;
404 rect.top = Top;
406 /* We don't really change the window position here.
407 * We just notify the embedder that he should do so. */
408 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
411 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
413 WebBrowser *This = WEBBROWSER_THIS(iface);
415 TRACE("(%p)->(%p)\n", This, pl);
417 *pl = This->pos_rect.right - This->pos_rect.left;
418 return S_OK;
421 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
423 WebBrowser *This = WEBBROWSER_THIS(iface);
424 RECT rect;
426 TRACE("(%p)->(%d)\n", This, Width);
428 if(!This->inplace)
429 return E_UNEXPECTED;
431 rect = This->pos_rect;
432 rect.right = rect.left+Width;
434 /* We don't really change the window size here.
435 * We just notify the embedder that he should do so. */
436 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
439 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
441 WebBrowser *This = WEBBROWSER_THIS(iface);
443 TRACE("(%p)->(%p)\n", This, pl);
445 *pl = This->pos_rect.bottom - This->pos_rect.top;
446 return S_OK;
449 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
451 WebBrowser *This = WEBBROWSER_THIS(iface);
452 RECT rect;
454 TRACE("(%p)->(%d)\n", This, Height);
456 if(!This->inplace)
457 return E_UNEXPECTED;
459 rect = This->pos_rect;
460 rect.bottom = rect.top+Height;
462 /* We don't really change the window size here.
463 * We just notify the embedder that he should do so. */
464 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
467 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
469 WebBrowser *This = WEBBROWSER_THIS(iface);
470 FIXME("(%p)->(%p)\n", This, LocationName);
471 return E_NOTIMPL;
474 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
476 WebBrowser *This = WEBBROWSER_THIS(iface);
478 FIXME("(%p)->(%p)\n", This, LocationURL);
480 if(!This->doc_host.url) {
481 static const WCHAR null_char = 0;
482 *LocationURL = SysAllocString(&null_char);
483 return S_FALSE;
486 *LocationURL = SysAllocString(This->doc_host.url);
487 return S_OK;
490 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
492 WebBrowser *This = WEBBROWSER_THIS(iface);
494 TRACE("(%p)->(%p)\n", This, pBool);
496 *pBool = This->doc_host.busy;
497 return S_OK;
500 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
502 WebBrowser *This = WEBBROWSER_THIS(iface);
504 TRACE("(%p)\n", This);
506 /* It's a InternetExplorer specific method, we have nothing to do here. */
507 return E_FAIL;
510 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
512 WebBrowser *This = WEBBROWSER_THIS(iface);
513 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
514 return E_NOTIMPL;
517 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
519 WebBrowser *This = WEBBROWSER_THIS(iface);
520 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
521 return E_NOTIMPL;
524 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
526 WebBrowser *This = WEBBROWSER_THIS(iface);
527 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
528 return E_NOTIMPL;
531 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
533 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
534 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
535 WebBrowser *This = WEBBROWSER_THIS(iface);
537 TRACE("(%p)->(%p)\n", This, Name);
539 *Name = SysAllocString(sName);
541 return S_OK;
544 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, LONG *pHWND)
546 WebBrowser *This = WEBBROWSER_THIS(iface);
548 TRACE("(%p)->(%p)\n", This, pHWND);
550 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
551 *pHWND = 0;
552 return E_FAIL;
555 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
557 WebBrowser *This = WEBBROWSER_THIS(iface);
558 FIXME("(%p)->(%p)\n", This, FullName);
559 return E_NOTIMPL;
562 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
564 WebBrowser *This = WEBBROWSER_THIS(iface);
565 FIXME("(%p)->(%p)\n", This, Path);
566 return E_NOTIMPL;
569 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
571 WebBrowser *This = WEBBROWSER_THIS(iface);
573 TRACE("(%p)->(%p)\n", This, pBool);
575 *pBool = This->visible;
576 return S_OK;
579 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
581 WebBrowser *This = WEBBROWSER_THIS(iface);
582 VARIANTARG arg;
583 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
585 TRACE("(%p)->(%x)\n", This, Value);
587 This->visible = Value;
589 V_VT(&arg) = VT_BOOL;
590 V_BOOL(&arg) = Value;
591 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
593 return S_OK;
596 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
598 WebBrowser *This = WEBBROWSER_THIS(iface);
600 TRACE("(%p)->(%p)\n", This, pBool);
602 *pBool = This->status_bar;
603 return S_OK;
606 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
608 WebBrowser *This = WEBBROWSER_THIS(iface);
609 VARIANTARG arg;
610 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
612 TRACE("(%p)->(%x)\n", This, Value);
614 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
616 /* In opposition to InternetExplorer, all we should do here is
617 * inform the embedder about the status bar change. */
619 V_VT(&arg) = VT_BOOL;
620 V_BOOL(&arg) = Value;
621 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
623 return S_OK;
626 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
628 WebBrowser *This = WEBBROWSER_THIS(iface);
629 FIXME("(%p)->(%p)\n", This, StatusText);
630 return E_NOTIMPL;
633 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
635 WebBrowser *This = WEBBROWSER_THIS(iface);
636 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
637 return E_NOTIMPL;
640 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
642 WebBrowser *This = WEBBROWSER_THIS(iface);
644 TRACE("(%p)->(%p)\n", This, Value);
646 *Value = This->tool_bar;
647 return S_OK;
650 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
652 WebBrowser *This = WEBBROWSER_THIS(iface);
653 VARIANTARG arg;
654 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
656 TRACE("(%p)->(%x)\n", This, Value);
658 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
660 /* In opposition to InternetExplorer, all we should do here is
661 * inform the embedder about the tool bar change. */
663 V_VT(&arg) = VT_BOOL;
664 V_BOOL(&arg) = This->tool_bar;
665 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
667 return S_OK;
670 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
672 WebBrowser *This = WEBBROWSER_THIS(iface);
674 TRACE("(%p)->(%p)\n", This, Value);
676 *Value = This->menu_bar;
677 return S_OK;
680 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
682 WebBrowser *This = WEBBROWSER_THIS(iface);
683 VARIANTARG arg;
684 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
686 TRACE("(%p)->(%x)\n", This, Value);
688 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
690 /* In opposition to InternetExplorer, all we should do here is
691 * inform the embedder about the menu bar change. */
693 V_VT(&arg) = VT_BOOL;
694 V_BOOL(&arg) = Value;
695 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
697 return S_OK;
700 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
702 WebBrowser *This = WEBBROWSER_THIS(iface);
704 TRACE("(%p)->(%p)\n", This, pbFullScreen);
706 *pbFullScreen = This->full_screen;
707 return S_OK;
710 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
712 WebBrowser *This = WEBBROWSER_THIS(iface);
713 VARIANTARG arg;
714 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
716 /* In opposition to InternetExplorer, all we should do here is
717 * inform the embedder about the fullscreen change. */
719 TRACE("(%p)->(%x)\n", This, bFullScreen);
721 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
723 V_VT(&arg) = VT_BOOL;
724 V_BOOL(&arg) = bFullScreen;
725 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
727 return S_OK;
730 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
731 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
733 WebBrowser *This = WEBBROWSER_THIS(iface);
734 LPCWSTR url;
736 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
737 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
739 if(!This->client)
740 return E_FAIL;
742 if(!URL)
743 return S_OK;
745 switch (V_VT(URL))
747 case VT_BSTR:
748 url = V_BSTR(URL);
749 break;
750 case VT_BSTR|VT_BYREF:
751 url = *V_BSTRREF(URL);
752 break;
753 default:
754 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
755 return E_INVALIDARG;
758 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
761 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
763 WebBrowser *This = WEBBROWSER_THIS(iface);
764 FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
765 return E_NOTIMPL;
768 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
769 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
771 WebBrowser *This = WEBBROWSER_THIS(iface);
772 FIXME("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
773 return E_NOTIMPL;
776 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
777 VARIANT *pvarShow, VARIANT *pvarSize)
779 WebBrowser *This = WEBBROWSER_THIS(iface);
780 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
781 debugstr_variant(pvarSize));
782 return E_NOTIMPL;
785 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
787 WebBrowser *This = WEBBROWSER_THIS(iface);
789 TRACE("(%p)->(%p)\n", This, lpReadyState);
791 *lpReadyState = This->doc_host.ready_state;
792 return S_OK;
795 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
797 WebBrowser *This = WEBBROWSER_THIS(iface);
799 TRACE("(%p)->(%p)\n", This, pbOffline);
801 *pbOffline = This->doc_host.offline;
802 return S_OK;
805 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
807 WebBrowser *This = WEBBROWSER_THIS(iface);
809 TRACE("(%p)->(%x)\n", This, bOffline);
811 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
812 return S_OK;
815 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
817 WebBrowser *This = WEBBROWSER_THIS(iface);
819 TRACE("(%p)->(%p)\n", This, pbSilent);
821 *pbSilent = This->doc_host.silent;
822 return S_OK;
825 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
827 WebBrowser *This = WEBBROWSER_THIS(iface);
829 TRACE("(%p)->(%x)\n", This, bSilent);
831 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
832 return S_OK;
835 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
836 VARIANT_BOOL *pbRegister)
838 WebBrowser *This = WEBBROWSER_THIS(iface);
840 FIXME("(%p)->(%p)\n", This, pbRegister);
842 *pbRegister = This->register_browser;
843 return S_OK;
846 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
847 VARIANT_BOOL bRegister)
849 WebBrowser *This = WEBBROWSER_THIS(iface);
851 FIXME("(%p)->(%x)\n", This, bRegister);
853 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
854 return S_OK;
857 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
858 VARIANT_BOOL *pbRegister)
860 WebBrowser *This = WEBBROWSER_THIS(iface);
861 FIXME("(%p)->(%p)\n", This, pbRegister);
862 *pbRegister=0;
863 return S_OK;
866 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
867 VARIANT_BOOL bRegister)
869 WebBrowser *This = WEBBROWSER_THIS(iface);
870 FIXME("(%p)->(%x)\n", This, bRegister);
871 return S_OK;
874 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
876 WebBrowser *This = WEBBROWSER_THIS(iface);
878 TRACE("(%p)->(%p)\n", This, pbRegister);
880 *pbRegister = This->theater_mode;
881 return S_OK;
884 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
886 WebBrowser *This = WEBBROWSER_THIS(iface);
887 VARIANTARG arg;
888 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
890 TRACE("(%p)->(%x)\n", This, bRegister);
892 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
894 /* In opposition to InternetExplorer, all we should do here is
895 * inform the embedder about the theater mode change. */
897 V_VT(&arg) = VT_BOOL;
898 V_BOOL(&arg) = bRegister;
899 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
901 return S_OK;
904 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
906 WebBrowser *This = WEBBROWSER_THIS(iface);
908 TRACE("(%p)->(%p)\n", This, Value);
910 *Value = This->address_bar;
911 return S_OK;
914 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
916 WebBrowser *This = WEBBROWSER_THIS(iface);
917 VARIANTARG arg;
918 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
920 TRACE("(%p)->(%x)\n", This, Value);
922 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
924 /* In opposition to InternetExplorer, all we should do here is
925 * inform the embedder about the address bar change. */
927 V_VT(&arg) = VT_BOOL;
928 V_BOOL(&arg) = Value;
929 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
931 return S_OK;
934 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
936 WebBrowser *This = WEBBROWSER_THIS(iface);
938 TRACE("(%p)->(%p)\n", This, Value);
940 /* It's InternetExplorer object's method. We have nothing to do here. */
941 return E_NOTIMPL;
944 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
946 WebBrowser *This = WEBBROWSER_THIS(iface);
947 VARIANTARG arg;
948 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
950 TRACE("(%p)->(%x)\n", This, Value);
952 /* In opposition to InternetExplorer, all we should do here is
953 * inform the embedder about the resizable change. */
955 V_VT(&arg) = VT_BOOL;
956 V_BOOL(&arg) = Value;
957 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
959 return S_OK;
962 #undef WEBBROWSER_THIS
964 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
966 WebBrowser_QueryInterface,
967 WebBrowser_AddRef,
968 WebBrowser_Release,
969 WebBrowser_GetTypeInfoCount,
970 WebBrowser_GetTypeInfo,
971 WebBrowser_GetIDsOfNames,
972 WebBrowser_Invoke,
973 WebBrowser_GoBack,
974 WebBrowser_GoForward,
975 WebBrowser_GoHome,
976 WebBrowser_GoSearch,
977 WebBrowser_Navigate,
978 WebBrowser_Refresh,
979 WebBrowser_Refresh2,
980 WebBrowser_Stop,
981 WebBrowser_get_Application,
982 WebBrowser_get_Parent,
983 WebBrowser_get_Container,
984 WebBrowser_get_Document,
985 WebBrowser_get_TopLevelContainer,
986 WebBrowser_get_Type,
987 WebBrowser_get_Left,
988 WebBrowser_put_Left,
989 WebBrowser_get_Top,
990 WebBrowser_put_Top,
991 WebBrowser_get_Width,
992 WebBrowser_put_Width,
993 WebBrowser_get_Height,
994 WebBrowser_put_Height,
995 WebBrowser_get_LocationName,
996 WebBrowser_get_LocationURL,
997 WebBrowser_get_Busy,
998 WebBrowser_Quit,
999 WebBrowser_ClientToWindow,
1000 WebBrowser_PutProperty,
1001 WebBrowser_GetProperty,
1002 WebBrowser_get_Name,
1003 WebBrowser_get_HWND,
1004 WebBrowser_get_FullName,
1005 WebBrowser_get_Path,
1006 WebBrowser_get_Visible,
1007 WebBrowser_put_Visible,
1008 WebBrowser_get_StatusBar,
1009 WebBrowser_put_StatusBar,
1010 WebBrowser_get_StatusText,
1011 WebBrowser_put_StatusText,
1012 WebBrowser_get_ToolBar,
1013 WebBrowser_put_ToolBar,
1014 WebBrowser_get_MenuBar,
1015 WebBrowser_put_MenuBar,
1016 WebBrowser_get_FullScreen,
1017 WebBrowser_put_FullScreen,
1018 WebBrowser_Navigate2,
1019 WebBrowser_QueryStatusWB,
1020 WebBrowser_ExecWB,
1021 WebBrowser_ShowBrowserBar,
1022 WebBrowser_get_ReadyState,
1023 WebBrowser_get_Offline,
1024 WebBrowser_put_Offline,
1025 WebBrowser_get_Silent,
1026 WebBrowser_put_Silent,
1027 WebBrowser_get_RegisterAsBrowser,
1028 WebBrowser_put_RegisterAsBrowser,
1029 WebBrowser_get_RegisterAsDropTarget,
1030 WebBrowser_put_RegisterAsDropTarget,
1031 WebBrowser_get_TheaterMode,
1032 WebBrowser_put_TheaterMode,
1033 WebBrowser_get_AddressBar,
1034 WebBrowser_put_AddressBar,
1035 WebBrowser_get_Resizable,
1036 WebBrowser_put_Resizable
1039 #define SERVPROV_THIS(iface) DEFINE_THIS(WebBrowser, OleObject, iface)
1041 * IServiceProvider interface.
1043 static HRESULT WINAPI WebBrowser_IServiceProvider_QueryInterface(IServiceProvider *iface,
1044 REFIID riid, LPVOID *ppv)
1046 WebBrowser *This = SERVPROV_THIS(iface);
1048 if (ppv == NULL)
1049 return E_POINTER;
1050 *ppv = NULL;
1052 if(IsEqualGUID(&IID_IUnknown, riid)) {
1053 *ppv = WEBBROWSER(This);
1054 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1055 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
1056 *ppv = WEBBROWSER(This);
1057 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
1060 if(*ppv) {
1061 IUnknown_AddRef((IUnknown*)*ppv);
1062 return S_OK;
1065 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
1066 return E_NOINTERFACE;
1069 static ULONG WINAPI WebBrowser_IServiceProvider_AddRef(IServiceProvider *iface)
1071 WebBrowser *This = SERVPROV_THIS(iface);
1072 return IWebBrowser_AddRef(WEBBROWSER(This));
1075 static ULONG WINAPI WebBrowser_IServiceProvider_Release(IServiceProvider *iface)
1077 WebBrowser *This = SERVPROV_THIS(iface);
1078 return IWebBrowser_Release(WEBBROWSER(This));
1081 static HRESULT STDMETHODCALLTYPE WebBrowser_IServiceProvider_QueryService(IServiceProvider *iface,
1082 REFGUID guidService, REFIID riid, void **ppv)
1084 WebBrowser *This = SERVPROV_THIS(iface);
1085 static const IID IID_IBrowserService2 =
1086 {0x68BD21CC,0x438B,0x11d2,{0xA5,0x60,0x00,0xA0,0xC,0x2D,0xBF,0xE8}};
1088 if(*ppv)
1089 ppv = NULL;
1091 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1092 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1093 return E_FAIL;
1096 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1098 return E_NOINTERFACE;
1101 #undef SERVPROV_THIS
1103 static const IServiceProviderVtbl ServiceProviderVtbl =
1105 WebBrowser_IServiceProvider_QueryInterface,
1106 WebBrowser_IServiceProvider_AddRef,
1107 WebBrowser_IServiceProvider_Release,
1108 WebBrowser_IServiceProvider_QueryService
1111 static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, void **ppv)
1113 WebBrowser *ret;
1114 HRESULT hres;
1116 TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
1118 ret = heap_alloc(sizeof(WebBrowser));
1120 ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
1121 ret->lpServiceProviderVtbl = &ServiceProviderVtbl;
1122 ret->ref = 0;
1123 ret->version = version;
1125 DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
1127 ret->register_browser = VARIANT_FALSE;
1128 ret->visible = VARIANT_TRUE;
1129 ret->menu_bar = VARIANT_TRUE;
1130 ret->address_bar = VARIANT_TRUE;
1131 ret->status_bar = VARIANT_TRUE;
1132 ret->tool_bar = VARIANT_TRUE;
1133 ret->full_screen = VARIANT_FALSE;
1134 ret->theater_mode = VARIANT_FALSE;
1136 WebBrowser_OleObject_Init(ret);
1137 WebBrowser_ViewObject_Init(ret);
1138 WebBrowser_Persist_Init(ret);
1139 WebBrowser_ClassInfo_Init(ret);
1140 WebBrowser_HlinkFrame_Init(ret);
1142 hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
1143 if(SUCCEEDED(hres)) {
1144 SHDOCVW_LockModule();
1145 }else {
1146 heap_free(ret);
1147 return hres;
1150 return hres;
1153 HRESULT WebBrowserV1_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1155 return WebBrowser_Create(1, pOuter, riid, ppv);
1158 HRESULT WebBrowserV2_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1160 return WebBrowser_Create(2, pOuter, riid, ppv);