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