2 * Copyright 2008 Jacek Caban for CodeWeavers
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.
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.
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
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
34 typedef struct HTMLPluginsCollection HTMLPluginsCollection
;
35 typedef struct HTMLMimeTypesCollection HTMLMimeTypesCollection
;
39 IOmNavigator IOmNavigator_iface
;
43 HTMLPluginsCollection
*plugins
;
44 HTMLMimeTypesCollection
*mime_types
;
49 IHTMLDOMImplementation IHTMLDOMImplementation_iface
;
52 } HTMLDOMImplementation
;
54 static inline HTMLDOMImplementation
*impl_from_IHTMLDOMImplementation(IHTMLDOMImplementation
*iface
)
56 return CONTAINING_RECORD(iface
, HTMLDOMImplementation
, IHTMLDOMImplementation_iface
);
59 static HRESULT WINAPI
HTMLDOMImplementation_QueryInterface(IHTMLDOMImplementation
*iface
, REFIID riid
, void **ppv
)
61 HTMLDOMImplementation
*This
= impl_from_IHTMLDOMImplementation(iface
);
63 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
65 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IHTMLDOMImplementation
, riid
)) {
66 *ppv
= &This
->IHTMLDOMImplementation_iface
;
67 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
68 return *ppv
? S_OK
: E_NOINTERFACE
;
70 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid
));
75 IUnknown_AddRef((IUnknown
*)*ppv
);
79 static ULONG WINAPI
HTMLDOMImplementation_AddRef(IHTMLDOMImplementation
*iface
)
81 HTMLDOMImplementation
*This
= impl_from_IHTMLDOMImplementation(iface
);
82 LONG ref
= InterlockedIncrement(&This
->ref
);
84 TRACE("(%p) ref=%d\n", This
, ref
);
89 static ULONG WINAPI
HTMLDOMImplementation_Release(IHTMLDOMImplementation
*iface
)
91 HTMLDOMImplementation
*This
= impl_from_IHTMLDOMImplementation(iface
);
92 LONG ref
= InterlockedDecrement(&This
->ref
);
94 TRACE("(%p) ref=%d\n", This
, ref
);
97 release_dispex(&This
->dispex
);
104 static HRESULT WINAPI
HTMLDOMImplementation_GetTypeInfoCount(IHTMLDOMImplementation
*iface
, UINT
*pctinfo
)
106 HTMLDOMImplementation
*This
= impl_from_IHTMLDOMImplementation(iface
);
108 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
111 static HRESULT WINAPI
HTMLDOMImplementation_GetTypeInfo(IHTMLDOMImplementation
*iface
, UINT iTInfo
,
112 LCID lcid
, ITypeInfo
**ppTInfo
)
114 HTMLDOMImplementation
*This
= impl_from_IHTMLDOMImplementation(iface
);
116 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
119 static HRESULT WINAPI
HTMLDOMImplementation_GetIDsOfNames(IHTMLDOMImplementation
*iface
, REFIID riid
,
120 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
122 HTMLDOMImplementation
*This
= impl_from_IHTMLDOMImplementation(iface
);
124 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
,
125 cNames
, lcid
, rgDispId
);
128 static HRESULT WINAPI
HTMLDOMImplementation_Invoke(IHTMLDOMImplementation
*iface
, DISPID dispIdMember
,
129 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
130 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
132 HTMLDOMImplementation
*This
= impl_from_IHTMLDOMImplementation(iface
);
134 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
135 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
138 static HRESULT WINAPI
HTMLDOMImplementation_hasFeature(IHTMLDOMImplementation
*iface
, BSTR feature
,
139 VARIANT version
, VARIANT_BOOL
*pfHasFeature
)
141 HTMLDOMImplementation
*This
= impl_from_IHTMLDOMImplementation(iface
);
143 FIXME("(%p)->(%s %s %p) returning false\n", This
, debugstr_w(feature
), debugstr_variant(&version
), pfHasFeature
);
145 *pfHasFeature
= VARIANT_FALSE
;
149 static const IHTMLDOMImplementationVtbl HTMLDOMImplementationVtbl
= {
150 HTMLDOMImplementation_QueryInterface
,
151 HTMLDOMImplementation_AddRef
,
152 HTMLDOMImplementation_Release
,
153 HTMLDOMImplementation_GetTypeInfoCount
,
154 HTMLDOMImplementation_GetTypeInfo
,
155 HTMLDOMImplementation_GetIDsOfNames
,
156 HTMLDOMImplementation_Invoke
,
157 HTMLDOMImplementation_hasFeature
160 static const tid_t HTMLDOMImplementation_iface_tids
[] = {
161 IHTMLDOMImplementation_tid
,
164 static dispex_static_data_t HTMLDOMImplementation_dispex
= {
166 IHTMLDOMImplementation_tid
,
167 HTMLDOMImplementation_iface_tids
170 HRESULT
create_dom_implementation(IHTMLDOMImplementation
**ret
)
172 HTMLDOMImplementation
*dom_implementation
;
174 dom_implementation
= heap_alloc_zero(sizeof(*dom_implementation
));
175 if(!dom_implementation
)
176 return E_OUTOFMEMORY
;
178 dom_implementation
->IHTMLDOMImplementation_iface
.lpVtbl
= &HTMLDOMImplementationVtbl
;
179 dom_implementation
->ref
= 1;
181 init_dispex(&dom_implementation
->dispex
, (IUnknown
*)&dom_implementation
->IHTMLDOMImplementation_iface
,
182 &HTMLDOMImplementation_dispex
);
184 *ret
= &dom_implementation
->IHTMLDOMImplementation_iface
;
188 static inline OmHistory
*impl_from_IOmHistory(IOmHistory
*iface
)
190 return CONTAINING_RECORD(iface
, OmHistory
, IOmHistory_iface
);
193 static HRESULT WINAPI
OmHistory_QueryInterface(IOmHistory
*iface
, REFIID riid
, void **ppv
)
195 OmHistory
*This
= impl_from_IOmHistory(iface
);
197 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
199 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
200 *ppv
= &This
->IOmHistory_iface
;
201 }else if(IsEqualGUID(&IID_IOmHistory
, riid
)) {
202 *ppv
= &This
->IOmHistory_iface
;
203 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
204 return *ppv
? S_OK
: E_NOINTERFACE
;
206 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid
));
208 return E_NOINTERFACE
;
211 IUnknown_AddRef((IUnknown
*)*ppv
);
215 static ULONG WINAPI
OmHistory_AddRef(IOmHistory
*iface
)
217 OmHistory
*This
= impl_from_IOmHistory(iface
);
218 LONG ref
= InterlockedIncrement(&This
->ref
);
220 TRACE("(%p) ref=%d\n", This
, ref
);
225 static ULONG WINAPI
OmHistory_Release(IOmHistory
*iface
)
227 OmHistory
*This
= impl_from_IOmHistory(iface
);
228 LONG ref
= InterlockedDecrement(&This
->ref
);
230 TRACE("(%p) ref=%d\n", This
, ref
);
233 release_dispex(&This
->dispex
);
240 static HRESULT WINAPI
OmHistory_GetTypeInfoCount(IOmHistory
*iface
, UINT
*pctinfo
)
242 OmHistory
*This
= impl_from_IOmHistory(iface
);
243 FIXME("(%p)->(%p)\n", This
, pctinfo
);
247 static HRESULT WINAPI
OmHistory_GetTypeInfo(IOmHistory
*iface
, UINT iTInfo
,
248 LCID lcid
, ITypeInfo
**ppTInfo
)
250 OmHistory
*This
= impl_from_IOmHistory(iface
);
252 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
255 static HRESULT WINAPI
OmHistory_GetIDsOfNames(IOmHistory
*iface
, REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
,
256 LCID lcid
, DISPID
*rgDispId
)
258 OmHistory
*This
= impl_from_IOmHistory(iface
);
260 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
264 static HRESULT WINAPI
OmHistory_Invoke(IOmHistory
*iface
, DISPID dispIdMember
, REFIID riid
, LCID lcid
,
265 WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
267 OmHistory
*This
= impl_from_IOmHistory(iface
);
269 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
270 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
273 static HRESULT WINAPI
OmHistory_get_length(IOmHistory
*iface
, short *p
)
275 OmHistory
*This
= impl_from_IOmHistory(iface
);
277 TRACE("(%p)->(%p)\n", This
, p
);
279 if(!This
->window
|| !This
->window
->base
.outer_window
->doc_obj
280 || !This
->window
->base
.outer_window
->doc_obj
->travel_log
) {
283 *p
= ITravelLog_CountEntries(This
->window
->base
.outer_window
->doc_obj
->travel_log
,
284 This
->window
->base
.outer_window
->doc_obj
->browser_service
);
289 static HRESULT WINAPI
OmHistory_back(IOmHistory
*iface
, VARIANT
*pvargdistance
)
291 OmHistory
*This
= impl_from_IOmHistory(iface
);
292 FIXME("(%p)->(%s)\n", This
, debugstr_variant(pvargdistance
));
296 static HRESULT WINAPI
OmHistory_forward(IOmHistory
*iface
, VARIANT
*pvargdistance
)
298 OmHistory
*This
= impl_from_IOmHistory(iface
);
299 FIXME("(%p)->(%s)\n", This
, debugstr_variant(pvargdistance
));
303 static HRESULT WINAPI
OmHistory_go(IOmHistory
*iface
, VARIANT
*pvargdistance
)
305 OmHistory
*This
= impl_from_IOmHistory(iface
);
306 FIXME("(%p)->(%s)\n", This
, debugstr_variant(pvargdistance
));
310 static const IOmHistoryVtbl OmHistoryVtbl
= {
311 OmHistory_QueryInterface
,
314 OmHistory_GetTypeInfoCount
,
315 OmHistory_GetTypeInfo
,
316 OmHistory_GetIDsOfNames
,
318 OmHistory_get_length
,
324 static const tid_t OmHistory_iface_tids
[] = {
328 static dispex_static_data_t OmHistory_dispex
= {
335 HRESULT
create_history(HTMLInnerWindow
*window
, OmHistory
**ret
)
339 history
= heap_alloc_zero(sizeof(*history
));
341 return E_OUTOFMEMORY
;
343 init_dispex(&history
->dispex
, (IUnknown
*)&history
->IOmHistory_iface
, &OmHistory_dispex
);
344 history
->IOmHistory_iface
.lpVtbl
= &OmHistoryVtbl
;
347 history
->window
= window
;
353 struct HTMLPluginsCollection
{
355 IHTMLPluginsCollection IHTMLPluginsCollection_iface
;
359 OmNavigator
*navigator
;
362 static inline HTMLPluginsCollection
*impl_from_IHTMLPluginsCollection(IHTMLPluginsCollection
*iface
)
364 return CONTAINING_RECORD(iface
, HTMLPluginsCollection
, IHTMLPluginsCollection_iface
);
367 static HRESULT WINAPI
HTMLPluginsCollection_QueryInterface(IHTMLPluginsCollection
*iface
, REFIID riid
, void **ppv
)
369 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
371 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
373 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
374 *ppv
= &This
->IHTMLPluginsCollection_iface
;
375 }else if(IsEqualGUID(&IID_IHTMLPluginsCollection
, riid
)) {
376 *ppv
= &This
->IHTMLPluginsCollection_iface
;
377 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
378 return *ppv
? S_OK
: E_NOINTERFACE
;
381 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid
));
382 return E_NOINTERFACE
;
385 IUnknown_AddRef((IUnknown
*)*ppv
);
389 static ULONG WINAPI
HTMLPluginsCollection_AddRef(IHTMLPluginsCollection
*iface
)
391 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
392 LONG ref
= InterlockedIncrement(&This
->ref
);
394 TRACE("(%p) ref=%d\n", This
, ref
);
399 static ULONG WINAPI
HTMLPluginsCollection_Release(IHTMLPluginsCollection
*iface
)
401 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
402 LONG ref
= InterlockedDecrement(&This
->ref
);
404 TRACE("(%p) ref=%d\n", This
, ref
);
408 This
->navigator
->plugins
= NULL
;
409 release_dispex(&This
->dispex
);
416 static HRESULT WINAPI
HTMLPluginsCollection_GetTypeInfoCount(IHTMLPluginsCollection
*iface
, UINT
*pctinfo
)
418 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
419 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
422 static HRESULT WINAPI
HTMLPluginsCollection_GetTypeInfo(IHTMLPluginsCollection
*iface
, UINT iTInfo
,
423 LCID lcid
, ITypeInfo
**ppTInfo
)
425 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
426 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
429 static HRESULT WINAPI
HTMLPluginsCollection_GetIDsOfNames(IHTMLPluginsCollection
*iface
, REFIID riid
,
430 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
432 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
433 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
437 static HRESULT WINAPI
HTMLPluginsCollection_Invoke(IHTMLPluginsCollection
*iface
, DISPID dispIdMember
,
438 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
439 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
441 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
442 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
443 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
446 static HRESULT WINAPI
HTMLPluginsCollection_get_length(IHTMLPluginsCollection
*iface
, LONG
*p
)
448 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
450 TRACE("(%p)->(%p)\n", This
, p
);
452 /* IE always returns 0 here */
457 static HRESULT WINAPI
HTMLPluginsCollection_refresh(IHTMLPluginsCollection
*iface
, VARIANT_BOOL reload
)
459 HTMLPluginsCollection
*This
= impl_from_IHTMLPluginsCollection(iface
);
461 TRACE("(%p)->(%x)\n", This
, reload
);
463 /* Nothing to do here. */
467 static const IHTMLPluginsCollectionVtbl HTMLPluginsCollectionVtbl
= {
468 HTMLPluginsCollection_QueryInterface
,
469 HTMLPluginsCollection_AddRef
,
470 HTMLPluginsCollection_Release
,
471 HTMLPluginsCollection_GetTypeInfoCount
,
472 HTMLPluginsCollection_GetTypeInfo
,
473 HTMLPluginsCollection_GetIDsOfNames
,
474 HTMLPluginsCollection_Invoke
,
475 HTMLPluginsCollection_get_length
,
476 HTMLPluginsCollection_refresh
479 static const tid_t HTMLPluginsCollection_iface_tids
[] = {
480 IHTMLPluginsCollection_tid
,
483 static dispex_static_data_t HTMLPluginsCollection_dispex
= {
486 HTMLPluginsCollection_iface_tids
489 static HRESULT
create_plugins_collection(OmNavigator
*navigator
, HTMLPluginsCollection
**ret
)
491 HTMLPluginsCollection
*col
;
493 col
= heap_alloc_zero(sizeof(*col
));
495 return E_OUTOFMEMORY
;
497 col
->IHTMLPluginsCollection_iface
.lpVtbl
= &HTMLPluginsCollectionVtbl
;
499 col
->navigator
= navigator
;
501 init_dispex(&col
->dispex
, (IUnknown
*)&col
->IHTMLPluginsCollection_iface
,
502 &HTMLPluginsCollection_dispex
);
508 struct HTMLMimeTypesCollection
{
510 IHTMLMimeTypesCollection IHTMLMimeTypesCollection_iface
;
514 OmNavigator
*navigator
;
517 static inline HTMLMimeTypesCollection
*impl_from_IHTMLMimeTypesCollection(IHTMLMimeTypesCollection
*iface
)
519 return CONTAINING_RECORD(iface
, HTMLMimeTypesCollection
, IHTMLMimeTypesCollection_iface
);
522 static HRESULT WINAPI
HTMLMimeTypesCollection_QueryInterface(IHTMLMimeTypesCollection
*iface
, REFIID riid
, void **ppv
)
524 HTMLMimeTypesCollection
*This
= impl_from_IHTMLMimeTypesCollection(iface
);
526 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
528 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
529 *ppv
= &This
->IHTMLMimeTypesCollection_iface
;
530 }else if(IsEqualGUID(&IID_IHTMLMimeTypesCollection
, riid
)) {
531 *ppv
= &This
->IHTMLMimeTypesCollection_iface
;
532 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
533 return *ppv
? S_OK
: E_NOINTERFACE
;
535 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid
));
537 return E_NOINTERFACE
;
540 IUnknown_AddRef((IUnknown
*)*ppv
);
544 static ULONG WINAPI
HTMLMimeTypesCollection_AddRef(IHTMLMimeTypesCollection
*iface
)
546 HTMLMimeTypesCollection
*This
= impl_from_IHTMLMimeTypesCollection(iface
);
547 LONG ref
= InterlockedIncrement(&This
->ref
);
549 TRACE("(%p) ref=%d\n", This
, ref
);
554 static ULONG WINAPI
HTMLMimeTypesCollection_Release(IHTMLMimeTypesCollection
*iface
)
556 HTMLMimeTypesCollection
*This
= impl_from_IHTMLMimeTypesCollection(iface
);
557 LONG ref
= InterlockedDecrement(&This
->ref
);
559 TRACE("(%p) ref=%d\n", This
, ref
);
563 This
->navigator
->mime_types
= NULL
;
564 release_dispex(&This
->dispex
);
571 static HRESULT WINAPI
HTMLMimeTypesCollection_GetTypeInfoCount(IHTMLMimeTypesCollection
*iface
, UINT
*pctinfo
)
573 HTMLMimeTypesCollection
*This
= impl_from_IHTMLMimeTypesCollection(iface
);
574 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
577 static HRESULT WINAPI
HTMLMimeTypesCollection_GetTypeInfo(IHTMLMimeTypesCollection
*iface
, UINT iTInfo
,
578 LCID lcid
, ITypeInfo
**ppTInfo
)
580 HTMLMimeTypesCollection
*This
= impl_from_IHTMLMimeTypesCollection(iface
);
581 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
584 static HRESULT WINAPI
HTMLMimeTypesCollection_GetIDsOfNames(IHTMLMimeTypesCollection
*iface
, REFIID riid
,
585 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
587 HTMLMimeTypesCollection
*This
= impl_from_IHTMLMimeTypesCollection(iface
);
588 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
592 static HRESULT WINAPI
HTMLMimeTypesCollection_Invoke(IHTMLMimeTypesCollection
*iface
, DISPID dispIdMember
,
593 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
594 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
596 HTMLMimeTypesCollection
*This
= impl_from_IHTMLMimeTypesCollection(iface
);
597 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
598 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
601 static HRESULT WINAPI
HTMLMimeTypesCollection_get_length(IHTMLMimeTypesCollection
*iface
, LONG
*p
)
603 HTMLMimeTypesCollection
*This
= impl_from_IHTMLMimeTypesCollection(iface
);
605 TRACE("(%p)->(%p)\n", This
, p
);
607 /* This is just a stub for compatibility with other browser in IE */
612 static const IHTMLMimeTypesCollectionVtbl HTMLMimeTypesCollectionVtbl
= {
613 HTMLMimeTypesCollection_QueryInterface
,
614 HTMLMimeTypesCollection_AddRef
,
615 HTMLMimeTypesCollection_Release
,
616 HTMLMimeTypesCollection_GetTypeInfoCount
,
617 HTMLMimeTypesCollection_GetTypeInfo
,
618 HTMLMimeTypesCollection_GetIDsOfNames
,
619 HTMLMimeTypesCollection_Invoke
,
620 HTMLMimeTypesCollection_get_length
623 static const tid_t HTMLMimeTypesCollection_iface_tids
[] = {
624 IHTMLMimeTypesCollection_tid
,
627 static dispex_static_data_t HTMLMimeTypesCollection_dispex
= {
629 IHTMLMimeTypesCollection_tid
,
630 HTMLMimeTypesCollection_iface_tids
633 static HRESULT
create_mime_types_collection(OmNavigator
*navigator
, HTMLMimeTypesCollection
**ret
)
635 HTMLMimeTypesCollection
*col
;
637 col
= heap_alloc_zero(sizeof(*col
));
639 return E_OUTOFMEMORY
;
641 col
->IHTMLMimeTypesCollection_iface
.lpVtbl
= &HTMLMimeTypesCollectionVtbl
;
643 col
->navigator
= navigator
;
645 init_dispex(&col
->dispex
, (IUnknown
*)&col
->IHTMLMimeTypesCollection_iface
,
646 &HTMLMimeTypesCollection_dispex
);
652 static inline OmNavigator
*impl_from_IOmNavigator(IOmNavigator
*iface
)
654 return CONTAINING_RECORD(iface
, OmNavigator
, IOmNavigator_iface
);
657 static HRESULT WINAPI
OmNavigator_QueryInterface(IOmNavigator
*iface
, REFIID riid
, void **ppv
)
659 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
661 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
663 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
664 *ppv
= &This
->IOmNavigator_iface
;
665 }else if(IsEqualGUID(&IID_IOmNavigator
, riid
)) {
666 *ppv
= &This
->IOmNavigator_iface
;
667 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
668 return *ppv
? S_OK
: E_NOINTERFACE
;
670 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid
));
672 return E_NOINTERFACE
;
675 IUnknown_AddRef((IUnknown
*)*ppv
);
679 static ULONG WINAPI
OmNavigator_AddRef(IOmNavigator
*iface
)
681 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
682 LONG ref
= InterlockedIncrement(&This
->ref
);
684 TRACE("(%p) ref=%d\n", This
, ref
);
689 static ULONG WINAPI
OmNavigator_Release(IOmNavigator
*iface
)
691 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
692 LONG ref
= InterlockedDecrement(&This
->ref
);
694 TRACE("(%p) ref=%d\n", This
, ref
);
698 This
->plugins
->navigator
= NULL
;
700 This
->mime_types
->navigator
= NULL
;
701 release_dispex(&This
->dispex
);
708 static HRESULT WINAPI
OmNavigator_GetTypeInfoCount(IOmNavigator
*iface
, UINT
*pctinfo
)
710 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
711 FIXME("(%p)->(%p)\n", This
, pctinfo
);
715 static HRESULT WINAPI
OmNavigator_GetTypeInfo(IOmNavigator
*iface
, UINT iTInfo
,
716 LCID lcid
, ITypeInfo
**ppTInfo
)
718 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
720 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
723 static HRESULT WINAPI
OmNavigator_GetIDsOfNames(IOmNavigator
*iface
, REFIID riid
,
724 LPOLESTR
*rgszNames
, UINT cNames
,
725 LCID lcid
, DISPID
*rgDispId
)
727 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
729 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
733 static HRESULT WINAPI
OmNavigator_Invoke(IOmNavigator
*iface
, DISPID dispIdMember
,
734 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
735 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
737 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
739 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
740 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
743 static HRESULT WINAPI
OmNavigator_get_appCodeName(IOmNavigator
*iface
, BSTR
*p
)
745 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
747 static const WCHAR mozillaW
[] = {'M','o','z','i','l','l','a',0};
749 TRACE("(%p)->(%p)\n", This
, p
);
751 *p
= SysAllocString(mozillaW
);
755 static HRESULT WINAPI
OmNavigator_get_appName(IOmNavigator
*iface
, BSTR
*p
)
757 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
759 static const WCHAR app_nameW
[] =
760 {'M','i','c','r','o','s','o','f','t',' ',
761 'I','n','t','e','r','n','e','t',' ',
762 'E','x','p','l','o','r','e','r',0};
764 TRACE("(%p)->(%p)\n", This
, p
);
766 *p
= SysAllocString(app_nameW
);
768 return E_OUTOFMEMORY
;
773 static HRESULT WINAPI
OmNavigator_get_appVersion(IOmNavigator
*iface
, BSTR
*p
)
775 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
777 char user_agent
[512];
781 TRACE("(%p)->(%p)\n", This
, p
);
783 size
= sizeof(user_agent
);
784 hres
= ObtainUserAgentString(0, user_agent
, &size
);
788 if(strncmp(user_agent
, "Mozilla/", 8)) {
789 FIXME("Unsupported user agent\n");
793 size
= MultiByteToWideChar(CP_ACP
, 0, user_agent
+8, -1, NULL
, 0);
794 *p
= SysAllocStringLen(NULL
, size
-1);
796 return E_OUTOFMEMORY
;
798 MultiByteToWideChar(CP_ACP
, 0, user_agent
+8, -1, *p
, size
);
802 static HRESULT WINAPI
OmNavigator_get_userAgent(IOmNavigator
*iface
, BSTR
*p
)
804 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
805 char user_agent
[512];
809 TRACE("(%p)->(%p)\n", This
, p
);
811 size
= sizeof(user_agent
);
812 hres
= ObtainUserAgentString(0, user_agent
, &size
);
816 size
= MultiByteToWideChar(CP_ACP
, 0, user_agent
, -1, NULL
, 0);
817 *p
= SysAllocStringLen(NULL
, size
-1);
819 return E_OUTOFMEMORY
;
821 MultiByteToWideChar(CP_ACP
, 0, user_agent
, -1, *p
, size
);
825 static HRESULT WINAPI
OmNavigator_javaEnabled(IOmNavigator
*iface
, VARIANT_BOOL
*enabled
)
827 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
829 FIXME("(%p)->(%p) semi-stub\n", This
, enabled
);
831 *enabled
= VARIANT_TRUE
;
835 static HRESULT WINAPI
OmNavigator_taintEnabled(IOmNavigator
*iface
, VARIANT_BOOL
*enabled
)
837 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
838 FIXME("(%p)->(%p)\n", This
, enabled
);
842 static HRESULT WINAPI
OmNavigator_get_mimeTypes(IOmNavigator
*iface
, IHTMLMimeTypesCollection
**p
)
844 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
846 TRACE("(%p)->(%p)\n", This
, p
);
848 if(!This
->mime_types
) {
851 hres
= create_mime_types_collection(This
, &This
->mime_types
);
855 IHTMLMimeTypesCollection_AddRef(&This
->mime_types
->IHTMLMimeTypesCollection_iface
);
858 *p
= &This
->mime_types
->IHTMLMimeTypesCollection_iface
;
862 static HRESULT WINAPI
OmNavigator_get_plugins(IOmNavigator
*iface
, IHTMLPluginsCollection
**p
)
864 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
866 TRACE("(%p)->(%p)\n", This
, p
);
871 hres
= create_plugins_collection(This
, &This
->plugins
);
875 IHTMLPluginsCollection_AddRef(&This
->plugins
->IHTMLPluginsCollection_iface
);
878 *p
= &This
->plugins
->IHTMLPluginsCollection_iface
;
882 static HRESULT WINAPI
OmNavigator_get_cookieEnabled(IOmNavigator
*iface
, VARIANT_BOOL
*p
)
884 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
886 WARN("(%p)->(%p) semi-stub\n", This
, p
);
892 static HRESULT WINAPI
OmNavigator_get_opsProfile(IOmNavigator
*iface
, IHTMLOpsProfile
**p
)
894 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
895 FIXME("(%p)->(%p)\n", This
, p
);
899 static HRESULT WINAPI
OmNavigator_toString(IOmNavigator
*iface
, BSTR
*String
)
901 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
903 static const WCHAR objectW
[] = {'[','o','b','j','e','c','t',']',0};
905 TRACE("(%p)->(%p)\n", This
, String
);
910 *String
= SysAllocString(objectW
);
911 return *String
? S_OK
: E_OUTOFMEMORY
;
914 static HRESULT WINAPI
OmNavigator_get_cpuClass(IOmNavigator
*iface
, BSTR
*p
)
916 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
918 static const WCHAR cpu_classW
[] =
925 TRACE("(%p)->(%p)\n", This
, p
);
927 *p
= SysAllocString(cpu_classW
);
928 return *p
? S_OK
: E_OUTOFMEMORY
;
931 static HRESULT
get_language_string(LCID lcid
, BSTR
*p
)
936 len
= LCIDToLocaleName(lcid
, NULL
, 0, 0);
938 WARN("LCIDToLocaleName failed: %u\n", GetLastError());
942 ret
= SysAllocStringLen(NULL
, len
-1);
944 return E_OUTOFMEMORY
;
946 len
= LCIDToLocaleName(lcid
, ret
, len
, 0);
948 WARN("LCIDToLocaleName failed: %u\n", GetLastError());
957 static HRESULT WINAPI
OmNavigator_get_systemLanguage(IOmNavigator
*iface
, BSTR
*p
)
959 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
961 TRACE("(%p)->(%p)\n", This
, p
);
963 return get_language_string(LOCALE_SYSTEM_DEFAULT
, p
);
966 static HRESULT WINAPI
OmNavigator_get_browserLanguage(IOmNavigator
*iface
, BSTR
*p
)
968 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
970 TRACE("(%p)->(%p)\n", This
, p
);
972 return get_language_string(GetUserDefaultUILanguage(), p
);
975 static HRESULT WINAPI
OmNavigator_get_userLanguage(IOmNavigator
*iface
, BSTR
*p
)
977 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
979 TRACE("(%p)->(%p)\n", This
, p
);
981 return get_language_string(LOCALE_USER_DEFAULT
, p
);
984 static HRESULT WINAPI
OmNavigator_get_platform(IOmNavigator
*iface
, BSTR
*p
)
986 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
989 static const WCHAR platformW
[] = {'W','i','n','6','4',0};
991 static const WCHAR platformW
[] = {'W','i','n','3','2',0};
994 TRACE("(%p)->(%p)\n", This
, p
);
996 *p
= SysAllocString(platformW
);
1000 static HRESULT WINAPI
OmNavigator_get_appMinorVersion(IOmNavigator
*iface
, BSTR
*p
)
1002 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
1004 static const WCHAR zeroW
[] = {'0',0};
1006 TRACE("(%p)->(%p)\n", This
, p
);
1008 /* NOTE: MSIE returns "0" or values like ";SP2;". Returning "0" should be enough. */
1009 *p
= SysAllocString(zeroW
);
1013 static HRESULT WINAPI
OmNavigator_get_connectionSpeed(IOmNavigator
*iface
, LONG
*p
)
1015 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
1016 FIXME("(%p)->(%p)\n", This
, p
);
1020 static HRESULT WINAPI
OmNavigator_get_onLine(IOmNavigator
*iface
, VARIANT_BOOL
*p
)
1022 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
1024 WARN("(%p)->(%p) semi-stub, returning true\n", This
, p
);
1030 static HRESULT WINAPI
OmNavigator_get_userProfile(IOmNavigator
*iface
, IHTMLOpsProfile
**p
)
1032 OmNavigator
*This
= impl_from_IOmNavigator(iface
);
1033 FIXME("(%p)->(%p)\n", This
, p
);
1037 static const IOmNavigatorVtbl OmNavigatorVtbl
= {
1038 OmNavigator_QueryInterface
,
1040 OmNavigator_Release
,
1041 OmNavigator_GetTypeInfoCount
,
1042 OmNavigator_GetTypeInfo
,
1043 OmNavigator_GetIDsOfNames
,
1045 OmNavigator_get_appCodeName
,
1046 OmNavigator_get_appName
,
1047 OmNavigator_get_appVersion
,
1048 OmNavigator_get_userAgent
,
1049 OmNavigator_javaEnabled
,
1050 OmNavigator_taintEnabled
,
1051 OmNavigator_get_mimeTypes
,
1052 OmNavigator_get_plugins
,
1053 OmNavigator_get_cookieEnabled
,
1054 OmNavigator_get_opsProfile
,
1055 OmNavigator_toString
,
1056 OmNavigator_get_cpuClass
,
1057 OmNavigator_get_systemLanguage
,
1058 OmNavigator_get_browserLanguage
,
1059 OmNavigator_get_userLanguage
,
1060 OmNavigator_get_platform
,
1061 OmNavigator_get_appMinorVersion
,
1062 OmNavigator_get_connectionSpeed
,
1063 OmNavigator_get_onLine
,
1064 OmNavigator_get_userProfile
1067 static const tid_t OmNavigator_iface_tids
[] = {
1071 static dispex_static_data_t OmNavigator_dispex
= {
1073 DispHTMLNavigator_tid
,
1074 OmNavigator_iface_tids
1077 IOmNavigator
*OmNavigator_Create(void)
1081 ret
= heap_alloc_zero(sizeof(*ret
));
1085 ret
->IOmNavigator_iface
.lpVtbl
= &OmNavigatorVtbl
;
1088 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IOmNavigator_iface
, &OmNavigator_dispex
);
1090 return &ret
->IOmNavigator_iface
;