1 /*
2 * Implementation of IWebBrowser interface for WebBrowser control
3 *
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
5 * Copyright 2005 Jacek Caban
6 *
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.
11 *
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.
16 *
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
20 */
21
22 #include "ieframe.h"
23
24 #include "exdispid.h"
25 #include "mshtml.h"
26
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(ieframe);
30
impl_from_IWebBrowser2(IWebBrowser2 * iface)31 static inline WebBrowser *impl_from_IWebBrowser2(IWebBrowser2 *iface)
32 {
33 return CONTAINING_RECORD(iface, WebBrowser, IWebBrowser2_iface);
34 }
35
WebBrowser_QueryInterface(IWebBrowser2 * iface,REFIID riid,LPVOID * ppv)36 static HRESULT WINAPI WebBrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, LPVOID *ppv)
37 {
38 WebBrowser *This = impl_from_IWebBrowser2(iface);
39
40 if (ppv == NULL)
41 return E_POINTER;
42 *ppv = NULL;
43
44 if(IsEqualGUID(&IID_IUnknown, riid)) {
45 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
46 *ppv = &This->IWebBrowser2_iface;
47 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
48 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
49 *ppv = &This->IWebBrowser2_iface;
50 }else if(IsEqualGUID(&IID_IWebBrowser, riid)) {
51 TRACE("(%p)->(IID_IWebBrowser %p)\n", This, ppv);
52 *ppv = &This->IWebBrowser2_iface;
53 }else if(IsEqualGUID(&IID_IWebBrowserApp, riid)) {
54 TRACE("(%p)->(IID_IWebBrowserApp %p)\n", This, ppv);
55 *ppv = &This->IWebBrowser2_iface;
56 }else if(IsEqualGUID(&IID_IWebBrowser2, riid)) {
57 TRACE("(%p)->(IID_IWebBrowser2 %p)\n", This, ppv);
58 *ppv = &This->IWebBrowser2_iface;
59 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
60 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
61 *ppv = &This->IOleObject_iface;
62 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
63 TRACE("(%p)->(IID_IOleWindow %p)\n", This, ppv);
64 *ppv = &This->IOleInPlaceObject_iface;
65 }else if(IsEqualGUID (&IID_IOleInPlaceObject, riid)) {
66 TRACE("(%p)->(IID_IOleInPlaceObject %p)\n", This, ppv);
67 *ppv = &This->IOleInPlaceObject_iface;
68 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
69 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
70 *ppv = &This->IOleControl_iface;
71 }else if(IsEqualGUID(&IID_IPersist, riid)) {
72 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
73 *ppv = &This->IPersistStorage_iface;
74 }else if(IsEqualGUID(&IID_IPersistStorage, riid)) {
75 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
76 *ppv = &This->IPersistStorage_iface;
77 }else if(IsEqualGUID(&IID_IPersistMemory, riid)) {
78 TRACE("(%p)->(IID_IPersistStorage %p)\n", This, ppv);
79 *ppv = &This->IPersistMemory_iface;
80 }else if(IsEqualGUID (&IID_IPersistStreamInit, riid)) {
81 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
82 *ppv = &This->IPersistStreamInit_iface;
83 }else if(IsEqualGUID(&IID_IProvideClassInfo, riid)) {
84 TRACE("(%p)->(IID_IProvideClassInfo %p)\n", This, ppv);
85 *ppv = &This->IProvideClassInfo2_iface;
86 }else if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
87 TRACE("(%p)->(IID_IProvideClassInfo2 %p)\n", This, ppv);
88 *ppv = &This->IProvideClassInfo2_iface;
89 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
90 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
91 *ppv = &This->doc_host.cps.IConnectionPointContainer_iface;
92 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
93 TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
94 *ppv = &This->IViewObject2_iface;
95 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
96 TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
97 *ppv = &This->IViewObject2_iface;
98 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
99 TRACE("(%p)->(IID_IOleInPlaceActiveObject %p)\n", This, ppv);
100 *ppv = &This->IOleInPlaceActiveObject_iface;
101 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
102 TRACE("(%p)->(IID_IOleCommandTarget %p)\n", This, ppv);
103 *ppv = &This->IOleCommandTarget_iface;
104 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
105 *ppv = &This->IServiceProvider_iface;
106 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
107 }else if(IsEqualGUID(&IID_IDataObject, riid)) {
108 *ppv = &This->IDataObject_iface;
109 TRACE("(%p)->(IID_IDataObject %p)\n", This, ppv);
110 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
111 TRACE("(%p)->(IID_IQuickActivate %p) returning NULL\n", This, ppv);
112 return E_NOINTERFACE;
113 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
114 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppv);
115 return E_NOINTERFACE;
116 }else if(IsEqualGUID(&IID_IPerPropertyBrowsing, riid)) {
117 TRACE("(%p)->(IID_IPerPropertyBrowsing %p) returning NULL\n", This, ppv);
118 return E_NOINTERFACE;
119 }else if(IsEqualGUID(&IID_IOleCache, riid)) {
120 TRACE("(%p)->(IID_IOleCache %p) returning NULL\n", This, ppv);
121 return E_NOINTERFACE;
122 }else if(IsEqualGUID(&IID_IOleInPlaceSite, riid)) {
123 TRACE("(%p)->(IID_IOleInPlaceSite %p) returning NULL\n", This, ppv);
124 return E_NOINTERFACE;
125 }else if(IsEqualGUID(&IID_IObjectWithSite, riid)) {
126 TRACE("(%p)->(IID_IObjectWithSite %p) returning NULL\n", This, ppv);
127 return E_NOINTERFACE;
128 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
129 TRACE("(%p)->(IID_IViewObjectEx %p) returning NULL\n", This, ppv);
130 return E_NOINTERFACE;
131 }else if(IsEqualGUID(&IID_IOleLink, riid)) {
132 TRACE("(%p)->(IID_IOleLink %p) returning NULL\n", This, ppv);
133 return E_NOINTERFACE;
134 }else if(IsEqualGUID(&IID_IMarshal, riid)) {
135 TRACE("(%p)->(IID_IMarshal %p) returning NULL\n", This, ppv);
136 return E_NOINTERFACE;
137 }else if(IsEqualGUID(&IID_IStdMarshalInfo, riid)) {
138 /* This is implemented since IE10 */
139 WARN("(%p)->(IID_IStdMarshalInfo %p) returning NULL\n", This, ppv);
140 return E_NOINTERFACE;
141 }else if(HlinkFrame_QI(&This->hlink_frame, riid, ppv)) {
142 return S_OK;
143 }
144
145 if(*ppv) {
146 IUnknown_AddRef((IUnknown*)*ppv);
147 return S_OK;
148 }
149
150 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
151 return E_NOINTERFACE;
152 }
153
WebBrowser_AddRef(IWebBrowser2 * iface)154 static ULONG WINAPI WebBrowser_AddRef(IWebBrowser2 *iface)
155 {
156 WebBrowser *This = impl_from_IWebBrowser2(iface);
157 LONG ref = InterlockedIncrement(&This->ref);
158 TRACE("(%p) ref=%d\n", This, ref);
159 return ref;
160 }
161
WebBrowser_Release(IWebBrowser2 * iface)162 static ULONG WINAPI WebBrowser_Release(IWebBrowser2 *iface)
163 {
164 WebBrowser *This = impl_from_IWebBrowser2(iface);
165 LONG ref = InterlockedDecrement(&This->ref);
166
167 TRACE("(%p) ref=%d\n", This, ref);
168
169 if(!ref) {
170 if(This->sink)
171 IAdviseSink_Release(This->sink);
172
173 if(This->doc_host.document)
174 IUnknown_Release(This->doc_host.document);
175
176 DocHost_Release(&This->doc_host);
177
178 WebBrowser_OleObject_Destroy(This);
179
180 heap_free(This);
181 unlock_module();
182 }
183
184 return ref;
185 }
186
187 /* IDispatch methods */
WebBrowser_GetTypeInfoCount(IWebBrowser2 * iface,UINT * pctinfo)188 static HRESULT WINAPI WebBrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
189 {
190 WebBrowser *This = impl_from_IWebBrowser2(iface);
191
192 TRACE("(%p)->(%p)\n", This, pctinfo);
193
194 *pctinfo = 1;
195 return S_OK;
196 }
197
WebBrowser_GetTypeInfo(IWebBrowser2 * iface,UINT iTInfo,LCID lcid,LPTYPEINFO * ppTInfo)198 static HRESULT WINAPI WebBrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
199 LPTYPEINFO *ppTInfo)
200 {
201 WebBrowser *This = impl_from_IWebBrowser2(iface);
202 ITypeInfo *typeinfo;
203 HRESULT hres;
204
205 TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
206
207 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
208 if(FAILED(hres))
209 return hres;
210
211 ITypeInfo_AddRef(typeinfo);
212 *ppTInfo = typeinfo;
213 return S_OK;
214 }
215
WebBrowser_GetIDsOfNames(IWebBrowser2 * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)216 static HRESULT WINAPI WebBrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
217 LPOLESTR *rgszNames, UINT cNames,
218 LCID lcid, DISPID *rgDispId)
219 {
220 WebBrowser *This = impl_from_IWebBrowser2(iface);
221 ITypeInfo *typeinfo;
222 HRESULT hres;
223
224 TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
225 lcid, rgDispId);
226
227 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
228 if(FAILED(hres))
229 return hres;
230
231 return ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
232 }
233
WebBrowser_Invoke(IWebBrowser2 * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExepInfo,UINT * puArgErr)234 static HRESULT WINAPI WebBrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
235 REFIID riid, LCID lcid, WORD wFlags,
236 DISPPARAMS *pDispParams, VARIANT *pVarResult,
237 EXCEPINFO *pExepInfo, UINT *puArgErr)
238 {
239 WebBrowser *This = impl_from_IWebBrowser2(iface);
240 ITypeInfo *typeinfo;
241 HRESULT hres;
242
243 TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
244 lcid, wFlags, pDispParams, pVarResult, pExepInfo, puArgErr);
245
246 hres = get_typeinfo(IWebBrowser2_tid, &typeinfo);
247 if(FAILED(hres))
248 return hres;
249
250 return ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags, pDispParams,
251 pVarResult, pExepInfo, puArgErr);
252 }
253
254 /* IWebBrowser methods */
WebBrowser_GoBack(IWebBrowser2 * iface)255 static HRESULT WINAPI WebBrowser_GoBack(IWebBrowser2 *iface)
256 {
257 WebBrowser *This = impl_from_IWebBrowser2(iface);
258 TRACE("(%p)\n", This);
259 return go_back(&This->doc_host);
260 }
261
WebBrowser_GoForward(IWebBrowser2 * iface)262 static HRESULT WINAPI WebBrowser_GoForward(IWebBrowser2 *iface)
263 {
264 WebBrowser *This = impl_from_IWebBrowser2(iface);
265 TRACE("(%p)\n", This);
266 return go_forward(&This->doc_host);
267 }
268
WebBrowser_GoHome(IWebBrowser2 * iface)269 static HRESULT WINAPI WebBrowser_GoHome(IWebBrowser2 *iface)
270 {
271 WebBrowser *This = impl_from_IWebBrowser2(iface);
272 TRACE("(%p)\n", This);
273 return go_home(&This->doc_host);
274 }
275
WebBrowser_GoSearch(IWebBrowser2 * iface)276 static HRESULT WINAPI WebBrowser_GoSearch(IWebBrowser2 *iface)
277 {
278 WebBrowser *This = impl_from_IWebBrowser2(iface);
279 FIXME("(%p)\n", This);
280 return E_NOTIMPL;
281 }
282
WebBrowser_Navigate(IWebBrowser2 * iface,BSTR szUrl,VARIANT * Flags,VARIANT * TargetFrameName,VARIANT * PostData,VARIANT * Headers)283 static HRESULT WINAPI WebBrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
284 VARIANT *Flags, VARIANT *TargetFrameName,
285 VARIANT *PostData, VARIANT *Headers)
286 {
287 WebBrowser *This = impl_from_IWebBrowser2(iface);
288
289 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
290 debugstr_variant(TargetFrameName), debugstr_variant(PostData),
291 debugstr_variant(Headers));
292
293 return navigate_url(&This->doc_host, szUrl, Flags, TargetFrameName, PostData, Headers);
294 }
295
WebBrowser_Refresh(IWebBrowser2 * iface)296 static HRESULT WINAPI WebBrowser_Refresh(IWebBrowser2 *iface)
297 {
298 WebBrowser *This = impl_from_IWebBrowser2(iface);
299
300 TRACE("(%p)\n", This);
301
302 return refresh_document(&This->doc_host, NULL);
303 }
304
WebBrowser_Refresh2(IWebBrowser2 * iface,VARIANT * Level)305 static HRESULT WINAPI WebBrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
306 {
307 WebBrowser *This = impl_from_IWebBrowser2(iface);
308
309 TRACE("(%p)->(%s)\n", This, debugstr_variant(Level));
310
311 return refresh_document(&This->doc_host, Level);
312 }
313
WebBrowser_Stop(IWebBrowser2 * iface)314 static HRESULT WINAPI WebBrowser_Stop(IWebBrowser2 *iface)
315 {
316 WebBrowser *This = impl_from_IWebBrowser2(iface);
317 FIXME("(%p)\n", This);
318 return S_OK;
319 }
320
WebBrowser_get_Application(IWebBrowser2 * iface,IDispatch ** ppDisp)321 static HRESULT WINAPI WebBrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
322 {
323 WebBrowser *This = impl_from_IWebBrowser2(iface);
324
325 TRACE("(%p)->(%p)\n", This, ppDisp);
326
327 if(!ppDisp)
328 return E_POINTER;
329
330 *ppDisp = (IDispatch*)&This->IWebBrowser2_iface;
331 IDispatch_AddRef(*ppDisp);
332 return S_OK;
333 }
334
WebBrowser_get_Parent(IWebBrowser2 * iface,IDispatch ** ppDisp)335 static HRESULT WINAPI WebBrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
336 {
337 WebBrowser *This = impl_from_IWebBrowser2(iface);
338 FIXME("(%p)->(%p)\n", This, ppDisp);
339 return E_NOTIMPL;
340 }
341
WebBrowser_get_Container(IWebBrowser2 * iface,IDispatch ** ppDisp)342 static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
343 {
344 WebBrowser *This = impl_from_IWebBrowser2(iface);
345 FIXME("(%p)->(%p)\n", This, ppDisp);
346 return E_NOTIMPL;
347 }
348
WebBrowser_get_Document(IWebBrowser2 * iface,IDispatch ** ppDisp)349 static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
350 {
351 WebBrowser *This = impl_from_IWebBrowser2(iface);
352 IDispatch *disp = NULL;
353
354 TRACE("(%p)->(%p)\n", This, ppDisp);
355
356 if(This->doc_host.document) {
357 HRESULT hres;
358
359 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
360 if(SUCCEEDED(hres)) {
361 IDispatch *html_doc;
362
363 /* Some broken apps cast returned IDispatch to IHTMLDocument2
364 * without QueryInterface call */
365 hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
366 if(SUCCEEDED(hres)) {
367 IDispatch_Release(disp);
368 disp = html_doc;
369 }
370 }
371 }
372
373 *ppDisp = disp;
374 return S_OK;
375 }
376
WebBrowser_get_TopLevelContainer(IWebBrowser2 * iface,VARIANT_BOOL * pBool)377 static HRESULT WINAPI WebBrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
378 {
379 WebBrowser *This = impl_from_IWebBrowser2(iface);
380 FIXME("(%p)->(%p)\n", This, pBool);
381 return E_NOTIMPL;
382 }
383
WebBrowser_get_Type(IWebBrowser2 * iface,BSTR * Type)384 static HRESULT WINAPI WebBrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
385 {
386 WebBrowser *This = impl_from_IWebBrowser2(iface);
387 FIXME("(%p)->(%p)\n", This, Type);
388 return E_NOTIMPL;
389 }
390
WebBrowser_get_Left(IWebBrowser2 * iface,LONG * pl)391 static HRESULT WINAPI WebBrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
392 {
393 WebBrowser *This = impl_from_IWebBrowser2(iface);
394
395 TRACE("(%p)->(%p)\n", This, pl);
396
397 *pl = This->pos_rect.left;
398 return S_OK;
399 }
400
WebBrowser_put_Left(IWebBrowser2 * iface,LONG Left)401 static HRESULT WINAPI WebBrowser_put_Left(IWebBrowser2 *iface, LONG Left)
402 {
403 WebBrowser *This = impl_from_IWebBrowser2(iface);
404 RECT rect;
405
406 TRACE("(%p)->(%d)\n", This, Left);
407
408 if(!This->inplace)
409 return E_UNEXPECTED;
410
411 rect = This->pos_rect;
412 rect.left = Left;
413
414 /* We don't really change the window position here.
415 * We just notify the embedder that he should do so. */
416 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
417 }
418
WebBrowser_get_Top(IWebBrowser2 * iface,LONG * pl)419 static HRESULT WINAPI WebBrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
420 {
421 WebBrowser *This = impl_from_IWebBrowser2(iface);
422
423 TRACE("(%p)->(%p)\n", This, pl);
424
425 *pl = This->pos_rect.top;
426 return S_OK;
427 }
428
WebBrowser_put_Top(IWebBrowser2 * iface,LONG Top)429 static HRESULT WINAPI WebBrowser_put_Top(IWebBrowser2 *iface, LONG Top)
430 {
431 WebBrowser *This = impl_from_IWebBrowser2(iface);
432 RECT rect;
433
434 TRACE("(%p)->(%d)\n", This, Top);
435
436 if(!This->inplace)
437 return E_UNEXPECTED;
438
439 rect = This->pos_rect;
440 rect.top = Top;
441
442 /* We don't really change the window position here.
443 * We just notify the embedder that he should do so. */
444 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
445 }
446
WebBrowser_get_Width(IWebBrowser2 * iface,LONG * pl)447 static HRESULT WINAPI WebBrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
448 {
449 WebBrowser *This = impl_from_IWebBrowser2(iface);
450
451 TRACE("(%p)->(%p)\n", This, pl);
452
453 *pl = This->pos_rect.right - This->pos_rect.left;
454 return S_OK;
455 }
456
WebBrowser_put_Width(IWebBrowser2 * iface,LONG Width)457 static HRESULT WINAPI WebBrowser_put_Width(IWebBrowser2 *iface, LONG Width)
458 {
459 WebBrowser *This = impl_from_IWebBrowser2(iface);
460 RECT rect;
461
462 TRACE("(%p)->(%d)\n", This, Width);
463
464 if(!This->inplace)
465 return E_UNEXPECTED;
466
467 rect = This->pos_rect;
468 rect.right = rect.left+Width;
469
470 /* We don't really change the window size here.
471 * We just notify the embedder that he should do so. */
472 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
473 }
474
WebBrowser_get_Height(IWebBrowser2 * iface,LONG * pl)475 static HRESULT WINAPI WebBrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
476 {
477 WebBrowser *This = impl_from_IWebBrowser2(iface);
478
479 TRACE("(%p)->(%p)\n", This, pl);
480
481 *pl = This->pos_rect.bottom - This->pos_rect.top;
482 return S_OK;
483 }
484
WebBrowser_put_Height(IWebBrowser2 * iface,LONG Height)485 static HRESULT WINAPI WebBrowser_put_Height(IWebBrowser2 *iface, LONG Height)
486 {
487 WebBrowser *This = impl_from_IWebBrowser2(iface);
488 RECT rect;
489
490 TRACE("(%p)->(%d)\n", This, Height);
491
492 if(!This->inplace)
493 return E_UNEXPECTED;
494
495 rect = This->pos_rect;
496 rect.bottom = rect.top+Height;
497
498 /* We don't really change the window size here.
499 * We just notify the embedder that he should do so. */
500 return IOleInPlaceSiteEx_OnPosRectChange(This->inplace, &rect);
501 }
502
WebBrowser_get_LocationName(IWebBrowser2 * iface,BSTR * LocationName)503 static HRESULT WINAPI WebBrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
504 {
505 WebBrowser *This = impl_from_IWebBrowser2(iface);
506 FIXME("(%p)->(%p)\n", This, LocationName);
507 return E_NOTIMPL;
508 }
509
WebBrowser_get_LocationURL(IWebBrowser2 * iface,BSTR * LocationURL)510 static HRESULT WINAPI WebBrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
511 {
512 WebBrowser *This = impl_from_IWebBrowser2(iface);
513
514 TRACE("(%p)->(%p)\n", This, LocationURL);
515
516 return get_location_url(&This->doc_host, LocationURL);
517 }
518
WebBrowser_get_Busy(IWebBrowser2 * iface,VARIANT_BOOL * pBool)519 static HRESULT WINAPI WebBrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
520 {
521 WebBrowser *This = impl_from_IWebBrowser2(iface);
522
523 TRACE("(%p)->(%p)\n", This, pBool);
524
525 *pBool = This->doc_host.busy;
526 return S_OK;
527 }
528
WebBrowser_Quit(IWebBrowser2 * iface)529 static HRESULT WINAPI WebBrowser_Quit(IWebBrowser2 *iface)
530 {
531 WebBrowser *This = impl_from_IWebBrowser2(iface);
532
533 TRACE("(%p)\n", This);
534
535 /* It's a InternetExplorer specific method, we have nothing to do here. */
536 return E_FAIL;
537 }
538
WebBrowser_ClientToWindow(IWebBrowser2 * iface,int * pcx,int * pcy)539 static HRESULT WINAPI WebBrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
540 {
541 WebBrowser *This = impl_from_IWebBrowser2(iface);
542 FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
543 return E_NOTIMPL;
544 }
545
WebBrowser_PutProperty(IWebBrowser2 * iface,BSTR szProperty,VARIANT vtValue)546 static HRESULT WINAPI WebBrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
547 {
548 WebBrowser *This = impl_from_IWebBrowser2(iface);
549 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
550 return E_NOTIMPL;
551 }
552
WebBrowser_GetProperty(IWebBrowser2 * iface,BSTR szProperty,VARIANT * pvtValue)553 static HRESULT WINAPI WebBrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
554 {
555 WebBrowser *This = impl_from_IWebBrowser2(iface);
556 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
557 return E_NOTIMPL;
558 }
559
WebBrowser_get_Name(IWebBrowser2 * iface,BSTR * Name)560 static HRESULT WINAPI WebBrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
561 {
562 static const WCHAR sName[] = {'M','i','c','r','o','s','o','f','t',' ','W','e','b',
563 ' ','B','r','o','w','s','e','r',' ','C','o','n','t','r','o','l',0};
564 WebBrowser *This = impl_from_IWebBrowser2(iface);
565
566 TRACE("(%p)->(%p)\n", This, Name);
567
568 *Name = SysAllocString(sName);
569
570 return S_OK;
571 }
572
WebBrowser_get_HWND(IWebBrowser2 * iface,SHANDLE_PTR * pHWND)573 static HRESULT WINAPI WebBrowser_get_HWND(IWebBrowser2 *iface, SHANDLE_PTR *pHWND)
574 {
575 WebBrowser *This = impl_from_IWebBrowser2(iface);
576
577 TRACE("(%p)->(%p)\n", This, pHWND);
578
579 /* WebBrowser control never has a frame window (in opposition to InternetExplorer) */
580 *pHWND = 0;
581 return E_FAIL;
582 }
583
WebBrowser_get_FullName(IWebBrowser2 * iface,BSTR * FullName)584 static HRESULT WINAPI WebBrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
585 {
586 WebBrowser *This = impl_from_IWebBrowser2(iface);
587 FIXME("(%p)->(%p)\n", This, FullName);
588 return E_NOTIMPL;
589 }
590
WebBrowser_get_Path(IWebBrowser2 * iface,BSTR * Path)591 static HRESULT WINAPI WebBrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
592 {
593 WebBrowser *This = impl_from_IWebBrowser2(iface);
594 FIXME("(%p)->(%p)\n", This, Path);
595 return E_NOTIMPL;
596 }
597
WebBrowser_get_Visible(IWebBrowser2 * iface,VARIANT_BOOL * pBool)598 static HRESULT WINAPI WebBrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
599 {
600 WebBrowser *This = impl_from_IWebBrowser2(iface);
601
602 TRACE("(%p)->(%p)\n", This, pBool);
603
604 *pBool = This->visible;
605 return S_OK;
606 }
607
WebBrowser_put_Visible(IWebBrowser2 * iface,VARIANT_BOOL Value)608 static HRESULT WINAPI WebBrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
609 {
610 WebBrowser *This = impl_from_IWebBrowser2(iface);
611 VARIANTARG arg;
612 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
613
614 TRACE("(%p)->(%x)\n", This, Value);
615
616 This->visible = Value;
617
618 V_VT(&arg) = VT_BOOL;
619 V_BOOL(&arg) = Value;
620 call_sink(This->doc_host.cps.wbe2, DISPID_ONVISIBLE, &dispparams);
621
622 return S_OK;
623 }
624
WebBrowser_get_StatusBar(IWebBrowser2 * iface,VARIANT_BOOL * pBool)625 static HRESULT WINAPI WebBrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
626 {
627 WebBrowser *This = impl_from_IWebBrowser2(iface);
628
629 TRACE("(%p)->(%p)\n", This, pBool);
630
631 *pBool = This->status_bar;
632 return S_OK;
633 }
634
WebBrowser_put_StatusBar(IWebBrowser2 * iface,VARIANT_BOOL Value)635 static HRESULT WINAPI WebBrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
636 {
637 WebBrowser *This = impl_from_IWebBrowser2(iface);
638 VARIANTARG arg;
639 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
640
641 TRACE("(%p)->(%x)\n", This, Value);
642
643 This->status_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
644
645 /* In opposition to InternetExplorer, all we should do here is
646 * inform the embedder about the status bar change. */
647
648 V_VT(&arg) = VT_BOOL;
649 V_BOOL(&arg) = Value;
650 call_sink(This->doc_host.cps.wbe2, DISPID_ONSTATUSBAR, &dispparams);
651
652 return S_OK;
653 }
654
WebBrowser_get_StatusText(IWebBrowser2 * iface,BSTR * StatusText)655 static HRESULT WINAPI WebBrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
656 {
657 WebBrowser *This = impl_from_IWebBrowser2(iface);
658 FIXME("(%p)->(%p)\n", This, StatusText);
659 return E_NOTIMPL;
660 }
661
WebBrowser_put_StatusText(IWebBrowser2 * iface,BSTR StatusText)662 static HRESULT WINAPI WebBrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
663 {
664 WebBrowser *This = impl_from_IWebBrowser2(iface);
665 FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
666 return E_NOTIMPL;
667 }
668
WebBrowser_get_ToolBar(IWebBrowser2 * iface,int * Value)669 static HRESULT WINAPI WebBrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
670 {
671 WebBrowser *This = impl_from_IWebBrowser2(iface);
672
673 TRACE("(%p)->(%p)\n", This, Value);
674
675 *Value = This->tool_bar;
676 return S_OK;
677 }
678
WebBrowser_put_ToolBar(IWebBrowser2 * iface,int Value)679 static HRESULT WINAPI WebBrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
680 {
681 WebBrowser *This = impl_from_IWebBrowser2(iface);
682 VARIANTARG arg;
683 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
684
685 TRACE("(%p)->(%x)\n", This, Value);
686
687 This->tool_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
688
689 /* In opposition to InternetExplorer, all we should do here is
690 * inform the embedder about the tool bar change. */
691
692 V_VT(&arg) = VT_BOOL;
693 V_BOOL(&arg) = This->tool_bar;
694 call_sink(This->doc_host.cps.wbe2, DISPID_ONTOOLBAR, &dispparams);
695
696 return S_OK;
697 }
698
WebBrowser_get_MenuBar(IWebBrowser2 * iface,VARIANT_BOOL * Value)699 static HRESULT WINAPI WebBrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
700 {
701 WebBrowser *This = impl_from_IWebBrowser2(iface);
702
703 TRACE("(%p)->(%p)\n", This, Value);
704
705 *Value = This->menu_bar;
706 return S_OK;
707 }
708
WebBrowser_put_MenuBar(IWebBrowser2 * iface,VARIANT_BOOL Value)709 static HRESULT WINAPI WebBrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
710 {
711 WebBrowser *This = impl_from_IWebBrowser2(iface);
712 VARIANTARG arg;
713 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
714
715 TRACE("(%p)->(%x)\n", This, Value);
716
717 This->menu_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
718
719 /* In opposition to InternetExplorer, all we should do here is
720 * inform the embedder about the menu bar change. */
721
722 V_VT(&arg) = VT_BOOL;
723 V_BOOL(&arg) = Value;
724 call_sink(This->doc_host.cps.wbe2, DISPID_ONMENUBAR, &dispparams);
725
726 return S_OK;
727 }
728
WebBrowser_get_FullScreen(IWebBrowser2 * iface,VARIANT_BOOL * pbFullScreen)729 static HRESULT WINAPI WebBrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
730 {
731 WebBrowser *This = impl_from_IWebBrowser2(iface);
732
733 TRACE("(%p)->(%p)\n", This, pbFullScreen);
734
735 *pbFullScreen = This->full_screen;
736 return S_OK;
737 }
738
WebBrowser_put_FullScreen(IWebBrowser2 * iface,VARIANT_BOOL bFullScreen)739 static HRESULT WINAPI WebBrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
740 {
741 WebBrowser *This = impl_from_IWebBrowser2(iface);
742 VARIANTARG arg;
743 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
744
745 /* In opposition to InternetExplorer, all we should do here is
746 * inform the embedder about the fullscreen change. */
747
748 TRACE("(%p)->(%x)\n", This, bFullScreen);
749
750 This->full_screen = bFullScreen ? VARIANT_TRUE : VARIANT_FALSE;
751
752 V_VT(&arg) = VT_BOOL;
753 V_BOOL(&arg) = bFullScreen;
754 call_sink(This->doc_host.cps.wbe2, DISPID_ONFULLSCREEN, &dispparams);
755
756 return S_OK;
757 }
758
WebBrowser_Navigate2(IWebBrowser2 * iface,VARIANT * URL,VARIANT * Flags,VARIANT * TargetFrameName,VARIANT * PostData,VARIANT * Headers)759 static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
760 VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
761 {
762 WebBrowser *This = impl_from_IWebBrowser2(iface);
763 LPCWSTR url;
764
765 TRACE("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
766 debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
767
768 if(!This->client)
769 return E_FAIL;
770
771 if(!URL)
772 return S_OK;
773
774 switch (V_VT(URL))
775 {
776 case VT_BSTR:
777 url = V_BSTR(URL);
778 break;
779 case VT_BSTR|VT_BYREF:
780 url = *V_BSTRREF(URL);
781 break;
782 default:
783 FIXME("Unsupported V_VT(URL) %d\n", V_VT(URL));
784 return E_INVALIDARG;
785 }
786
787 return navigate_url(&This->doc_host, url, Flags, TargetFrameName, PostData, Headers);
788 }
789
WebBrowser_QueryStatusWB(IWebBrowser2 * iface,OLECMDID cmdID,OLECMDF * pcmdf)790 static HRESULT WINAPI WebBrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
791 {
792 WebBrowser *This = impl_from_IWebBrowser2(iface);
793 IOleCommandTarget *target = NULL;
794 OLECMD ole_command[1];
795 HRESULT hres;
796
797 TRACE("(%p)->(%d %p)\n", This, cmdID, pcmdf);
798
799 if (!pcmdf)
800 return E_POINTER;
801 ole_command[0].cmdID = cmdID;
802 ole_command[0].cmdf = *pcmdf;
803
804 if (This->container)
805 {
806 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
807 if(FAILED(hres))
808 target = NULL;
809 }
810 if (!target && This->doc_host.document)
811 {
812 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
813 if(FAILED(hres))
814 target = NULL;
815 }
816
817 if (!target)
818 return E_UNEXPECTED;
819
820 hres = IOleCommandTarget_QueryStatus(target, NULL, 1, ole_command, NULL);
821 if (SUCCEEDED(hres))
822 *pcmdf = ole_command[0].cmdf;
823 if (hres == OLECMDERR_E_NOTSUPPORTED)
824 {
825 *pcmdf = 0;
826 hres = S_OK;
827 }
828 IOleCommandTarget_Release(target);
829
830 return hres;
831 }
832
WebBrowser_ExecWB(IWebBrowser2 * iface,OLECMDID cmdID,OLECMDEXECOPT cmdexecopt,VARIANT * pvaIn,VARIANT * pvaOut)833 static HRESULT WINAPI WebBrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
834 OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
835 {
836 WebBrowser *This = impl_from_IWebBrowser2(iface);
837 IOleCommandTarget *target = NULL;
838 HRESULT hres;
839
840 TRACE("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
841
842 if(This->container)
843 {
844 hres = IOleContainer_QueryInterface(This->container, &IID_IOleCommandTarget, (LPVOID*)&target);
845 if(FAILED(hres))
846 target = NULL;
847 }
848 if(!target && This->doc_host.document)
849 {
850 hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IOleCommandTarget, (LPVOID*)&target);
851 if(FAILED(hres))
852 target = NULL;
853 }
854
855 if(!target)
856 return E_UNEXPECTED;
857
858 hres = IOleCommandTarget_Exec(target, NULL, cmdID, cmdexecopt, pvaIn, pvaOut);
859 IOleCommandTarget_Release(target);
860
861 return hres;
862 }
863
WebBrowser_ShowBrowserBar(IWebBrowser2 * iface,VARIANT * pvaClsid,VARIANT * pvarShow,VARIANT * pvarSize)864 static HRESULT WINAPI WebBrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
865 VARIANT *pvarShow, VARIANT *pvarSize)
866 {
867 WebBrowser *This = impl_from_IWebBrowser2(iface);
868 FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
869 debugstr_variant(pvarSize));
870 return E_NOTIMPL;
871 }
872
WebBrowser_get_ReadyState(IWebBrowser2 * iface,READYSTATE * lpReadyState)873 static HRESULT WINAPI WebBrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
874 {
875 WebBrowser *This = impl_from_IWebBrowser2(iface);
876
877 TRACE("(%p)->(%p)\n", This, lpReadyState);
878
879 *lpReadyState = This->doc_host.ready_state;
880 return S_OK;
881 }
882
WebBrowser_get_Offline(IWebBrowser2 * iface,VARIANT_BOOL * pbOffline)883 static HRESULT WINAPI WebBrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
884 {
885 WebBrowser *This = impl_from_IWebBrowser2(iface);
886
887 TRACE("(%p)->(%p)\n", This, pbOffline);
888
889 *pbOffline = This->doc_host.offline;
890 return S_OK;
891 }
892
WebBrowser_put_Offline(IWebBrowser2 * iface,VARIANT_BOOL bOffline)893 static HRESULT WINAPI WebBrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
894 {
895 WebBrowser *This = impl_from_IWebBrowser2(iface);
896
897 TRACE("(%p)->(%x)\n", This, bOffline);
898
899 This->doc_host.offline = bOffline ? VARIANT_TRUE : VARIANT_FALSE;
900 return S_OK;
901 }
902
WebBrowser_get_Silent(IWebBrowser2 * iface,VARIANT_BOOL * pbSilent)903 static HRESULT WINAPI WebBrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
904 {
905 WebBrowser *This = impl_from_IWebBrowser2(iface);
906
907 TRACE("(%p)->(%p)\n", This, pbSilent);
908
909 *pbSilent = This->doc_host.silent;
910 return S_OK;
911 }
912
WebBrowser_put_Silent(IWebBrowser2 * iface,VARIANT_BOOL bSilent)913 static HRESULT WINAPI WebBrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
914 {
915 WebBrowser *This = impl_from_IWebBrowser2(iface);
916
917 TRACE("(%p)->(%x)\n", This, bSilent);
918
919 This->doc_host.silent = bSilent ? VARIANT_TRUE : VARIANT_FALSE;
920 return S_OK;
921 }
922
WebBrowser_get_RegisterAsBrowser(IWebBrowser2 * iface,VARIANT_BOOL * pbRegister)923 static HRESULT WINAPI WebBrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
924 VARIANT_BOOL *pbRegister)
925 {
926 WebBrowser *This = impl_from_IWebBrowser2(iface);
927
928 FIXME("(%p)->(%p)\n", This, pbRegister);
929
930 *pbRegister = This->register_browser;
931 return S_OK;
932 }
933
WebBrowser_put_RegisterAsBrowser(IWebBrowser2 * iface,VARIANT_BOOL bRegister)934 static HRESULT WINAPI WebBrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
935 VARIANT_BOOL bRegister)
936 {
937 WebBrowser *This = impl_from_IWebBrowser2(iface);
938
939 FIXME("(%p)->(%x)\n", This, bRegister);
940
941 This->register_browser = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
942 return S_OK;
943 }
944
WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 * iface,VARIANT_BOOL * pbRegister)945 static HRESULT WINAPI WebBrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
946 VARIANT_BOOL *pbRegister)
947 {
948 WebBrowser *This = impl_from_IWebBrowser2(iface);
949
950 FIXME("(%p)->(%p)\n", This, pbRegister);
951
952 if(!pbRegister)
953 return E_INVALIDARG;
954
955 *pbRegister=0;
956 return S_OK;
957 }
958
WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 * iface,VARIANT_BOOL bRegister)959 static HRESULT WINAPI WebBrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
960 VARIANT_BOOL bRegister)
961 {
962 WebBrowser *This = impl_from_IWebBrowser2(iface);
963 FIXME("(%p)->(%x)\n", This, bRegister);
964 return S_OK;
965 }
966
WebBrowser_get_TheaterMode(IWebBrowser2 * iface,VARIANT_BOOL * pbRegister)967 static HRESULT WINAPI WebBrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
968 {
969 WebBrowser *This = impl_from_IWebBrowser2(iface);
970
971 TRACE("(%p)->(%p)\n", This, pbRegister);
972
973 *pbRegister = This->theater_mode;
974 return S_OK;
975 }
976
WebBrowser_put_TheaterMode(IWebBrowser2 * iface,VARIANT_BOOL bRegister)977 static HRESULT WINAPI WebBrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
978 {
979 WebBrowser *This = impl_from_IWebBrowser2(iface);
980 VARIANTARG arg;
981 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
982
983 TRACE("(%p)->(%x)\n", This, bRegister);
984
985 This->theater_mode = bRegister ? VARIANT_TRUE : VARIANT_FALSE;
986
987 /* In opposition to InternetExplorer, all we should do here is
988 * inform the embedder about the theater mode change. */
989
990 V_VT(&arg) = VT_BOOL;
991 V_BOOL(&arg) = bRegister;
992 call_sink(This->doc_host.cps.wbe2, DISPID_ONTHEATERMODE, &dispparams);
993
994 return S_OK;
995 }
996
WebBrowser_get_AddressBar(IWebBrowser2 * iface,VARIANT_BOOL * Value)997 static HRESULT WINAPI WebBrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
998 {
999 WebBrowser *This = impl_from_IWebBrowser2(iface);
1000
1001 TRACE("(%p)->(%p)\n", This, Value);
1002
1003 *Value = This->address_bar;
1004 return S_OK;
1005 }
1006
WebBrowser_put_AddressBar(IWebBrowser2 * iface,VARIANT_BOOL Value)1007 static HRESULT WINAPI WebBrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
1008 {
1009 WebBrowser *This = impl_from_IWebBrowser2(iface);
1010 VARIANTARG arg;
1011 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1012
1013 TRACE("(%p)->(%x)\n", This, Value);
1014
1015 This->address_bar = Value ? VARIANT_TRUE : VARIANT_FALSE;
1016
1017 /* In opposition to InternetExplorer, all we should do here is
1018 * inform the embedder about the address bar change. */
1019
1020 V_VT(&arg) = VT_BOOL;
1021 V_BOOL(&arg) = Value;
1022 call_sink(This->doc_host.cps.wbe2, DISPID_ONADDRESSBAR, &dispparams);
1023
1024 return S_OK;
1025 }
1026
WebBrowser_get_Resizable(IWebBrowser2 * iface,VARIANT_BOOL * Value)1027 static HRESULT WINAPI WebBrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
1028 {
1029 WebBrowser *This = impl_from_IWebBrowser2(iface);
1030
1031 TRACE("(%p)->(%p)\n", This, Value);
1032
1033 /* It's InternetExplorer object's method. We have nothing to do here. */
1034 return E_NOTIMPL;
1035 }
1036
WebBrowser_put_Resizable(IWebBrowser2 * iface,VARIANT_BOOL Value)1037 static HRESULT WINAPI WebBrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
1038 {
1039 WebBrowser *This = impl_from_IWebBrowser2(iface);
1040 VARIANTARG arg;
1041 DISPPARAMS dispparams = {&arg, NULL, 1, 0};
1042
1043 TRACE("(%p)->(%x)\n", This, Value);
1044
1045 /* In opposition to InternetExplorer, all we should do here is
1046 * inform the embedder about the resizable change. */
1047
1048 V_VT(&arg) = VT_BOOL;
1049 V_BOOL(&arg) = Value;
1050 call_sink(This->doc_host.cps.wbe2, DISPID_WINDOWSETRESIZABLE, &dispparams);
1051
1052 return S_OK;
1053 }
1054
1055 static const IWebBrowser2Vtbl WebBrowser2Vtbl =
1056 {
1057 WebBrowser_QueryInterface,
1058 WebBrowser_AddRef,
1059 WebBrowser_Release,
1060 WebBrowser_GetTypeInfoCount,
1061 WebBrowser_GetTypeInfo,
1062 WebBrowser_GetIDsOfNames,
1063 WebBrowser_Invoke,
1064 WebBrowser_GoBack,
1065 WebBrowser_GoForward,
1066 WebBrowser_GoHome,
1067 WebBrowser_GoSearch,
1068 WebBrowser_Navigate,
1069 WebBrowser_Refresh,
1070 WebBrowser_Refresh2,
1071 WebBrowser_Stop,
1072 WebBrowser_get_Application,
1073 WebBrowser_get_Parent,
1074 WebBrowser_get_Container,
1075 WebBrowser_get_Document,
1076 WebBrowser_get_TopLevelContainer,
1077 WebBrowser_get_Type,
1078 WebBrowser_get_Left,
1079 WebBrowser_put_Left,
1080 WebBrowser_get_Top,
1081 WebBrowser_put_Top,
1082 WebBrowser_get_Width,
1083 WebBrowser_put_Width,
1084 WebBrowser_get_Height,
1085 WebBrowser_put_Height,
1086 WebBrowser_get_LocationName,
1087 WebBrowser_get_LocationURL,
1088 WebBrowser_get_Busy,
1089 WebBrowser_Quit,
1090 WebBrowser_ClientToWindow,
1091 WebBrowser_PutProperty,
1092 WebBrowser_GetProperty,
1093 WebBrowser_get_Name,
1094 WebBrowser_get_HWND,
1095 WebBrowser_get_FullName,
1096 WebBrowser_get_Path,
1097 WebBrowser_get_Visible,
1098 WebBrowser_put_Visible,
1099 WebBrowser_get_StatusBar,
1100 WebBrowser_put_StatusBar,
1101 WebBrowser_get_StatusText,
1102 WebBrowser_put_StatusText,
1103 WebBrowser_get_ToolBar,
1104 WebBrowser_put_ToolBar,
1105 WebBrowser_get_MenuBar,
1106 WebBrowser_put_MenuBar,
1107 WebBrowser_get_FullScreen,
1108 WebBrowser_put_FullScreen,
1109 WebBrowser_Navigate2,
1110 WebBrowser_QueryStatusWB,
1111 WebBrowser_ExecWB,
1112 WebBrowser_ShowBrowserBar,
1113 WebBrowser_get_ReadyState,
1114 WebBrowser_get_Offline,
1115 WebBrowser_put_Offline,
1116 WebBrowser_get_Silent,
1117 WebBrowser_put_Silent,
1118 WebBrowser_get_RegisterAsBrowser,
1119 WebBrowser_put_RegisterAsBrowser,
1120 WebBrowser_get_RegisterAsDropTarget,
1121 WebBrowser_put_RegisterAsDropTarget,
1122 WebBrowser_get_TheaterMode,
1123 WebBrowser_put_TheaterMode,
1124 WebBrowser_get_AddressBar,
1125 WebBrowser_put_AddressBar,
1126 WebBrowser_get_Resizable,
1127 WebBrowser_put_Resizable
1128 };
1129
impl_from_IServiceProvider(IServiceProvider * iface)1130 static inline WebBrowser *impl_from_IServiceProvider(IServiceProvider *iface)
1131 {
1132 return CONTAINING_RECORD(iface, WebBrowser, IServiceProvider_iface);
1133 }
1134
WBServiceProvider_QueryInterface(IServiceProvider * iface,REFIID riid,LPVOID * ppv)1135 static HRESULT WINAPI WBServiceProvider_QueryInterface(IServiceProvider *iface,
1136 REFIID riid, LPVOID *ppv)
1137 {
1138 WebBrowser *This = impl_from_IServiceProvider(iface);
1139 return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
1140 }
1141
WBServiceProvider_AddRef(IServiceProvider * iface)1142 static ULONG WINAPI WBServiceProvider_AddRef(IServiceProvider *iface)
1143 {
1144 WebBrowser *This = impl_from_IServiceProvider(iface);
1145 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
1146 }
1147
WBServiceProvider_Release(IServiceProvider * iface)1148 static ULONG WINAPI WBServiceProvider_Release(IServiceProvider *iface)
1149 {
1150 WebBrowser *This = impl_from_IServiceProvider(iface);
1151 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
1152 }
1153
WBServiceProvider_QueryService(IServiceProvider * iface,REFGUID guidService,REFIID riid,void ** ppv)1154 static HRESULT STDMETHODCALLTYPE WBServiceProvider_QueryService(IServiceProvider *iface,
1155 REFGUID guidService, REFIID riid, void **ppv)
1156 {
1157 WebBrowser *This = impl_from_IServiceProvider(iface);
1158
1159 if(IsEqualGUID(&SID_SHTMLWindow, riid)) {
1160 TRACE("(%p)->(SID_SHTMLWindow)\n", This);
1161 return IHTMLWindow2_QueryInterface(&This->doc_host.html_window.IHTMLWindow2_iface, riid, ppv);
1162 }
1163
1164 if(IsEqualGUID(&IID_IBrowserService2, riid)) {
1165 TRACE("(%p)->(IID_IBrowserService2 return E_FAIL)\n", This);
1166 *ppv = NULL;
1167 return E_FAIL;
1168 }
1169
1170 FIXME("(%p)->(%s, %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
1171 *ppv = NULL;
1172 return E_NOINTERFACE;
1173 }
1174
1175 static const IServiceProviderVtbl ServiceProviderVtbl =
1176 {
1177 WBServiceProvider_QueryInterface,
1178 WBServiceProvider_AddRef,
1179 WBServiceProvider_Release,
1180 WBServiceProvider_QueryService
1181 };
1182
impl_from_DocHost(DocHost * iface)1183 static inline WebBrowser *impl_from_DocHost(DocHost *iface)
1184 {
1185 return CONTAINING_RECORD(iface, WebBrowser, doc_host);
1186 }
1187
WebBrowser_addref(DocHost * iface)1188 static ULONG WebBrowser_addref(DocHost *iface)
1189 {
1190 WebBrowser *This = impl_from_DocHost(iface);
1191 return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
1192 }
1193
WebBrowser_release(DocHost * iface)1194 static ULONG WebBrowser_release(DocHost *iface)
1195 {
1196 WebBrowser *This = impl_from_DocHost(iface);
1197 return IWebBrowser2_Release(&This->IWebBrowser2_iface);
1198 }
1199
DocHostContainer_get_docobj_rect(DocHost * This,RECT * rc)1200 static void DocHostContainer_get_docobj_rect(DocHost *This, RECT *rc)
1201 {
1202 GetClientRect(This->frame_hwnd, rc);
1203 }
1204
DocHostContainer_set_status_text(DocHost * This,const WCHAR * text)1205 static HRESULT DocHostContainer_set_status_text(DocHost *This, const WCHAR *text)
1206 {
1207 return E_NOTIMPL;
1208 }
1209
DocHostContainer_on_command_state_change(DocHost * This,LONG command,BOOL enable)1210 static void DocHostContainer_on_command_state_change(DocHost *This, LONG command, BOOL enable)
1211 {
1212 }
1213
DocHostContainer_set_url(DocHost * This,const WCHAR * url)1214 static void DocHostContainer_set_url(DocHost *This, const WCHAR *url)
1215 {
1216 }
1217
1218 static const IDocHostContainerVtbl DocHostContainerVtbl = {
1219 WebBrowser_addref,
1220 WebBrowser_release,
1221 DocHostContainer_get_docobj_rect,
1222 DocHostContainer_set_status_text,
1223 DocHostContainer_on_command_state_change,
1224 DocHostContainer_set_url
1225 };
1226
create_webbrowser(int version,IUnknown * outer,REFIID riid,void ** ppv)1227 static HRESULT create_webbrowser(int version, IUnknown *outer, REFIID riid, void **ppv)
1228 {
1229 WebBrowser *ret;
1230 HRESULT hres;
1231
1232 TRACE("(%p %s %p) version=%d\n", outer, debugstr_guid(riid), ppv, version);
1233
1234 ret = heap_alloc_zero(sizeof(WebBrowser));
1235
1236 ret->IWebBrowser2_iface.lpVtbl = &WebBrowser2Vtbl;
1237 ret->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
1238 ret->ref = 1;
1239 ret->version = version;
1240
1241 DocHost_Init(&ret->doc_host, &ret->IWebBrowser2_iface, &DocHostContainerVtbl);
1242
1243 ret->visible = VARIANT_TRUE;
1244 ret->menu_bar = VARIANT_TRUE;
1245 ret->address_bar = VARIANT_TRUE;
1246 ret->status_bar = VARIANT_TRUE;
1247 ret->tool_bar = VARIANT_TRUE;
1248
1249 WebBrowser_OleObject_Init(ret);
1250 WebBrowser_ViewObject_Init(ret);
1251 WebBrowser_Persist_Init(ret);
1252 WebBrowser_ClassInfo_Init(ret);
1253
1254 HlinkFrame_Init(&ret->hlink_frame, (IUnknown*)&ret->IWebBrowser2_iface, &ret->doc_host);
1255
1256 lock_module();
1257
1258 hres = IWebBrowser2_QueryInterface(&ret->IWebBrowser2_iface, riid, ppv);
1259
1260 IWebBrowser2_Release(&ret->IWebBrowser2_iface);
1261 return hres;
1262 }
1263
WebBrowserV1_Create(IClassFactory * iface,IUnknown * pOuter,REFIID riid,void ** ppv)1264 HRESULT WINAPI WebBrowserV1_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1265 {
1266 return create_webbrowser(1, pOuter, riid, ppv);
1267 }
1268
WebBrowser_Create(IClassFactory * iface,IUnknown * pOuter,REFIID riid,void ** ppv)1269 HRESULT WINAPI WebBrowser_Create(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppv)
1270 {
1271 return create_webbrowser(2, pOuter, riid, ppv);
1272 }
1273