2 * Copyright 2006-2007 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
19 #define NONAMELESSUNION
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(ieframe
);
36 static const WCHAR emptyW
[] = {0};
39 IBindStatusCallback IBindStatusCallback_iface
;
40 IHttpNegotiate IHttpNegotiate_iface
;
41 IHttpSecurity IHttpSecurity_iface
;
54 static void dump_BINDINFO(BINDINFO
*bi
)
56 static const char * const BINDINFOF_str
[] = {
58 "BINDINFOF_URLENCODESTGMEDDATA",
59 "BINDINFOF_URLENCODEDEXTRAINFO"
62 static const char * const BINDVERB_str
[] = {
82 bi
->cbSize
, debugstr_w(bi
->szExtraInfo
),
83 bi
->stgmedData
.tymed
, bi
->stgmedData
.u
.hGlobal
, bi
->stgmedData
.pUnkForRelease
,
84 bi
->grfBindInfoF
> BINDINFOF_URLENCODEDEXTRAINFO
85 ? "unknown" : BINDINFOF_str
[bi
->grfBindInfoF
],
86 bi
->dwBindVerb
> BINDVERB_CUSTOM
87 ? "unknown" : BINDVERB_str
[bi
->dwBindVerb
],
88 debugstr_w(bi
->szCustomVerb
),
89 bi
->cbstgmedData
, bi
->dwOptions
, bi
->dwOptionsFlags
, bi
->dwCodePage
,
90 bi
->securityAttributes
.nLength
,
91 bi
->securityAttributes
.lpSecurityDescriptor
,
92 bi
->securityAttributes
.bInheritHandle
,
93 debugstr_guid(&bi
->iid
),
94 bi
->pUnk
, bi
->dwReserved
98 static void set_status_text(BindStatusCallback
*This
, ULONG statuscode
, LPCWSTR str
)
101 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
102 WCHAR fmt
[IDS_STATUSFMT_MAXLEN
];
103 WCHAR buffer
[IDS_STATUSFMT_MAXLEN
+ INTERNET_MAX_URL_LENGTH
];
108 TRACE("(%p, %d, %s)\n", This
, statuscode
, debugstr_w(str
));
110 if (statuscode
&& str
&& *str
) {
112 /* the format string must have one "%s" for the str */
113 LoadStringW(ieframe_instance
, IDS_STATUSFMT_FIRST
+ statuscode
, fmt
, IDS_STATUSFMT_MAXLEN
);
114 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), fmt
, str
);
117 V_VT(&arg
) = VT_BSTR
;
118 V_BSTR(&arg
) = str
? SysAllocString(buffer
) : SysAllocString(emptyW
);
119 TRACE("=> %s\n", debugstr_w(V_BSTR(&arg
)));
121 call_sink(This
->doc_host
->cps
.wbe2
, DISPID_STATUSTEXTCHANGE
, &dispparams
);
123 if(This
->doc_host
->frame
)
124 IOleInPlaceFrame_SetStatusText(This
->doc_host
->frame
, buffer
);
130 HRESULT
set_dochost_url(DocHost
*This
, const WCHAR
*url
)
135 new_url
= heap_strdupW(url
);
137 return E_OUTOFMEMORY
;
142 heap_free(This
->url
);
145 This
->container_vtbl
->set_url(This
, This
->url
);
149 void notify_download_state(DocHost
*dochost
, BOOL is_downloading
)
151 DISPPARAMS dwl_dp
= {NULL
};
152 TRACE("(%x)\n", is_downloading
);
153 call_sink(dochost
->cps
.wbe2
, is_downloading
? DISPID_DOWNLOADBEGIN
: DISPID_DOWNLOADCOMPLETE
, &dwl_dp
);
156 static inline BindStatusCallback
*impl_from_IBindStatusCallback(IBindStatusCallback
*iface
)
158 return CONTAINING_RECORD(iface
, BindStatusCallback
, IBindStatusCallback_iface
);
161 static HRESULT WINAPI
BindStatusCallback_QueryInterface(IBindStatusCallback
*iface
,
162 REFIID riid
, void **ppv
)
164 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
166 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
167 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
168 *ppv
= &This
->IBindStatusCallback_iface
;
169 }else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
)) {
170 TRACE("(%p)->(IID_IBindStatusCallback %p)\n", This
, ppv
);
171 *ppv
= &This
->IBindStatusCallback_iface
;
172 }else if(IsEqualGUID(&IID_IHttpNegotiate
, riid
)) {
173 TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This
, ppv
);
174 *ppv
= &This
->IHttpNegotiate_iface
;
175 }else if(IsEqualGUID(&IID_IWindowForBindingUI
, riid
)) {
176 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This
, ppv
);
177 *ppv
= &This
->IHttpSecurity_iface
;
178 }else if(IsEqualGUID(&IID_IHttpSecurity
, riid
)) {
179 TRACE("(%p)->(IID_IHttpSecurity %p)\n", This
, ppv
);
180 *ppv
= &This
->IHttpSecurity_iface
;
183 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
184 return E_NOINTERFACE
;
187 IUnknown_AddRef((IUnknown
*)*ppv
);
191 static ULONG WINAPI
BindStatusCallback_AddRef(IBindStatusCallback
*iface
)
193 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
194 LONG ref
= InterlockedIncrement(&This
->ref
);
196 TRACE("(%p) ref=%d\n", This
, ref
);
201 static ULONG WINAPI
BindStatusCallback_Release(IBindStatusCallback
*iface
)
203 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
204 LONG ref
= InterlockedDecrement(&This
->ref
);
206 TRACE("(%p) ref=%d\n", This
, ref
);
210 IOleClientSite_Release(&This
->doc_host
->IOleClientSite_iface
);
212 IBinding_Release(This
->binding
);
214 GlobalFree(This
->post_data
);
215 SysFreeString(This
->headers
);
216 SysFreeString(This
->url
);
223 static HRESULT WINAPI
BindStatusCallback_OnStartBinding(IBindStatusCallback
*iface
,
224 DWORD dwReserved
, IBinding
*pbind
)
226 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
228 TRACE("(%p)->(%d %p)\n", This
, dwReserved
, pbind
);
230 This
->binding
= pbind
;
231 IBinding_AddRef(This
->binding
);
236 static HRESULT WINAPI
BindStatusCallback_GetPriority(IBindStatusCallback
*iface
,
239 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
240 FIXME("(%p)->(%p)\n", This
, pnPriority
);
244 static HRESULT WINAPI
BindStatusCallback_OnLowResource(IBindStatusCallback
*iface
,
247 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
248 FIXME("(%p)->(%d)\n", This
, reserved
);
252 static DWORD
get_http_status_code(IBinding
*binding
)
254 IWinInetHttpInfo
*http_info
;
255 DWORD status
, size
= sizeof(DWORD
);
258 hres
= IBinding_QueryInterface(binding
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
260 return HTTP_STATUS_OK
;
262 hres
= IWinInetHttpInfo_QueryInfo(http_info
, HTTP_QUERY_STATUS_CODE
|HTTP_QUERY_FLAG_NUMBER
,
263 &status
, &size
, NULL
, NULL
);
264 IWinInetHttpInfo_Release(http_info
);
267 return HTTP_STATUS_OK
;
271 static HRESULT WINAPI
BindStatusCallback_OnProgress(IBindStatusCallback
*iface
,
272 ULONG ulProgress
, ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
274 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
277 TRACE("(%p)->(%d %d %d %s)\n", This
, ulProgress
, ulProgressMax
, ulStatusCode
,
278 debugstr_w(szStatusText
));
280 switch(ulStatusCode
) {
281 case BINDSTATUS_REDIRECTING
:
282 return set_dochost_url(This
->doc_host
, szStatusText
);
283 case BINDSTATUS_BEGINDOWNLOADDATA
:
284 set_status_text(This
, ulStatusCode
, szStatusText
);
285 status_code
= get_http_status_code(This
->binding
);
286 if(status_code
!= HTTP_STATUS_OK
)
287 handle_navigation_error(This
->doc_host
, status_code
, This
->url
, NULL
);
290 case BINDSTATUS_FINDINGRESOURCE
:
291 case BINDSTATUS_ENDDOWNLOADDATA
:
292 case BINDSTATUS_SENDINGREQUEST
:
293 set_status_text(This
, ulStatusCode
, szStatusText
);
296 case BINDSTATUS_CONNECTING
:
297 case BINDSTATUS_CACHEFILENAMEAVAILABLE
:
298 case BINDSTATUS_CLASSIDAVAILABLE
:
299 case BINDSTATUS_MIMETYPEAVAILABLE
:
300 case BINDSTATUS_BEGINSYNCOPERATION
:
301 case BINDSTATUS_ENDSYNCOPERATION
:
304 FIXME("status code %u\n", ulStatusCode
);
310 void handle_navigation_error(DocHost
* doc_host
, HRESULT hres
, BSTR url
, IHTMLWindow2
*win2
)
312 VARIANT var_status_code
, var_frame_name
, var_url
;
313 DISPPARAMS dispparams
;
314 VARIANTARG params
[5];
315 VARIANT_BOOL cancel
= VARIANT_FALSE
;
317 dispparams
.cArgs
= 5;
318 dispparams
.cNamedArgs
= 0;
319 dispparams
.rgdispidNamedArgs
= NULL
;
320 dispparams
.rgvarg
= params
;
322 V_VT(params
) = VT_BOOL
|VT_BYREF
;
323 V_BOOLREF(params
) = &cancel
;
325 V_VT(params
+1) = VT_VARIANT
|VT_BYREF
;
326 V_VARIANTREF(params
+1) = &var_status_code
;
327 V_VT(&var_status_code
) = VT_I4
;
328 V_I4(&var_status_code
) = hres
;
330 V_VT(params
+2) = VT_VARIANT
|VT_BYREF
;
331 V_VARIANTREF(params
+2) = &var_frame_name
;
332 V_VT(&var_frame_name
) = VT_BSTR
;
334 hres
= IHTMLWindow2_get_name(win2
, &V_BSTR(&var_frame_name
));
336 V_BSTR(&var_frame_name
) = NULL
;
338 V_BSTR(&var_frame_name
) = NULL
;
340 V_VT(params
+3) = VT_VARIANT
|VT_BYREF
;
341 V_VARIANTREF(params
+3) = &var_url
;
342 V_VT(&var_url
) = VT_BSTR
;
343 V_BSTR(&var_url
) = url
;
345 V_VT(params
+4) = VT_DISPATCH
;
346 V_DISPATCH(params
+4) = (IDispatch
*)doc_host
->wb
;
348 call_sink(doc_host
->cps
.wbe2
, DISPID_NAVIGATEERROR
, &dispparams
);
349 SysFreeString(V_BSTR(&var_frame_name
));
352 FIXME("Navigate to error page\n");
355 static HRESULT WINAPI
BindStatusCallback_OnStopBinding(IBindStatusCallback
*iface
,
356 HRESULT hresult
, LPCWSTR szError
)
358 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
360 TRACE("(%p)->(%08x %s)\n", This
, hresult
, debugstr_w(szError
));
362 set_status_text(This
, 0, emptyW
);
367 if(!This
->doc_host
->olecmd
)
368 notify_download_state(This
->doc_host
, FALSE
);
370 handle_navigation_error(This
->doc_host
, hresult
, This
->url
, NULL
);
372 IOleClientSite_Release(&This
->doc_host
->IOleClientSite_iface
);
373 This
->doc_host
= NULL
;
375 IBinding_Release(This
->binding
);
376 This
->binding
= NULL
;
381 static HRESULT WINAPI
BindStatusCallback_GetBindInfo(IBindStatusCallback
*iface
,
382 DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
384 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
386 TRACE("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
388 *grfBINDF
= BINDF_ASYNCHRONOUS
;
390 if(This
->post_data
) {
391 pbindinfo
->dwBindVerb
= BINDVERB_POST
;
393 pbindinfo
->stgmedData
.tymed
= TYMED_HGLOBAL
;
394 pbindinfo
->stgmedData
.u
.hGlobal
= This
->post_data
;
395 pbindinfo
->cbstgmedData
= This
->post_data_len
;
396 pbindinfo
->stgmedData
.pUnkForRelease
= (IUnknown
*)&This
->IBindStatusCallback_iface
;
397 IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
403 static HRESULT WINAPI
BindStatusCallback_OnDataAvailable(IBindStatusCallback
*iface
,
404 DWORD grfBSCF
, DWORD dwSize
, FORMATETC
*pformatetc
, STGMEDIUM
*pstgmed
)
406 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
407 FIXME("(%p)->(%08x %d %p %p)\n", This
, grfBSCF
, dwSize
, pformatetc
, pstgmed
);
411 static HRESULT WINAPI
BindStatusCallback_OnObjectAvailable(IBindStatusCallback
*iface
,
412 REFIID riid
, IUnknown
*punk
)
414 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
416 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), punk
);
418 return dochost_object_available(This
->doc_host
, punk
);
421 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl
= {
422 BindStatusCallback_QueryInterface
,
423 BindStatusCallback_AddRef
,
424 BindStatusCallback_Release
,
425 BindStatusCallback_OnStartBinding
,
426 BindStatusCallback_GetPriority
,
427 BindStatusCallback_OnLowResource
,
428 BindStatusCallback_OnProgress
,
429 BindStatusCallback_OnStopBinding
,
430 BindStatusCallback_GetBindInfo
,
431 BindStatusCallback_OnDataAvailable
,
432 BindStatusCallback_OnObjectAvailable
435 static inline BindStatusCallback
*impl_from_IHttpNegotiate(IHttpNegotiate
*iface
)
437 return CONTAINING_RECORD(iface
, BindStatusCallback
, IHttpNegotiate_iface
);
440 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate
*iface
,
441 REFIID riid
, void **ppv
)
443 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
444 return IBindStatusCallback_QueryInterface(&This
->IBindStatusCallback_iface
, riid
, ppv
);
447 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate
*iface
)
449 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
450 return IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
453 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate
*iface
)
455 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
456 return IBindStatusCallback_Release(&This
->IBindStatusCallback_iface
);
459 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate
*iface
,
460 LPCWSTR szURL
, LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
462 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
464 TRACE("(%p)->(%s %s %d %p)\n", This
, debugstr_w(szURL
), debugstr_w(szHeaders
),
465 dwReserved
, pszAdditionalHeaders
);
468 int size
= (strlenW(This
->headers
)+1)*sizeof(WCHAR
);
469 *pszAdditionalHeaders
= CoTaskMemAlloc(size
);
470 memcpy(*pszAdditionalHeaders
, This
->headers
, size
);
476 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate
*iface
,
477 DWORD dwResponseCode
, LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
,
478 LPWSTR
*pszAdditionalRequestHeaders
)
480 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
481 TRACE("(%p)->(%d %s %s %p)\n", This
, dwResponseCode
, debugstr_w(szResponseHeaders
),
482 debugstr_w(szRequestHeaders
), pszAdditionalRequestHeaders
);
486 static const IHttpNegotiateVtbl HttpNegotiateVtbl
= {
487 HttpNegotiate_QueryInterface
,
488 HttpNegotiate_AddRef
,
489 HttpNegotiate_Release
,
490 HttpNegotiate_BeginningTransaction
,
491 HttpNegotiate_OnResponse
494 static inline BindStatusCallback
*impl_from_IHttpSecurity(IHttpSecurity
*iface
)
496 return CONTAINING_RECORD(iface
, BindStatusCallback
, IHttpSecurity_iface
);
499 static HRESULT WINAPI
HttpSecurity_QueryInterface(IHttpSecurity
*iface
, REFIID riid
, void **ppv
)
501 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
502 return IBindStatusCallback_QueryInterface(&This
->IBindStatusCallback_iface
, riid
, ppv
);
505 static ULONG WINAPI
HttpSecurity_AddRef(IHttpSecurity
*iface
)
507 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
508 return IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
511 static ULONG WINAPI
HttpSecurity_Release(IHttpSecurity
*iface
)
513 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
514 return IBindStatusCallback_Release(&This
->IBindStatusCallback_iface
);
517 static HRESULT WINAPI
HttpSecurity_GetWindow(IHttpSecurity
*iface
, REFGUID rguidReason
, HWND
*phwnd
)
519 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
521 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(rguidReason
), phwnd
);
526 *phwnd
= This
->doc_host
->frame_hwnd
;
530 static HRESULT WINAPI
HttpSecurity_OnSecurityProblem(IHttpSecurity
*iface
, DWORD dwProblem
)
532 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
533 FIXME("(%p)->(%u)\n", This
, dwProblem
);
537 static const IHttpSecurityVtbl HttpSecurityVtbl
= {
538 HttpSecurity_QueryInterface
,
540 HttpSecurity_Release
,
541 HttpSecurity_GetWindow
,
542 HttpSecurity_OnSecurityProblem
545 static BindStatusCallback
*create_callback(DocHost
*doc_host
, LPCWSTR url
, PBYTE post_data
,
546 ULONG post_data_len
, LPCWSTR headers
)
548 BindStatusCallback
*ret
= heap_alloc(sizeof(BindStatusCallback
));
550 ret
->IBindStatusCallback_iface
.lpVtbl
= &BindStatusCallbackVtbl
;
551 ret
->IHttpNegotiate_iface
.lpVtbl
= &HttpNegotiateVtbl
;
552 ret
->IHttpSecurity_iface
.lpVtbl
= &HttpSecurityVtbl
;
555 ret
->url
= SysAllocString(url
);
556 ret
->post_data
= NULL
;
557 ret
->post_data_len
= post_data_len
;
558 ret
->headers
= headers
? SysAllocString(headers
) : NULL
;
560 ret
->doc_host
= doc_host
;
561 IOleClientSite_AddRef(&doc_host
->IOleClientSite_iface
);
566 ret
->post_data
= GlobalAlloc(0, post_data_len
);
567 memcpy(ret
->post_data
, post_data
, post_data_len
);
573 static void on_before_navigate2(DocHost
*This
, LPCWSTR url
, SAFEARRAY
*post_data
, LPWSTR headers
, VARIANT_BOOL
*cancel
)
575 VARIANT var_url
, var_flags
, var_frame_name
, var_post_data
, var_post_data2
, var_headers
;
576 DISPPARAMS dispparams
;
577 VARIANTARG params
[7];
578 WCHAR file_path
[MAX_PATH
];
579 DWORD file_path_len
= sizeof(file_path
) / sizeof(*file_path
);
581 dispparams
.cArgs
= 7;
582 dispparams
.cNamedArgs
= 0;
583 dispparams
.rgdispidNamedArgs
= NULL
;
584 dispparams
.rgvarg
= params
;
586 This
->busy
= VARIANT_TRUE
;
588 V_VT(params
) = VT_BOOL
|VT_BYREF
;
589 V_BOOLREF(params
) = cancel
;
591 V_VT(params
+1) = (VT_BYREF
|VT_VARIANT
);
592 V_VARIANTREF(params
+1) = &var_headers
;
593 V_VT(&var_headers
) = VT_BSTR
;
594 V_BSTR(&var_headers
) = headers
;
596 V_VT(params
+2) = (VT_BYREF
|VT_VARIANT
);
597 V_VARIANTREF(params
+2) = &var_post_data2
;
598 V_VT(&var_post_data2
) = (VT_BYREF
|VT_VARIANT
);
599 V_VARIANTREF(&var_post_data2
) = &var_post_data
;
602 V_VT(&var_post_data
) = VT_UI1
|VT_ARRAY
;
603 V_ARRAY(&var_post_data
) = post_data
;
605 V_VT(&var_post_data
) = VT_EMPTY
;
608 V_VT(params
+3) = (VT_BYREF
|VT_VARIANT
);
609 V_VARIANTREF(params
+3) = &var_frame_name
;
610 V_VT(&var_frame_name
) = VT_BSTR
;
611 V_BSTR(&var_frame_name
) = NULL
;
613 V_VT(params
+4) = (VT_BYREF
|VT_VARIANT
);
614 V_VARIANTREF(params
+4) = &var_flags
;
615 V_VT(&var_flags
) = VT_I4
;
616 V_I4(&var_flags
) = 0;
618 V_VT(params
+5) = (VT_BYREF
|VT_VARIANT
);
619 V_VARIANTREF(params
+5) = &var_url
;
620 V_VT(&var_url
) = VT_BSTR
;
621 if(PathCreateFromUrlW(url
, file_path
, &file_path_len
, 0) == S_OK
)
622 V_BSTR(&var_url
) = SysAllocString(file_path
);
624 V_BSTR(&var_url
) = SysAllocString(url
);
626 V_VT(params
+6) = (VT_DISPATCH
);
627 V_DISPATCH(params
+6) = (IDispatch
*)This
->wb
;
629 call_sink(This
->cps
.wbe2
, DISPID_BEFORENAVIGATE2
, &dispparams
);
631 SysFreeString(V_BSTR(&var_url
));
634 /* FIXME: urlmon should handle it */
635 static BOOL
try_application_url(LPCWSTR url
)
637 SHELLEXECUTEINFOW exec_info
;
643 static const WCHAR wszURLProtocol
[] = {'U','R','L',' ','P','r','o','t','o','c','o','l',0};
645 hres
= CoInternetParseUrl(url
, PARSE_SCHEMA
, 0, app
, sizeof(app
)/sizeof(WCHAR
), NULL
, 0);
649 res
= RegOpenKeyW(HKEY_CLASSES_ROOT
, app
, &hkey
);
650 if(res
!= ERROR_SUCCESS
)
653 res
= RegQueryValueExW(hkey
, wszURLProtocol
, NULL
, &type
, NULL
, NULL
);
655 if(res
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
658 TRACE("opening application %s\n", debugstr_w(app
));
660 memset(&exec_info
, 0, sizeof(exec_info
));
661 exec_info
.cbSize
= sizeof(exec_info
);
662 exec_info
.lpFile
= url
;
663 exec_info
.nShow
= SW_SHOW
;
665 return ShellExecuteExW(&exec_info
);
668 static HRESULT
create_moniker(LPCWSTR url
, IMoniker
**mon
)
670 WCHAR new_url
[INTERNET_MAX_URL_LENGTH
];
675 return CreateURLMoniker(NULL
, url
, mon
);
677 size
= sizeof(new_url
)/sizeof(WCHAR
);
678 hres
= UrlApplySchemeW(url
, new_url
, &size
, URL_APPLY_GUESSSCHEME
| URL_APPLY_GUESSFILE
| URL_APPLY_DEFAULT
);
679 TRACE("was %s got %s\n", debugstr_w(url
), debugstr_w(new_url
));
681 WARN("UrlApplyScheme failed: %08x\n", hres
);
685 return CreateURLMoniker(NULL
, new_url
, mon
);
688 static HRESULT
bind_to_object(DocHost
*This
, IMoniker
*mon
, LPCWSTR url
, IBindCtx
*bindctx
,
689 IBindStatusCallback
*callback
)
691 IUnknown
*unk
= NULL
;
696 IMoniker_AddRef(mon
);
698 hres
= create_moniker(url
, &mon
);
703 hres
= IMoniker_GetDisplayName(mon
, 0, NULL
, &display_name
);
705 FIXME("GetDisplayName failed: %08x\n", hres
);
709 hres
= set_dochost_url(This
, display_name
);
710 CoTaskMemFree(display_name
);
714 IBindCtx_RegisterObjectParam(bindctx
, (LPOLESTR
)SZ_HTML_CLIENTSITE_OBJECTPARAM
,
715 (IUnknown
*)&This
->IOleClientSite_iface
);
717 hres
= IMoniker_BindToObject(mon
, bindctx
, NULL
, &IID_IUnknown
, (void**)&unk
);
718 if(SUCCEEDED(hres
)) {
721 IUnknown_Release(unk
);
722 }else if(try_application_url(url
)) {
725 FIXME("BindToObject failed: %08x\n", hres
);
728 IMoniker_Release(mon
);
732 static void html_window_navigate(DocHost
*This
, IHTMLPrivateWindow
*window
, BSTR url
, BSTR headers
, SAFEARRAY
*post_data
)
734 VARIANT headers_var
, post_data_var
;
738 hres
= set_dochost_url(This
, url
);
742 empty_str
= SysAllocStringLen(NULL
, 0);
745 V_VT(&headers_var
) = VT_BSTR
;
746 V_BSTR(&headers_var
) = headers
;
748 V_VT(&headers_var
) = VT_EMPTY
;
752 V_VT(&post_data_var
) = VT_UI1
|VT_ARRAY
;
753 V_ARRAY(&post_data_var
) = post_data
;
755 V_VT(&post_data_var
) = VT_EMPTY
;
758 set_doc_state(This
, READYSTATE_LOADING
);
759 hres
= IHTMLPrivateWindow_SuperNavigate(window
, url
, empty_str
, NULL
, NULL
, &post_data_var
, &headers_var
, 0);
760 SysFreeString(empty_str
);
762 WARN("SuprtNavigate failed: %08x\n", hres
);
766 task_header_t header
;
769 SAFEARRAY
*post_data
;
771 } task_doc_navigate_t
;
773 static void doc_navigate_task_destr(task_header_t
*t
)
775 task_doc_navigate_t
*task
= (task_doc_navigate_t
*)t
;
777 SysFreeString(task
->url
);
778 SysFreeString(task
->headers
);
780 SafeArrayDestroy(task
->post_data
);
784 static void doc_navigate_proc(DocHost
*This
, task_header_t
*t
)
786 task_doc_navigate_t
*task
= (task_doc_navigate_t
*)t
;
787 IHTMLPrivateWindow
*priv_window
;
790 if(!This
->doc_navigate
) {
795 if(task
->async_notif
) {
796 VARIANT_BOOL cancel
= VARIANT_FALSE
;
797 on_before_navigate2(This
, task
->url
, task
->post_data
, task
->headers
, &cancel
);
799 TRACE("Navigation canceled\n");
804 hres
= IUnknown_QueryInterface(This
->doc_navigate
, &IID_IHTMLPrivateWindow
, (void**)&priv_window
);
805 if(SUCCEEDED(hres
)) {
806 html_window_navigate(This
, priv_window
, task
->url
, task
->headers
, task
->post_data
);
807 IHTMLPrivateWindow_Release(priv_window
);
809 WARN("Could not get IHTMLPrivateWindow iface: %08x\n", hres
);
813 static HRESULT
async_doc_navigate(DocHost
*This
, LPCWSTR url
, LPCWSTR headers
, PBYTE post_data
, ULONG post_data_size
,
816 task_doc_navigate_t
*task
;
818 TRACE("%s\n", debugstr_w(url
));
820 task
= heap_alloc_zero(sizeof(*task
));
822 return E_OUTOFMEMORY
;
824 task
->url
= SysAllocString(url
);
826 doc_navigate_task_destr(&task
->header
);
827 return E_OUTOFMEMORY
;
831 task
->headers
= SysAllocString(headers
);
833 doc_navigate_task_destr(&task
->header
);
834 return E_OUTOFMEMORY
;
839 task
->post_data
= SafeArrayCreateVector(VT_UI1
, 0, post_data_size
);
840 if(!task
->post_data
) {
841 doc_navigate_task_destr(&task
->header
);
842 return E_OUTOFMEMORY
;
845 memcpy(task
->post_data
->pvData
, post_data
, post_data_size
);
849 VARIANT_BOOL cancel
= VARIANT_FALSE
;
851 on_before_navigate2(This
, task
->url
, task
->post_data
, task
->headers
, &cancel
);
853 TRACE("Navigation canceled\n");
854 doc_navigate_task_destr(&task
->header
);
859 task
->async_notif
= async_notif
;
860 abort_dochost_tasks(This
, doc_navigate_proc
);
861 push_dochost_task(This
, &task
->header
, doc_navigate_proc
, doc_navigate_task_destr
, FALSE
);
865 static HRESULT
navigate_bsc(DocHost
*This
, BindStatusCallback
*bsc
, IMoniker
*mon
)
867 VARIANT_BOOL cancel
= VARIANT_FALSE
;
868 SAFEARRAY
*post_data
= NULL
;
872 set_doc_state(This
, READYSTATE_LOADING
);
875 post_data
= SafeArrayCreateVector(VT_UI1
, 0, bsc
->post_data_len
);
876 memcpy(post_data
->pvData
, post_data
, bsc
->post_data_len
);
879 on_before_navigate2(This
, bsc
->url
, post_data
, bsc
->headers
, &cancel
);
881 SafeArrayDestroy(post_data
);
883 FIXME("Navigation canceled\n");
887 notify_download_state(This
, TRUE
);
888 on_commandstate_change(This
, CSC_NAVIGATEBACK
, FALSE
);
889 on_commandstate_change(This
, CSC_NAVIGATEFORWARD
, FALSE
);
892 deactivate_document(This
);
894 CreateAsyncBindCtx(0, &bsc
->IBindStatusCallback_iface
, 0, &bindctx
);
897 IOleInPlaceFrame_EnableModeless(This
->frame
, FALSE
);
899 hres
= bind_to_object(This
, mon
, bsc
->url
, bindctx
, &bsc
->IBindStatusCallback_iface
);
902 IOleInPlaceFrame_EnableModeless(This
->frame
, TRUE
);
904 IBindCtx_Release(bindctx
);
910 task_header_t header
;
911 BindStatusCallback
*bsc
;
912 } task_navigate_bsc_t
;
914 static void navigate_bsc_task_destr(task_header_t
*t
)
916 task_navigate_bsc_t
*task
= (task_navigate_bsc_t
*)t
;
918 IBindStatusCallback_Release(&task
->bsc
->IBindStatusCallback_iface
);
922 static void navigate_bsc_proc(DocHost
*This
, task_header_t
*t
)
924 task_navigate_bsc_t
*task
= (task_navigate_bsc_t
*)t
;
927 create_doc_view_hwnd(This
);
929 navigate_bsc(This
, task
->bsc
, NULL
);
933 HRESULT
navigate_url(DocHost
*This
, LPCWSTR url
, const VARIANT
*Flags
,
934 const VARIANT
*TargetFrameName
, VARIANT
*PostData
, VARIANT
*Headers
)
936 SAFEARRAY
*post_array
= NULL
;
937 PBYTE post_data
= NULL
;
938 ULONG post_data_len
= 0;
939 LPWSTR headers
= NULL
;
942 TRACE("navigating to %s\n", debugstr_w(url
));
944 if((Flags
&& V_VT(Flags
) != VT_EMPTY
&& V_VT(Flags
) != VT_ERROR
)
945 || (TargetFrameName
&& V_VT(TargetFrameName
) != VT_EMPTY
&& V_VT(TargetFrameName
) != VT_ERROR
))
946 FIXME("Unsupported args (Flags %s; TargetFrameName %s)\n", debugstr_variant(Flags
), debugstr_variant(TargetFrameName
));
949 if(V_VT(PostData
) & VT_ARRAY
)
950 post_array
= V_ISBYREF(PostData
) ? *V_ARRAYREF(PostData
) : V_ARRAY(PostData
);
952 WARN("Invalid post data %s\n", debugstr_variant(PostData
));
957 SafeArrayAccessData(post_array
, (void**)&post_data
);
958 SafeArrayGetUBound(post_array
, 1, &elem_max
);
959 post_data_len
= (elem_max
+1) * SafeArrayGetElemsize(post_array
);
962 if(Headers
&& V_VT(Headers
) == VT_BSTR
) {
963 headers
= V_BSTR(Headers
);
964 TRACE("Headers: %s\n", debugstr_w(headers
));
967 set_doc_state(This
, READYSTATE_LOADING
);
968 This
->ready_state
= READYSTATE_LOADING
;
970 if(This
->doc_navigate
) {
971 WCHAR new_url
[INTERNET_MAX_URL_LENGTH
];
973 if(PathIsURLW(url
)) {
978 size
= sizeof(new_url
)/sizeof(WCHAR
);
979 hres
= UrlApplySchemeW(url
, new_url
, &size
,
980 URL_APPLY_GUESSSCHEME
| URL_APPLY_GUESSFILE
| URL_APPLY_DEFAULT
);
982 WARN("UrlApplyScheme failed: %08x\n", hres
);
987 hres
= async_doc_navigate(This
, *new_url
? new_url
: url
, headers
, post_data
,
988 post_data_len
, TRUE
);
990 task_navigate_bsc_t
*task
;
992 task
= heap_alloc(sizeof(*task
));
993 task
->bsc
= create_callback(This
, url
, post_data
, post_data_len
, headers
);
994 push_dochost_task(This
, &task
->header
, navigate_bsc_proc
, navigate_bsc_task_destr
, This
->url
== NULL
);
998 SafeArrayUnaccessData(post_array
);
1003 static HRESULT
navigate_hlink(DocHost
*This
, IMoniker
*mon
, IBindCtx
*bindctx
,
1004 IBindStatusCallback
*callback
)
1006 IHttpNegotiate
*http_negotiate
;
1007 BindStatusCallback
*bsc
;
1008 PBYTE post_data
= NULL
;
1009 ULONG post_data_len
= 0;
1010 LPWSTR headers
= NULL
, url
;
1017 hres
= IMoniker_GetDisplayName(mon
, 0, NULL
, &url
);
1019 FIXME("GetDisplayName failed: %08x\n", hres
);
1021 hres
= IBindStatusCallback_QueryInterface(callback
, &IID_IHttpNegotiate
,
1022 (void**)&http_negotiate
);
1023 if(SUCCEEDED(hres
)) {
1024 static const WCHAR null_string
[] = {0};
1026 IHttpNegotiate_BeginningTransaction(http_negotiate
, null_string
, null_string
, 0,
1028 IHttpNegotiate_Release(http_negotiate
);
1031 memset(&bindinfo
, 0, sizeof(bindinfo
));
1032 bindinfo
.cbSize
= sizeof(bindinfo
);
1034 hres
= IBindStatusCallback_GetBindInfo(callback
, &bindf
, &bindinfo
);
1035 dump_BINDINFO(&bindinfo
);
1036 if(bindinfo
.dwBindVerb
== BINDVERB_POST
) {
1037 post_data_len
= bindinfo
.cbstgmedData
;
1039 post_data
= bindinfo
.stgmedData
.u
.hGlobal
;
1042 if(This
->doc_navigate
) {
1043 hres
= async_doc_navigate(This
, url
, headers
, post_data
, post_data_len
, FALSE
);
1045 bsc
= create_callback(This
, url
, post_data
, post_data_len
, headers
);
1046 hres
= navigate_bsc(This
, bsc
, mon
);
1047 IBindStatusCallback_Release(&bsc
->IBindStatusCallback_iface
);
1051 CoTaskMemFree(headers
);
1052 ReleaseBindInfo(&bindinfo
);
1057 HRESULT
go_home(DocHost
*This
)
1060 DWORD res
, type
, size
;
1061 WCHAR wszPageName
[MAX_PATH
];
1062 static const WCHAR wszAboutBlank
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
1063 static const WCHAR wszStartPage
[] = {'S','t','a','r','t',' ','P','a','g','e',0};
1064 static const WCHAR wszSubKey
[] = {'S','o','f','t','w','a','r','e','\\',
1065 'M','i','c','r','o','s','o','f','t','\\',
1066 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
1069 res
= RegOpenKeyW(HKEY_CURRENT_USER
, wszSubKey
, &hkey
);
1070 if (res
!= ERROR_SUCCESS
)
1071 return navigate_url(This
, wszAboutBlank
, NULL
, NULL
, NULL
, NULL
);
1073 size
= sizeof(wszPageName
);
1074 res
= RegQueryValueExW(hkey
, wszStartPage
, NULL
, &type
, (LPBYTE
)wszPageName
, &size
);
1076 if (res
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
1077 return navigate_url(This
, wszAboutBlank
, NULL
, NULL
, NULL
, NULL
);
1079 return navigate_url(This
, wszPageName
, NULL
, NULL
, NULL
, NULL
);
1082 static HRESULT
navigate_history(DocHost
*This
, unsigned travellog_pos
)
1084 IPersistHistory
*persist_history
;
1085 travellog_entry_t
*entry
;
1089 if(!This
->doc_navigate
) {
1090 FIXME("unsupported doc_navigate FALSE\n");
1094 This
->travellog
.loading_pos
= travellog_pos
;
1095 entry
= This
->travellog
.log
+ This
->travellog
.loading_pos
;
1097 update_navigation_commands(This
);
1100 return async_doc_navigate(This
, entry
->url
, NULL
, NULL
, 0, FALSE
);
1102 hres
= IUnknown_QueryInterface(This
->document
, &IID_IPersistHistory
, (void**)&persist_history
);
1107 IStream_Seek(entry
->stream
, li
, STREAM_SEEK_SET
, NULL
);
1109 hres
= IPersistHistory_LoadHistory(persist_history
, entry
->stream
, NULL
);
1110 IPersistHistory_Release(persist_history
);
1114 HRESULT
go_back(DocHost
*This
)
1116 if(!This
->travellog
.position
) {
1117 WARN("No history available\n");
1121 return navigate_history(This
, This
->travellog
.position
-1);
1124 HRESULT
go_forward(DocHost
*This
)
1126 if(This
->travellog
.position
>= This
->travellog
.length
) {
1127 WARN("No history available\n");
1131 return navigate_history(This
, This
->travellog
.position
+1);
1134 HRESULT
get_location_url(DocHost
*This
, BSTR
*ret
)
1136 FIXME("semi-stub\n");
1138 *ret
= This
->url
? SysAllocString(This
->url
) : SysAllocStringLen(NULL
, 0);
1140 return E_OUTOFMEMORY
;
1142 return This
->url
? S_OK
: S_FALSE
;
1145 static inline HlinkFrame
*impl_from_IHlinkFrame(IHlinkFrame
*iface
)
1147 return CONTAINING_RECORD(iface
, HlinkFrame
, IHlinkFrame_iface
);
1150 static HRESULT WINAPI
HlinkFrame_QueryInterface(IHlinkFrame
*iface
, REFIID riid
, void **ppv
)
1152 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1153 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1156 static ULONG WINAPI
HlinkFrame_AddRef(IHlinkFrame
*iface
)
1158 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1159 return IUnknown_AddRef(This
->outer
);
1162 static ULONG WINAPI
HlinkFrame_Release(IHlinkFrame
*iface
)
1164 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1165 return IUnknown_Release(This
->outer
);
1168 static HRESULT WINAPI
HlinkFrame_SetBrowseContext(IHlinkFrame
*iface
,
1169 IHlinkBrowseContext
*pihlbc
)
1171 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1172 FIXME("(%p)->(%p)\n", This
, pihlbc
);
1176 static HRESULT WINAPI
HlinkFrame_GetBrowseContext(IHlinkFrame
*iface
,
1177 IHlinkBrowseContext
**ppihlbc
)
1179 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1180 FIXME("(%p)->(%p)\n", This
, ppihlbc
);
1184 static HRESULT WINAPI
HlinkFrame_Navigate(IHlinkFrame
*iface
, DWORD grfHLNF
, LPBC pbc
,
1185 IBindStatusCallback
*pibsc
, IHlink
*pihlNavigate
)
1187 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1189 LPWSTR location
= NULL
;
1191 TRACE("(%p)->(%08x %p %p %p)\n", This
, grfHLNF
, pbc
, pibsc
, pihlNavigate
);
1194 FIXME("unsupported grfHLNF=%08x\n", grfHLNF
);
1196 /* Windows calls GetTargetFrameName here. */
1198 IHlink_GetMonikerReference(pihlNavigate
, 1, &mon
, &location
);
1201 FIXME("location = %s\n", debugstr_w(location
));
1202 CoTaskMemFree(location
);
1205 /* Windows calls GetHlinkSite here */
1207 if(grfHLNF
& HLNF_OPENINNEWWINDOW
) {
1208 FIXME("Not supported HLNF_OPENINNEWWINDOW\n");
1212 return navigate_hlink(This
->doc_host
, mon
, pbc
, pibsc
);
1215 static HRESULT WINAPI
HlinkFrame_OnNavigate(IHlinkFrame
*iface
, DWORD grfHLNF
,
1216 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
, DWORD dwreserved
)
1218 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1219 FIXME("(%p)->(%08x %p %s %s %d)\n", This
, grfHLNF
, pimkTarget
, debugstr_w(pwzLocation
),
1220 debugstr_w(pwzFriendlyName
), dwreserved
);
1224 static HRESULT WINAPI
HlinkFrame_UpdateHlink(IHlinkFrame
*iface
, ULONG uHLID
,
1225 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
)
1227 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1228 FIXME("(%p)->(%u %p %s %s)\n", This
, uHLID
, pimkTarget
, debugstr_w(pwzLocation
),
1229 debugstr_w(pwzFriendlyName
));
1233 static const IHlinkFrameVtbl HlinkFrameVtbl
= {
1234 HlinkFrame_QueryInterface
,
1237 HlinkFrame_SetBrowseContext
,
1238 HlinkFrame_GetBrowseContext
,
1239 HlinkFrame_Navigate
,
1240 HlinkFrame_OnNavigate
,
1241 HlinkFrame_UpdateHlink
1244 static inline HlinkFrame
*impl_from_ITargetFrame(ITargetFrame
*iface
)
1246 return CONTAINING_RECORD(iface
, HlinkFrame
, ITargetFrame_iface
);
1249 static HRESULT WINAPI
TargetFrame_QueryInterface(ITargetFrame
*iface
, REFIID riid
, void **ppv
)
1251 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1252 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1255 static ULONG WINAPI
TargetFrame_AddRef(ITargetFrame
*iface
)
1257 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1258 return IUnknown_AddRef(This
->outer
);
1261 static ULONG WINAPI
TargetFrame_Release(ITargetFrame
*iface
)
1263 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1264 return IUnknown_Release(This
->outer
);
1267 static HRESULT WINAPI
TargetFrame_SetFrameName(ITargetFrame
*iface
, LPCWSTR pszFrameName
)
1269 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1270 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameName
));
1274 static HRESULT WINAPI
TargetFrame_GetFrameName(ITargetFrame
*iface
, LPWSTR
*ppszFrameName
)
1276 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1277 FIXME("(%p)->(%p)\n", This
, ppszFrameName
);
1281 static HRESULT WINAPI
TargetFrame_GetParentFrame(ITargetFrame
*iface
, IUnknown
**ppunkParent
)
1283 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1284 FIXME("(%p)->(%p)\n", This
, ppunkParent
);
1288 static HRESULT WINAPI
TargetFrame_FindFrame(ITargetFrame
*iface
, LPCWSTR pszTargetName
,
1289 IUnknown
*ppunkContextFrame
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1291 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1292 FIXME("(%p)->(%s %p %x %p)\n", This
, debugstr_w(pszTargetName
),
1293 ppunkContextFrame
, dwFlags
, ppunkTargetFrame
);
1297 static HRESULT WINAPI
TargetFrame_SetFrameSrc(ITargetFrame
*iface
, LPCWSTR pszFrameSrc
)
1299 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1300 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameSrc
));
1304 static HRESULT WINAPI
TargetFrame_GetFrameSrc(ITargetFrame
*iface
, LPWSTR
*ppszFrameSrc
)
1306 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1307 FIXME("(%p)->(%p)\n", This
, ppszFrameSrc
);
1311 static HRESULT WINAPI
TargetFrame_GetFramesContainer(ITargetFrame
*iface
, IOleContainer
**ppContainer
)
1313 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1314 FIXME("(%p)->(%p)\n", This
, ppContainer
);
1318 static HRESULT WINAPI
TargetFrame_SetFrameOptions(ITargetFrame
*iface
, DWORD dwFlags
)
1320 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1321 FIXME("(%p)->(%x)\n", This
, dwFlags
);
1325 static HRESULT WINAPI
TargetFrame_GetFrameOptions(ITargetFrame
*iface
, DWORD
*pdwFlags
)
1327 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1328 FIXME("(%p)->(%p)\n", This
, pdwFlags
);
1332 static HRESULT WINAPI
TargetFrame_SetFrameMargins(ITargetFrame
*iface
, DWORD dwWidth
, DWORD dwHeight
)
1334 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1335 FIXME("(%p)->(%d %d)\n", This
, dwWidth
, dwHeight
);
1339 static HRESULT WINAPI
TargetFrame_GetFrameMargins(ITargetFrame
*iface
, DWORD
*pdwWidth
, DWORD
*pdwHeight
)
1341 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1342 FIXME("(%p)->(%p %p)\n", This
, pdwWidth
, pdwHeight
);
1346 static HRESULT WINAPI
TargetFrame_RemoteNavigate(ITargetFrame
*iface
, ULONG cLength
, ULONG
*pulData
)
1348 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1349 FIXME("(%p)->(%u %p)\n", This
, cLength
, pulData
);
1353 static HRESULT WINAPI
TargetFrame_OnChildFrameActivate(ITargetFrame
*iface
, IUnknown
*pUnkChildFrame
)
1355 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1356 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1360 static HRESULT WINAPI
TargetFrame_OnChildFrameDeactivate(ITargetFrame
*iface
, IUnknown
*pUnkChildFrame
)
1362 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1363 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1367 static const ITargetFrameVtbl TargetFrameVtbl
= {
1368 TargetFrame_QueryInterface
,
1370 TargetFrame_Release
,
1371 TargetFrame_SetFrameName
,
1372 TargetFrame_GetFrameName
,
1373 TargetFrame_GetParentFrame
,
1374 TargetFrame_FindFrame
,
1375 TargetFrame_SetFrameSrc
,
1376 TargetFrame_GetFrameSrc
,
1377 TargetFrame_GetFramesContainer
,
1378 TargetFrame_SetFrameOptions
,
1379 TargetFrame_GetFrameOptions
,
1380 TargetFrame_SetFrameMargins
,
1381 TargetFrame_GetFrameMargins
,
1382 TargetFrame_RemoteNavigate
,
1383 TargetFrame_OnChildFrameActivate
,
1384 TargetFrame_OnChildFrameDeactivate
1387 static inline HlinkFrame
*impl_from_ITargetFrame2(ITargetFrame2
*iface
)
1389 return CONTAINING_RECORD(iface
, HlinkFrame
, ITargetFrame2_iface
);
1392 static HRESULT WINAPI
TargetFrame2_QueryInterface(ITargetFrame2
*iface
, REFIID riid
, void **ppv
)
1394 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1395 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1398 static ULONG WINAPI
TargetFrame2_AddRef(ITargetFrame2
*iface
)
1400 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1401 return IUnknown_AddRef(This
->outer
);
1404 static ULONG WINAPI
TargetFrame2_Release(ITargetFrame2
*iface
)
1406 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1407 return IUnknown_Release(This
->outer
);
1410 static HRESULT WINAPI
TargetFrame2_SetFrameName(ITargetFrame2
*iface
, LPCWSTR pszFrameName
)
1412 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1413 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameName
));
1417 static HRESULT WINAPI
TargetFrame2_GetFrameName(ITargetFrame2
*iface
, LPWSTR
*ppszFrameName
)
1419 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1420 FIXME("(%p)->(%p)\n", This
, ppszFrameName
);
1424 static HRESULT WINAPI
TargetFrame2_GetParentFrame(ITargetFrame2
*iface
, IUnknown
**ppunkParent
)
1426 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1427 FIXME("(%p)->(%p)\n", This
, ppunkParent
);
1431 static HRESULT WINAPI
TargetFrame2_SetFrameSrc(ITargetFrame2
*iface
, LPCWSTR pszFrameSrc
)
1433 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1434 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameSrc
));
1438 static HRESULT WINAPI
TargetFrame2_GetFrameSrc(ITargetFrame2
*iface
, LPWSTR
*ppszFrameSrc
)
1440 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1441 FIXME("(%p)->()\n", This
);
1445 static HRESULT WINAPI
TargetFrame2_GetFramesContainer(ITargetFrame2
*iface
, IOleContainer
**ppContainer
)
1447 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1448 FIXME("(%p)->(%p)\n", This
, ppContainer
);
1452 static HRESULT WINAPI
TargetFrame2_SetFrameOptions(ITargetFrame2
*iface
, DWORD dwFlags
)
1454 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1455 FIXME("(%p)->(%x)\n", This
, dwFlags
);
1459 static HRESULT WINAPI
TargetFrame2_GetFrameOptions(ITargetFrame2
*iface
, DWORD
*pdwFlags
)
1461 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1462 FIXME("(%p)->(%p)\n", This
, pdwFlags
);
1466 static HRESULT WINAPI
TargetFrame2_SetFrameMargins(ITargetFrame2
*iface
, DWORD dwWidth
, DWORD dwHeight
)
1468 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1469 FIXME("(%p)->(%d %d)\n", This
, dwWidth
, dwHeight
);
1473 static HRESULT WINAPI
TargetFrame2_GetFrameMargins(ITargetFrame2
*iface
, DWORD
*pdwWidth
, DWORD
*pdwHeight
)
1475 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1476 FIXME("(%p)->(%p %p)\n", This
, pdwWidth
, pdwHeight
);
1480 static HRESULT WINAPI
TargetFrame2_FindFrame(ITargetFrame2
*iface
, LPCWSTR pszTargetName
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1482 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1483 FIXME("(%p)->(%s %x %p)\n", This
, debugstr_w(pszTargetName
), dwFlags
, ppunkTargetFrame
);
1487 static HRESULT WINAPI
TargetFrame2_GetTargetAlias(ITargetFrame2
*iface
, LPCWSTR pszTargetName
, LPWSTR
*ppszTargetAlias
)
1489 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1490 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(pszTargetName
), ppszTargetAlias
);
1494 static const ITargetFrame2Vtbl TargetFrame2Vtbl
= {
1495 TargetFrame2_QueryInterface
,
1496 TargetFrame2_AddRef
,
1497 TargetFrame2_Release
,
1498 TargetFrame2_SetFrameName
,
1499 TargetFrame2_GetFrameName
,
1500 TargetFrame2_GetParentFrame
,
1501 TargetFrame2_SetFrameSrc
,
1502 TargetFrame2_GetFrameSrc
,
1503 TargetFrame2_GetFramesContainer
,
1504 TargetFrame2_SetFrameOptions
,
1505 TargetFrame2_GetFrameOptions
,
1506 TargetFrame2_SetFrameMargins
,
1507 TargetFrame2_GetFrameMargins
,
1508 TargetFrame2_FindFrame
,
1509 TargetFrame2_GetTargetAlias
1512 static inline HlinkFrame
*impl_from_ITargetFramePriv2(ITargetFramePriv2
*iface
)
1514 return CONTAINING_RECORD(iface
, HlinkFrame
, ITargetFramePriv2_iface
);
1517 static HRESULT WINAPI
TargetFramePriv2_QueryInterface(ITargetFramePriv2
*iface
, REFIID riid
, void **ppv
)
1519 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1520 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1523 static ULONG WINAPI
TargetFramePriv2_AddRef(ITargetFramePriv2
*iface
)
1525 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1526 return IUnknown_AddRef(This
->outer
);
1529 static ULONG WINAPI
TargetFramePriv2_Release(ITargetFramePriv2
*iface
)
1531 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1532 return IUnknown_Release(This
->outer
);
1535 static HRESULT WINAPI
TargetFramePriv2_FindFrameDownwards(ITargetFramePriv2
*iface
,
1536 LPCWSTR pszTargetName
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1538 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1539 FIXME("(%p)->(%s %x %p)\n", This
, debugstr_w(pszTargetName
), dwFlags
, ppunkTargetFrame
);
1543 static HRESULT WINAPI
TargetFramePriv2_FindFrameInContext(ITargetFramePriv2
*iface
,
1544 LPCWSTR pszTargetName
, IUnknown
*punkContextFrame
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1546 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1547 FIXME("(%p)->(%s %p %x %p)\n", This
, debugstr_w(pszTargetName
), punkContextFrame
, dwFlags
, ppunkTargetFrame
);
1551 static HRESULT WINAPI
TargetFramePriv2_OnChildFrameActivate(ITargetFramePriv2
*iface
, IUnknown
*pUnkChildFrame
)
1553 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1554 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1558 static HRESULT WINAPI
TargetFramePriv2_OnChildFrameDeactivate(ITargetFramePriv2
*iface
, IUnknown
*pUnkChildFrame
)
1560 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1561 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1565 static HRESULT WINAPI
TargetFramePriv2_NavigateHack(ITargetFramePriv2
*iface
, DWORD grfHLNF
, LPBC pbc
,
1566 IBindStatusCallback
*pibsc
, LPCWSTR pszTargetName
, LPCWSTR pszUrl
, LPCWSTR pszLocation
)
1568 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1569 FIXME("(%p)->(%x %p %p %s %s %s)\n", This
, grfHLNF
, pbc
, pibsc
, debugstr_w(pszTargetName
),
1570 debugstr_w(pszUrl
), debugstr_w(pszLocation
));
1574 static HRESULT WINAPI
TargetFramePriv2_FindBrowserByIndex(ITargetFramePriv2
*iface
, DWORD dwID
, IUnknown
**ppunkBrowser
)
1576 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1577 FIXME("(%p)->(%d %p)\n", This
, dwID
, ppunkBrowser
);
1581 static HRESULT WINAPI
TargetFramePriv2_AggregatedNavigation2(ITargetFramePriv2
*iface
, DWORD grfHLNF
, LPBC pbc
,
1582 IBindStatusCallback
*pibsc
, LPCWSTR pszTargetName
, IUri
*pUri
, LPCWSTR pszLocation
)
1584 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1588 TRACE("(%p)->(%x %p %p %s %p %s)\n", This
, grfHLNF
, pbc
, pibsc
, debugstr_w(pszTargetName
),
1589 pUri
, debugstr_w(pszLocation
));
1592 * NOTE: This is an undocumented function. It seems to be working the way it's implemented,
1593 * but I couldn't get its tests working. It's used by mshtml to load content in a new
1594 * instance of browser.
1597 hres
= CreateURLMonikerEx2(NULL
, pUri
, &mon
, 0);
1601 hres
= navigate_hlink(This
->doc_host
, mon
, pbc
, pibsc
);
1602 IMoniker_Release(mon
);
1606 static const ITargetFramePriv2Vtbl TargetFramePriv2Vtbl
= {
1607 TargetFramePriv2_QueryInterface
,
1608 TargetFramePriv2_AddRef
,
1609 TargetFramePriv2_Release
,
1610 TargetFramePriv2_FindFrameDownwards
,
1611 TargetFramePriv2_FindFrameInContext
,
1612 TargetFramePriv2_OnChildFrameActivate
,
1613 TargetFramePriv2_OnChildFrameDeactivate
,
1614 TargetFramePriv2_NavigateHack
,
1615 TargetFramePriv2_FindBrowserByIndex
,
1616 TargetFramePriv2_AggregatedNavigation2
1619 static inline HlinkFrame
*impl_from_IWebBrowserPriv2IE9(IWebBrowserPriv2IE9
*iface
)
1621 return CONTAINING_RECORD(iface
, HlinkFrame
, IWebBrowserPriv2IE9_iface
);
1624 static HRESULT WINAPI
WebBrowserPriv2IE9_QueryInterface(IWebBrowserPriv2IE9
*iface
, REFIID riid
, void **ppv
)
1626 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1627 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1630 static ULONG WINAPI
WebBrowserPriv2IE9_AddRef(IWebBrowserPriv2IE9
*iface
)
1632 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1633 return IUnknown_AddRef(This
->outer
);
1636 static ULONG WINAPI
WebBrowserPriv2IE9_Release(IWebBrowserPriv2IE9
*iface
)
1638 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1639 return IUnknown_Release(This
->outer
);
1642 static HRESULT WINAPI
WebBrowserPriv2IE9_NavigateWithBindCtx2(IWebBrowserPriv2IE9
*iface
, IUri
*uri
, VARIANT
*flags
,
1643 VARIANT
*target_frame
, VARIANT
*post_data
, VARIANT
*headers
, IBindCtx
*bind_ctx
, LPOLESTR url_fragment
, DWORD unused
)
1645 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1646 FIXME("(%p)->(%p %s %s %s %s %p %s)\n", This
, uri
, debugstr_variant(flags
), debugstr_variant(target_frame
),
1647 debugstr_variant(post_data
), debugstr_variant(headers
), bind_ctx
, debugstr_w(url_fragment
));
1651 static const IWebBrowserPriv2IE9Vtbl WebBrowserPriv2IE9Vtbl
= {
1652 WebBrowserPriv2IE9_QueryInterface
,
1653 WebBrowserPriv2IE9_AddRef
,
1654 WebBrowserPriv2IE9_Release
,
1655 WebBrowserPriv2IE9_NavigateWithBindCtx2
1658 BOOL
HlinkFrame_QI(HlinkFrame
*This
, REFIID riid
, void **ppv
)
1660 if(IsEqualGUID(&IID_IHlinkFrame
, riid
)) {
1661 TRACE("(%p)->(IID_IHlinkFrame %p)\n", This
, ppv
);
1662 *ppv
= &This
->IHlinkFrame_iface
;
1663 }else if(IsEqualGUID(&IID_ITargetFrame
, riid
)) {
1664 TRACE("(%p)->(IID_ITargetFrame %p)\n", This
, ppv
);
1665 *ppv
= &This
->ITargetFrame_iface
;
1666 }else if(IsEqualGUID(&IID_ITargetFrame2
, riid
)) {
1667 TRACE("(%p)->(IID_ITargetFrame2 %p)\n", This
, ppv
);
1668 *ppv
= &This
->ITargetFrame2_iface
;
1669 }else if(IsEqualGUID(&IID_ITargetFramePriv
, riid
)) {
1670 TRACE("(%p)->(IID_ITargetFramePriv %p)\n", This
, ppv
);
1671 *ppv
= &This
->ITargetFramePriv2_iface
;
1672 }else if(IsEqualGUID(&IID_ITargetFramePriv2
, riid
)) {
1673 TRACE("(%p)->(IID_ITargetFramePriv2 %p)\n", This
, ppv
);
1674 *ppv
= &This
->ITargetFramePriv2_iface
;
1675 }else if(IsEqualGUID(&IID_IWebBrowserPriv2IE9
, riid
)) {
1676 TRACE("(%p)->(IID_IWebBrowserPriv2IE9 %p)\n", This
, ppv
);
1677 *ppv
= &This
->IWebBrowserPriv2IE9_iface
;
1682 IUnknown_AddRef((IUnknown
*)*ppv
);
1686 void HlinkFrame_Init(HlinkFrame
*This
, IUnknown
*outer
, DocHost
*doc_host
)
1688 This
->IHlinkFrame_iface
.lpVtbl
= &HlinkFrameVtbl
;
1689 This
->ITargetFrame_iface
.lpVtbl
= &TargetFrameVtbl
;
1690 This
->ITargetFrame2_iface
.lpVtbl
= &TargetFrame2Vtbl
;
1691 This
->ITargetFramePriv2_iface
.lpVtbl
= &TargetFramePriv2Vtbl
;
1692 This
->IWebBrowserPriv2IE9_iface
.lpVtbl
= &WebBrowserPriv2IE9Vtbl
;
1694 This
->outer
= outer
;
1695 This
->doc_host
= doc_host
;