xref: /reactos/dll/win32/ieframe/ie.c (revision 803b5e13)
1 /*
2  * Copyright 2006 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include "ieframe.h"
20 
21 #include "wine/debug.h"
22 
23 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
24 
25 static inline InternetExplorer *impl_from_IWebBrowser2(IWebBrowser2 *iface)
26 {
27     return CONTAINING_RECORD(iface, InternetExplorer, IWebBrowser2_iface);
28 }
29 
30 static HRESULT WINAPI InternetExplorer_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
31 {
32     InternetExplorer *This = impl_from_IWebBrowser2(iface);
33 
34     *ppv = NULL;
35 
36     if(IsEqualGUID(&IID_IUnknown, riid)) {
37         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
38         *ppv = &This->IWebBrowser2_iface;
39     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
40         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
41         *ppv = &This->IWebBrowser2_iface;
42     }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
43         TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
44         *ppv = &This->IWebBrowser2_iface;
45     }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
46         TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
47         *ppv = &This->IWebBrowser2_iface;
48     }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
49         TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
50         *ppv = &This->IWebBrowser2_iface;
51     }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
52         TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
53         *ppv = &This->doc_host.cps.IConnectionPointContainer_iface;
54     }else if(IsEqualGUID(&IID_IExternalConnection, riid)) {
55         TRACE("(%p)->(IID_IExternalConnection %p)\n", This, ppv);
56         *ppv = &This->IExternalConnection_iface;
57     }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
58         TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
59         *ppv = &This->IServiceProvider_iface;
60     }else if(HlinkFrame_QI(&This->hlink_frame, riid, ppv)) {
61         return S_OK;
62     }
63 
64     if(*ppv) {
65         IUnknown_AddRef((IUnknown*)*ppv);
66         return S_OK;
67     }
68 
69     WARN("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
70     return E_NOINTERFACE;
71 }
72 
73 static ULONG WINAPI InternetExplorer_AddRef(IWebBrowser2 *iface)
74 {
75     InternetExplorer *This = impl_from_IWebBrowser2(iface);
76     LONG ref = InterlockedIncrement(&This->ref);
77     TRACE("(%p) ref=%d\n", This, ref);
78     return ref;
79 }
80 
81 static ULONG WINAPI InternetExplorer_Release(IWebBrowser2 *iface)
82 {
83     InternetExplorer *This = impl_from_IWebBrowser2(iface);
84     LONG ref = InterlockedDecrement(&This->ref);
85 
86     TRACE("(%p) ref=%d\n", This, ref);
87 
88     if(!ref) {
89         deactivate_document(&This->doc_host);
90         DocHost_Release(&This->doc_host);
91 
92         if(This->frame_hwnd)
93             DestroyWindow(This->frame_hwnd);
94         list_remove(&This->entry);
95         heap_free(This);
96 
97         released_obj();
98     }
99 
100     return ref;
101 }
102 
103 static HRESULT WINAPI InternetExplorer_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
104 {
105     InternetExplorer *This = impl_from_IWebBrowser2(iface);
106 
107     TRACE("(%p)->(%p)\n", This, pctinfo);
108 
109     *pctinfo = 1;
110     return S_OK;
111 }
112 
113 static HRESULT WINAPI InternetExplorer_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
114                                      LPTYPEINFO *ppTInfo)
115 {
116     InternetExplorer *This = impl_from_IWebBrowser2(iface);
117     ITypeInfo *typeinfo;
118     HRESULT hres;
119 
120     TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
121 
122     hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
123     if(FAILED(hres))
124         return hres;
125 
126     ITypeInfo_AddRef(typeinfo);
127     *ppTInfo = typeinfo;
128     return S_OK;
129 }
130 
131 static HRESULT WINAPI InternetExplorer_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
132                                        LPOLESTR *rgszNames, UINT cNames,
133                                        LCID lcid, DISPID *rgDispId)
134 {
135     InternetExplorer *This = impl_from_IWebBrowser2(iface);
136     ITypeInfo *typeinfo;
137     HRESULT hres;
138 
139     TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
140           lcid, rgDispId);
141 
142     hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
143     if(FAILED(hres))
144         return hres;
145 
146     return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
147 }
148 
149 static HRESULT WINAPI InternetExplorer_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
150                                 REFIID riid, LCID lcid, WORD wFlags,
151                                 DISPPARAMS *pDispParams, VARIANT *pVarResult,
152                                 EXCEPINFO *pExepInfo, UINT *puArgErr)
153 {
154     InternetExplorer *This = impl_from_IWebBrowser2(iface);
155     ITypeInfo *typeinfo;
156     HRESULT hres;
157 
158     TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
159             lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
160 
161     hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
162     if(FAILED(hres))
163         return hres;
164 
165     return ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags, pDispParams,
166             pVarResult, pExepInfo, puArgErr);
167 }
168 
169 static HRESULT WINAPI InternetExplorer_GoBack(IWebBrowser2 *iface)
170 {
171     InternetExplorer *This = impl_from_IWebBrowser2(iface);
172     TRACE("(%p)\n", This);
173     return go_back(&This->doc_host);
174 }
175 
176 static HRESULT WINAPI InternetExplorer_GoForward(IWebBrowser2 *iface)
177 {
178     InternetExplorer *This = impl_from_IWebBrowser2(iface);
179     TRACE("(%p)\n", This);
180     return go_forward(&This->doc_host);
181 }
182 
183 static HRESULT WINAPI InternetExplorer_GoHome(IWebBrowser2 *iface)
184 {
185     InternetExplorer *This = impl_from_IWebBrowser2(iface);
186     TRACE("(%p)\n", This);
187     return go_home(&This->doc_host);
188 }
189 
190 static HRESULT WINAPI InternetExplorer_GoSearch(IWebBrowser2 *iface)
191 {
192     InternetExplorer *This = impl_from_IWebBrowser2(iface);
193     FIXME("(%p)\n", This);
194     return E_NOTIMPL;
195 }
196 
197 static HRESULT WINAPI InternetExplorer_Navigate(IWebBrowser2 *iface, BSTR szUrl,
198                                   VARIANT *Flags, VARIANT *TargetFrameName,
199                                   VARIANT *PostData, VARIANT *Headers)
200 {
201     InternetExplorer *This = impl_from_IWebBrowser2(iface);
202 
203     TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
204           debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
205 
206     return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
207 }
208 
209 static HRESULT WINAPI InternetExplorer_Refresh(IWebBrowser2 *iface)
210 {
211     InternetExplorer *This = impl_from_IWebBrowser2(iface);
212 
213     TRACE("(%p)\n", This);
214 
215     return refresh_document(&This->doc_host, NULL);
216 }
217 
218 static HRESULT WINAPI InternetExplorer_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
219 {
220     InternetExplorer *This = impl_from_IWebBrowser2(iface);
221 
222     TRACE("(%p)->(%s)\n", This, debugstr_variant(Level));
223 
224     return refresh_document(&This->doc_host, Level);
225 }
226 
227 static HRESULT WINAPI InternetExplorer_Stop(IWebBrowser2 *iface)
228 {
229     InternetExplorer *This = impl_from_IWebBrowser2(iface);
230     FIXME("(%p)\n", This);
231     return E_NOTIMPL;
232 }
233 
234 static HRESULT WINAPI InternetExplorer_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
235 {
236     InternetExplorer *This = impl_from_IWebBrowser2(iface);
237     FIXME("(%p)->(%p)\n", This, ppDisp);
238     return E_NOTIMPL;
239 }
240 
241 static HRESULT WINAPI InternetExplorer_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
242 {
243     InternetExplorer *This = impl_from_IWebBrowser2(iface);
244     FIXME("(%p)->(%p)\n", This, ppDisp);
245     return E_NOTIMPL;
246 }
247 
248 static HRESULT WINAPI InternetExplorer_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
249 {
250     InternetExplorer *This = impl_from_IWebBrowser2(iface);
251     FIXME("(%p)->(%p)\n", This, ppDisp);
252     return E_NOTIMPL;
253 }
254 
255 static HRESULT WINAPI InternetExplorer_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
256 {
257     InternetExplorer *This = impl_from_IWebBrowser2(iface);
258     FIXME("(%p)->(%p)\n", This, ppDisp);
259     return E_NOTIMPL;
260 }
261 
262 static HRESULT WINAPI InternetExplorer_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
263 {
264     InternetExplorer *This = impl_from_IWebBrowser2(iface);
265     FIXME("(%p)->(%p)\n", This, pBool);
266     return E_NOTIMPL;
267 }
268 
269 static HRESULT WINAPI InternetExplorer_get_Type(IWebBrowser2 *iface, BSTR *Type)
270 {
271     InternetExplorer *This = impl_from_IWebBrowser2(iface);
272     FIXME("(%p)->(%p)\n", This, Type);
273     return E_NOTIMPL;
274 }
275 
276 static HRESULT WINAPI InternetExplorer_get_Left(IWebBrowser2 *iface, LONG *pl)
277 {
278     InternetExplorer *This = impl_from_IWebBrowser2(iface);
279     FIXME("(%p)->(%p)\n", This, pl);
280     return E_NOTIMPL;
281 }
282 
283 static HRESULT WINAPI InternetExplorer_put_Left(IWebBrowser2 *iface, LONG Left)
284 {
285     InternetExplorer *This = impl_from_IWebBrowser2(iface);
286     FIXME("(%p)->(%d)\n", This, Left);
287     return E_NOTIMPL;
288 }
289 
290 static HRESULT WINAPI InternetExplorer_get_Top(IWebBrowser2 *iface, LONG *pl)
291 {
292     InternetExplorer *This = impl_from_IWebBrowser2(iface);
293     FIXME("(%p)->(%p)\n", This, pl);
294     return E_NOTIMPL;
295 }
296 
297 static HRESULT WINAPI InternetExplorer_put_Top(IWebBrowser2 *iface, LONG Top)
298 {
299     InternetExplorer *This = impl_from_IWebBrowser2(iface);
300     FIXME("(%p)->(%d)\n", This, Top);
301     return E_NOTIMPL;
302 }
303 
304 static HRESULT WINAPI InternetExplorer_get_Width(IWebBrowser2 *iface, LONG *pl)
305 {
306     InternetExplorer *This = impl_from_IWebBrowser2(iface);
307     FIXME("(%p)->(%p)\n", This, pl);
308     return E_NOTIMPL;
309 }
310 
311 static HRESULT WINAPI InternetExplorer_put_Width(IWebBrowser2 *iface, LONG Width)
312 {
313     InternetExplorer *This = impl_from_IWebBrowser2(iface);
314     FIXME("(%p)->(%d)\n", This, Width);
315     return E_NOTIMPL;
316 }
317 
318 static HRESULT WINAPI InternetExplorer_get_Height(IWebBrowser2 *iface, LONG *pl)
319 {
320     InternetExplorer *This = impl_from_IWebBrowser2(iface);
321     FIXME("(%p)->(%p)\n", This, pl);
322     return E_NOTIMPL;
323 }
324 
325 static HRESULT WINAPI InternetExplorer_put_Height(IWebBrowser2 *iface, LONG Height)
326 {
327     InternetExplorer *This = impl_from_IWebBrowser2(iface);
328     FIXME("(%p)->(%d)\n", This, Height);
329     return E_NOTIMPL;
330 }
331 
332 static HRESULT WINAPI InternetExplorer_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
333 {
334     InternetExplorer *This = impl_from_IWebBrowser2(iface);
335     FIXME("(%p)->(%p)\n", This, LocationName);
336     return E_NOTIMPL;
337 }
338 
339 static HRESULT WINAPI InternetExplorer_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
340 {
341     InternetExplorer *This = impl_from_IWebBrowser2(iface);
342 
343     TRACE("(%p)->(%p)\n", This, LocationURL);
344 
345     return get_location_url(&This->doc_host, LocationURL);
346 }
347 
348 static HRESULT WINAPI InternetExplorer_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
349 {
350     InternetExplorer *This = impl_from_IWebBrowser2(iface);
351 
352     TRACE("(%p)->(%p)\n", This, pBool);
353 
354     *pBool = This->doc_host.busy;
355     return S_OK;
356 }
357 
358 static HRESULT WINAPI InternetExplorer_Quit(IWebBrowser2 *iface)
359 {
360     InternetExplorer *This = impl_from_IWebBrowser2(iface);
361     FIXME("(%p)\n", This);
362     return E_NOTIMPL;
363 }
364 
365 static HRESULT WINAPI InternetExplorer_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
366 {
367     InternetExplorer *This = impl_from_IWebBrowser2(iface);
368     FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
369     return E_NOTIMPL;
370 }
371 
372 static HRESULT WINAPI InternetExplorer_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
373 {
374     InternetExplorer *This = impl_from_IWebBrowser2(iface);
375     FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
376     return E_NOTIMPL;
377 }
378 
379 static HRESULT WINAPI InternetExplorer_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
380 {
381     InternetExplorer *This = impl_from_IWebBrowser2(iface);
382     FIXME("(%p)->(%s %p)\n", This, debugstr_w(szProperty), pvtValue);
383     return E_NOTIMPL;
384 }
385 
386 static HRESULT WINAPI InternetExplorer_get_Name(IWebBrowser2 *iface, BSTR *Name)
387 {
388     InternetExplorer *This = impl_from_IWebBrowser2(iface);
389     FIXME("(%p)->(%p)\n", This, Name);
390     return E_NOTIMPL;
391 }
392 
393 static HRESULT WINAPI InternetExplorer_get_HWND(IWebBrowser2 *iface, SHANDLE_PTR *pHWND)
394 {
395     InternetExplorer *This = impl_from_IWebBrowser2(iface);
396 
397     TRACE("(%p)->(%p)\n", This, pHWND);
398 
399     *pHWND = (SHANDLE_PTR)This->frame_hwnd;
400     return S_OK;
401 }
402 
403 static HRESULT WINAPI InternetExplorer_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
404 {
405     InternetExplorer *This = impl_from_IWebBrowser2(iface);
406     FIXME("(%p)->(%p)\n", This, FullName);
407     return E_NOTIMPL;
408 }
409 
410 static HRESULT WINAPI InternetExplorer_get_Path(IWebBrowser2 *iface, BSTR *Path)
411 {
412     InternetExplorer *This = impl_from_IWebBrowser2(iface);
413     FIXME("(%p)->(%p)\n", This, Path);
414     return E_NOTIMPL;
415 }
416 
417 static HRESULT WINAPI InternetExplorer_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
418 {
419     InternetExplorer *This = impl_from_IWebBrowser2(iface);
420 
421     TRACE("(%p)->(%p)\n", This, pBool);
422 
423     *pBool = IsWindowVisible(This->frame_hwnd) ? VARIANT_TRUE : VARIANT_FALSE;
424     return S_OK;
425 }
426 
427 static HRESULT WINAPI InternetExplorer_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
428 {
429     InternetExplorer *This = impl_from_IWebBrowser2(iface);
430     TRACE("(%p)->(%x)\n", This, Value);
431 
432     ShowWindow(This->frame_hwnd, Value ? SW_SHOW : SW_HIDE);
433 
434     return S_OK;
435 }
436 
437 static HRESULT WINAPI InternetExplorer_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
438 {
439     InternetExplorer *This = impl_from_IWebBrowser2(iface);
440     FIXME("(%p)->(%p)\n", This, pBool);
441     return E_NOTIMPL;
442 }
443 
444 static HRESULT WINAPI InternetExplorer_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
445 {
446     InternetExplorer *This = impl_from_IWebBrowser2(iface);
447     FIXME("(%p)->(%x)\n", This, Value);
448     return E_NOTIMPL;
449 }
450 
451 static HRESULT WINAPI InternetExplorer_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
452 {
453     InternetExplorer *This = impl_from_IWebBrowser2(iface);
454     FIXME("(%p)->(%p)\n", This, StatusText);
455     return E_NOTIMPL;
456 }
457 
458 static HRESULT WINAPI InternetExplorer_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
459 {
460     InternetExplorer *This = impl_from_IWebBrowser2(iface);
461 
462     TRACE("(%p)->(%s)\n", This, debugstr_w(StatusText));
463 
464     return update_ie_statustext(This, StatusText);
465 }
466 
467 static HRESULT WINAPI InternetExplorer_get_ToolBar(IWebBrowser2 *iface, int *Value)
468 {
469     InternetExplorer *This = impl_from_IWebBrowser2(iface);
470     FIXME("(%p)->(%p)\n", This, Value);
471     return E_NOTIMPL;
472 }
473 
474 static HRESULT WINAPI InternetExplorer_put_ToolBar(IWebBrowser2 *iface, int Value)
475 {
476     InternetExplorer *This = impl_from_IWebBrowser2(iface);
477     FIXME("(%p)->(%d)\n", This, Value);
478     return E_NOTIMPL;
479 }
480 
481 static HRESULT WINAPI InternetExplorer_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
482 {
483     InternetExplorer *This = impl_from_IWebBrowser2(iface);
484     FIXME("(%p)->(%p)\n", This, Value);
485     return E_NOTIMPL;
486 }
487 
488 static HRESULT WINAPI InternetExplorer_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
489 {
490     InternetExplorer *This = impl_from_IWebBrowser2(iface);
491     HMENU menu = NULL;
492 
493     TRACE("(%p)->(%x)\n", This, Value);
494 
495     if(Value)
496         menu = This->menu;
497 
498     if(!SetMenu(This->frame_hwnd, menu))
499         return HRESULT_FROM_WIN32(GetLastError());
500 
501     return S_OK;
502 }
503 
504 static HRESULT WINAPI InternetExplorer_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
505 {
506     InternetExplorer *This = impl_from_IWebBrowser2(iface);
507     FIXME("(%p)->(%p)\n", This, pbFullScreen);
508     return E_NOTIMPL;
509 }
510 
511 static HRESULT WINAPI InternetExplorer_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
512 {
513     InternetExplorer *This = impl_from_IWebBrowser2(iface);
514     FIXME("(%p)->(%x)\n", This, bFullScreen);
515     return E_NOTIMPL;
516 }
517 
518 static HRESULT WINAPI InternetExplorer_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
519         VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
520 {
521     InternetExplorer *This = impl_from_IWebBrowser2(iface);
522 
523     TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
524         debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
525 
526     if(!URL)
527         return S_OK;
528 
529     if(V_VT(URL) != VT_BSTR) {
530         FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
531         return E_INVALIDARG;
532     }
533 
534     return navigate_url(&This->doc_host, V_BSTR(URL), Flags, TargetFrameName, PostData, Headers);
535 }
536 
537 static HRESULT WINAPI InternetExplorer_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
538 {
539     InternetExplorer *This = impl_from_IWebBrowser2(iface);
540     FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
541     return E_NOTIMPL;
542 }
543 
544 static HRESULT WINAPI InternetExplorer_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
545         OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
546 {
547     InternetExplorer *This = impl_from_IWebBrowser2(iface);
548     FIXME("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
549     return E_NOTIMPL;
550 }
551 
552 static HRESULT WINAPI InternetExplorer_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
553         VARIANT *pvarShow, VARIANT *pvarSize)
554 {
555     InternetExplorer *This = impl_from_IWebBrowser2(iface);
556     FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
557         debugstr_variant(pvarSize));
558     return E_NOTIMPL;
559 }
560 
561 static HRESULT WINAPI InternetExplorer_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
562 {
563     InternetExplorer *This = impl_from_IWebBrowser2(iface);
564     FIXME("(%p)->(%p)\n", This, lpReadyState);
565     return E_NOTIMPL;
566 }
567 
568 static HRESULT WINAPI InternetExplorer_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
569 {
570     InternetExplorer *This = impl_from_IWebBrowser2(iface);
571     FIXME("(%p)->(%p)\n", This, pbOffline);
572     return E_NOTIMPL;
573 }
574 
575 static HRESULT WINAPI InternetExplorer_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
576 {
577     InternetExplorer *This = impl_from_IWebBrowser2(iface);
578     FIXME("(%p)->(%x)\n", This, bOffline);
579     return E_NOTIMPL;
580 }
581 
582 static HRESULT WINAPI InternetExplorer_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
583 {
584     InternetExplorer *This = impl_from_IWebBrowser2(iface);
585     FIXME("(%p)->(%p)\n", This, pbSilent);
586     return E_NOTIMPL;
587 }
588 
589 static HRESULT WINAPI InternetExplorer_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
590 {
591     InternetExplorer *This = impl_from_IWebBrowser2(iface);
592     FIXME("(%p)->(%x)\n", This, bSilent);
593     return E_NOTIMPL;
594 }
595 
596 static HRESULT WINAPI InternetExplorer_get_RegisterAsBrowser(IWebBrowser2 *iface,
597         VARIANT_BOOL *pbRegister)
598 {
599     InternetExplorer *This = impl_from_IWebBrowser2(iface);
600     FIXME("(%p)->(%p)\n", This, pbRegister);
601     return E_NOTIMPL;
602 }
603 
604 static HRESULT WINAPI InternetExplorer_put_RegisterAsBrowser(IWebBrowser2 *iface,
605         VARIANT_BOOL bRegister)
606 {
607     InternetExplorer *This = impl_from_IWebBrowser2(iface);
608     FIXME("(%p)->(%x)\n", This, bRegister);
609     return E_NOTIMPL;
610 }
611 
612 static HRESULT WINAPI InternetExplorer_get_RegisterAsDropTarget(IWebBrowser2 *iface,
613         VARIANT_BOOL *pbRegister)
614 {
615     InternetExplorer *This = impl_from_IWebBrowser2(iface);
616     FIXME("(%p)->(%p)\n", This, pbRegister);
617     return E_NOTIMPL;
618 }
619 
620 static HRESULT WINAPI InternetExplorer_put_RegisterAsDropTarget(IWebBrowser2 *iface,
621         VARIANT_BOOL bRegister)
622 {
623     InternetExplorer *This = impl_from_IWebBrowser2(iface);
624     FIXME("(%p)->(%x)\n", This, bRegister);
625     return E_NOTIMPL;
626 }
627 
628 static HRESULT WINAPI InternetExplorer_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
629 {
630     InternetExplorer *This = impl_from_IWebBrowser2(iface);
631     FIXME("(%p)->(%p)\n", This, pbRegister);
632     return E_NOTIMPL;
633 }
634 
635 static HRESULT WINAPI InternetExplorer_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
636 {
637     InternetExplorer *This = impl_from_IWebBrowser2(iface);
638     FIXME("(%p)->(%x)\n", This, bRegister);
639     return E_NOTIMPL;
640 }
641 
642 static HRESULT WINAPI InternetExplorer_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
643 {
644     InternetExplorer *This = impl_from_IWebBrowser2(iface);
645     FIXME("(%p)->(%p)\n", This, Value);
646     return E_NOTIMPL;
647 }
648 
649 static HRESULT WINAPI InternetExplorer_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
650 {
651     InternetExplorer *This = impl_from_IWebBrowser2(iface);
652     FIXME("(%p)->(%x)\n", This, Value);
653     return E_NOTIMPL;
654 }
655 
656 static HRESULT WINAPI InternetExplorer_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
657 {
658     InternetExplorer *This = impl_from_IWebBrowser2(iface);
659     FIXME("(%p)->(%p)\n", This, Value);
660     return E_NOTIMPL;
661 }
662 
663 static HRESULT WINAPI InternetExplorer_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
664 {
665     InternetExplorer *This = impl_from_IWebBrowser2(iface);
666     FIXME("(%p)->(%x)\n", This, Value);
667     return E_NOTIMPL;
668 }
669 
670 static const IWebBrowser2Vtbl InternetExplorerVtbl =
671 {
672     InternetExplorer_QueryInterface,
673     InternetExplorer_AddRef,
674     InternetExplorer_Release,
675     InternetExplorer_GetTypeInfoCount,
676     InternetExplorer_GetTypeInfo,
677     InternetExplorer_GetIDsOfNames,
678     InternetExplorer_Invoke,
679     InternetExplorer_GoBack,
680     InternetExplorer_GoForward,
681     InternetExplorer_GoHome,
682     InternetExplorer_GoSearch,
683     InternetExplorer_Navigate,
684     InternetExplorer_Refresh,
685     InternetExplorer_Refresh2,
686     InternetExplorer_Stop,
687     InternetExplorer_get_Application,
688     InternetExplorer_get_Parent,
689     InternetExplorer_get_Container,
690     InternetExplorer_get_Document,
691     InternetExplorer_get_TopLevelContainer,
692     InternetExplorer_get_Type,
693     InternetExplorer_get_Left,
694     InternetExplorer_put_Left,
695     InternetExplorer_get_Top,
696     InternetExplorer_put_Top,
697     InternetExplorer_get_Width,
698     InternetExplorer_put_Width,
699     InternetExplorer_get_Height,
700     InternetExplorer_put_Height,
701     InternetExplorer_get_LocationName,
702     InternetExplorer_get_LocationURL,
703     InternetExplorer_get_Busy,
704     InternetExplorer_Quit,
705     InternetExplorer_ClientToWindow,
706     InternetExplorer_PutProperty,
707     InternetExplorer_GetProperty,
708     InternetExplorer_get_Name,
709     InternetExplorer_get_HWND,
710     InternetExplorer_get_FullName,
711     InternetExplorer_get_Path,
712     InternetExplorer_get_Visible,
713     InternetExplorer_put_Visible,
714     InternetExplorer_get_StatusBar,
715     InternetExplorer_put_StatusBar,
716     InternetExplorer_get_StatusText,
717     InternetExplorer_put_StatusText,
718     InternetExplorer_get_ToolBar,
719     InternetExplorer_put_ToolBar,
720     InternetExplorer_get_MenuBar,
721     InternetExplorer_put_MenuBar,
722     InternetExplorer_get_FullScreen,
723     InternetExplorer_put_FullScreen,
724     InternetExplorer_Navigate2,
725     InternetExplorer_QueryStatusWB,
726     InternetExplorer_ExecWB,
727     InternetExplorer_ShowBrowserBar,
728     InternetExplorer_get_ReadyState,
729     InternetExplorer_get_Offline,
730     InternetExplorer_put_Offline,
731     InternetExplorer_get_Silent,
732     InternetExplorer_put_Silent,
733     InternetExplorer_get_RegisterAsBrowser,
734     InternetExplorer_put_RegisterAsBrowser,
735     InternetExplorer_get_RegisterAsDropTarget,
736     InternetExplorer_put_RegisterAsDropTarget,
737     InternetExplorer_get_TheaterMode,
738     InternetExplorer_put_TheaterMode,
739     InternetExplorer_get_AddressBar,
740     InternetExplorer_put_AddressBar,
741     InternetExplorer_get_Resizable,
742     InternetExplorer_put_Resizable
743 };
744 
745 static inline InternetExplorer *impl_from_IExternalConnection(IExternalConnection *iface)
746 {
747     return CONTAINING_RECORD(iface, InternetExplorer, IExternalConnection_iface);
748 }
749 
750 /*
751  * Document may keep references to InternetExplorer object causing circular references.
752  * We keep track of external references and release the document object when all
753  * external references are released. A visible main window is also considered as
754  * an external reference.
755  */
756 DWORD release_extern_ref(InternetExplorer *This, BOOL last_closes)
757 {
758     LONG ref = InterlockedDecrement(&This->extern_ref);
759 
760     TRACE("ref = %d\n", ref);
761 
762     if(ref)
763         return ref;
764 
765     if(!last_closes) {
766         WARN("Last external connection released with FALSE last_closes.\n");
767         return ref;
768     }
769 
770     deactivate_document(&This->doc_host);
771     return ref;
772 }
773 
774 static HRESULT WINAPI ExternalConnection_QueryInterface(IExternalConnection *iface, REFIID riid, void **ppv)
775 {
776     InternetExplorer *This = impl_from_IExternalConnection(iface);
777     return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
778 }
779 
780 static ULONG WINAPI ExternalConnection_AddRef(IExternalConnection *iface)
781 {
782     InternetExplorer *This = impl_from_IExternalConnection(iface);
783     return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
784 }
785 
786 static ULONG WINAPI ExternalConnection_Release(IExternalConnection *iface)
787 {
788     InternetExplorer *This = impl_from_IExternalConnection(iface);
789     return IWebBrowser2_Release(&This->IWebBrowser2_iface);
790 }
791 
792 static DWORD WINAPI ExternalConnection_AddConnection(IExternalConnection *iface, DWORD extconn, DWORD reserved)
793 {
794     InternetExplorer *This = impl_from_IExternalConnection(iface);
795 
796     TRACE("(%p)->(%x %x)\n", This, extconn, reserved);
797 
798     if(extconn != EXTCONN_STRONG)
799         return 0;
800 
801     return InterlockedIncrement(&This->extern_ref);
802 }
803 
804 static DWORD WINAPI ExternalConnection_ReleaseConnection(IExternalConnection *iface, DWORD extconn,
805         DWORD reserved, BOOL fLastReleaseCloses)
806 {
807     InternetExplorer *This = impl_from_IExternalConnection(iface);
808 
809     TRACE("(%p)->(%x %x %x)\n", This, extconn, reserved, fLastReleaseCloses);
810 
811     if(extconn != EXTCONN_STRONG)
812         return 0;
813 
814     return release_extern_ref(This, fLastReleaseCloses);
815 }
816 
817 static const IExternalConnectionVtbl ExternalConnectionVtbl = {
818     ExternalConnection_QueryInterface,
819     ExternalConnection_AddRef,
820     ExternalConnection_Release,
821     ExternalConnection_AddConnection,
822     ExternalConnection_ReleaseConnection
823 };
824 
825 static inline InternetExplorer *impl_from_IServiceProvider(IServiceProvider *iface)
826 {
827     return CONTAINING_RECORD(iface, InternetExplorer, IServiceProvider_iface);
828 }
829 
830 static HRESULT WINAPI IEServiceProvider_QueryInterface(IServiceProvider *iface,
831             REFIID riid, LPVOID *ppv)
832 {
833     InternetExplorer *This = impl_from_IServiceProvider(iface);
834     return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
835 }
836 
837 static ULONG WINAPI IEServiceProvider_AddRef(IServiceProvider *iface)
838 {
839     InternetExplorer *This = impl_from_IServiceProvider(iface);
840     return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
841 }
842 
843 static ULONG WINAPI IEServiceProvider_Release(IServiceProvider *iface)
844 {
845     InternetExplorer *This = impl_from_IServiceProvider(iface);
846     return IWebBrowser2_Release(&This->IWebBrowser2_iface);
847 }
848 
849 static HRESULT WINAPI IEServiceProvider_QueryService(IServiceProvider *iface,
850         REFGUID guidService, REFIID riid, void **ppv)
851 {
852     InternetExplorer *This = impl_from_IServiceProvider(iface);
853 
854     if(IsEqualGUID(&SID_SHTMLWindow, riid)) {
855         TRACE("(%p)->(SID_SHTMLWindow)\n", This);
856         return IHTMLWindow2_QueryInterface(&This->doc_host.html_window.IHTMLWindow2_iface, riid, ppv);
857     }
858 
859     FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
860     *ppv = NULL;
861     return E_NOINTERFACE;
862 }
863 
864 static const IServiceProviderVtbl ServiceProviderVtbl =
865 {
866     IEServiceProvider_QueryInterface,
867     IEServiceProvider_AddRef,
868     IEServiceProvider_Release,
869     IEServiceProvider_QueryService
870 };
871 
872 void InternetExplorer_WebBrowser_Init(InternetExplorer *This)
873 {
874     This->IWebBrowser2_iface.lpVtbl = &InternetExplorerVtbl;
875     This->IExternalConnection_iface.lpVtbl = &ExternalConnectionVtbl;
876     This->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
877 }
878