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
[] = {
76 " %ld, %08lx, %ld, %ld\n"
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, %ld, %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 swprintf(buffer
, ARRAY_SIZE(buffer
), 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
= wcsdup(url
);
137 return E_OUTOFMEMORY
;
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 dochost
->busy
= is_downloading
? VARIANT_TRUE
: VARIANT_FALSE
;
154 call_sink(dochost
->cps
.wbe2
, is_downloading
? DISPID_DOWNLOADBEGIN
: DISPID_DOWNLOADCOMPLETE
, &dwl_dp
);
157 static inline BindStatusCallback
*impl_from_IBindStatusCallback(IBindStatusCallback
*iface
)
159 return CONTAINING_RECORD(iface
, BindStatusCallback
, IBindStatusCallback_iface
);
162 static HRESULT WINAPI
BindStatusCallback_QueryInterface(IBindStatusCallback
*iface
,
163 REFIID riid
, void **ppv
)
165 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
167 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
168 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
169 *ppv
= &This
->IBindStatusCallback_iface
;
170 }else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
)) {
171 TRACE("(%p)->(IID_IBindStatusCallback %p)\n", This
, ppv
);
172 *ppv
= &This
->IBindStatusCallback_iface
;
173 }else if(IsEqualGUID(&IID_IHttpNegotiate
, riid
)) {
174 TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This
, ppv
);
175 *ppv
= &This
->IHttpNegotiate_iface
;
176 }else if(IsEqualGUID(&IID_IWindowForBindingUI
, riid
)) {
177 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This
, ppv
);
178 *ppv
= &This
->IHttpSecurity_iface
;
179 }else if(IsEqualGUID(&IID_IHttpSecurity
, riid
)) {
180 TRACE("(%p)->(IID_IHttpSecurity %p)\n", This
, ppv
);
181 *ppv
= &This
->IHttpSecurity_iface
;
184 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
185 return E_NOINTERFACE
;
188 IUnknown_AddRef((IUnknown
*)*ppv
);
192 static ULONG WINAPI
BindStatusCallback_AddRef(IBindStatusCallback
*iface
)
194 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
195 LONG ref
= InterlockedIncrement(&This
->ref
);
197 TRACE("(%p) ref=%ld\n", This
, ref
);
202 static ULONG WINAPI
BindStatusCallback_Release(IBindStatusCallback
*iface
)
204 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
205 LONG ref
= InterlockedDecrement(&This
->ref
);
207 TRACE("(%p) ref=%ld\n", This
, ref
);
211 IOleClientSite_Release(&This
->doc_host
->IOleClientSite_iface
);
213 IBinding_Release(This
->binding
);
215 GlobalFree(This
->post_data
);
216 SysFreeString(This
->headers
);
217 SysFreeString(This
->url
);
224 static HRESULT WINAPI
BindStatusCallback_OnStartBinding(IBindStatusCallback
*iface
,
225 DWORD dwReserved
, IBinding
*pbind
)
227 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
229 TRACE("(%p)->(%ld %p)\n", This
, dwReserved
, pbind
);
231 This
->binding
= pbind
;
232 IBinding_AddRef(This
->binding
);
237 static HRESULT WINAPI
BindStatusCallback_GetPriority(IBindStatusCallback
*iface
,
240 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
241 FIXME("(%p)->(%p)\n", This
, pnPriority
);
245 static HRESULT WINAPI
BindStatusCallback_OnLowResource(IBindStatusCallback
*iface
,
248 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
249 FIXME("(%p)->(%ld)\n", This
, reserved
);
253 static DWORD
get_http_status_code(IBinding
*binding
)
255 IWinInetHttpInfo
*http_info
;
256 DWORD status
, size
= sizeof(DWORD
);
259 hres
= IBinding_QueryInterface(binding
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
261 return HTTP_STATUS_OK
;
263 hres
= IWinInetHttpInfo_QueryInfo(http_info
, HTTP_QUERY_STATUS_CODE
|HTTP_QUERY_FLAG_NUMBER
,
264 &status
, &size
, NULL
, NULL
);
265 IWinInetHttpInfo_Release(http_info
);
268 return HTTP_STATUS_OK
;
272 static HRESULT WINAPI
BindStatusCallback_OnProgress(IBindStatusCallback
*iface
,
273 ULONG ulProgress
, ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
275 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
278 TRACE("(%p)->(%ld %ld %ld %s)\n", This
, ulProgress
, ulProgressMax
, ulStatusCode
,
279 debugstr_w(szStatusText
));
281 switch(ulStatusCode
) {
282 case BINDSTATUS_REDIRECTING
:
283 return set_dochost_url(This
->doc_host
, szStatusText
);
284 case BINDSTATUS_BEGINDOWNLOADDATA
:
285 set_status_text(This
, ulStatusCode
, szStatusText
);
286 status_code
= get_http_status_code(This
->binding
);
287 if(status_code
!= HTTP_STATUS_OK
)
288 handle_navigation_error(This
->doc_host
, status_code
, This
->url
, NULL
);
291 case BINDSTATUS_FINDINGRESOURCE
:
292 case BINDSTATUS_ENDDOWNLOADDATA
:
293 case BINDSTATUS_SENDINGREQUEST
:
294 set_status_text(This
, ulStatusCode
, szStatusText
);
297 case BINDSTATUS_CONNECTING
:
298 case BINDSTATUS_CACHEFILENAMEAVAILABLE
:
299 case BINDSTATUS_CLASSIDAVAILABLE
:
300 case BINDSTATUS_MIMETYPEAVAILABLE
:
301 case BINDSTATUS_BEGINSYNCOPERATION
:
302 case BINDSTATUS_ENDSYNCOPERATION
:
305 FIXME("status code %lu\n", ulStatusCode
);
311 void handle_navigation_error(DocHost
* doc_host
, HRESULT hres
, BSTR url
, IHTMLWindow2
*win2
)
313 VARIANT var_status_code
, var_frame_name
, var_url
;
314 DISPPARAMS dispparams
;
315 VARIANTARG params
[5];
316 VARIANT_BOOL cancel
= VARIANT_FALSE
;
318 dispparams
.cArgs
= 5;
319 dispparams
.cNamedArgs
= 0;
320 dispparams
.rgdispidNamedArgs
= NULL
;
321 dispparams
.rgvarg
= params
;
323 V_VT(params
) = VT_BOOL
|VT_BYREF
;
324 V_BOOLREF(params
) = &cancel
;
326 V_VT(params
+1) = VT_VARIANT
|VT_BYREF
;
327 V_VARIANTREF(params
+1) = &var_status_code
;
328 V_VT(&var_status_code
) = VT_I4
;
329 V_I4(&var_status_code
) = hres
;
331 V_VT(params
+2) = VT_VARIANT
|VT_BYREF
;
332 V_VARIANTREF(params
+2) = &var_frame_name
;
333 V_VT(&var_frame_name
) = VT_BSTR
;
335 hres
= IHTMLWindow2_get_name(win2
, &V_BSTR(&var_frame_name
));
337 V_BSTR(&var_frame_name
) = NULL
;
339 V_BSTR(&var_frame_name
) = NULL
;
341 V_VT(params
+3) = VT_VARIANT
|VT_BYREF
;
342 V_VARIANTREF(params
+3) = &var_url
;
343 V_VT(&var_url
) = VT_BSTR
;
344 V_BSTR(&var_url
) = url
;
346 V_VT(params
+4) = VT_DISPATCH
;
347 V_DISPATCH(params
+4) = (IDispatch
*)doc_host
->wb
;
349 call_sink(doc_host
->cps
.wbe2
, DISPID_NAVIGATEERROR
, &dispparams
);
350 SysFreeString(V_BSTR(&var_frame_name
));
353 FIXME("Navigate to error page\n");
356 static HRESULT WINAPI
BindStatusCallback_OnStopBinding(IBindStatusCallback
*iface
,
357 HRESULT hresult
, LPCWSTR szError
)
359 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
361 TRACE("(%p)->(%08lx %s)\n", This
, hresult
, debugstr_w(szError
));
363 set_status_text(This
, 0, emptyW
);
368 if(!This
->doc_host
->olecmd
)
369 notify_download_state(This
->doc_host
, FALSE
);
371 handle_navigation_error(This
->doc_host
, hresult
, This
->url
, NULL
);
373 IOleClientSite_Release(&This
->doc_host
->IOleClientSite_iface
);
374 This
->doc_host
= NULL
;
376 IBinding_Release(This
->binding
);
377 This
->binding
= NULL
;
382 static HRESULT WINAPI
BindStatusCallback_GetBindInfo(IBindStatusCallback
*iface
,
383 DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
385 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
387 TRACE("(%p)->(%p %p)\n", This
, grfBINDF
, pbindinfo
);
389 *grfBINDF
= BINDF_ASYNCHRONOUS
;
391 if(This
->post_data
) {
392 pbindinfo
->dwBindVerb
= BINDVERB_POST
;
394 pbindinfo
->stgmedData
.tymed
= TYMED_HGLOBAL
;
395 pbindinfo
->stgmedData
.u
.hGlobal
= This
->post_data
;
396 pbindinfo
->cbstgmedData
= This
->post_data_len
;
397 pbindinfo
->stgmedData
.pUnkForRelease
= (IUnknown
*)&This
->IBindStatusCallback_iface
;
398 IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
404 static HRESULT WINAPI
BindStatusCallback_OnDataAvailable(IBindStatusCallback
*iface
,
405 DWORD grfBSCF
, DWORD dwSize
, FORMATETC
*pformatetc
, STGMEDIUM
*pstgmed
)
407 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
408 FIXME("(%p)->(%08lx %ld %p %p)\n", This
, grfBSCF
, dwSize
, pformatetc
, pstgmed
);
412 static HRESULT WINAPI
BindStatusCallback_OnObjectAvailable(IBindStatusCallback
*iface
,
413 REFIID riid
, IUnknown
*punk
)
415 BindStatusCallback
*This
= impl_from_IBindStatusCallback(iface
);
417 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), punk
);
419 return dochost_object_available(This
->doc_host
, punk
);
422 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl
= {
423 BindStatusCallback_QueryInterface
,
424 BindStatusCallback_AddRef
,
425 BindStatusCallback_Release
,
426 BindStatusCallback_OnStartBinding
,
427 BindStatusCallback_GetPriority
,
428 BindStatusCallback_OnLowResource
,
429 BindStatusCallback_OnProgress
,
430 BindStatusCallback_OnStopBinding
,
431 BindStatusCallback_GetBindInfo
,
432 BindStatusCallback_OnDataAvailable
,
433 BindStatusCallback_OnObjectAvailable
436 static inline BindStatusCallback
*impl_from_IHttpNegotiate(IHttpNegotiate
*iface
)
438 return CONTAINING_RECORD(iface
, BindStatusCallback
, IHttpNegotiate_iface
);
441 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate
*iface
,
442 REFIID riid
, void **ppv
)
444 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
445 return IBindStatusCallback_QueryInterface(&This
->IBindStatusCallback_iface
, riid
, ppv
);
448 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate
*iface
)
450 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
451 return IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
454 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate
*iface
)
456 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
457 return IBindStatusCallback_Release(&This
->IBindStatusCallback_iface
);
460 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate
*iface
,
461 LPCWSTR szURL
, LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
463 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
465 TRACE("(%p)->(%s %s %ld %p)\n", This
, debugstr_w(szURL
), debugstr_w(szHeaders
),
466 dwReserved
, pszAdditionalHeaders
);
469 int size
= (lstrlenW(This
->headers
)+1)*sizeof(WCHAR
);
470 *pszAdditionalHeaders
= CoTaskMemAlloc(size
);
471 memcpy(*pszAdditionalHeaders
, This
->headers
, size
);
477 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate
*iface
,
478 DWORD dwResponseCode
, LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
,
479 LPWSTR
*pszAdditionalRequestHeaders
)
481 BindStatusCallback
*This
= impl_from_IHttpNegotiate(iface
);
482 TRACE("(%p)->(%ld %s %s %p)\n", This
, dwResponseCode
, debugstr_w(szResponseHeaders
),
483 debugstr_w(szRequestHeaders
), pszAdditionalRequestHeaders
);
487 static const IHttpNegotiateVtbl HttpNegotiateVtbl
= {
488 HttpNegotiate_QueryInterface
,
489 HttpNegotiate_AddRef
,
490 HttpNegotiate_Release
,
491 HttpNegotiate_BeginningTransaction
,
492 HttpNegotiate_OnResponse
495 static inline BindStatusCallback
*impl_from_IHttpSecurity(IHttpSecurity
*iface
)
497 return CONTAINING_RECORD(iface
, BindStatusCallback
, IHttpSecurity_iface
);
500 static HRESULT WINAPI
HttpSecurity_QueryInterface(IHttpSecurity
*iface
, REFIID riid
, void **ppv
)
502 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
503 return IBindStatusCallback_QueryInterface(&This
->IBindStatusCallback_iface
, riid
, ppv
);
506 static ULONG WINAPI
HttpSecurity_AddRef(IHttpSecurity
*iface
)
508 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
509 return IBindStatusCallback_AddRef(&This
->IBindStatusCallback_iface
);
512 static ULONG WINAPI
HttpSecurity_Release(IHttpSecurity
*iface
)
514 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
515 return IBindStatusCallback_Release(&This
->IBindStatusCallback_iface
);
518 static HRESULT WINAPI
HttpSecurity_GetWindow(IHttpSecurity
*iface
, REFGUID rguidReason
, HWND
*phwnd
)
520 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
522 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(rguidReason
), phwnd
);
527 *phwnd
= This
->doc_host
->frame_hwnd
;
531 static HRESULT WINAPI
HttpSecurity_OnSecurityProblem(IHttpSecurity
*iface
, DWORD dwProblem
)
533 BindStatusCallback
*This
= impl_from_IHttpSecurity(iface
);
534 FIXME("(%p)->(%lu)\n", This
, dwProblem
);
538 static const IHttpSecurityVtbl HttpSecurityVtbl
= {
539 HttpSecurity_QueryInterface
,
541 HttpSecurity_Release
,
542 HttpSecurity_GetWindow
,
543 HttpSecurity_OnSecurityProblem
546 static BindStatusCallback
*create_callback(DocHost
*doc_host
, LPCWSTR url
, PBYTE post_data
,
547 ULONG post_data_len
, LPCWSTR headers
)
549 BindStatusCallback
*ret
= malloc(sizeof(BindStatusCallback
));
551 ret
->IBindStatusCallback_iface
.lpVtbl
= &BindStatusCallbackVtbl
;
552 ret
->IHttpNegotiate_iface
.lpVtbl
= &HttpNegotiateVtbl
;
553 ret
->IHttpSecurity_iface
.lpVtbl
= &HttpSecurityVtbl
;
556 ret
->url
= SysAllocString(url
);
557 ret
->post_data
= NULL
;
558 ret
->post_data_len
= post_data_len
;
559 ret
->headers
= headers
? SysAllocString(headers
) : NULL
;
561 ret
->doc_host
= doc_host
;
562 IOleClientSite_AddRef(&doc_host
->IOleClientSite_iface
);
567 ret
->post_data
= GlobalAlloc(0, post_data_len
);
568 memcpy(ret
->post_data
, post_data
, post_data_len
);
574 static void on_before_navigate2(DocHost
*This
, LPCWSTR url
, SAFEARRAY
*post_data
, LPWSTR headers
, VARIANT_BOOL
*cancel
)
576 VARIANT var_url
, var_flags
, var_frame_name
, var_post_data
, var_post_data2
, var_headers
;
577 DISPPARAMS dispparams
;
578 VARIANTARG params
[7];
579 WCHAR file_path
[MAX_PATH
];
580 DWORD file_path_len
= ARRAY_SIZE(file_path
);
582 dispparams
.cArgs
= 7;
583 dispparams
.cNamedArgs
= 0;
584 dispparams
.rgdispidNamedArgs
= NULL
;
585 dispparams
.rgvarg
= params
;
587 V_VT(params
) = VT_BOOL
|VT_BYREF
;
588 V_BOOLREF(params
) = cancel
;
590 V_VT(params
+1) = (VT_BYREF
|VT_VARIANT
);
591 V_VARIANTREF(params
+1) = &var_headers
;
592 V_VT(&var_headers
) = VT_BSTR
;
593 V_BSTR(&var_headers
) = headers
;
595 V_VT(params
+2) = (VT_BYREF
|VT_VARIANT
);
596 V_VARIANTREF(params
+2) = &var_post_data2
;
597 V_VT(&var_post_data2
) = (VT_BYREF
|VT_VARIANT
);
598 V_VARIANTREF(&var_post_data2
) = &var_post_data
;
601 V_VT(&var_post_data
) = VT_UI1
|VT_ARRAY
;
602 V_ARRAY(&var_post_data
) = post_data
;
604 V_VT(&var_post_data
) = VT_EMPTY
;
607 V_VT(params
+3) = (VT_BYREF
|VT_VARIANT
);
608 V_VARIANTREF(params
+3) = &var_frame_name
;
609 V_VT(&var_frame_name
) = VT_BSTR
;
610 V_BSTR(&var_frame_name
) = NULL
;
612 V_VT(params
+4) = (VT_BYREF
|VT_VARIANT
);
613 V_VARIANTREF(params
+4) = &var_flags
;
614 V_VT(&var_flags
) = VT_I4
;
615 V_I4(&var_flags
) = 0;
617 V_VT(params
+5) = (VT_BYREF
|VT_VARIANT
);
618 V_VARIANTREF(params
+5) = &var_url
;
619 V_VT(&var_url
) = VT_BSTR
;
620 if(PathCreateFromUrlW(url
, file_path
, &file_path_len
, 0) == S_OK
)
621 V_BSTR(&var_url
) = SysAllocString(file_path
);
623 V_BSTR(&var_url
) = SysAllocString(url
);
625 V_VT(params
+6) = (VT_DISPATCH
);
626 V_DISPATCH(params
+6) = (IDispatch
*)This
->wb
;
628 call_sink(This
->cps
.wbe2
, DISPID_BEFORENAVIGATE2
, &dispparams
);
630 SysFreeString(V_BSTR(&var_url
));
633 /* FIXME: urlmon should handle it */
634 static BOOL
try_application_url(LPCWSTR url
)
636 SHELLEXECUTEINFOW exec_info
;
642 static const WCHAR wszURLProtocol
[] = {'U','R','L',' ','P','r','o','t','o','c','o','l',0};
644 hres
= CoInternetParseUrl(url
, PARSE_SCHEMA
, 0, app
, ARRAY_SIZE(app
), NULL
, 0);
648 res
= RegOpenKeyW(HKEY_CLASSES_ROOT
, app
, &hkey
);
649 if(res
!= ERROR_SUCCESS
)
652 res
= RegQueryValueExW(hkey
, wszURLProtocol
, NULL
, &type
, NULL
, NULL
);
654 if(res
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
657 TRACE("opening application %s\n", debugstr_w(app
));
659 memset(&exec_info
, 0, sizeof(exec_info
));
660 exec_info
.cbSize
= sizeof(exec_info
);
661 exec_info
.lpFile
= url
;
662 exec_info
.nShow
= SW_SHOW
;
664 return ShellExecuteExW(&exec_info
);
667 static HRESULT
create_moniker(LPCWSTR url
, IMoniker
**mon
)
669 WCHAR new_url
[INTERNET_MAX_URL_LENGTH
];
674 return CreateURLMoniker(NULL
, url
, mon
);
676 size
= ARRAY_SIZE(new_url
);
677 hres
= UrlApplySchemeW(url
, new_url
, &size
, URL_APPLY_GUESSSCHEME
| URL_APPLY_GUESSFILE
| URL_APPLY_DEFAULT
);
678 TRACE("was %s got %s\n", debugstr_w(url
), debugstr_w(new_url
));
680 WARN("UrlApplyScheme failed: %08lx\n", hres
);
684 return CreateURLMoniker(NULL
, new_url
, mon
);
687 static HRESULT
bind_to_object(DocHost
*This
, IMoniker
*mon
, LPCWSTR url
, IBindCtx
*bindctx
,
688 IBindStatusCallback
*callback
)
690 IUnknown
*unk
= NULL
;
695 IMoniker_AddRef(mon
);
697 hres
= create_moniker(url
, &mon
);
702 hres
= IMoniker_GetDisplayName(mon
, 0, NULL
, &display_name
);
704 FIXME("GetDisplayName failed: %08lx\n", hres
);
705 IMoniker_Release(mon
);
709 hres
= set_dochost_url(This
, display_name
);
710 CoTaskMemFree(display_name
);
712 IMoniker_Release(mon
);
716 IBindCtx_RegisterObjectParam(bindctx
, (LPOLESTR
)SZ_HTML_CLIENTSITE_OBJECTPARAM
,
717 (IUnknown
*)&This
->IOleClientSite_iface
);
719 hres
= IMoniker_BindToObject(mon
, bindctx
, NULL
, &IID_IUnknown
, (void**)&unk
);
720 if(SUCCEEDED(hres
)) {
723 IUnknown_Release(unk
);
724 }else if(try_application_url(url
)) {
727 FIXME("BindToObject failed: %08lx\n", hres
);
730 IMoniker_Release(mon
);
734 static void html_window_navigate(DocHost
*This
, IHTMLPrivateWindow
*window
, BSTR url
, BSTR headers
, SAFEARRAY
*post_data
)
736 VARIANT headers_var
, post_data_var
;
740 hres
= set_dochost_url(This
, url
);
744 empty_str
= SysAllocStringLen(NULL
, 0);
747 V_VT(&headers_var
) = VT_BSTR
;
748 V_BSTR(&headers_var
) = headers
;
750 V_VT(&headers_var
) = VT_EMPTY
;
754 V_VT(&post_data_var
) = VT_UI1
|VT_ARRAY
;
755 V_ARRAY(&post_data_var
) = post_data
;
757 V_VT(&post_data_var
) = VT_EMPTY
;
760 set_doc_state(This
, READYSTATE_LOADING
);
761 hres
= IHTMLPrivateWindow_SuperNavigate(window
, url
, empty_str
, NULL
, NULL
, &post_data_var
, &headers_var
, 0);
762 SysFreeString(empty_str
);
764 WARN("SuprtNavigate failed: %08lx\n", hres
);
768 task_header_t header
;
771 SAFEARRAY
*post_data
;
773 } task_doc_navigate_t
;
775 static void doc_navigate_task_destr(task_header_t
*t
)
777 task_doc_navigate_t
*task
= (task_doc_navigate_t
*)t
;
779 SysFreeString(task
->url
);
780 SysFreeString(task
->headers
);
782 SafeArrayDestroy(task
->post_data
);
786 static void doc_navigate_proc(DocHost
*This
, task_header_t
*t
)
788 task_doc_navigate_t
*task
= (task_doc_navigate_t
*)t
;
789 IHTMLPrivateWindow
*priv_window
;
792 if(!This
->doc_navigate
) {
797 if(task
->async_notif
) {
798 VARIANT_BOOL cancel
= VARIANT_FALSE
;
799 on_before_navigate2(This
, task
->url
, task
->post_data
, task
->headers
, &cancel
);
801 TRACE("Navigation canceled\n");
806 hres
= IUnknown_QueryInterface(This
->doc_navigate
, &IID_IHTMLPrivateWindow
, (void**)&priv_window
);
807 if(SUCCEEDED(hres
)) {
808 html_window_navigate(This
, priv_window
, task
->url
, task
->headers
, task
->post_data
);
809 IHTMLPrivateWindow_Release(priv_window
);
811 WARN("Could not get IHTMLPrivateWindow iface: %08lx\n", hres
);
815 static HRESULT
async_doc_navigate(DocHost
*This
, LPCWSTR url
, LPCWSTR headers
, PBYTE post_data
, ULONG post_data_size
,
818 task_doc_navigate_t
*task
;
820 TRACE("%s\n", debugstr_w(url
));
822 task
= calloc(1, sizeof(*task
));
824 return E_OUTOFMEMORY
;
826 task
->url
= SysAllocString(url
);
828 doc_navigate_task_destr(&task
->header
);
829 return E_OUTOFMEMORY
;
833 task
->headers
= SysAllocString(headers
);
835 doc_navigate_task_destr(&task
->header
);
836 return E_OUTOFMEMORY
;
841 task
->post_data
= SafeArrayCreateVector(VT_UI1
, 0, post_data_size
);
842 if(!task
->post_data
) {
843 doc_navigate_task_destr(&task
->header
);
844 return E_OUTOFMEMORY
;
847 memcpy(task
->post_data
->pvData
, post_data
, post_data_size
);
851 VARIANT_BOOL cancel
= VARIANT_FALSE
;
853 on_before_navigate2(This
, task
->url
, task
->post_data
, task
->headers
, &cancel
);
855 TRACE("Navigation canceled\n");
856 doc_navigate_task_destr(&task
->header
);
861 task
->async_notif
= async_notif
;
862 abort_dochost_tasks(This
, doc_navigate_proc
);
863 push_dochost_task(This
, &task
->header
, doc_navigate_proc
, doc_navigate_task_destr
, FALSE
);
867 static HRESULT
navigate_bsc(DocHost
*This
, BindStatusCallback
*bsc
, IMoniker
*mon
)
869 VARIANT_BOOL cancel
= VARIANT_FALSE
;
870 SAFEARRAY
*post_data
= NULL
;
874 set_doc_state(This
, READYSTATE_LOADING
);
877 post_data
= SafeArrayCreateVector(VT_UI1
, 0, bsc
->post_data_len
);
878 memcpy(post_data
->pvData
, post_data
, bsc
->post_data_len
);
881 on_before_navigate2(This
, bsc
->url
, post_data
, bsc
->headers
, &cancel
);
883 SafeArrayDestroy(post_data
);
885 FIXME("Navigation canceled\n");
889 notify_download_state(This
, TRUE
);
890 This
->busy
= VARIANT_FALSE
;
892 on_commandstate_change(This
, CSC_NAVIGATEBACK
, FALSE
);
893 on_commandstate_change(This
, CSC_NAVIGATEFORWARD
, FALSE
);
896 deactivate_document(This
);
898 CreateAsyncBindCtx(0, &bsc
->IBindStatusCallback_iface
, 0, &bindctx
);
901 IOleInPlaceFrame_EnableModeless(This
->frame
, FALSE
);
903 hres
= bind_to_object(This
, mon
, bsc
->url
, bindctx
, &bsc
->IBindStatusCallback_iface
);
906 IOleInPlaceFrame_EnableModeless(This
->frame
, TRUE
);
908 IBindCtx_Release(bindctx
);
914 task_header_t header
;
915 BindStatusCallback
*bsc
;
916 } task_navigate_bsc_t
;
918 static void navigate_bsc_task_destr(task_header_t
*t
)
920 task_navigate_bsc_t
*task
= (task_navigate_bsc_t
*)t
;
922 IBindStatusCallback_Release(&task
->bsc
->IBindStatusCallback_iface
);
926 static void navigate_bsc_proc(DocHost
*This
, task_header_t
*t
)
928 task_navigate_bsc_t
*task
= (task_navigate_bsc_t
*)t
;
931 create_doc_view_hwnd(This
);
933 navigate_bsc(This
, task
->bsc
, NULL
);
937 HRESULT
navigate_url(DocHost
*This
, LPCWSTR url
, const VARIANT
*Flags
,
938 const VARIANT
*TargetFrameName
, VARIANT
*PostData
, VARIANT
*Headers
)
940 SAFEARRAY
*post_array
= NULL
;
941 PBYTE post_data
= NULL
;
942 ULONG post_data_len
= 0;
943 LPWSTR headers
= NULL
;
946 TRACE("navigating to %s\n", debugstr_w(url
));
948 if((Flags
&& V_VT(Flags
) != VT_EMPTY
&& V_VT(Flags
) != VT_ERROR
)
949 || (TargetFrameName
&& V_VT(TargetFrameName
) != VT_EMPTY
&& V_VT(TargetFrameName
) != VT_ERROR
))
950 FIXME("Unsupported args (Flags %s; TargetFrameName %s)\n", debugstr_variant(Flags
), debugstr_variant(TargetFrameName
));
953 if(V_VT(PostData
) & VT_ARRAY
)
954 post_array
= V_ISBYREF(PostData
) ? *V_ARRAYREF(PostData
) : V_ARRAY(PostData
);
956 WARN("Invalid post data %s\n", debugstr_variant(PostData
));
961 SafeArrayAccessData(post_array
, (void**)&post_data
);
962 SafeArrayGetUBound(post_array
, 1, &elem_max
);
963 post_data_len
= (elem_max
+1) * SafeArrayGetElemsize(post_array
);
966 if(Headers
&& V_VT(Headers
) == VT_BSTR
) {
967 headers
= V_BSTR(Headers
);
968 TRACE("Headers: %s\n", debugstr_w(headers
));
971 set_doc_state(This
, READYSTATE_LOADING
);
972 This
->ready_state
= READYSTATE_LOADING
;
974 if(This
->doc_navigate
) {
975 WCHAR new_url
[INTERNET_MAX_URL_LENGTH
];
977 if(PathIsURLW(url
)) {
982 size
= ARRAY_SIZE(new_url
);
983 hres
= UrlApplySchemeW(url
, new_url
, &size
,
984 URL_APPLY_GUESSSCHEME
| URL_APPLY_GUESSFILE
| URL_APPLY_DEFAULT
);
986 WARN("UrlApplyScheme failed: %08lx\n", hres
);
991 hres
= async_doc_navigate(This
, *new_url
? new_url
: url
, headers
, post_data
,
992 post_data_len
, TRUE
);
994 task_navigate_bsc_t
*task
;
996 task
= malloc(sizeof(*task
));
997 task
->bsc
= create_callback(This
, url
, post_data
, post_data_len
, headers
);
998 push_dochost_task(This
, &task
->header
, navigate_bsc_proc
, navigate_bsc_task_destr
, This
->url
== NULL
);
1002 SafeArrayUnaccessData(post_array
);
1007 static HRESULT
navigate_hlink(DocHost
*This
, IMoniker
*mon
, IBindCtx
*bindctx
,
1008 IBindStatusCallback
*callback
)
1010 IHttpNegotiate
*http_negotiate
;
1011 BindStatusCallback
*bsc
;
1012 PBYTE post_data
= NULL
;
1013 ULONG post_data_len
= 0;
1014 LPWSTR headers
= NULL
, url
;
1021 hres
= IMoniker_GetDisplayName(mon
, 0, NULL
, &url
);
1023 FIXME("GetDisplayName failed: %08lx\n", hres
);
1025 hres
= IBindStatusCallback_QueryInterface(callback
, &IID_IHttpNegotiate
,
1026 (void**)&http_negotiate
);
1027 if(SUCCEEDED(hres
)) {
1028 static const WCHAR null_string
[] = {0};
1030 IHttpNegotiate_BeginningTransaction(http_negotiate
, null_string
, null_string
, 0,
1032 IHttpNegotiate_Release(http_negotiate
);
1035 memset(&bindinfo
, 0, sizeof(bindinfo
));
1036 bindinfo
.cbSize
= sizeof(bindinfo
);
1038 hres
= IBindStatusCallback_GetBindInfo(callback
, &bindf
, &bindinfo
);
1039 dump_BINDINFO(&bindinfo
);
1040 if(bindinfo
.dwBindVerb
== BINDVERB_POST
) {
1041 post_data_len
= bindinfo
.cbstgmedData
;
1043 post_data
= bindinfo
.stgmedData
.u
.hGlobal
;
1046 if(This
->doc_navigate
) {
1047 hres
= async_doc_navigate(This
, url
, headers
, post_data
, post_data_len
, FALSE
);
1049 bsc
= create_callback(This
, url
, post_data
, post_data_len
, headers
);
1050 hres
= navigate_bsc(This
, bsc
, mon
);
1051 IBindStatusCallback_Release(&bsc
->IBindStatusCallback_iface
);
1055 CoTaskMemFree(headers
);
1056 ReleaseBindInfo(&bindinfo
);
1061 HRESULT
go_home(DocHost
*This
)
1064 DWORD res
, type
, size
;
1065 WCHAR wszPageName
[MAX_PATH
];
1066 static const WCHAR wszAboutBlank
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
1067 static const WCHAR wszStartPage
[] = {'S','t','a','r','t',' ','P','a','g','e',0};
1068 static const WCHAR wszSubKey
[] = {'S','o','f','t','w','a','r','e','\\',
1069 'M','i','c','r','o','s','o','f','t','\\',
1070 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
1073 res
= RegOpenKeyW(HKEY_CURRENT_USER
, wszSubKey
, &hkey
);
1074 if (res
!= ERROR_SUCCESS
)
1075 return navigate_url(This
, wszAboutBlank
, NULL
, NULL
, NULL
, NULL
);
1077 size
= sizeof(wszPageName
);
1078 res
= RegQueryValueExW(hkey
, wszStartPage
, NULL
, &type
, (LPBYTE
)wszPageName
, &size
);
1080 if (res
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
1081 return navigate_url(This
, wszAboutBlank
, NULL
, NULL
, NULL
, NULL
);
1083 return navigate_url(This
, wszPageName
, NULL
, NULL
, NULL
, NULL
);
1086 static HRESULT
navigate_history(DocHost
*This
, unsigned travellog_pos
)
1088 IPersistHistory
*persist_history
;
1089 travellog_entry_t
*entry
;
1093 if(!This
->doc_navigate
) {
1094 FIXME("unsupported doc_navigate FALSE\n");
1098 This
->travellog
.loading_pos
= travellog_pos
;
1099 entry
= This
->travellog
.log
+ This
->travellog
.loading_pos
;
1101 update_navigation_commands(This
);
1104 return async_doc_navigate(This
, entry
->url
, NULL
, NULL
, 0, FALSE
);
1106 hres
= IUnknown_QueryInterface(This
->document
, &IID_IPersistHistory
, (void**)&persist_history
);
1111 IStream_Seek(entry
->stream
, li
, STREAM_SEEK_SET
, NULL
);
1113 hres
= IPersistHistory_LoadHistory(persist_history
, entry
->stream
, NULL
);
1114 IPersistHistory_Release(persist_history
);
1118 HRESULT
go_back(DocHost
*This
)
1120 if(!This
->travellog
.position
) {
1121 WARN("No history available\n");
1125 return navigate_history(This
, This
->travellog
.position
-1);
1128 HRESULT
go_forward(DocHost
*This
)
1130 if(This
->travellog
.position
>= This
->travellog
.length
) {
1131 WARN("No history available\n");
1135 return navigate_history(This
, This
->travellog
.position
+1);
1138 HRESULT
get_location_url(DocHost
*This
, BSTR
*ret
)
1140 FIXME("semi-stub\n");
1142 *ret
= This
->url
? SysAllocString(This
->url
) : SysAllocStringLen(NULL
, 0);
1144 return E_OUTOFMEMORY
;
1146 return This
->url
? S_OK
: S_FALSE
;
1149 static inline HlinkFrame
*impl_from_IHlinkFrame(IHlinkFrame
*iface
)
1151 return CONTAINING_RECORD(iface
, HlinkFrame
, IHlinkFrame_iface
);
1154 static HRESULT WINAPI
HlinkFrame_QueryInterface(IHlinkFrame
*iface
, REFIID riid
, void **ppv
)
1156 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1157 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1160 static ULONG WINAPI
HlinkFrame_AddRef(IHlinkFrame
*iface
)
1162 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1163 return IUnknown_AddRef(This
->outer
);
1166 static ULONG WINAPI
HlinkFrame_Release(IHlinkFrame
*iface
)
1168 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1169 return IUnknown_Release(This
->outer
);
1172 static HRESULT WINAPI
HlinkFrame_SetBrowseContext(IHlinkFrame
*iface
,
1173 IHlinkBrowseContext
*pihlbc
)
1175 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1176 FIXME("(%p)->(%p)\n", This
, pihlbc
);
1180 static HRESULT WINAPI
HlinkFrame_GetBrowseContext(IHlinkFrame
*iface
,
1181 IHlinkBrowseContext
**ppihlbc
)
1183 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1184 FIXME("(%p)->(%p)\n", This
, ppihlbc
);
1188 static HRESULT WINAPI
HlinkFrame_Navigate(IHlinkFrame
*iface
, DWORD grfHLNF
, LPBC pbc
,
1189 IBindStatusCallback
*pibsc
, IHlink
*pihlNavigate
)
1191 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1193 LPWSTR location
= NULL
;
1195 TRACE("(%p)->(%08lx %p %p %p)\n", This
, grfHLNF
, pbc
, pibsc
, pihlNavigate
);
1198 FIXME("unsupported grfHLNF=%08lx\n", grfHLNF
);
1200 /* Windows calls GetTargetFrameName here. */
1202 IHlink_GetMonikerReference(pihlNavigate
, 1, &mon
, &location
);
1205 FIXME("location = %s\n", debugstr_w(location
));
1206 CoTaskMemFree(location
);
1209 /* Windows calls GetHlinkSite here */
1211 if(grfHLNF
& HLNF_OPENINNEWWINDOW
) {
1212 FIXME("Not supported HLNF_OPENINNEWWINDOW\n");
1216 return navigate_hlink(This
->doc_host
, mon
, pbc
, pibsc
);
1219 static HRESULT WINAPI
HlinkFrame_OnNavigate(IHlinkFrame
*iface
, DWORD grfHLNF
,
1220 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
, DWORD dwreserved
)
1222 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1223 FIXME("(%p)->(%08lx %p %s %s %ld)\n", This
, grfHLNF
, pimkTarget
, debugstr_w(pwzLocation
),
1224 debugstr_w(pwzFriendlyName
), dwreserved
);
1228 static HRESULT WINAPI
HlinkFrame_UpdateHlink(IHlinkFrame
*iface
, ULONG uHLID
,
1229 IMoniker
*pimkTarget
, LPCWSTR pwzLocation
, LPCWSTR pwzFriendlyName
)
1231 HlinkFrame
*This
= impl_from_IHlinkFrame(iface
);
1232 FIXME("(%p)->(%lu %p %s %s)\n", This
, uHLID
, pimkTarget
, debugstr_w(pwzLocation
),
1233 debugstr_w(pwzFriendlyName
));
1237 static const IHlinkFrameVtbl HlinkFrameVtbl
= {
1238 HlinkFrame_QueryInterface
,
1241 HlinkFrame_SetBrowseContext
,
1242 HlinkFrame_GetBrowseContext
,
1243 HlinkFrame_Navigate
,
1244 HlinkFrame_OnNavigate
,
1245 HlinkFrame_UpdateHlink
1248 static inline HlinkFrame
*impl_from_ITargetFrame(ITargetFrame
*iface
)
1250 return CONTAINING_RECORD(iface
, HlinkFrame
, ITargetFrame_iface
);
1253 static HRESULT WINAPI
TargetFrame_QueryInterface(ITargetFrame
*iface
, REFIID riid
, void **ppv
)
1255 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1256 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1259 static ULONG WINAPI
TargetFrame_AddRef(ITargetFrame
*iface
)
1261 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1262 return IUnknown_AddRef(This
->outer
);
1265 static ULONG WINAPI
TargetFrame_Release(ITargetFrame
*iface
)
1267 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1268 return IUnknown_Release(This
->outer
);
1271 static HRESULT WINAPI
TargetFrame_SetFrameName(ITargetFrame
*iface
, LPCWSTR pszFrameName
)
1273 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1274 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameName
));
1278 static HRESULT WINAPI
TargetFrame_GetFrameName(ITargetFrame
*iface
, LPWSTR
*ppszFrameName
)
1280 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1281 FIXME("(%p)->(%p)\n", This
, ppszFrameName
);
1285 static HRESULT WINAPI
TargetFrame_GetParentFrame(ITargetFrame
*iface
, IUnknown
**ppunkParent
)
1287 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1288 FIXME("(%p)->(%p)\n", This
, ppunkParent
);
1292 static HRESULT WINAPI
TargetFrame_FindFrame(ITargetFrame
*iface
, LPCWSTR pszTargetName
,
1293 IUnknown
*ppunkContextFrame
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1295 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1296 FIXME("(%p)->(%s %p %lx %p)\n", This
, debugstr_w(pszTargetName
),
1297 ppunkContextFrame
, dwFlags
, ppunkTargetFrame
);
1301 static HRESULT WINAPI
TargetFrame_SetFrameSrc(ITargetFrame
*iface
, LPCWSTR pszFrameSrc
)
1303 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1304 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameSrc
));
1308 static HRESULT WINAPI
TargetFrame_GetFrameSrc(ITargetFrame
*iface
, LPWSTR
*ppszFrameSrc
)
1310 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1311 FIXME("(%p)->(%p)\n", This
, ppszFrameSrc
);
1315 static HRESULT WINAPI
TargetFrame_GetFramesContainer(ITargetFrame
*iface
, IOleContainer
**ppContainer
)
1317 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1318 FIXME("(%p)->(%p)\n", This
, ppContainer
);
1322 static HRESULT WINAPI
TargetFrame_SetFrameOptions(ITargetFrame
*iface
, DWORD dwFlags
)
1324 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1325 FIXME("(%p)->(%lx)\n", This
, dwFlags
);
1329 static HRESULT WINAPI
TargetFrame_GetFrameOptions(ITargetFrame
*iface
, DWORD
*pdwFlags
)
1331 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1332 FIXME("(%p)->(%p)\n", This
, pdwFlags
);
1336 static HRESULT WINAPI
TargetFrame_SetFrameMargins(ITargetFrame
*iface
, DWORD dwWidth
, DWORD dwHeight
)
1338 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1339 FIXME("(%p)->(%ld %ld)\n", This
, dwWidth
, dwHeight
);
1343 static HRESULT WINAPI
TargetFrame_GetFrameMargins(ITargetFrame
*iface
, DWORD
*pdwWidth
, DWORD
*pdwHeight
)
1345 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1346 FIXME("(%p)->(%p %p)\n", This
, pdwWidth
, pdwHeight
);
1350 static HRESULT WINAPI
TargetFrame_RemoteNavigate(ITargetFrame
*iface
, ULONG cLength
, ULONG
*pulData
)
1352 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1353 FIXME("(%p)->(%lu %p)\n", This
, cLength
, pulData
);
1357 static HRESULT WINAPI
TargetFrame_OnChildFrameActivate(ITargetFrame
*iface
, IUnknown
*pUnkChildFrame
)
1359 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1360 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1364 static HRESULT WINAPI
TargetFrame_OnChildFrameDeactivate(ITargetFrame
*iface
, IUnknown
*pUnkChildFrame
)
1366 HlinkFrame
*This
= impl_from_ITargetFrame(iface
);
1367 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1371 static const ITargetFrameVtbl TargetFrameVtbl
= {
1372 TargetFrame_QueryInterface
,
1374 TargetFrame_Release
,
1375 TargetFrame_SetFrameName
,
1376 TargetFrame_GetFrameName
,
1377 TargetFrame_GetParentFrame
,
1378 TargetFrame_FindFrame
,
1379 TargetFrame_SetFrameSrc
,
1380 TargetFrame_GetFrameSrc
,
1381 TargetFrame_GetFramesContainer
,
1382 TargetFrame_SetFrameOptions
,
1383 TargetFrame_GetFrameOptions
,
1384 TargetFrame_SetFrameMargins
,
1385 TargetFrame_GetFrameMargins
,
1386 TargetFrame_RemoteNavigate
,
1387 TargetFrame_OnChildFrameActivate
,
1388 TargetFrame_OnChildFrameDeactivate
1391 static inline HlinkFrame
*impl_from_ITargetFrame2(ITargetFrame2
*iface
)
1393 return CONTAINING_RECORD(iface
, HlinkFrame
, ITargetFrame2_iface
);
1396 static HRESULT WINAPI
TargetFrame2_QueryInterface(ITargetFrame2
*iface
, REFIID riid
, void **ppv
)
1398 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1399 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1402 static ULONG WINAPI
TargetFrame2_AddRef(ITargetFrame2
*iface
)
1404 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1405 return IUnknown_AddRef(This
->outer
);
1408 static ULONG WINAPI
TargetFrame2_Release(ITargetFrame2
*iface
)
1410 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1411 return IUnknown_Release(This
->outer
);
1414 static HRESULT WINAPI
TargetFrame2_SetFrameName(ITargetFrame2
*iface
, LPCWSTR pszFrameName
)
1416 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1417 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameName
));
1421 static HRESULT WINAPI
TargetFrame2_GetFrameName(ITargetFrame2
*iface
, LPWSTR
*ppszFrameName
)
1423 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1424 FIXME("(%p)->(%p)\n", This
, ppszFrameName
);
1428 static HRESULT WINAPI
TargetFrame2_GetParentFrame(ITargetFrame2
*iface
, IUnknown
**ppunkParent
)
1430 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1431 FIXME("(%p)->(%p)\n", This
, ppunkParent
);
1435 static HRESULT WINAPI
TargetFrame2_SetFrameSrc(ITargetFrame2
*iface
, LPCWSTR pszFrameSrc
)
1437 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1438 FIXME("(%p)->(%s)\n", This
, debugstr_w(pszFrameSrc
));
1442 static HRESULT WINAPI
TargetFrame2_GetFrameSrc(ITargetFrame2
*iface
, LPWSTR
*ppszFrameSrc
)
1444 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1445 FIXME("(%p)->()\n", This
);
1449 static HRESULT WINAPI
TargetFrame2_GetFramesContainer(ITargetFrame2
*iface
, IOleContainer
**ppContainer
)
1451 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1452 FIXME("(%p)->(%p)\n", This
, ppContainer
);
1456 static HRESULT WINAPI
TargetFrame2_SetFrameOptions(ITargetFrame2
*iface
, DWORD dwFlags
)
1458 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1459 FIXME("(%p)->(%lx)\n", This
, dwFlags
);
1463 static HRESULT WINAPI
TargetFrame2_GetFrameOptions(ITargetFrame2
*iface
, DWORD
*pdwFlags
)
1465 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1466 FIXME("(%p)->(%p)\n", This
, pdwFlags
);
1470 static HRESULT WINAPI
TargetFrame2_SetFrameMargins(ITargetFrame2
*iface
, DWORD dwWidth
, DWORD dwHeight
)
1472 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1473 FIXME("(%p)->(%ld %ld)\n", This
, dwWidth
, dwHeight
);
1477 static HRESULT WINAPI
TargetFrame2_GetFrameMargins(ITargetFrame2
*iface
, DWORD
*pdwWidth
, DWORD
*pdwHeight
)
1479 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1480 FIXME("(%p)->(%p %p)\n", This
, pdwWidth
, pdwHeight
);
1484 static HRESULT WINAPI
TargetFrame2_FindFrame(ITargetFrame2
*iface
, LPCWSTR pszTargetName
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1486 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1487 FIXME("(%p)->(%s %lx %p)\n", This
, debugstr_w(pszTargetName
), dwFlags
, ppunkTargetFrame
);
1491 static HRESULT WINAPI
TargetFrame2_GetTargetAlias(ITargetFrame2
*iface
, LPCWSTR pszTargetName
, LPWSTR
*ppszTargetAlias
)
1493 HlinkFrame
*This
= impl_from_ITargetFrame2(iface
);
1494 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(pszTargetName
), ppszTargetAlias
);
1498 static const ITargetFrame2Vtbl TargetFrame2Vtbl
= {
1499 TargetFrame2_QueryInterface
,
1500 TargetFrame2_AddRef
,
1501 TargetFrame2_Release
,
1502 TargetFrame2_SetFrameName
,
1503 TargetFrame2_GetFrameName
,
1504 TargetFrame2_GetParentFrame
,
1505 TargetFrame2_SetFrameSrc
,
1506 TargetFrame2_GetFrameSrc
,
1507 TargetFrame2_GetFramesContainer
,
1508 TargetFrame2_SetFrameOptions
,
1509 TargetFrame2_GetFrameOptions
,
1510 TargetFrame2_SetFrameMargins
,
1511 TargetFrame2_GetFrameMargins
,
1512 TargetFrame2_FindFrame
,
1513 TargetFrame2_GetTargetAlias
1516 static inline HlinkFrame
*impl_from_ITargetFramePriv2(ITargetFramePriv2
*iface
)
1518 return CONTAINING_RECORD(iface
, HlinkFrame
, ITargetFramePriv2_iface
);
1521 static HRESULT WINAPI
TargetFramePriv2_QueryInterface(ITargetFramePriv2
*iface
, REFIID riid
, void **ppv
)
1523 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1524 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1527 static ULONG WINAPI
TargetFramePriv2_AddRef(ITargetFramePriv2
*iface
)
1529 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1530 return IUnknown_AddRef(This
->outer
);
1533 static ULONG WINAPI
TargetFramePriv2_Release(ITargetFramePriv2
*iface
)
1535 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1536 return IUnknown_Release(This
->outer
);
1539 static HRESULT WINAPI
TargetFramePriv2_FindFrameDownwards(ITargetFramePriv2
*iface
,
1540 LPCWSTR pszTargetName
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1542 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1543 FIXME("(%p)->(%s %lx %p)\n", This
, debugstr_w(pszTargetName
), dwFlags
, ppunkTargetFrame
);
1547 static HRESULT WINAPI
TargetFramePriv2_FindFrameInContext(ITargetFramePriv2
*iface
,
1548 LPCWSTR pszTargetName
, IUnknown
*punkContextFrame
, DWORD dwFlags
, IUnknown
**ppunkTargetFrame
)
1550 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1551 FIXME("(%p)->(%s %p %lx %p)\n", This
, debugstr_w(pszTargetName
), punkContextFrame
, dwFlags
, ppunkTargetFrame
);
1555 static HRESULT WINAPI
TargetFramePriv2_OnChildFrameActivate(ITargetFramePriv2
*iface
, IUnknown
*pUnkChildFrame
)
1557 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1558 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1562 static HRESULT WINAPI
TargetFramePriv2_OnChildFrameDeactivate(ITargetFramePriv2
*iface
, IUnknown
*pUnkChildFrame
)
1564 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1565 FIXME("(%p)->(%p)\n", This
, pUnkChildFrame
);
1569 static HRESULT WINAPI
TargetFramePriv2_NavigateHack(ITargetFramePriv2
*iface
, DWORD grfHLNF
, LPBC pbc
,
1570 IBindStatusCallback
*pibsc
, LPCWSTR pszTargetName
, LPCWSTR pszUrl
, LPCWSTR pszLocation
)
1572 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1573 FIXME("(%p)->(%lx %p %p %s %s %s)\n", This
, grfHLNF
, pbc
, pibsc
, debugstr_w(pszTargetName
),
1574 debugstr_w(pszUrl
), debugstr_w(pszLocation
));
1578 static HRESULT WINAPI
TargetFramePriv2_FindBrowserByIndex(ITargetFramePriv2
*iface
, DWORD dwID
, IUnknown
**ppunkBrowser
)
1580 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1581 FIXME("(%p)->(%ld %p)\n", This
, dwID
, ppunkBrowser
);
1585 static HRESULT WINAPI
TargetFramePriv2_AggregatedNavigation2(ITargetFramePriv2
*iface
, DWORD grfHLNF
, LPBC pbc
,
1586 IBindStatusCallback
*pibsc
, LPCWSTR pszTargetName
, IUri
*pUri
, LPCWSTR pszLocation
)
1588 HlinkFrame
*This
= impl_from_ITargetFramePriv2(iface
);
1592 TRACE("(%p)->(%lx %p %p %s %p %s)\n", This
, grfHLNF
, pbc
, pibsc
, debugstr_w(pszTargetName
),
1593 pUri
, debugstr_w(pszLocation
));
1596 * NOTE: This is an undocumented function. It seems to be working the way it's implemented,
1597 * but I couldn't get its tests working. It's used by mshtml to load content in a new
1598 * instance of browser.
1601 hres
= CreateURLMonikerEx2(NULL
, pUri
, &mon
, 0);
1605 hres
= navigate_hlink(This
->doc_host
, mon
, pbc
, pibsc
);
1606 IMoniker_Release(mon
);
1610 static const ITargetFramePriv2Vtbl TargetFramePriv2Vtbl
= {
1611 TargetFramePriv2_QueryInterface
,
1612 TargetFramePriv2_AddRef
,
1613 TargetFramePriv2_Release
,
1614 TargetFramePriv2_FindFrameDownwards
,
1615 TargetFramePriv2_FindFrameInContext
,
1616 TargetFramePriv2_OnChildFrameActivate
,
1617 TargetFramePriv2_OnChildFrameDeactivate
,
1618 TargetFramePriv2_NavigateHack
,
1619 TargetFramePriv2_FindBrowserByIndex
,
1620 TargetFramePriv2_AggregatedNavigation2
1623 static inline HlinkFrame
*impl_from_IWebBrowserPriv2IE9(IWebBrowserPriv2IE9
*iface
)
1625 return CONTAINING_RECORD(iface
, HlinkFrame
, IWebBrowserPriv2IE9_iface
);
1628 static HRESULT WINAPI
WebBrowserPriv2IE9_QueryInterface(IWebBrowserPriv2IE9
*iface
, REFIID riid
, void **ppv
)
1630 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1631 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
1634 static ULONG WINAPI
WebBrowserPriv2IE9_AddRef(IWebBrowserPriv2IE9
*iface
)
1636 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1637 return IUnknown_AddRef(This
->outer
);
1640 static ULONG WINAPI
WebBrowserPriv2IE9_Release(IWebBrowserPriv2IE9
*iface
)
1642 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1643 return IUnknown_Release(This
->outer
);
1646 static HRESULT WINAPI
WebBrowserPriv2IE9_NavigateWithBindCtx2(IWebBrowserPriv2IE9
*iface
, IUri
*uri
, VARIANT
*flags
,
1647 VARIANT
*target_frame
, VARIANT
*post_data
, VARIANT
*headers
, IBindCtx
*bind_ctx
, LPOLESTR url_fragment
, DWORD unused
)
1649 HlinkFrame
*This
= impl_from_IWebBrowserPriv2IE9(iface
);
1650 FIXME("(%p)->(%p %s %s %s %s %p %s)\n", This
, uri
, debugstr_variant(flags
), debugstr_variant(target_frame
),
1651 debugstr_variant(post_data
), debugstr_variant(headers
), bind_ctx
, debugstr_w(url_fragment
));
1655 static const IWebBrowserPriv2IE9Vtbl WebBrowserPriv2IE9Vtbl
= {
1656 WebBrowserPriv2IE9_QueryInterface
,
1657 WebBrowserPriv2IE9_AddRef
,
1658 WebBrowserPriv2IE9_Release
,
1659 WebBrowserPriv2IE9_NavigateWithBindCtx2
1662 BOOL
HlinkFrame_QI(HlinkFrame
*This
, REFIID riid
, void **ppv
)
1664 if(IsEqualGUID(&IID_IHlinkFrame
, riid
)) {
1665 TRACE("(%p)->(IID_IHlinkFrame %p)\n", This
, ppv
);
1666 *ppv
= &This
->IHlinkFrame_iface
;
1667 }else if(IsEqualGUID(&IID_ITargetFrame
, riid
)) {
1668 TRACE("(%p)->(IID_ITargetFrame %p)\n", This
, ppv
);
1669 *ppv
= &This
->ITargetFrame_iface
;
1670 }else if(IsEqualGUID(&IID_ITargetFrame2
, riid
)) {
1671 TRACE("(%p)->(IID_ITargetFrame2 %p)\n", This
, ppv
);
1672 *ppv
= &This
->ITargetFrame2_iface
;
1673 }else if(IsEqualGUID(&IID_ITargetFramePriv
, riid
)) {
1674 TRACE("(%p)->(IID_ITargetFramePriv %p)\n", This
, ppv
);
1675 *ppv
= &This
->ITargetFramePriv2_iface
;
1676 }else if(IsEqualGUID(&IID_ITargetFramePriv2
, riid
)) {
1677 TRACE("(%p)->(IID_ITargetFramePriv2 %p)\n", This
, ppv
);
1678 *ppv
= &This
->ITargetFramePriv2_iface
;
1679 }else if(IsEqualGUID(&IID_IWebBrowserPriv2IE9
, riid
)) {
1680 TRACE("(%p)->(IID_IWebBrowserPriv2IE9 %p)\n", This
, ppv
);
1681 *ppv
= &This
->IWebBrowserPriv2IE9_iface
;
1686 IUnknown_AddRef((IUnknown
*)*ppv
);
1690 void HlinkFrame_Init(HlinkFrame
*This
, IUnknown
*outer
, DocHost
*doc_host
)
1692 This
->IHlinkFrame_iface
.lpVtbl
= &HlinkFrameVtbl
;
1693 This
->ITargetFrame_iface
.lpVtbl
= &TargetFrameVtbl
;
1694 This
->ITargetFrame2_iface
.lpVtbl
= &TargetFrame2Vtbl
;
1695 This
->ITargetFramePriv2_iface
.lpVtbl
= &TargetFramePriv2Vtbl
;
1696 This
->IWebBrowserPriv2IE9_iface
.lpVtbl
= &WebBrowserPriv2IE9Vtbl
;
1698 This
->outer
= outer
;
1699 This
->doc_host
= doc_host
;