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
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(ieframe
);
34 static const WCHAR emptyW
[] = {0};
37 IBindStatusCallback IBindStatusCallback_iface
;
38 IHttpNegotiate IHttpNegotiate_iface
;
39 IHttpSecurity IHttpSecurity_iface
;
52 static void dump_BINDINFO(BINDINFO
*bi
)
54 static const char * const BINDINFOF_str
[] = {
56 "BINDINFOF_URLENCODESTGMEDDATA",
57 "BINDINFOF_URLENCODEDEXTRAINFO"
60 static const char * const BINDVERB_str
[] = {
74 " %ld, %08lx, %ld, %ld\n"
80 bi
->cbSize
, debugstr_w(bi
->szExtraInfo
),
81 bi
->stgmedData
.tymed
, bi
->stgmedData
.hGlobal
, bi
->stgmedData
.pUnkForRelease
,
82 bi
->grfBindInfoF
> BINDINFOF_URLENCODEDEXTRAINFO
83 ? "unknown" : BINDINFOF_str
[bi
->grfBindInfoF
],
84 bi
->dwBindVerb
> BINDVERB_CUSTOM
85 ? "unknown" : BINDVERB_str
[bi
->dwBindVerb
],
86 debugstr_w(bi
->szCustomVerb
),
87 bi
->cbstgmedData
, bi
->dwOptions
, bi
->dwOptionsFlags
, bi
->dwCodePage
,
88 bi
->securityAttributes
.nLength
,
89 bi
->securityAttributes
.lpSecurityDescriptor
,
90 bi
->securityAttributes
.bInheritHandle
,
91 debugstr_guid(&bi
->iid
),
92 bi
->pUnk
, bi
->dwReserved
96 static void set_status_text(BindStatusCallback
*This
, ULONG statuscode
, LPCWSTR str
)
99 DISPPARAMS dispparams
= {&arg
, NULL
, 1, 0};
100 WCHAR fmt
[IDS_STATUSFMT_MAXLEN
];
101 WCHAR buffer
[IDS_STATUSFMT_MAXLEN
+ INTERNET_MAX_URL_LENGTH
];
106 TRACE("(%p, %ld, %s)\n", This
, statuscode
, debugstr_w(str
));
108 if (statuscode
&& str
&& *str
) {
110 /* the format string must have one "%s" for the str */
111 LoadStringW(ieframe_instance
, IDS_STATUSFMT_FIRST
+ statuscode
, fmt
, IDS_STATUSFMT_MAXLEN
);
112 swprintf(buffer
, ARRAY_SIZE(buffer
), fmt
, str
);
115 V_VT(&arg
) = VT_BSTR
;
116 V_BSTR(&arg
) = str
? SysAllocString(buffer
) : SysAllocString(emptyW
);
117 TRACE("=> %s\n", debugstr_w(V_BSTR(&arg
)));
119 call_sink(This
->doc_host
->cps
.wbe2
, DISPID_STATUSTEXTCHANGE
, &dispparams
);
121 if(This
->doc_host
->frame
)
122 IOleInPlaceFrame_SetStatusText(This
->doc_host
->frame
, buffer
);
128 HRESULT
set_dochost_url(DocHost
*This
, const WCHAR
*url
)
133 new_url
= wcsdup(url
);
135 return E_OUTOFMEMORY
;
143 This
->container_vtbl
->set_url(This
, This
->url
);
147 void notify_download_state(DocHost
*dochost
, BOOL is_downloading
)
149 DISPPARAMS dwl_dp
= {NULL
};
150 TRACE("(%x)\n", is_downloading
);
151 dochost
->busy
= is_downloading
? VARIANT_TRUE
: VARIANT_FALSE
;
152 call_sink(dochost
->cps
.wbe2
, is_downloading
? DISPID_DOWNLOADBEGIN
: DISPID_DOWNLOADCOMPLETE
, &dwl_dp
);
155 static inline BindStatusCallback
*impl_from_IBindStatusCallback(IBindStatusCallback
*iface
)
157 return CONTAINING_RECORD(iface
, BindStatusCallback
, IBindStatusCallback_iface
);
160 static HRESULT WINAPI
BindStatusCallback_QueryInterface(IBindStatusCallback
*iface
,
161 REFIID riid
, void **ppv
)
163 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
165 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
166 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
167 *ppv
= &This
->IBindStatusCallback_iface
;
168 }else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
)) {
169 TRACE("(%p)->(IID_IBindStatusCallback %p)\n", This
, ppv
);
170 *ppv
= &This
->IBindStatusCallback_iface
;
171 }else if(IsEqualGUID(&IID_IHttpNegotiate
, riid
)) {
172 TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This
, ppv
);
173 *ppv
= &This
->IHttpNegotiate_iface
;
174 }else if(IsEqualGUID(&IID_IWindowForBindingUI
, riid
)) {
175 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This
, ppv
);
176 *ppv
= &This
->IHttpSecurity_iface
;
177 }else if(IsEqualGUID(&IID_IHttpSecurity
, riid
)) {
178 TRACE("(%p)->(IID_IHttpSecurity %p)\n", This
, ppv
);
179 *ppv
= &This
->IHttpSecurity_iface
;
182 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
183 return E_NOINTERFACE
;
186 IUnknown_AddRef((IUnknown
*)*ppv
);
190 static ULONG WINAPI
BindStatusCallback_AddRef(IBindStatusCallback
*iface
)
192 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
193 LONG ref
= InterlockedIncrement(&This
->ref
);
195 TRACE("(%p) ref=%ld\n", This
, ref
);
200 static ULONG WINAPI
BindStatusCallback_Release(IBindStatusCallback
*iface
)
202 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
203 LONG ref
= InterlockedDecrement(&This
->ref
);
205 TRACE("(%p) ref=%ld\n", This
, ref
);
209 IOleClientSite_Release(&This
->doc_host
->IOleClientSite_iface
);
211 IBinding_Release(This
->binding
);
213 GlobalFree(This
->post_data
);
214 SysFreeString(This
->headers
);
215 SysFreeString(This
->url
);
222 static HRESULT WINAPI
BindStatusCallback_OnStartBinding(IBindStatusCallback
*iface
,
223 DWORD dwReserved
, IBinding
*pbind
)
225 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
227 TRACE("(%p)->(%ld %p)\n", This
, dwReserved
, pbind
);
229 This
->binding
= pbind
;
230 IBinding_AddRef(This
->binding
);
235 static HRESULT WINAPI
BindStatusCallback_GetPriority(IBindStatusCallback
*iface
,
238 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
239 FIXME("(%p)->(%p)\n", This
, pnPriority
);
243 static HRESULT WINAPI
BindStatusCallback_OnLowResource(IBindStatusCallback
*iface
,
246 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
247 FIXME("(%p)->(%ld)\n", This
, reserved
);
251 static DWORD
get_http_status_code(IBinding
*binding
)
253 IWinInetHttpInfo
*http_info
;
254 DWORD status
, size
= sizeof(DWORD
);
257 hres
= IBinding_QueryInterface(binding
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
259 return HTTP_STATUS_OK
;
261 hres
= IWinInetHttpInfo_QueryInfo(http_info
, HTTP_QUERY_STATUS_CODE
|HTTP_QUERY_FLAG_NUMBER
,
262 &status
, &size
, NULL
, NULL
);
263 IWinInetHttpInfo_Release(http_info
);
266 return HTTP_STATUS_OK
;
270 static HRESULT WINAPI
BindStatusCallback_OnProgress(IBindStatusCallback
*iface
,
271 ULONG ulProgress
, ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
273 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
276 TRACE("(%p)->(%ld %ld %ld %s)\n", This
, ulProgress
, ulProgressMax
, ulStatusCode
,
277 debugstr_w(szStatusText
));
279 switch(ulStatusCode
) {
280 case BINDSTATUS_REDIRECTING
:
281 return set_dochost_url(This
->doc_host
, szStatusText
);
282 case BINDSTATUS_BEGINDOWNLOADDATA
:
283 set_status_text(This
, ulStatusCode
, szStatusText
);
284 status_code
= get_http_status_code(This
->binding
);
285 if(status_code
!= HTTP_STATUS_OK
)
286 handle_navigation_error(This
->doc_host
, status_code
, This
->url
, NULL
);
289 case BINDSTATUS_FINDINGRESOURCE
:
290 case BINDSTATUS_ENDDOWNLOADDATA
:
291 case BINDSTATUS_SENDINGREQUEST
:
292 set_status_text(This
, ulStatusCode
, szStatusText
);
295 case BINDSTATUS_CONNECTING
:
296 case BINDSTATUS_CACHEFILENAMEAVAILABLE
:
297 case BINDSTATUS_CLASSIDAVAILABLE
:
298 case BINDSTATUS_MIMETYPEAVAILABLE
:
299 case BINDSTATUS_BEGINSYNCOPERATION
:
300 case BINDSTATUS_ENDSYNCOPERATION
:
303 FIXME("status code %lu\n", ulStatusCode
);
309 void handle_navigation_error(DocHost
* doc_host
, HRESULT hres
, BSTR url
, IHTMLWindow2
*win2
)
311 VARIANT var_status_code
, var_frame_name
, var_url
;
312 DISPPARAMS dispparams
;
313 VARIANTARG params
[5];
314 VARIANT_BOOL cancel
= VARIANT_FALSE
;
316 dispparams
.cArgs
= 5;
317 dispparams
.cNamedArgs
= 0;
318 dispparams
.rgdispidNamedArgs
= NULL
;
319 dispparams
.rgvarg
= params
;
321 V_VT(params
) = VT_BOOL
|VT_BYREF
;
322 V_BOOLREF(params
) = &cancel
;
324 V_VT(params
+1) = VT_VARIANT
|VT_BYREF
;
325 V_VARIANTREF(params
+1) = &var_status_code
;
326 V_VT(&var_status_code
) = VT_I4
;
327 V_I4(&var_status_code
) = hres
;
329 V_VT(params
+2) = VT_VARIANT
|VT_BYREF
;
330 V_VARIANTREF(params
+2) = &var_frame_name
;
331 V_VT(&var_frame_name
) = VT_BSTR
;
333 hres
= IHTMLWindow2_get_name(win2
, &V_BSTR(&var_frame_name
));
335 V_BSTR(&var_frame_name
) = NULL
;
337 V_BSTR(&var_frame_name
) = NULL
;
339 V_VT(params
+3) = VT_VARIANT
|VT_BYREF
;
340 V_VARIANTREF(params
+3) = &var_url
;
341 V_VT(&var_url
) = VT_BSTR
;
342 V_BSTR(&var_url
) = url
;
344 V_VT(params
+4) = VT_DISPATCH
;
345 V_DISPATCH(params
+4) = (IDispatch
*)doc_host
->wb
;
347 call_sink(doc_host
->cps
.wbe2
, DISPID_NAVIGATEERROR
, &dispparams
);
348 SysFreeString(V_BSTR(&var_frame_name
));
351 FIXME("Navigate to error page\n");
354 static HRESULT WINAPI
BindStatusCallback_OnStopBinding(IBindStatusCallback
*iface
,
355 HRESULT hresult
, LPCWSTR szError
)
357 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
359 TRACE("(%p)->(%08lx %s)\n", This
, hresult
, debugstr_w(szError
));
361 set_status_text(This
, 0, emptyW
);
366 if(!This
->doc_host
->olecmd
)
367 notify_download_state(This
->doc_host
, FALSE
);
369 handle_navigation_error(This
->doc_host
, hresult
, This
->url
, NULL
);
371 IOleClientSite_Release(&This
->doc_host
->IOleClientSite_iface
);
372 This
->doc_host
= NULL
;
374 IBinding_Release(This
->binding
);
375 This
->binding
= NULL
;
380 static HRESULT WINAPI
BindStatusCallback_GetBindInfo(IBindStatusCallback
*iface
,
381 DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
383 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
385 TRACE("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
387 *grfBINDF
= BINDF_ASYNCHRONOUS
;
389 if(This
->post_data
) {
390 pbindinfo
->dwBindVerb
= BINDVERB_POST
;
392 pbindinfo
->stgmedData
.tymed
= TYMED_HGLOBAL
;
393 pbindinfo
->stgmedData
.hGlobal
= This
->post_data
;
394 pbindinfo
->cbstgmedData
= This
->post_data_len
;
395 pbindinfo
->stgmedData
.pUnkForRelease
= (IUnknown
*)&This
->IBindStatusCallback_iface
;
396 IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
402 static HRESULT WINAPI
BindStatusCallback_OnDataAvailable(IBindStatusCallback
*iface
,
403 DWORD grfBSCF
, DWORD dwSize
, FORMATETC
*pformatetc
, STGMEDIUM
*pstgmed
)
405 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
406 FIXME("(%p)->(%08lx %ld %p %p)\n", This
, grfBSCF
, dwSize
, pformatetc
, pstgmed
);
410 static HRESULT WINAPI
BindStatusCallback_OnObjectAvailable(IBindStatusCallback
*iface
,
411 REFIID riid
, IUnknown
*punk
)
413 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
415 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), punk
);
417 return dochost_object_available(This
->doc_host
, punk
);
420 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl
= {
421 BindStatusCallback_QueryInterface
,
422 BindStatusCallback_AddRef
,
423 BindStatusCallback_Release
,
424 BindStatusCallback_OnStartBinding
,
425 BindStatusCallback_GetPriority
,
426 BindStatusCallback_OnLowResource
,
427 BindStatusCallback_OnProgress
,
428 BindStatusCallback_OnStopBinding
,
429 BindStatusCallback_GetBindInfo
,
430 BindStatusCallback_OnDataAvailable
,
431 BindStatusCallback_OnObjectAvailable
434 static inline BindStatusCallback
*impl_from_IHttpNegotiate(IHttpNegotiate
*iface
)
436 return CONTAINING_RECORD(iface
, BindStatusCallback
, IHttpNegotiate_iface
);
439 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate
*iface
,
440 REFIID riid
, void **ppv
)
442 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
443 return IBindStatusCallback_QueryInterface(&This
->IBindStatusCallback_iface
, riid
, ppv
);
446 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate
*iface
)
448 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
449 return IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
452 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate
*iface
)
454 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
455 return IBindStatusCallback_Release(&This
->IBindStatusCallback_iface
);
458 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate
*iface
,
459 LPCWSTR szURL
, LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
461 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
463 TRACE("(%p)->(%s %s %ld %p)\n", This
, debugstr_w(szURL
), debugstr_w(szHeaders
),
464 dwReserved
, pszAdditionalHeaders
);
467 int size
= (lstrlenW(This
->headers
)+1)*sizeof(WCHAR
);
468 *pszAdditionalHeaders
= CoTaskMemAlloc(size
);
469 memcpy(*pszAdditionalHeaders
, This
->headers
, size
);
475 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate
*iface
,
476 DWORD dwResponseCode
, LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
,
477 LPWSTR
*pszAdditionalRequestHeaders
)
479 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
480 TRACE("(%p)->(%ld %s %s %p)\n", This
, dwResponseCode
, debugstr_w(szResponseHeaders
),
481 debugstr_w(szRequestHeaders
), pszAdditionalRequestHeaders
);
485 static const IHttpNegotiateVtbl HttpNegotiateVtbl
= {
486 HttpNegotiate_QueryInterface
,
487 HttpNegotiate_AddRef
,
488 HttpNegotiate_Release
,
489 HttpNegotiate_BeginningTransaction
,
490 HttpNegotiate_OnResponse
493 static inline BindStatusCallback
*impl_from_IHttpSecurity(IHttpSecurity
*iface
)
495 return CONTAINING_RECORD(iface
, BindStatusCallback
, IHttpSecurity_iface
);
498 static HRESULT WINAPI
HttpSecurity_QueryInterface(IHttpSecurity
*iface
, REFIID riid
, void **ppv
)
500 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
501 return IBindStatusCallback_QueryInterface(&This
->IBindStatusCallback_iface
, riid
, ppv
);
504 static ULONG WINAPI
HttpSecurity_AddRef(IHttpSecurity
*iface
)
506 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
507 return IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
510 static ULONG WINAPI
HttpSecurity_Release(IHttpSecurity
*iface
)
512 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
513 return IBindStatusCallback_Release(&This
->IBindStatusCallback_iface
);
516 static HRESULT WINAPI
HttpSecurity_GetWindow(IHttpSecurity
*iface
, REFGUID rguidReason
, HWND
*phwnd
)
518 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
520 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(rguidReason
), phwnd
);
525 *phwnd
= This
->doc_host
->frame_hwnd
;
529 static HRESULT WINAPI
HttpSecurity_OnSecurityProblem(IHttpSecurity
*iface
, DWORD dwProblem
)
531 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
532 FIXME("(%p)->(%lu)\n", This
, dwProblem
);
536 static const IHttpSecurityVtbl HttpSecurityVtbl
= {
537 HttpSecurity_QueryInterface
,
539 HttpSecurity_Release
,
540 HttpSecurity_GetWindow
,
541 HttpSecurity_OnSecurityProblem
544 static BindStatusCallback
*create_callback(DocHost
*doc_host
, LPCWSTR url
, PBYTE post_data
,
545 ULONG post_data_len
, LPCWSTR headers
)
547 BindStatusCallback
*ret
= malloc(sizeof(BindStatusCallback
));
549 ret
->IBindStatusCallback_iface
.lpVtbl
= &BindStatusCallbackVtbl
;
550 ret
->IHttpNegotiate_iface
.lpVtbl
= &HttpNegotiateVtbl
;
551 ret
->IHttpSecurity_iface
.lpVtbl
= &HttpSecurityVtbl
;
554 ret
->url
= SysAllocString(url
);
555 ret
->post_data
= NULL
;
556 ret
->post_data_len
= post_data_len
;
557 ret
->headers
= headers
? SysAllocString(headers
) : NULL
;
559 ret
->doc_host
= doc_host
;
560 IOleClientSite_AddRef(&doc_host
->IOleClientSite_iface
);
565 ret
->post_data
= GlobalAlloc(0, post_data_len
);
566 memcpy(ret
->post_data
, post_data
, post_data_len
);
572 static void on_before_navigate2(DocHost
*This
, LPCWSTR url
, SAFEARRAY
*post_data
, LPWSTR headers
, VARIANT_BOOL
*cancel
)
574 VARIANT var_url
, var_flags
, var_frame_name
, var_post_data
, var_post_data2
, var_headers
;
575 DISPPARAMS dispparams
;
576 VARIANTARG params
[7];
577 WCHAR file_path
[MAX_PATH
];
578 DWORD file_path_len
= ARRAY_SIZE(file_path
);
580 dispparams
.cArgs
= 7;
581 dispparams
.cNamedArgs
= 0;
582 dispparams
.rgdispidNamedArgs
= NULL
;
583 dispparams
.rgvarg
= params
;
585 V_VT(params
) = VT_BOOL
|VT_BYREF
;
586 V_BOOLREF(params
) = cancel
;
588 V_VT(params
+1) = (VT_BYREF
|VT_VARIANT
);
589 V_VARIANTREF(params
+1) = &var_headers
;
590 V_VT(&var_headers
) = VT_BSTR
;
591 V_BSTR(&var_headers
) = headers
;
593 V_VT(params
+2) = (VT_BYREF
|VT_VARIANT
);
594 V_VARIANTREF(params
+2) = &var_post_data2
;
595 V_VT(&var_post_data2
) = (VT_BYREF
|VT_VARIANT
);
596 V_VARIANTREF(&var_post_data2
) = &var_post_data
;
599 V_VT(&var_post_data
) = VT_UI1
|VT_ARRAY
;
600 V_ARRAY(&var_post_data
) = post_data
;
602 V_VT(&var_post_data
) = VT_EMPTY
;
605 V_VT(params
+3) = (VT_BYREF
|VT_VARIANT
);
606 V_VARIANTREF(params
+3) = &var_frame_name
;
607 V_VT(&var_frame_name
) = VT_BSTR
;
608 V_BSTR(&var_frame_name
) = NULL
;
610 V_VT(params
+4) = (VT_BYREF
|VT_VARIANT
);
611 V_VARIANTREF(params
+4) = &var_flags
;
612 V_VT(&var_flags
) = VT_I4
;
613 V_I4(&var_flags
) = 0;
615 V_VT(params
+5) = (VT_BYREF
|VT_VARIANT
);
616 V_VARIANTREF(params
+5) = &var_url
;
617 V_VT(&var_url
) = VT_BSTR
;
618 if(PathCreateFromUrlW(url
, file_path
, &file_path_len
, 0) == S_OK
)
619 V_BSTR(&var_url
) = SysAllocString(file_path
);
621 V_BSTR(&var_url
) = SysAllocString(url
);
623 V_VT(params
+6) = (VT_DISPATCH
);
624 V_DISPATCH(params
+6) = (IDispatch
*)This
->wb
;
626 call_sink(This
->cps
.wbe2
, DISPID_BEFORENAVIGATE2
, &dispparams
);
628 SysFreeString(V_BSTR(&var_url
));
631 /* FIXME: urlmon should handle it */
632 static BOOL
try_application_url(LPCWSTR url
)
634 SHELLEXECUTEINFOW exec_info
;
640 static const WCHAR wszURLProtocol
[] = {'U','R','L',' ','P','r','o','t','o','c','o','l',0};
642 hres
= CoInternetParseUrl(url
, PARSE_SCHEMA
, 0, app
, ARRAY_SIZE(app
), NULL
, 0);
646 res
= RegOpenKeyW(HKEY_CLASSES_ROOT
, app
, &hkey
);
647 if(res
!= ERROR_SUCCESS
)
650 res
= RegQueryValueExW(hkey
, wszURLProtocol
, NULL
, &type
, NULL
, NULL
);
652 if(res
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
655 TRACE("opening application %s\n", debugstr_w(app
));
657 memset(&exec_info
, 0, sizeof(exec_info
));
658 exec_info
.cbSize
= sizeof(exec_info
);
659 exec_info
.lpFile
= url
;
660 exec_info
.nShow
= SW_SHOW
;
662 return ShellExecuteExW(&exec_info
);
665 static HRESULT
create_moniker(LPCWSTR url
, IMoniker
**mon
)
667 WCHAR new_url
[INTERNET_MAX_URL_LENGTH
];
672 return CreateURLMoniker(NULL
, url
, mon
);
674 size
= ARRAY_SIZE(new_url
);
675 hres
= UrlApplySchemeW(url
, new_url
, &size
, URL_APPLY_GUESSSCHEME
| URL_APPLY_GUESSFILE
| URL_APPLY_DEFAULT
);
676 TRACE("was %s got %s\n", debugstr_w(url
), debugstr_w(new_url
));
678 WARN("UrlApplyScheme failed: %08lx\n", hres
);
682 return CreateURLMoniker(NULL
, new_url
, mon
);
685 static HRESULT
bind_to_object(DocHost
*This
, IMoniker
*mon
, LPCWSTR url
, IBindCtx
*bindctx
,
686 IBindStatusCallback
*callback
)
688 IUnknown
*unk
= NULL
;
693 IMoniker_AddRef(mon
);
695 hres
= create_moniker(url
, &mon
);
700 hres
= IMoniker_GetDisplayName(mon
, 0, NULL
, &display_name
);
702 FIXME("GetDisplayName failed: %08lx\n", hres
);
703 IMoniker_Release(mon
);
707 hres
= set_dochost_url(This
, display_name
);
708 CoTaskMemFree(display_name
);
710 IMoniker_Release(mon
);
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: %08lx\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: %08lx\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: %08lx\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
= calloc(1, 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 This
->busy
= VARIANT_FALSE
;
890 on_commandstate_change(This
, CSC_NAVIGATEBACK
, FALSE
);
891 on_commandstate_change(This
, CSC_NAVIGATEFORWARD
, FALSE
);
894 deactivate_document(This
);
896 CreateAsyncBindCtx(0, &bsc
->IBindStatusCallback_iface
, 0, &bindctx
);
899 IOleInPlaceFrame_EnableModeless(This
->frame
, FALSE
);
901 hres
= bind_to_object(This
, mon
, bsc
->url
, bindctx
, &bsc
->IBindStatusCallback_iface
);
904 IOleInPlaceFrame_EnableModeless(This
->frame
, TRUE
);
906 IBindCtx_Release(bindctx
);
912 task_header_t header
;
913 BindStatusCallback
*bsc
;
914 } task_navigate_bsc_t
;
916 static void navigate_bsc_task_destr(task_header_t
*t
)
918 task_navigate_bsc_t
*task
= (task_navigate_bsc_t
*)t
;
920 IBindStatusCallback_Release(&task
->bsc
->IBindStatusCallback_iface
);
924 static void navigate_bsc_proc(DocHost
*This
, task_header_t
*t
)
926 task_navigate_bsc_t
*task
= (task_navigate_bsc_t
*)t
;
929 create_doc_view_hwnd(This
);
931 navigate_bsc(This
, task
->bsc
, NULL
);
935 HRESULT
navigate_url(DocHost
*This
, LPCWSTR url
, const VARIANT
*Flags
,
936 const VARIANT
*TargetFrameName
, VARIANT
*PostData
, VARIANT
*Headers
)
938 SAFEARRAY
*post_array
= NULL
;
939 PBYTE post_data
= NULL
;
940 ULONG post_data_len
= 0;
941 LPWSTR headers
= NULL
;
944 TRACE("navigating to %s\n", debugstr_w(url
));
946 if((Flags
&& V_VT(Flags
) != VT_EMPTY
&& V_VT(Flags
) != VT_ERROR
)
947 || (TargetFrameName
&& V_VT(TargetFrameName
) != VT_EMPTY
&& V_VT(TargetFrameName
) != VT_ERROR
))
948 FIXME("Unsupported args (Flags %s; TargetFrameName %s)\n", debugstr_variant(Flags
), debugstr_variant(TargetFrameName
));
951 if(V_VT(PostData
) & VT_ARRAY
)
952 post_array
= V_ISBYREF(PostData
) ? *V_ARRAYREF(PostData
) : V_ARRAY(PostData
);
954 WARN("Invalid post data %s\n", debugstr_variant(PostData
));
959 SafeArrayAccessData(post_array
, (void**)&post_data
);
960 SafeArrayGetUBound(post_array
, 1, &elem_max
);
961 post_data_len
= (elem_max
+1) * SafeArrayGetElemsize(post_array
);
964 if(Headers
&& V_VT(Headers
) == VT_BSTR
) {
965 headers
= V_BSTR(Headers
);
966 TRACE("Headers: %s\n", debugstr_w(headers
));
969 set_doc_state(This
, READYSTATE_LOADING
);
970 This
->ready_state
= READYSTATE_LOADING
;
972 if(This
->doc_navigate
) {
973 WCHAR new_url
[INTERNET_MAX_URL_LENGTH
];
975 if(PathIsURLW(url
)) {
980 size
= ARRAY_SIZE(new_url
);
981 hres
= UrlApplySchemeW(url
, new_url
, &size
,
982 URL_APPLY_GUESSSCHEME
| URL_APPLY_GUESSFILE
| URL_APPLY_DEFAULT
);
984 WARN("UrlApplyScheme failed: %08lx\n", hres
);
989 hres
= async_doc_navigate(This
, *new_url
? new_url
: url
, headers
, post_data
,
990 post_data_len
, TRUE
);
992 task_navigate_bsc_t
*task
;
994 task
= malloc(sizeof(*task
));
995 task
->bsc
= create_callback(This
, url
, post_data
, post_data_len
, headers
);
996 push_dochost_task(This
, &task
->header
, navigate_bsc_proc
, navigate_bsc_task_destr
, This
->url
== NULL
);
1000 SafeArrayUnaccessData(post_array
);
1005 static HRESULT
navigate_hlink(DocHost
*This
, IMoniker
*mon
, IBindCtx
*bindctx
,
1006 IBindStatusCallback
*callback
)
1008 IHttpNegotiate
*http_negotiate
;
1009 BindStatusCallback
*bsc
;
1010 PBYTE post_data
= NULL
;
1011 ULONG post_data_len
= 0;
1012 LPWSTR headers
= NULL
, url
;
1019 hres
= IMoniker_GetDisplayName(mon
, 0, NULL
, &url
);
1021 FIXME("GetDisplayName failed: %08lx\n", hres
);
1023 hres
= IBindStatusCallback_QueryInterface(callback
, &IID_IHttpNegotiate
,
1024 (void**)&http_negotiate
);
1025 if(SUCCEEDED(hres
)) {
1026 static const WCHAR null_string
[] = {0};
1028 IHttpNegotiate_BeginningTransaction(http_negotiate
, null_string
, null_string
, 0,
1030 IHttpNegotiate_Release(http_negotiate
);
1033 memset(&bindinfo
, 0, sizeof(bindinfo
));
1034 bindinfo
.cbSize
= sizeof(bindinfo
);
1036 hres
= IBindStatusCallback_GetBindInfo(callback
, &bindf
, &bindinfo
);
1037 dump_BINDINFO(&bindinfo
);
1038 if(bindinfo
.dwBindVerb
== BINDVERB_POST
) {
1039 post_data_len
= bindinfo
.cbstgmedData
;
1041 post_data
= bindinfo
.stgmedData
.hGlobal
;
1044 if(This
->doc_navigate
) {
1045 hres
= async_doc_navigate(This
, url
, headers
, post_data
, post_data_len
, FALSE
);
1047 bsc
= create_callback(This
, url
, post_data
, post_data_len
, headers
);
1048 hres
= navigate_bsc(This
, bsc
, mon
);
1049 IBindStatusCallback_Release(&bsc
->IBindStatusCallback_iface
);
1053 CoTaskMemFree(headers
);
1054 ReleaseBindInfo(&bindinfo
);
1059 HRESULT
go_home(DocHost
*This
)
1062 DWORD res
, type
, size
;
1063 WCHAR wszPageName
[MAX_PATH
];
1064 static const WCHAR wszAboutBlank
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
1065 static const WCHAR wszStartPage
[] = {'S','t','a','r','t',' ','P','a','g','e',0};
1066 static const WCHAR wszSubKey
[] = {'S','o','f','t','w','a','r','e','\\',
1067 'M','i','c','r','o','s','o','f','t','\\',
1068 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
1071 res
= RegOpenKeyW(HKEY_CURRENT_USER
, wszSubKey
, &hkey
);
1072 if (res
!= ERROR_SUCCESS
)
1073 return navigate_url(This
, wszAboutBlank
, NULL
, NULL
, NULL
, NULL
);
1075 size
= sizeof(wszPageName
);
1076 res
= RegQueryValueExW(hkey
, wszStartPage
, NULL
, &type
, (LPBYTE
)wszPageName
, &size
);
1078 if (res
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
1079 return navigate_url(This
, wszAboutBlank
, NULL
, NULL
, NULL
, NULL
);
1081 return navigate_url(This
, wszPageName
, NULL
, NULL
, NULL
, NULL
);
1084 static HRESULT
navigate_history(DocHost
*This
, unsigned travellog_pos
)
1086 IPersistHistory
*persist_history
;
1087 travellog_entry_t
*entry
;
1091 if(!This
->doc_navigate
) {
1092 FIXME("unsupported doc_navigate FALSE\n");
1096 This
->travellog
.loading_pos
= travellog_pos
;
1097 entry
= This
->travellog
.log
+ This
->travellog
.loading_pos
;
1099 update_navigation_commands(This
);
1102 return async_doc_navigate(This
, entry
->url
, NULL
, NULL
, 0, FALSE
);
1104 hres
= IUnknown_QueryInterface(This
->document
, &IID_IPersistHistory
, (void**)&persist_history
);
1109 IStream_Seek(entry
->stream
, li
, STREAM_SEEK_SET
, NULL
);
1111 hres
= IPersistHistory_LoadHistory(persist_history
, entry
->stream
, NULL
);
1112 IPersistHistory_Release(persist_history
);
1116 HRESULT
go_back(DocHost
*This
)
1118 if(!This
->travellog
.position
) {
1119 WARN("No history available\n");
1123 return navigate_history(This
, This
->travellog
.position
-1);
1126 HRESULT
go_forward(DocHost
*This
)
1128 if(This
->travellog
.position
>= This
->travellog
.length
) {
1129 WARN("No history available\n");
1133 return navigate_history(This
, This
->travellog
.position
+1);
1136 HRESULT
get_location_url(DocHost
*This
, BSTR
*ret
)
1138 FIXME("semi-stub\n");
1140 *ret
= This
->url
? SysAllocString(This
->url
) : SysAllocStringLen(NULL
, 0);
1142 return E_OUTOFMEMORY
;
1144 return This
->url
? S_OK
: S_FALSE
;
1147 static inline HlinkFrame
*impl_from_IHlinkFrame(IHlinkFrame
*iface
)
1149 return CONTAINING_RECORD(iface
, HlinkFrame
, IHlinkFrame_iface
);
1152 static HRESULT WINAPI
HlinkFrame_QueryInterface(IHlinkFrame
*iface
, REFIID riid
, void **ppv
)
1154 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1155 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1158 static ULONG WINAPI
HlinkFrame_AddRef(IHlinkFrame
*iface
)
1160 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1161 return IUnknown_AddRef(This
->outer
);
1164 static ULONG WINAPI
HlinkFrame_Release(IHlinkFrame
*iface
)
1166 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1167 return IUnknown_Release(This
->outer
);
1170 static HRESULT WINAPI
HlinkFrame_SetBrowseContext(IHlinkFrame
*iface
,
1171 IHlinkBrowseContext
*pihlbc
)
1173 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1174 FIXME("(%p)->(%p)\n", This
, pihlbc
);
1178 static HRESULT WINAPI
HlinkFrame_GetBrowseContext(IHlinkFrame
*iface
,
1179 IHlinkBrowseContext
**ppihlbc
)
1181 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1182 FIXME("(%p)->(%p)\n", This
, ppihlbc
);
1186 static HRESULT WINAPI
HlinkFrame_Navigate(IHlinkFrame
*iface
, DWORD grfHLNF
, LPBC pbc
,
1187 IBindStatusCallback
*pibsc
, IHlink
*pihlNavigate
)
1189 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1191 LPWSTR location
= NULL
;
1193 TRACE("(%p)->(%08lx %p %p %p)\n", This
, grfHLNF
, pbc
, pibsc
, pihlNavigate
);
1196 FIXME("unsupported grfHLNF=%08lx\n", grfHLNF
);
1198 /* Windows calls GetTargetFrameName here. */
1200 IHlink_GetMonikerReference(pihlNavigate
, 1, &mon
, &location
);
1203 FIXME("location = %s\n", debugstr_w(location
));
1204 CoTaskMemFree(location
);
1207 /* Windows calls GetHlinkSite here */
1209 if(grfHLNF
& HLNF_OPENINNEWWINDOW
) {
1210 FIXME("Not supported HLNF_OPENINNEWWINDOW\n");
1214 return navigate_hlink(This
->doc_host
, mon
, pbc
, pibsc
);
1217 static HRESULT WINAPI
HlinkFrame_OnNavigate(IHlinkFrame
*iface
, DWORD grfHLNF
,
1218 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
, DWORD dwreserved
)
1220 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1221 FIXME("(%p)->(%08lx %p %s %s %ld)\n", This
, grfHLNF
, pimkTarget
, debugstr_w(pwzLocation
),
1222 debugstr_w(pwzFriendlyName
), dwreserved
);
1226 static HRESULT WINAPI
HlinkFrame_UpdateHlink(IHlinkFrame
*iface
, ULONG uHLID
,
1227 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
)
1229 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1230 FIXME("(%p)->(%lu %p %s %s)\n", This
, uHLID
, pimkTarget
, debugstr_w(pwzLocation
),
1231 debugstr_w(pwzFriendlyName
));
1235 static const IHlinkFrameVtbl HlinkFrameVtbl
= {
1236 HlinkFrame_QueryInterface
,
1239 HlinkFrame_SetBrowseContext
,
1240 HlinkFrame_GetBrowseContext
,
1241 HlinkFrame_Navigate
,
1242 HlinkFrame_OnNavigate
,
1243 HlinkFrame_UpdateHlink
1246 static inline HlinkFrame
*impl_from_ITargetFrame(ITargetFrame
*iface
)
1248 return CONTAINING_RECORD(iface
, HlinkFrame
, ITargetFrame_iface
);
1251 static HRESULT WINAPI
TargetFrame_QueryInterface(ITargetFrame
*iface
, REFIID riid
, void **ppv
)
1253 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1254 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1257 static ULONG WINAPI
TargetFrame_AddRef(ITargetFrame
*iface
)
1259 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1260 return IUnknown_AddRef(This
->outer
);
1263 static ULONG WINAPI
TargetFrame_Release(ITargetFrame
*iface
)
1265 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1266 return IUnknown_Release(This
->outer
);
1269 static HRESULT WINAPI
TargetFrame_SetFrameName(ITargetFrame
*iface
, LPCWSTR pszFrameName
)
1271 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1272 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameName
));
1276 static HRESULT WINAPI
TargetFrame_GetFrameName(ITargetFrame
*iface
, LPWSTR
*ppszFrameName
)
1278 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1279 FIXME("(%p)->(%p)\n", This
, ppszFrameName
);
1283 static HRESULT WINAPI
TargetFrame_GetParentFrame(ITargetFrame
*iface
, IUnknown
**ppunkParent
)
1285 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1286 FIXME("(%p)->(%p)\n", This
, ppunkParent
);
1290 static HRESULT WINAPI
TargetFrame_FindFrame(ITargetFrame
*iface
, LPCWSTR pszTargetName
,
1291 IUnknown
*ppunkContextFrame
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1293 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1294 FIXME("(%p)->(%s %p %lx %p)\n", This
, debugstr_w(pszTargetName
),
1295 ppunkContextFrame
, dwFlags
, ppunkTargetFrame
);
1299 static HRESULT WINAPI
TargetFrame_SetFrameSrc(ITargetFrame
*iface
, LPCWSTR pszFrameSrc
)
1301 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1302 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameSrc
));
1306 static HRESULT WINAPI
TargetFrame_GetFrameSrc(ITargetFrame
*iface
, LPWSTR
*ppszFrameSrc
)
1308 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1309 FIXME("(%p)->(%p)\n", This
, ppszFrameSrc
);
1313 static HRESULT WINAPI
TargetFrame_GetFramesContainer(ITargetFrame
*iface
, IOleContainer
**ppContainer
)
1315 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1316 FIXME("(%p)->(%p)\n", This
, ppContainer
);
1320 static HRESULT WINAPI
TargetFrame_SetFrameOptions(ITargetFrame
*iface
, DWORD dwFlags
)
1322 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1323 FIXME("(%p)->(%lx)\n", This
, dwFlags
);
1327 static HRESULT WINAPI
TargetFrame_GetFrameOptions(ITargetFrame
*iface
, DWORD
*pdwFlags
)
1329 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1330 FIXME("(%p)->(%p)\n", This
, pdwFlags
);
1334 static HRESULT WINAPI
TargetFrame_SetFrameMargins(ITargetFrame
*iface
, DWORD dwWidth
, DWORD dwHeight
)
1336 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1337 FIXME("(%p)->(%ld %ld)\n", This
, dwWidth
, dwHeight
);
1341 static HRESULT WINAPI
TargetFrame_GetFrameMargins(ITargetFrame
*iface
, DWORD
*pdwWidth
, DWORD
*pdwHeight
)
1343 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1344 FIXME("(%p)->(%p %p)\n", This
, pdwWidth
, pdwHeight
);
1348 static HRESULT WINAPI
TargetFrame_RemoteNavigate(ITargetFrame
*iface
, ULONG cLength
, ULONG
*pulData
)
1350 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1351 FIXME("(%p)->(%lu %p)\n", This
, cLength
, pulData
);
1355 static HRESULT WINAPI
TargetFrame_OnChildFrameActivate(ITargetFrame
*iface
, IUnknown
*pUnkChildFrame
)
1357 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1358 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1362 static HRESULT WINAPI
TargetFrame_OnChildFrameDeactivate(ITargetFrame
*iface
, IUnknown
*pUnkChildFrame
)
1364 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1365 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1369 static const ITargetFrameVtbl TargetFrameVtbl
= {
1370 TargetFrame_QueryInterface
,
1372 TargetFrame_Release
,
1373 TargetFrame_SetFrameName
,
1374 TargetFrame_GetFrameName
,
1375 TargetFrame_GetParentFrame
,
1376 TargetFrame_FindFrame
,
1377 TargetFrame_SetFrameSrc
,
1378 TargetFrame_GetFrameSrc
,
1379 TargetFrame_GetFramesContainer
,
1380 TargetFrame_SetFrameOptions
,
1381 TargetFrame_GetFrameOptions
,
1382 TargetFrame_SetFrameMargins
,
1383 TargetFrame_GetFrameMargins
,
1384 TargetFrame_RemoteNavigate
,
1385 TargetFrame_OnChildFrameActivate
,
1386 TargetFrame_OnChildFrameDeactivate
1389 static inline HlinkFrame
*impl_from_ITargetFrame2(ITargetFrame2
*iface
)
1391 return CONTAINING_RECORD(iface
, HlinkFrame
, ITargetFrame2_iface
);
1394 static HRESULT WINAPI
TargetFrame2_QueryInterface(ITargetFrame2
*iface
, REFIID riid
, void **ppv
)
1396 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1397 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1400 static ULONG WINAPI
TargetFrame2_AddRef(ITargetFrame2
*iface
)
1402 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1403 return IUnknown_AddRef(This
->outer
);
1406 static ULONG WINAPI
TargetFrame2_Release(ITargetFrame2
*iface
)
1408 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1409 return IUnknown_Release(This
->outer
);
1412 static HRESULT WINAPI
TargetFrame2_SetFrameName(ITargetFrame2
*iface
, LPCWSTR pszFrameName
)
1414 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1415 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameName
));
1419 static HRESULT WINAPI
TargetFrame2_GetFrameName(ITargetFrame2
*iface
, LPWSTR
*ppszFrameName
)
1421 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1422 FIXME("(%p)->(%p)\n", This
, ppszFrameName
);
1426 static HRESULT WINAPI
TargetFrame2_GetParentFrame(ITargetFrame2
*iface
, IUnknown
**ppunkParent
)
1428 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1429 FIXME("(%p)->(%p)\n", This
, ppunkParent
);
1433 static HRESULT WINAPI
TargetFrame2_SetFrameSrc(ITargetFrame2
*iface
, LPCWSTR pszFrameSrc
)
1435 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1436 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameSrc
));
1440 static HRESULT WINAPI
TargetFrame2_GetFrameSrc(ITargetFrame2
*iface
, LPWSTR
*ppszFrameSrc
)
1442 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1443 FIXME("(%p)->()\n", This
);
1447 static HRESULT WINAPI
TargetFrame2_GetFramesContainer(ITargetFrame2
*iface
, IOleContainer
**ppContainer
)
1449 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1450 FIXME("(%p)->(%p)\n", This
, ppContainer
);
1454 static HRESULT WINAPI
TargetFrame2_SetFrameOptions(ITargetFrame2
*iface
, DWORD dwFlags
)
1456 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1457 FIXME("(%p)->(%lx)\n", This
, dwFlags
);
1461 static HRESULT WINAPI
TargetFrame2_GetFrameOptions(ITargetFrame2
*iface
, DWORD
*pdwFlags
)
1463 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1464 FIXME("(%p)->(%p)\n", This
, pdwFlags
);
1468 static HRESULT WINAPI
TargetFrame2_SetFrameMargins(ITargetFrame2
*iface
, DWORD dwWidth
, DWORD dwHeight
)
1470 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1471 FIXME("(%p)->(%ld %ld)\n", This
, dwWidth
, dwHeight
);
1475 static HRESULT WINAPI
TargetFrame2_GetFrameMargins(ITargetFrame2
*iface
, DWORD
*pdwWidth
, DWORD
*pdwHeight
)
1477 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1478 FIXME("(%p)->(%p %p)\n", This
, pdwWidth
, pdwHeight
);
1482 static HRESULT WINAPI
TargetFrame2_FindFrame(ITargetFrame2
*iface
, LPCWSTR pszTargetName
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1484 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1485 FIXME("(%p)->(%s %lx %p)\n", This
, debugstr_w(pszTargetName
), dwFlags
, ppunkTargetFrame
);
1489 static HRESULT WINAPI
TargetFrame2_GetTargetAlias(ITargetFrame2
*iface
, LPCWSTR pszTargetName
, LPWSTR
*ppszTargetAlias
)
1491 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1492 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(pszTargetName
), ppszTargetAlias
);
1496 static const ITargetFrame2Vtbl TargetFrame2Vtbl
= {
1497 TargetFrame2_QueryInterface
,
1498 TargetFrame2_AddRef
,
1499 TargetFrame2_Release
,
1500 TargetFrame2_SetFrameName
,
1501 TargetFrame2_GetFrameName
,
1502 TargetFrame2_GetParentFrame
,
1503 TargetFrame2_SetFrameSrc
,
1504 TargetFrame2_GetFrameSrc
,
1505 TargetFrame2_GetFramesContainer
,
1506 TargetFrame2_SetFrameOptions
,
1507 TargetFrame2_GetFrameOptions
,
1508 TargetFrame2_SetFrameMargins
,
1509 TargetFrame2_GetFrameMargins
,
1510 TargetFrame2_FindFrame
,
1511 TargetFrame2_GetTargetAlias
1514 static inline HlinkFrame
*impl_from_ITargetFramePriv2(ITargetFramePriv2
*iface
)
1516 return CONTAINING_RECORD(iface
, HlinkFrame
, ITargetFramePriv2_iface
);
1519 static HRESULT WINAPI
TargetFramePriv2_QueryInterface(ITargetFramePriv2
*iface
, REFIID riid
, void **ppv
)
1521 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1522 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1525 static ULONG WINAPI
TargetFramePriv2_AddRef(ITargetFramePriv2
*iface
)
1527 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1528 return IUnknown_AddRef(This
->outer
);
1531 static ULONG WINAPI
TargetFramePriv2_Release(ITargetFramePriv2
*iface
)
1533 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1534 return IUnknown_Release(This
->outer
);
1537 static HRESULT WINAPI
TargetFramePriv2_FindFrameDownwards(ITargetFramePriv2
*iface
,
1538 LPCWSTR pszTargetName
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1540 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1541 FIXME("(%p)->(%s %lx %p)\n", This
, debugstr_w(pszTargetName
), dwFlags
, ppunkTargetFrame
);
1545 static HRESULT WINAPI
TargetFramePriv2_FindFrameInContext(ITargetFramePriv2
*iface
,
1546 LPCWSTR pszTargetName
, IUnknown
*punkContextFrame
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1548 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1549 FIXME("(%p)->(%s %p %lx %p)\n", This
, debugstr_w(pszTargetName
), punkContextFrame
, dwFlags
, ppunkTargetFrame
);
1553 static HRESULT WINAPI
TargetFramePriv2_OnChildFrameActivate(ITargetFramePriv2
*iface
, IUnknown
*pUnkChildFrame
)
1555 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1556 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1560 static HRESULT WINAPI
TargetFramePriv2_OnChildFrameDeactivate(ITargetFramePriv2
*iface
, IUnknown
*pUnkChildFrame
)
1562 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1563 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1567 static HRESULT WINAPI
TargetFramePriv2_NavigateHack(ITargetFramePriv2
*iface
, DWORD grfHLNF
, LPBC pbc
,
1568 IBindStatusCallback
*pibsc
, LPCWSTR pszTargetName
, LPCWSTR pszUrl
, LPCWSTR pszLocation
)
1570 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1571 FIXME("(%p)->(%lx %p %p %s %s %s)\n", This
, grfHLNF
, pbc
, pibsc
, debugstr_w(pszTargetName
),
1572 debugstr_w(pszUrl
), debugstr_w(pszLocation
));
1576 static HRESULT WINAPI
TargetFramePriv2_FindBrowserByIndex(ITargetFramePriv2
*iface
, DWORD dwID
, IUnknown
**ppunkBrowser
)
1578 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1579 FIXME("(%p)->(%ld %p)\n", This
, dwID
, ppunkBrowser
);
1583 static HRESULT WINAPI
TargetFramePriv2_AggregatedNavigation2(ITargetFramePriv2
*iface
, DWORD grfHLNF
, LPBC pbc
,
1584 IBindStatusCallback
*pibsc
, LPCWSTR pszTargetName
, IUri
*pUri
, LPCWSTR pszLocation
)
1586 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1590 TRACE("(%p)->(%lx %p %p %s %p %s)\n", This
, grfHLNF
, pbc
, pibsc
, debugstr_w(pszTargetName
),
1591 pUri
, debugstr_w(pszLocation
));
1594 * NOTE: This is an undocumented function. It seems to be working the way it's implemented,
1595 * but I couldn't get its tests working. It's used by mshtml to load content in a new
1596 * instance of browser.
1599 hres
= CreateURLMonikerEx2(NULL
, pUri
, &mon
, 0);
1603 hres
= navigate_hlink(This
->doc_host
, mon
, pbc
, pibsc
);
1604 IMoniker_Release(mon
);
1608 static const ITargetFramePriv2Vtbl TargetFramePriv2Vtbl
= {
1609 TargetFramePriv2_QueryInterface
,
1610 TargetFramePriv2_AddRef
,
1611 TargetFramePriv2_Release
,
1612 TargetFramePriv2_FindFrameDownwards
,
1613 TargetFramePriv2_FindFrameInContext
,
1614 TargetFramePriv2_OnChildFrameActivate
,
1615 TargetFramePriv2_OnChildFrameDeactivate
,
1616 TargetFramePriv2_NavigateHack
,
1617 TargetFramePriv2_FindBrowserByIndex
,
1618 TargetFramePriv2_AggregatedNavigation2
1621 static inline HlinkFrame
*impl_from_IWebBrowserPriv2IE9(IWebBrowserPriv2IE9
*iface
)
1623 return CONTAINING_RECORD(iface
, HlinkFrame
, IWebBrowserPriv2IE9_iface
);
1626 static HRESULT WINAPI
WebBrowserPriv2IE9_QueryInterface(IWebBrowserPriv2IE9
*iface
, REFIID riid
, void **ppv
)
1628 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1629 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1632 static ULONG WINAPI
WebBrowserPriv2IE9_AddRef(IWebBrowserPriv2IE9
*iface
)
1634 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1635 return IUnknown_AddRef(This
->outer
);
1638 static ULONG WINAPI
WebBrowserPriv2IE9_Release(IWebBrowserPriv2IE9
*iface
)
1640 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1641 return IUnknown_Release(This
->outer
);
1644 static HRESULT WINAPI
WebBrowserPriv2IE9_NavigateWithBindCtx2(IWebBrowserPriv2IE9
*iface
, IUri
*uri
, VARIANT
*flags
,
1645 VARIANT
*target_frame
, VARIANT
*post_data
, VARIANT
*headers
, IBindCtx
*bind_ctx
, LPOLESTR url_fragment
, DWORD unused
)
1647 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1648 FIXME("(%p)->(%p %s %s %s %s %p %s)\n", This
, uri
, debugstr_variant(flags
), debugstr_variant(target_frame
),
1649 debugstr_variant(post_data
), debugstr_variant(headers
), bind_ctx
, debugstr_w(url_fragment
));
1653 static const IWebBrowserPriv2IE9Vtbl WebBrowserPriv2IE9Vtbl
= {
1654 WebBrowserPriv2IE9_QueryInterface
,
1655 WebBrowserPriv2IE9_AddRef
,
1656 WebBrowserPriv2IE9_Release
,
1657 WebBrowserPriv2IE9_NavigateWithBindCtx2
1660 BOOL
HlinkFrame_QI(HlinkFrame
*This
, REFIID riid
, void **ppv
)
1662 if(IsEqualGUID(&IID_IHlinkFrame
, riid
)) {
1663 TRACE("(%p)->(IID_IHlinkFrame %p)\n", This
, ppv
);
1664 *ppv
= &This
->IHlinkFrame_iface
;
1665 }else if(IsEqualGUID(&IID_ITargetFrame
, riid
)) {
1666 TRACE("(%p)->(IID_ITargetFrame %p)\n", This
, ppv
);
1667 *ppv
= &This
->ITargetFrame_iface
;
1668 }else if(IsEqualGUID(&IID_ITargetFrame2
, riid
)) {
1669 TRACE("(%p)->(IID_ITargetFrame2 %p)\n", This
, ppv
);
1670 *ppv
= &This
->ITargetFrame2_iface
;
1671 }else if(IsEqualGUID(&IID_ITargetFramePriv
, riid
)) {
1672 TRACE("(%p)->(IID_ITargetFramePriv %p)\n", This
, ppv
);
1673 *ppv
= &This
->ITargetFramePriv2_iface
;
1674 }else if(IsEqualGUID(&IID_ITargetFramePriv2
, riid
)) {
1675 TRACE("(%p)->(IID_ITargetFramePriv2 %p)\n", This
, ppv
);
1676 *ppv
= &This
->ITargetFramePriv2_iface
;
1677 }else if(IsEqualGUID(&IID_IWebBrowserPriv2IE9
, riid
)) {
1678 TRACE("(%p)->(IID_IWebBrowserPriv2IE9 %p)\n", This
, ppv
);
1679 *ppv
= &This
->IWebBrowserPriv2IE9_iface
;
1684 IUnknown_AddRef((IUnknown
*)*ppv
);
1688 void HlinkFrame_Init(HlinkFrame
*This
, IUnknown
*outer
, DocHost
*doc_host
)
1690 This
->IHlinkFrame_iface
.lpVtbl
= &HlinkFrameVtbl
;
1691 This
->ITargetFrame_iface
.lpVtbl
= &TargetFrameVtbl
;
1692 This
->ITargetFrame2_iface
.lpVtbl
= &TargetFrame2Vtbl
;
1693 This
->ITargetFramePriv2_iface
.lpVtbl
= &TargetFramePriv2Vtbl
;
1694 This
->IWebBrowserPriv2IE9_iface
.lpVtbl
= &WebBrowserPriv2IE9Vtbl
;
1696 This
->outer
= outer
;
1697 This
->doc_host
= doc_host
;