2 * Copyright 2005 Jacek Caban
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
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
35 #define NO_SHLWAPI_REG
38 #include "wine/debug.h"
40 #include "mshtml_private.h"
41 #include "htmlscript.h"
42 #include "htmlevent.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
48 /* Undocumented notification, see tests */
49 #define CMDID_EXPLORER_UPDATEHISTORY 38
56 } download_proc_task_t;
58 static BOOL use_gecko_script(HTMLOuterWindow *window)
63 hres = IInternetSecurityManager_MapUrlToZone(window->secmgr, window->url, &zone, 0);
65 WARN("Could not map %s to zone: %08x\n", debugstr_w(window->url), hres);
69 TRACE("zone %d\n", zone);
70 return zone == URLZONE_UNTRUSTED;
73 static void notify_travellog_update(HTMLDocumentObj *doc)
75 IOleCommandTarget *cmdtrg;
78 if(!doc->is_webbrowser)
81 /* Don't notify if we were in about: page */
82 if(doc->basedoc.window->uri) {
85 hres = IUri_GetScheme(doc->basedoc.window->uri, &scheme);
86 if(SUCCEEDED(hres) && scheme == URL_SCHEME_ABOUT)
90 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
97 IOleCommandTarget_Exec(cmdtrg, &CGID_Explorer, CMDID_EXPLORER_UPDATEHISTORY, 0, &vin, NULL);
98 IOleCommandTarget_Release(cmdtrg);
102 void set_current_uri(HTMLOuterWindow *window, IUri *uri)
105 IUri_Release(window->uri);
109 if(window->uri_nofrag) {
110 IUri_Release(window->uri_nofrag);
111 window->uri_nofrag = NULL;
114 SysFreeString(window->url);
123 window->uri_nofrag = get_uri_nofrag(uri);
124 if(!window->uri_nofrag) {
125 FIXME("get_uri_nofrag failed\n");
127 window->uri_nofrag = uri;
130 IUri_GetDisplayUri(uri, &window->url);
133 void set_current_mon(HTMLOuterWindow *This, IMoniker *mon)
135 IUriContainer *uri_container;
141 notify_travellog_update(This->doc_obj);
142 IMoniker_Release(This->mon);
149 IMoniker_AddRef(mon);
152 hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
153 if(SUCCEEDED(hres)) {
154 hres = IUriContainer_GetIUri(uri_container, &uri);
155 IUriContainer_Release(uri_container);
157 WARN("GetIUri failed: %08x\n", hres);
165 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
166 if(SUCCEEDED(hres)) {
167 hres = CreateUri(url, 0, 0, &uri);
169 WARN("CrateUri failed: %08x\n", hres);
170 set_current_uri(This, NULL);
171 This->url = SysAllocString(url);
177 WARN("GetDisplayName failed: %08x\n", hres);
181 set_current_uri(This, uri);
184 set_script_mode(This, use_gecko_script(This) ? SCRIPTMODE_GECKO : SCRIPTMODE_ACTIVESCRIPT);
187 HRESULT create_relative_uri(HTMLOuterWindow *window, const WCHAR *rel_uri, IUri **uri)
190 ? CoInternetCombineUrlEx(window->uri, rel_uri, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, uri, 0)
191 : CreateUri(rel_uri, 0, 0, uri);
194 void set_download_state(HTMLDocumentObj *doc, int state)
197 IOleCommandTarget *olecmd;
200 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
201 if(SUCCEEDED(hres)) {
207 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETDOWNLOADSTATE,
208 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
209 IOleCommandTarget_Release(olecmd);
213 doc->download_state = state;
216 static void set_progress_proc(task_t *_task)
218 docobj_task_t *task = (docobj_task_t*)_task;
219 IOleCommandTarget *olecmd = NULL;
220 HTMLDocumentObj *doc = task->doc;
223 TRACE("(%p)\n", doc);
226 IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
229 VARIANT progress_max, progress;
231 V_VT(&progress_max) = VT_I4;
232 V_I4(&progress_max) = 0; /* FIXME */
233 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSMAX, OLECMDEXECOPT_DONTPROMPTUSER,
234 &progress_max, NULL);
236 V_VT(&progress) = VT_I4;
237 V_I4(&progress) = 0; /* FIXME */
238 IOleCommandTarget_Exec(olecmd, NULL, OLECMDID_SETPROGRESSPOS, OLECMDEXECOPT_DONTPROMPTUSER,
240 IOleCommandTarget_Release(olecmd);
243 if(doc->usermode == EDITMODE && doc->hostui) {
244 DOCHOSTUIINFO hostinfo;
246 memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO));
247 hostinfo.cbSize = sizeof(DOCHOSTUIINFO);
248 hres = IDocHostUIHandler_GetHostInfo(doc->hostui, &hostinfo);
250 /* FIXME: use hostinfo */
251 TRACE("hostinfo = {%u %08x %08x %s %s}\n",
252 hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick,
253 debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS));
257 static void set_downloading_proc(task_t *_task)
259 download_proc_task_t *task = (download_proc_task_t*)_task;
260 HTMLDocumentObj *doc = task->doc;
263 TRACE("(%p)\n", doc);
265 set_statustext(doc, IDS_STATUS_DOWNLOADINGFROM, task->url);
267 if(task->set_download)
268 set_download_state(doc, 1);
274 IAdviseSink_OnViewChange(doc->view_sink, DVASPECT_CONTENT, -1);
277 IDropTarget *drop_target = NULL;
279 hres = IDocHostUIHandler_GetDropTarget(doc->hostui, NULL /* FIXME */, &drop_target);
280 if(SUCCEEDED(hres) && drop_target) {
281 FIXME("Use IDropTarget\n");
282 IDropTarget_Release(drop_target);
287 static void set_downloading_task_destr(task_t *_task)
289 download_proc_task_t *task = (download_proc_task_t*)_task;
291 CoTaskMemFree(task->url);
295 void prepare_for_binding(HTMLDocument *This, IMoniker *mon, DWORD flags)
299 if(This->doc_obj->client) {
300 VARIANT silent, offline;
302 hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent);
303 if(SUCCEEDED(hres)) {
304 if(V_VT(&silent) != VT_BOOL)
305 WARN("silent = %s\n", debugstr_variant(&silent));
306 else if(V_BOOL(&silent))
307 FIXME("silent == true\n");
310 hres = get_client_disp_property(This->doc_obj->client,
311 DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &offline);
312 if(SUCCEEDED(hres)) {
313 if(V_VT(&offline) != VT_BOOL)
314 WARN("offline = %s\n", debugstr_variant(&offline));
315 else if(V_BOOL(&offline))
316 FIXME("offline == true\n");
320 if(This->window->mon) {
321 update_doc(This, UPDATE_TITLE|UPDATE_UI);
323 update_doc(This, UPDATE_TITLE);
324 set_current_mon(This->window, mon);
327 if(This->doc_obj->client) {
328 IOleCommandTarget *cmdtrg = NULL;
330 hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget,
332 if(SUCCEEDED(hres)) {
335 if(flags & BINDING_NAVIGATED) {
336 V_VT(&var) = VT_UNKNOWN;
337 V_UNKNOWN(&var) = (IUnknown*)&This->window->base.IHTMLWindow2_iface;
338 V_VT(&out) = VT_EMPTY;
339 hres = IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 63, 0, &var, &out);
345 IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL);
348 IOleCommandTarget_Release(cmdtrg);
353 HRESULT set_moniker(HTMLDocument *This, IMoniker *mon, IBindCtx *pibc, nsChannelBSC *async_bsc, BOOL set_download)
355 download_proc_task_t *download_task;
356 nsChannelBSC *bscallback;
361 hres = IMoniker_GetDisplayName(mon, pibc, NULL, &url);
363 WARN("GetDiaplayName failed: %08x\n", hres);
367 TRACE("got url: %s\n", debugstr_w(url));
369 set_ready_state(This->window, READYSTATE_LOADING);
371 hres = create_doc_uri(This->window, url, &nsuri);
372 if(SUCCEEDED(hres)) {
374 bscallback = async_bsc;
376 hres = create_channelbsc(mon, NULL, NULL, 0, TRUE, &bscallback);
379 if(SUCCEEDED(hres)) {
380 remove_target_tasks(This->task_magic);
381 abort_window_bindings(This->window->base.inner_window);
383 hres = load_nsuri(This->window, nsuri, bscallback, 0/*LOAD_INITIAL_DOCUMENT_URI*/);
384 nsISupports_Release((nsISupports*)nsuri); /* FIXME */
386 hres = create_pending_window(This->window, bscallback);
387 if(bscallback != async_bsc)
388 IBindStatusCallback_Release(&bscallback->bsc.IBindStatusCallback_iface);
396 HTMLDocument_LockContainer(This->doc_obj, TRUE);
398 if(This->doc_obj->frame) {
401 task = heap_alloc(sizeof(docobj_task_t));
402 task->doc = This->doc_obj;
403 hres = push_task(&task->header, set_progress_proc, NULL, This->doc_obj->basedoc.task_magic);
410 download_task = heap_alloc(sizeof(download_proc_task_t));
411 download_task->doc = This->doc_obj;
412 download_task->set_download = set_download;
413 download_task->url = url;
414 return push_task(&download_task->header, set_downloading_proc, set_downloading_task_destr, This->doc_obj->basedoc.task_magic);
417 void set_ready_state(HTMLOuterWindow *window, READYSTATE readystate)
419 window->readystate = readystate;
421 if(window->doc_obj && window->doc_obj->basedoc.window == window)
422 call_property_onchanged(&window->doc_obj->basedoc.cp_propnotif, DISPID_READYSTATE);
424 fire_event(window->base.inner_window->doc, EVENTID_READYSTATECHANGE, FALSE,
425 window->base.inner_window->doc->node.nsnode, NULL, NULL);
427 if(window->frame_element)
428 fire_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE,
429 TRUE, window->frame_element->element.node.nsnode, NULL, NULL);
432 static HRESULT get_doc_string(HTMLDocumentNode *This, char **str)
441 WARN("NULL nsdoc\n");
445 nsres = nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMNode, (void**)&nsnode);
446 if(NS_FAILED(nsres)) {
447 ERR("Could not get nsIDOMNode failed: %08x\n", nsres);
451 nsAString_Init(&nsstr, NULL);
452 hres = nsnode_to_nsstring(nsnode, &nsstr);
453 nsIDOMNode_Release(nsnode);
455 nsAString_Finish(&nsstr);
459 nsAString_GetData(&nsstr, &strw);
460 TRACE("%s\n", debugstr_w(strw));
462 *str = heap_strdupWtoA(strw);
464 nsAString_Finish(&nsstr);
467 return E_OUTOFMEMORY;
472 /**********************************************************
473 * IPersistMoniker implementation
476 static inline HTMLDocument *impl_from_IPersistMoniker(IPersistMoniker *iface)
478 return CONTAINING_RECORD(iface, HTMLDocument, IPersistMoniker_iface);
481 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
483 HTMLDocument *This = impl_from_IPersistMoniker(iface);
484 return htmldoc_query_interface(This, riid, ppv);
487 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
489 HTMLDocument *This = impl_from_IPersistMoniker(iface);
490 return htmldoc_addref(This);
493 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
495 HTMLDocument *This = impl_from_IPersistMoniker(iface);
496 return htmldoc_release(This);
499 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
501 HTMLDocument *This = impl_from_IPersistMoniker(iface);
502 return IPersistFile_GetClassID(&This->IPersistFile_iface, pClassID);
505 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
507 HTMLDocument *This = impl_from_IPersistMoniker(iface);
509 TRACE("(%p)\n", This);
511 return IPersistStreamInit_IsDirty(&This->IPersistStreamInit_iface);
514 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
515 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
517 HTMLDocument *This = impl_from_IPersistMoniker(iface);
520 TRACE("(%p)->(%x %p %p %08x)\n", This, fFullyAvailable, pimkName, pibc, grfMode);
523 IUnknown *unk = NULL;
527 * "__PrecreatedObject"
528 * "BIND_CONTEXT_PARAM"
529 * "__HTMLLOADOPTIONS"
532 * "_ITransData_Object_"
536 hres = IBindCtx_GetObjectParam(pibc, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, &unk);
537 if(SUCCEEDED(hres) && unk) {
538 IOleClientSite *client = NULL;
540 hres = IUnknown_QueryInterface(unk, &IID_IOleClientSite, (void**)&client);
541 if(SUCCEEDED(hres)) {
542 TRACE("Got client site %p\n", client);
543 IOleObject_SetClientSite(&This->IOleObject_iface, client);
544 IOleClientSite_Release(client);
547 IUnknown_Release(unk);
551 prepare_for_binding(This, pimkName, FALSE);
552 call_docview_84(This->doc_obj);
553 hres = set_moniker(This, pimkName, pibc, NULL, TRUE);
557 return start_binding(This->window->pending_window, (BSCallback*)This->window->pending_window->bscallback, pibc);
560 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName,
561 LPBC pbc, BOOL fRemember)
563 HTMLDocument *This = impl_from_IPersistMoniker(iface);
564 FIXME("(%p)->(%p %p %x)\n", This, pimkName, pbc, fRemember);
568 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
570 HTMLDocument *This = impl_from_IPersistMoniker(iface);
571 FIXME("(%p)->(%p %p)\n", This, pimkName, pibc);
575 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **ppimkName)
577 HTMLDocument *This = impl_from_IPersistMoniker(iface);
579 TRACE("(%p)->(%p)\n", This, ppimkName);
581 if(!This->window || !This->window->mon)
584 IMoniker_AddRef(This->window->mon);
585 *ppimkName = This->window->mon;
589 static const IPersistMonikerVtbl PersistMonikerVtbl = {
590 PersistMoniker_QueryInterface,
591 PersistMoniker_AddRef,
592 PersistMoniker_Release,
593 PersistMoniker_GetClassID,
594 PersistMoniker_IsDirty,
597 PersistMoniker_SaveCompleted,
598 PersistMoniker_GetCurMoniker
601 /**********************************************************
602 * IMonikerProp implementation
605 static inline HTMLDocument *impl_from_IMonikerProp(IMonikerProp *iface)
607 return CONTAINING_RECORD(iface, HTMLDocument, IMonikerProp_iface);
610 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
612 HTMLDocument *This = impl_from_IMonikerProp(iface);
613 return htmldoc_query_interface(This, riid, ppv);
616 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
618 HTMLDocument *This = impl_from_IMonikerProp(iface);
619 return htmldoc_addref(This);
622 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
624 HTMLDocument *This = impl_from_IMonikerProp(iface);
625 return htmldoc_release(This);
628 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
630 HTMLDocument *This = impl_from_IMonikerProp(iface);
632 TRACE("(%p)->(%d %s)\n", This, mkp, debugstr_w(val));
636 heap_free(This->doc_obj->mime);
637 This->doc_obj->mime = heap_strdupW(val);
644 FIXME("mkp %d\n", mkp);
651 static const IMonikerPropVtbl MonikerPropVtbl = {
652 MonikerProp_QueryInterface,
655 MonikerProp_PutProperty
658 /**********************************************************
659 * IPersistFile implementation
662 static inline HTMLDocument *impl_from_IPersistFile(IPersistFile *iface)
664 return CONTAINING_RECORD(iface, HTMLDocument, IPersistFile_iface);
667 static HRESULT WINAPI PersistFile_QueryInterface(IPersistFile *iface, REFIID riid, void **ppv)
669 HTMLDocument *This = impl_from_IPersistFile(iface);
670 return htmldoc_query_interface(This, riid, ppv);
673 static ULONG WINAPI PersistFile_AddRef(IPersistFile *iface)
675 HTMLDocument *This = impl_from_IPersistFile(iface);
676 return htmldoc_addref(This);
679 static ULONG WINAPI PersistFile_Release(IPersistFile *iface)
681 HTMLDocument *This = impl_from_IPersistFile(iface);
682 return htmldoc_release(This);
685 static HRESULT WINAPI PersistFile_GetClassID(IPersistFile *iface, CLSID *pClassID)
687 HTMLDocument *This = impl_from_IPersistFile(iface);
689 TRACE("(%p)->(%p)\n", This, pClassID);
694 *pClassID = CLSID_HTMLDocument;
698 static HRESULT WINAPI PersistFile_IsDirty(IPersistFile *iface)
700 HTMLDocument *This = impl_from_IPersistFile(iface);
702 TRACE("(%p)\n", This);
704 return IPersistStreamInit_IsDirty(&This->IPersistStreamInit_iface);
707 static HRESULT WINAPI PersistFile_Load(IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode)
709 HTMLDocument *This = impl_from_IPersistFile(iface);
710 FIXME("(%p)->(%s %08x)\n", This, debugstr_w(pszFileName), dwMode);
714 static HRESULT WINAPI PersistFile_Save(IPersistFile *iface, LPCOLESTR pszFileName, BOOL fRemember)
716 HTMLDocument *This = impl_from_IPersistFile(iface);
722 TRACE("(%p)->(%s %x)\n", This, debugstr_w(pszFileName), fRemember);
724 file = CreateFileW(pszFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
725 FILE_ATTRIBUTE_NORMAL, NULL);
726 if(file == INVALID_HANDLE_VALUE) {
727 WARN("Could not create file: %u\n", GetLastError());
731 hres = get_doc_string(This->doc_node, &str);
733 WriteFile(file, str, strlen(str), &written, NULL);
739 static HRESULT WINAPI PersistFile_SaveCompleted(IPersistFile *iface, LPCOLESTR pszFileName)
741 HTMLDocument *This = impl_from_IPersistFile(iface);
742 FIXME("(%p)->(%s)\n", This, debugstr_w(pszFileName));
746 static HRESULT WINAPI PersistFile_GetCurFile(IPersistFile *iface, LPOLESTR *pszFileName)
748 HTMLDocument *This = impl_from_IPersistFile(iface);
749 FIXME("(%p)->(%p)\n", This, pszFileName);
753 static const IPersistFileVtbl PersistFileVtbl = {
754 PersistFile_QueryInterface,
757 PersistFile_GetClassID,
761 PersistFile_SaveCompleted,
762 PersistFile_GetCurFile
765 static inline HTMLDocument *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
767 return CONTAINING_RECORD(iface, HTMLDocument, IPersistStreamInit_iface);
770 static HRESULT WINAPI PersistStreamInit_QueryInterface(IPersistStreamInit *iface,
771 REFIID riid, void **ppv)
773 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
774 return htmldoc_query_interface(This, riid, ppv);
777 static ULONG WINAPI PersistStreamInit_AddRef(IPersistStreamInit *iface)
779 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
780 return htmldoc_addref(This);
783 static ULONG WINAPI PersistStreamInit_Release(IPersistStreamInit *iface)
785 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
786 return htmldoc_release(This);
789 static HRESULT WINAPI PersistStreamInit_GetClassID(IPersistStreamInit *iface, CLSID *pClassID)
791 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
792 return IPersistFile_GetClassID(&This->IPersistFile_iface, pClassID);
795 static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
797 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
799 TRACE("(%p)\n", This);
801 if(This->doc_obj->usermode == EDITMODE)
802 return editor_is_dirty(This);
807 static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, LPSTREAM pStm)
809 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
813 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
815 TRACE("(%p)->(%p)\n", This, pStm);
817 hres = CreateURLMoniker(NULL, about_blankW, &mon);
819 WARN("CreateURLMoniker failed: %08x\n", hres);
823 prepare_for_binding(This, mon, FALSE);
824 hres = set_moniker(This, mon, NULL, NULL, TRUE);
825 IMoniker_Release(mon);
829 return channelbsc_load_stream(This->window->pending_window, pStm);
832 static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, LPSTREAM pStm,
835 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
840 TRACE("(%p)->(%p %x)\n", This, pStm, fClearDirty);
842 hres = get_doc_string(This->doc_node, &str);
846 hres = IStream_Write(pStm, str, strlen(str), &written);
848 FIXME("Write failed: %08x\n", hres);
853 set_dirty(This, VARIANT_FALSE);
858 static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface,
859 ULARGE_INTEGER *pcbSize)
861 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
862 FIXME("(%p)->(%p)\n", This, pcbSize);
866 static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
868 HTMLDocument *This = impl_from_IPersistStreamInit(iface);
872 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
874 TRACE("(%p)\n", This);
876 hres = CreateURLMoniker(NULL, about_blankW, &mon);
878 WARN("CreateURLMoniker failed: %08x\n", hres);
882 prepare_for_binding(This, mon, FALSE);
883 hres = set_moniker(This, mon, NULL, NULL, FALSE);
884 IMoniker_Release(mon);
888 return channelbsc_load_stream(This->window->pending_window, NULL);
891 static const IPersistStreamInitVtbl PersistStreamInitVtbl = {
892 PersistStreamInit_QueryInterface,
893 PersistStreamInit_AddRef,
894 PersistStreamInit_Release,
895 PersistStreamInit_GetClassID,
896 PersistStreamInit_IsDirty,
897 PersistStreamInit_Load,
898 PersistStreamInit_Save,
899 PersistStreamInit_GetSizeMax,
900 PersistStreamInit_InitNew
903 /**********************************************************
904 * IPersistHistory implementation
907 static inline HTMLDocument *impl_from_IPersistHistory(IPersistHistory *iface)
909 return CONTAINING_RECORD(iface, HTMLDocument, IPersistHistory_iface);
912 static HRESULT WINAPI PersistHistory_QueryInterface(IPersistHistory *iface, REFIID riid, void **ppv)
914 HTMLDocument *This = impl_from_IPersistHistory(iface);
915 return htmldoc_query_interface(This, riid, ppv);
918 static ULONG WINAPI PersistHistory_AddRef(IPersistHistory *iface)
920 HTMLDocument *This = impl_from_IPersistHistory(iface);
921 return htmldoc_addref(This);
924 static ULONG WINAPI PersistHistory_Release(IPersistHistory *iface)
926 HTMLDocument *This = impl_from_IPersistHistory(iface);
927 return htmldoc_release(This);
930 static HRESULT WINAPI PersistHistory_GetClassID(IPersistHistory *iface, CLSID *pClassID)
932 HTMLDocument *This = impl_from_IPersistHistory(iface);
933 return IPersistFile_GetClassID(&This->IPersistFile_iface, pClassID);
936 static HRESULT WINAPI PersistHistory_LoadHistory(IPersistHistory *iface, IStream *pStream, IBindCtx *pbc)
938 HTMLDocument *This = impl_from_IPersistHistory(iface);
939 FIXME("(%p)->(%p %p)\n", This, pStream, pbc);
943 static HRESULT WINAPI PersistHistory_SaveHistory(IPersistHistory *iface, IStream *pStream)
945 HTMLDocument *This = impl_from_IPersistHistory(iface);
950 TRACE("(%p)->(%p)\n", This, pStream);
952 if(!This->window || !This->window->uri) {
953 FIXME("No current URI\n");
957 /* NOTE: The format we store is *not* compatible with native MSHTML. We currently
958 * store only URI of the page (as a length followed by a string) */
959 hres = IUri_GetDisplayUri(This->window->uri, &display_uri);
963 len = SysStringLen(display_uri);
964 hres = IStream_Write(pStream, &len, sizeof(len), &written);
966 hres = IStream_Write(pStream, display_uri, len*sizeof(WCHAR), &written);
967 SysFreeString(display_uri);
971 static HRESULT WINAPI PersistHistory_SetPositionCookie(IPersistHistory *iface, DWORD dwPositioncookie)
973 HTMLDocument *This = impl_from_IPersistHistory(iface);
974 FIXME("(%p)->(%x)\n", This, dwPositioncookie);
978 static HRESULT WINAPI PersistHistory_GetPositionCookie(IPersistHistory *iface, DWORD *pdwPositioncookie)
980 HTMLDocument *This = impl_from_IPersistHistory(iface);
981 FIXME("(%p)->(%p)\n", This, pdwPositioncookie);
985 static const IPersistHistoryVtbl PersistHistoryVtbl = {
986 PersistHistory_QueryInterface,
987 PersistHistory_AddRef,
988 PersistHistory_Release,
989 PersistHistory_GetClassID,
990 PersistHistory_LoadHistory,
991 PersistHistory_SaveHistory,
992 PersistHistory_SetPositionCookie,
993 PersistHistory_GetPositionCookie
996 void HTMLDocument_Persist_Init(HTMLDocument *This)
998 This->IPersistMoniker_iface.lpVtbl = &PersistMonikerVtbl;
999 This->IPersistFile_iface.lpVtbl = &PersistFileVtbl;
1000 This->IMonikerProp_iface.lpVtbl = &MonikerPropVtbl;
1001 This->IPersistStreamInit_iface.lpVtbl = &PersistStreamInitVtbl;
1002 This->IPersistHistory_iface.lpVtbl = &PersistHistoryVtbl;