shdocvw: Guess URL scheme if not available.
[wine.git] / dlls / shdocvw / webbrowser.c
blob95586f0d303fdfaf2eb73002d0a598b508575bcb
1 /*
2 * Implementation of IWebBrowser interface for WebBrowser control
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
5 * Copyright 2005 Jacek Caban
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
23 #include "shdocvw.h"
24 #include "exdispid.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
28 /**********************************************************************
29 * Implement the IWebBrowser interface
32 #define WEBBROWSER_THIS(iface) DEFINE_THIS(WebBrowser, WebBrowser2, iface)
34 static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
36 WebBrowser *This = WEBBROWSER_THIS(iface);
38 if (ppv == NULL)
39 return E_POINTER;
40 *ppv = NULL;
42 if(IsEqualGUID(&IID_IUnknown, riid)) {
43 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
44 *ppv = WEBBROWSER(This);
45 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
46 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
47 *ppv = WEBBROWSER(This);
48 }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
49 TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
50 *ppv = WEBBROWSER(This);
51 }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
52 TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
53 *ppv = WEBBROWSER(This);
54 }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
55 TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
56 *ppv = WEBBROWSER(This);
57 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
58 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
59 *ppv = OLEOBJ(This);
60 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
61 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
62 *ppv = INPLACEOBJ(This);
63 }else if(IsEqualGUID (&IID_IOleInPlaceObject, riid)) {
64 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
65 *ppv = INPLACEOBJ(This);
66 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
67 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
68 *ppv = CONTROL(This);
69 }else if(IsEqualGUID(&IID_IPersist, riid)) {
70 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
71 *ppv = PERSTORAGE(This);
72 }else if(IsEqualGUID(&IID_IPersistStorage, riid)) {
73 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
74 *ppv = PERSTORAGE(This);
75 }else if(IsEqualGUID(&IID_IPersistMemory, riid)) {
76 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
77 *ppv = PERMEMORY(This);
78 }else if(IsEqualGUID (&IID_IPersistStreamInit, riid)) {
79 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
80 *ppv = PERSTRINIT(This);
81 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
82 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
83 *ppv = CLASSINFO(This);
84 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
85 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
86 *ppv = CLASSINFO(This);
87 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
88 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
89 *ppv = CONPTCONT(&This->doc_host.cps);
90 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
91 TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
92 *ppv = VIEWOBJ(This);
93 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
94 TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
95 *ppv = VIEWOBJ2(This);
96 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
97 TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
98 *ppv = ACTIVEOBJ(This);
99 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
100 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
101 *ppv = OLECMD(This);
102 }else if(IsEqualGUID(&IID_IHlinkFrame, riid)) {
103 TRACE("(%p)->(IID_IHlinkFrame %p)\n", This, ppv);
104 *ppv = HLINKFRAME(This);
105 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
106 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
107 return E_NOINTERFACE;
108 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
109 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
110 return E_NOINTERFACE;
111 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
112 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
113 return E_NOINTERFACE;
114 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
115 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
116 return E_NOINTERFACE;
117 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
118 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
119 return E_NOINTERFACE;
120 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
121 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
122 return E_NOINTERFACE;
125 if(*ppv) {
126 IUnknown_AddRef((IUnknown*)*ppv);
127 return S_OK;
130 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
131 return E_NOINTERFACE;
134 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
136 WebBrowser *This = WEBBROWSER_THIS(iface);
137 LONG ref = InterlockedIncrement(&This->ref);
138 TRACE("(%p) ref=%d\n", This, ref);
139 return ref;
142 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
144 WebBrowser *This = WEBBROWSER_THIS(iface);
145 LONG ref = InterlockedDecrement(&This->ref);
147 TRACE("(%p) ref=%d\n", This, ref);
149 if(!ref) {
150 if(This->doc_host.document)
151 IUnknown_Release(This->doc_host.document);
153 DocHost_Release(&This->doc_host);
155 WebBrowser_OleObject_Destroy(This);
157 heap_free(This);
158 SHDOCVW_UnlockModule();
161 return ref;
164 /* IDispatch methods */
165 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
167 WebBrowser *This = WEBBROWSER_THIS(iface);
168 FIXME("(%p)->(%p)\n", This, pctinfo);
169 return E_NOTIMPL;
172 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
173 LPTYPEINFO *ppTInfo)
175 WebBrowser *This = WEBBROWSER_THIS(iface);
176 FIXME("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
177 return E_NOTIMPL;
180 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
181 LPOLESTR *rgszNames, UINT cNames,
182 LCID lcid, DISPID *rgDispId)
184 WebBrowser *This = WEBBROWSER_THIS(iface);
185 FIXME("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
186 lcid, rgDispId);
187 return E_NOTIMPL;
190 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
191 REFIID riid, LCID lcid, WORD wFlags,
192 DISPPARAMS *pDispParams, VARIANT *pVarResult,
193 EXCEPINFO *pExepInfo, UINT *puArgErr)
195 WebBrowser *This = WEBBROWSER_THIS(iface);
196 ITypeInfo *typeinfo;
197 HRESULT hres;
199 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
200 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
202 hres = get_typeinfo(&typeinfo);
203 if(FAILED(hres))
204 return hres;
206 return ITypeInfo_Invoke(typeinfo, WEBBROWSER2(This), dispIdMember, wFlags, pDispParams,
207 pVarResult, pExepInfo, puArgErr);
210 /* IWebBrowser methods */
211 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
213 WebBrowser *This = WEBBROWSER_THIS(iface);
214 FIXME("(%p)\n", This);
215 return E_NOTIMPL;
218 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
220 WebBrowser *This = WEBBROWSER_THIS(iface);
221 FIXME("(%p)\n", This);
222 return E_NOTIMPL;
225 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
227 WebBrowser *This = WEBBROWSER_THIS(iface);
228 TRACE("(%p)\n", This);
229 return go_home(&This->doc_host);
232 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
234 WebBrowser *This = WEBBROWSER_THIS(iface);
235 FIXME("(%p)\n", This);
236 return E_NOTIMPL;
239 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
240 VARIANT *Flags, VARIANT *TargetFrameName,
241 VARIANT *PostData, VARIANT *Headers)
243 WebBrowser *This = WEBBROWSER_THIS(iface);
245 TRACE("(%p)->(%s %p %p %p %p)\n", This, debugstr_w(szUrl), Flags, TargetFrameName,
246 PostData, Headers);
248 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
251 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
253 WebBrowser *This = WEBBROWSER_THIS(iface);
254 FIXME("(%p)\n", This);
255 return E_NOTIMPL;
258 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
260 WebBrowser *This = WEBBROWSER_THIS(iface);
261 FIXME("(%p)->(%p)\n", This, Level);
262 return E_NOTIMPL;
265 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
267 WebBrowser *This = WEBBROWSER_THIS(iface);
268 FIXME("(%p)\n", This);
269 return E_NOTIMPL;
272 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
274 WebBrowser *This = WEBBROWSER_THIS(iface);
276 TRACE("(%p)->(%p)\n", This, ppDisp);
278 if(!ppDisp)
279 return E_POINTER;
281 *ppDisp = (IDispatch*)WEBBROWSER2(This);
282 IDispatch_AddRef(*ppDisp);
283 return S_OK;
286 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
288 WebBrowser *This = WEBBROWSER_THIS(iface);
289 FIXME("(%p)->(%p)\n", This, ppDisp);
290 return E_NOTIMPL;
293 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
295 WebBrowser *This = WEBBROWSER_THIS(iface);
296 FIXME("(%p)->(%p)\n", This, ppDisp);
297 return E_NOTIMPL;
300 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
302 WebBrowser *This = WEBBROWSER_THIS(iface);
304 TRACE("(%p)->(%p)\n", This, ppDisp);
306 *ppDisp = NULL;
307 if(This->doc_host.document)
308 IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)ppDisp);
310 return S_OK;
313 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
315 WebBrowser *This = WEBBROWSER_THIS(iface);
316 FIXME("(%p)->(%p)\n", This, pBool);
317 return E_NOTIMPL;
320 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
322 WebBrowser *This = WEBBROWSER_THIS(iface);
323 FIXME("(%p)->(%p)\n", This, Type);
324 return E_NOTIMPL;
327 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, long *pl)
329 WebBrowser *This = WEBBROWSER_THIS(iface);
331 TRACE("(%p)->(%p)\n", This, pl);
333 *pl = This->pos_rect.left;
334 return S_OK;
337 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, long Left)
339 WebBrowser *This = WEBBROWSER_THIS(iface);
340 RECT rect;
342 TRACE("(%p)->(%ld)\n", This, Left);
344 if(!This->inplace)
345 return E_UNEXPECTED;
347 memcpy(&rect, &This->pos_rect, sizeof(RECT));
348 rect.left = Left;
350 /* We don't really change the window position here.
351 * We just notify the embedder that he should do so. */
352 return IOleInPlaceSite_OnPosRectChange(This->inplace, &rect);
355 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, long *pl)
357 WebBrowser *This = WEBBROWSER_THIS(iface);
359 TRACE("(%p)->(%p)\n", This, pl);
361 *pl = This->pos_rect.top;
362 return S_OK;
365 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, long Top)
367 WebBrowser *This = WEBBROWSER_THIS(iface);
368 RECT rect;
370 TRACE("(%p)->(%ld)\n", This, Top);
372 if(!This->inplace)
373 return E_UNEXPECTED;
375 memcpy(&rect, &This->pos_rect, sizeof(RECT));
376 rect.top = Top;
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_Width(IWebBrowser2 *iface, long *pl)
385 WebBrowser *This = WEBBROWSER_THIS(iface);
387 TRACE("(%p)->(%p)\n", This, pl);
389 *pl = This->pos_rect.right - This->pos_rect.left;
390 return S_OK;
393 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, long Width)
395 WebBrowser *This = WEBBROWSER_THIS(iface);
396 RECT rect;
398 TRACE("(%p)->(%ld)\n", This, Width);
400 if(!This->inplace)
401 return E_UNEXPECTED;
403 memcpy(&rect, &This->pos_rect, sizeof(RECT));
404 rect.right = rect.left+Width;
406 /* We don't really change the window size 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_Height(IWebBrowser2 *iface, long *pl)
413 WebBrowser *This = WEBBROWSER_THIS(iface);
415 TRACE("(%p)->(%p)\n", This, pl);
417 *pl = This->pos_rect.bottom - This->pos_rect.top;
418 return S_OK;
421 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, long Height)
423 WebBrowser *This = WEBBROWSER_THIS(iface);
424 RECT rect;
426 TRACE("(%p)->(%ld)\n", This, Height);
428 if(!This->inplace)
429 return E_UNEXPECTED;
431 memcpy(&rect, &This->pos_rect, sizeof(RECT));
432 rect.bottom = rect.top+Height;
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_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
441 WebBrowser *This = WEBBROWSER_THIS(iface);
442 FIXME("(%p)->(%p)\n", This, LocationName);
443 return E_NOTIMPL;
446 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
448 WebBrowser *This = WEBBROWSER_THIS(iface);
450 FIXME("(%p)->(%p)\n", This, LocationURL);
452 if(!This->doc_host.url) {
453 static const WCHAR null_char = 0;
454 *LocationURL = SysAllocString(&null_char);
455 return S_FALSE;
458 *LocationURL = SysAllocString(This->doc_host.url);
459 return S_OK;
462 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
464 WebBrowser *This = WEBBROWSER_THIS(iface);
465 FIXME("(%p)->(%p)\n", This, pBool);
466 return E_NOTIMPL;
469 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
471 WebBrowser *This = WEBBROWSER_THIS(iface);
473 TRACE("(%p)\n", This);
475 /* It's a InternetExplorer specific method, we have nothing to do here. */
476 return E_FAIL;
479 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
481 WebBrowser *This = WEBBROWSER_THIS(iface);
482 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
483 return E_NOTIMPL;
486 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
488 WebBrowser *This = WEBBROWSER_THIS(iface);
489 FIXME("(%p)->(%s)\n", This, debugstr_w(szProperty));
490 return E_NOTIMPL;
493 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
495 WebBrowser *This = WEBBROWSER_THIS(iface);
496 FIXME("(%p)->(%s %p)\n", This, debugstr_w(szProperty), pvtValue);
497 return E_NOTIMPL;
500 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
502 WebBrowser *This = WEBBROWSER_THIS(iface);
503 FIXME("(%p)->(%p)\n", This, Name);
504 return E_NOTIMPL;
507 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, long *pHWND)
509 WebBrowser *This = WEBBROWSER_THIS(iface);
511 TRACE("(%p)->(%p)\n", This, pHWND);
513 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
514 *pHWND = 0;
515 return E_FAIL;
518 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
520 WebBrowser *This = WEBBROWSER_THIS(iface);
521 FIXME("(%p)->(%p)\n", This, FullName);
522 return E_NOTIMPL;
525 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
527 WebBrowser *This = WEBBROWSER_THIS(iface);
528 FIXME("(%p)->(%p)\n", This, Path);
529 return E_NOTIMPL;
532 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
534 WebBrowser *This = WEBBROWSER_THIS(iface);
536 TRACE("(%p)->(%p)\n", This, pBool);
538 *pBool = This->visible;
539 return S_OK;
542 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
544 WebBrowser *This = WEBBROWSER_THIS(iface);
545 VARIANTARG arg;
546 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
548 TRACE("(%p)->(%x)\n", This, Value);
550 This->visible = Value;
552 V_VT(&arg) = VT_BOOL;
553 V_BOOL(&arg) = Value;
554 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
556 return S_OK;
559 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
561 WebBrowser *This = WEBBROWSER_THIS(iface);
563 TRACE("(%p)->(%p)\n", This, pBool);
565 *pBool = This->status_bar;
566 return S_OK;
569 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
571 WebBrowser *This = WEBBROWSER_THIS(iface);
572 VARIANTARG arg;
573 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
575 TRACE("(%p)->(%x)\n", This, Value);
577 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
579 /* In opposition to InternetExplorer, all we should do here is
580 * inform the embedder about the status bar change. */
582 V_VT(&arg) = VT_BOOL;
583 V_BOOL(&arg) = Value;
584 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
586 return S_OK;
589 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
591 WebBrowser *This = WEBBROWSER_THIS(iface);
592 FIXME("(%p)->(%p)\n", This, StatusText);
593 return E_NOTIMPL;
596 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
598 WebBrowser *This = WEBBROWSER_THIS(iface);
599 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
600 return E_NOTIMPL;
603 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
605 WebBrowser *This = WEBBROWSER_THIS(iface);
607 TRACE("(%p)->(%p)\n", This, Value);
609 *Value = This->tool_bar;
610 return S_OK;
613 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
615 WebBrowser *This = WEBBROWSER_THIS(iface);
616 VARIANTARG arg;
617 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
619 TRACE("(%p)->(%x)\n", This, Value);
621 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
623 /* In opposition to InternetExplorer, all we should do here is
624 * inform the embedder about the tool bar change. */
626 V_VT(&arg) = VT_BOOL;
627 V_BOOL(&arg) = Value;
628 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
630 return S_OK;
633 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
635 WebBrowser *This = WEBBROWSER_THIS(iface);
637 TRACE("(%p)->(%p)\n", This, Value);
639 *Value = This->menu_bar;
640 return S_OK;
643 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL 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->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
653 /* In opposition to InternetExplorer, all we should do here is
654 * inform the embedder about the menu bar change. */
656 V_VT(&arg) = VT_BOOL;
657 V_BOOL(&arg) = Value;
658 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
660 return S_OK;
663 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
665 WebBrowser *This = WEBBROWSER_THIS(iface);
667 TRACE("(%p)->(%p)\n", This, pbFullScreen);
669 *pbFullScreen = This->full_screen;
670 return S_OK;
673 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
675 WebBrowser *This = WEBBROWSER_THIS(iface);
676 VARIANTARG arg;
677 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
679 /* In opposition to InternetExplorer, all we should do here is
680 * inform the embedder about the fullscreen change. */
682 TRACE("(%p)->(%x)\n", This, bFullScreen);
684 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
686 V_VT(&arg) = VT_BOOL;
687 V_BOOL(&arg) = bFullScreen;
688 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
690 return S_OK;
693 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
694 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
696 WebBrowser *This = WEBBROWSER_THIS(iface);
698 TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers);
700 if(!This->client)
701 return E_FAIL;
703 if(!URL)
704 return S_OK;
706 if(V_VT(URL) != VT_BSTR) {
707 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
708 return E_INVALIDARG;
711 return navigate_url(&This->doc_host, V_BSTR(URL), Flags, TargetFrameName, PostData, Headers);
714 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
716 WebBrowser *This = WEBBROWSER_THIS(iface);
717 FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
718 return E_NOTIMPL;
721 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
722 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
724 WebBrowser *This = WEBBROWSER_THIS(iface);
725 FIXME("(%p)->(%d %d %p %p)\n", This, cmdID, cmdexecopt, pvaIn, pvaOut);
726 return E_NOTIMPL;
729 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
730 VARIANT *pvarShow, VARIANT *pvarSize)
732 WebBrowser *This = WEBBROWSER_THIS(iface);
733 FIXME("(%p)->(%p %p %p)\n", This, pvaClsid, pvarShow, pvarSize);
734 return E_NOTIMPL;
737 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
739 WebBrowser *This = WEBBROWSER_THIS(iface);
740 FIXME("(%p)->(%p)\n", This, lpReadyState);
741 return E_NOTIMPL;
744 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
746 WebBrowser *This = WEBBROWSER_THIS(iface);
748 TRACE("(%p)->(%p)\n", This, pbOffline);
750 *pbOffline = This->doc_host.offline;
751 return S_OK;
754 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
756 WebBrowser *This = WEBBROWSER_THIS(iface);
758 TRACE("(%p)->(%x)\n", This, bOffline);
760 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
761 return S_OK;
764 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
766 WebBrowser *This = WEBBROWSER_THIS(iface);
768 TRACE("(%p)->(%p)\n", This, pbSilent);
770 *pbSilent = This->doc_host.silent;
771 return S_OK;
774 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
776 WebBrowser *This = WEBBROWSER_THIS(iface);
778 TRACE("(%p)->(%x)\n", This, bSilent);
780 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
781 return S_OK;
784 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
785 VARIANT_BOOL *pbRegister)
787 WebBrowser *This = WEBBROWSER_THIS(iface);
788 FIXME("(%p)->(%p)\n", This, pbRegister);
789 return E_NOTIMPL;
792 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
793 VARIANT_BOOL bRegister)
795 WebBrowser *This = WEBBROWSER_THIS(iface);
796 FIXME("(%p)->(%x)\n", This, bRegister);
797 return E_NOTIMPL;
800 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
801 VARIANT_BOOL *pbRegister)
803 WebBrowser *This = WEBBROWSER_THIS(iface);
804 FIXME("(%p)->(%p)\n", This, pbRegister);
805 *pbRegister=0;
806 return S_OK;
809 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
810 VARIANT_BOOL bRegister)
812 WebBrowser *This = WEBBROWSER_THIS(iface);
813 FIXME("(%p)->(%x)\n", This, bRegister);
814 return S_OK;
817 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
819 WebBrowser *This = WEBBROWSER_THIS(iface);
821 TRACE("(%p)->(%p)\n", This, pbRegister);
823 *pbRegister = This->theater_mode;
824 return S_OK;
827 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
829 WebBrowser *This = WEBBROWSER_THIS(iface);
830 VARIANTARG arg;
831 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
833 TRACE("(%p)->(%x)\n", This, bRegister);
835 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
837 /* In opposition to InternetExplorer, all we should do here is
838 * inform the embedder about the theater mode change. */
840 V_VT(&arg) = VT_BOOL;
841 V_BOOL(&arg) = bRegister;
842 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
844 return S_OK;
847 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
849 WebBrowser *This = WEBBROWSER_THIS(iface);
851 TRACE("(%p)->(%p)\n", This, Value);
853 *Value = This->address_bar;
854 return S_OK;
857 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
859 WebBrowser *This = WEBBROWSER_THIS(iface);
860 VARIANTARG arg;
861 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
863 TRACE("(%p)->(%x)\n", This, Value);
865 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
867 /* In opposition to InternetExplorer, all we should do here is
868 * inform the embedder about the address bar change. */
870 V_VT(&arg) = VT_BOOL;
871 V_BOOL(&arg) = Value;
872 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
874 return S_OK;
877 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
879 WebBrowser *This = WEBBROWSER_THIS(iface);
881 TRACE("(%p)->(%p)\n", This, Value);
883 /* It's InternetExplorer object's method. We have nothing to do here. */
884 return E_NOTIMPL;
887 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
889 WebBrowser *This = WEBBROWSER_THIS(iface);
890 VARIANTARG arg;
891 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
893 TRACE("(%p)->(%x)\n", This, Value);
895 /* In opposition to InternetExplorer, all we should do here is
896 * inform the embedder about the resizable change. */
898 V_VT(&arg) = VT_BOOL;
899 V_BOOL(&arg) = Value;
900 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
902 return S_OK;
905 #undef WEBBROWSER_THIS
907 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
909 WebBrowser_QueryInterface,
910 WebBrowser_AddRef,
911 WebBrowser_Release,
912 WebBrowser_GetTypeInfoCount,
913 WebBrowser_GetTypeInfo,
914 WebBrowser_GetIDsOfNames,
915 WebBrowser_Invoke,
916 WebBrowser_GoBack,
917 WebBrowser_GoForward,
918 WebBrowser_GoHome,
919 WebBrowser_GoSearch,
920 WebBrowser_Navigate,
921 WebBrowser_Refresh,
922 WebBrowser_Refresh2,
923 WebBrowser_Stop,
924 WebBrowser_get_Application,
925 WebBrowser_get_Parent,
926 WebBrowser_get_Container,
927 WebBrowser_get_Document,
928 WebBrowser_get_TopLevelContainer,
929 WebBrowser_get_Type,
930 WebBrowser_get_Left,
931 WebBrowser_put_Left,
932 WebBrowser_get_Top,
933 WebBrowser_put_Top,
934 WebBrowser_get_Width,
935 WebBrowser_put_Width,
936 WebBrowser_get_Height,
937 WebBrowser_put_Height,
938 WebBrowser_get_LocationName,
939 WebBrowser_get_LocationURL,
940 WebBrowser_get_Busy,
941 WebBrowser_Quit,
942 WebBrowser_ClientToWindow,
943 WebBrowser_PutProperty,
944 WebBrowser_GetProperty,
945 WebBrowser_get_Name,
946 WebBrowser_get_HWND,
947 WebBrowser_get_FullName,
948 WebBrowser_get_Path,
949 WebBrowser_get_Visible,
950 WebBrowser_put_Visible,
951 WebBrowser_get_StatusBar,
952 WebBrowser_put_StatusBar,
953 WebBrowser_get_StatusText,
954 WebBrowser_put_StatusText,
955 WebBrowser_get_ToolBar,
956 WebBrowser_put_ToolBar,
957 WebBrowser_get_MenuBar,
958 WebBrowser_put_MenuBar,
959 WebBrowser_get_FullScreen,
960 WebBrowser_put_FullScreen,
961 WebBrowser_Navigate2,
962 WebBrowser_QueryStatusWB,
963 WebBrowser_ExecWB,
964 WebBrowser_ShowBrowserBar,
965 WebBrowser_get_ReadyState,
966 WebBrowser_get_Offline,
967 WebBrowser_put_Offline,
968 WebBrowser_get_Silent,
969 WebBrowser_put_Silent,
970 WebBrowser_get_RegisterAsBrowser,
971 WebBrowser_put_RegisterAsBrowser,
972 WebBrowser_get_RegisterAsDropTarget,
973 WebBrowser_put_RegisterAsDropTarget,
974 WebBrowser_get_TheaterMode,
975 WebBrowser_put_TheaterMode,
976 WebBrowser_get_AddressBar,
977 WebBrowser_put_AddressBar,
978 WebBrowser_get_Resizable,
979 WebBrowser_put_Resizable
982 static HRESULT WebBrowser_Create(INT version, IUnknown *pOuter, REFIID riid, void **ppv)
984 WebBrowser *ret;
985 HRESULT hres;
987 TRACE("(%p %s %p) version=%d\n", pOuter, debugstr_guid(riid), ppv, version);
989 ret = heap_alloc(sizeof(WebBrowser));
991 ret->lpWebBrowser2Vtbl = &WebBrowser2Vtbl;
992 ret->ref = 0;
993 ret->version = version;
995 DocHost_Init(&ret->doc_host, (IDispatch*)WEBBROWSER2(ret));
997 ret->visible = VARIANT_TRUE;
998 ret->menu_bar = VARIANT_TRUE;
999 ret->address_bar = VARIANT_TRUE;
1000 ret->status_bar = VARIANT_TRUE;
1001 ret->tool_bar = VARIANT_TRUE;
1002 ret->full_screen = VARIANT_FALSE;
1003 ret->theater_mode = VARIANT_FALSE;
1005 WebBrowser_OleObject_Init(ret);
1006 WebBrowser_ViewObject_Init(ret);
1007 WebBrowser_Persist_Init(ret);
1008 WebBrowser_ClassInfo_Init(ret);
1009 WebBrowser_HlinkFrame_Init(ret);
1011 hres = IWebBrowser_QueryInterface(WEBBROWSER(ret), riid, ppv);
1012 if(SUCCEEDED(hres)) {
1013 SHDOCVW_LockModule();
1014 }else {
1015 heap_free(ret);
1016 return hres;
1019 return hres;
1022 HRESULT WebBrowserV1_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1024 return WebBrowser_Create(1, pOuter, riid, ppv);
1027 HRESULT WebBrowserV2_Create(IUnknown *pOuter, REFIID riid, void **ppv)
1029 return WebBrowser_Create(2, pOuter, riid, ppv);