diff --git a/dlls/ieframe/dochost.c b/dlls/ieframe/dochost.c index e1a897abf65..f95c4bd653c 100644 --- a/dlls/ieframe/dochost.c +++ b/dlls/ieframe/dochost.c @@ -20,6 +20,7 @@ #include "exdispid.h" #include "mshtml.h" +#include "perhist.h" #include "initguid.h" #include "wine/debug.h" @@ -335,9 +336,33 @@ static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l static void free_travellog_entry(travellog_entry_t *entry) { + if(entry->stream) + IStream_Release(entry->stream); heap_free(entry->url); } +static IStream *get_travellog_stream(DocHost *This) +{ + IPersistHistory *persist_history; + IStream *stream; + HRESULT hres; + + hres = IUnknown_QueryInterface(This->document, &IID_IPersistHistory, (void**)&persist_history); + if(FAILED(hres)) + return NULL; + + hres = CreateStreamOnHGlobal(NULL, TRUE, &stream); + if(SUCCEEDED(hres)) + hres = IPersistHistory_SaveHistory(persist_history, stream); + IPersistHistory_Release(persist_history); + if(FAILED(hres)) { + IStream_Release(stream); + return NULL; + } + + return stream; +} + static void update_travellog(DocHost *This) { travellog_entry_t *new_entry; @@ -368,9 +393,12 @@ static void update_travellog(DocHost *This) new_entry = This->travellog.log + This->travellog.position; new_entry->url = heap_strdupW(This->url); + TRACE("Adding %s at %d\n", debugstr_w(This->url), This->travellog.position); if(!new_entry->url) return; + new_entry->stream = get_travellog_stream(This); + if(This->travellog.loading_pos == -1) { This->travellog.position++; }else { diff --git a/dlls/ieframe/ieframe.h b/dlls/ieframe/ieframe.h index 2508ef256a6..4140e05c06d 100644 --- a/dlls/ieframe/ieframe.h +++ b/dlls/ieframe/ieframe.h @@ -96,6 +96,7 @@ typedef struct { typedef struct { WCHAR *url; + IStream *stream; } travellog_entry_t; typedef struct _IDocHostContainerVtbl diff --git a/dlls/ieframe/navigate.c b/dlls/ieframe/navigate.c index b6e277c0c51..703e32cf0e8 100644 --- a/dlls/ieframe/navigate.c +++ b/dlls/ieframe/navigate.c @@ -27,6 +27,7 @@ #include "shlwapi.h" #include "wininet.h" #include "mshtml.h" +#include "perhist.h" #include "resource.h" #include "wine/debug.h" @@ -1058,28 +1059,44 @@ HRESULT go_home(DocHost *This) return navigate_url(This, wszPageName, NULL, NULL, NULL, NULL); } -HRESULT go_back(DocHost *This) +static HRESULT navigate_history(DocHost *This, unsigned travellog_pos) { - WCHAR *url; + IPersistHistory *persist_history; + travellog_entry_t *entry; + LARGE_INTEGER li; HRESULT hres; + if(!This->doc_navigate) { + FIXME("unsupported doc_navigate FALSE\n"); + return E_NOTIMPL; + } + + This->travellog.loading_pos = travellog_pos; + entry = This->travellog.log + This->travellog.loading_pos; + + if(!entry->stream) + return async_doc_navigate(This, entry->url, NULL, NULL, 0, FALSE); + + hres = IUnknown_QueryInterface(This->document, &IID_IPersistHistory, (void**)&persist_history); + if(FAILED(hres)) + return hres; + + li.QuadPart = 0; + IStream_Seek(entry->stream, li, STREAM_SEEK_SET, NULL); + + hres = IPersistHistory_LoadHistory(persist_history, entry->stream, NULL); + IPersistHistory_Release(persist_history); + return hres; +} + +HRESULT go_back(DocHost *This) +{ if(!This->travellog.position) { WARN("No history available\n"); return E_FAIL; } - This->travellog.loading_pos = This->travellog.position-1; - url = This->travellog.log[This->travellog.loading_pos].url; - - if(This->doc_navigate) { - hres = async_doc_navigate(This, url, NULL, NULL, 0, FALSE); - }else { - FIXME("unsupported doc_navigate FALSE\n"); - hres = E_NOTIMPL; - } - - heap_free(url); - return hres; + return navigate_history(This, This->travellog.position-1); } HRESULT get_location_url(DocHost *This, BSTR *ret)