WebBackForwardListItem.h [plain text]
#pragma once
#include "APIObject.h"
#include "SessionState.h"
#include "WebPageProxyIdentifier.h"
#include <wtf/Ref.h>
#include <wtf/WeakPtr.h>
#include <wtf/text/WTFString.h>
namespace API {
class Data;
}
namespace IPC {
class Decoder;
class Encoder;
}
namespace WebKit {
class SuspendedPageProxy;
class WebBackForwardCache;
class WebBackForwardCacheEntry;
class WebBackForwardListItem : public API::ObjectImpl<API::Object::Type::BackForwardListItem> {
public:
static Ref<WebBackForwardListItem> create(BackForwardListItemState&&, WebPageProxyIdentifier);
virtual ~WebBackForwardListItem();
static WebBackForwardListItem* itemForID(const WebCore::BackForwardItemIdentifier&);
static HashMap<WebCore::BackForwardItemIdentifier, WebBackForwardListItem*>& allItems();
const WebCore::BackForwardItemIdentifier& itemID() const { return m_itemState.identifier; }
const BackForwardListItemState& itemState() { return m_itemState; }
WebPageProxyIdentifier pageID() const { return m_pageID; }
WebCore::ProcessIdentifier lastProcessIdentifier() const { return m_lastProcessIdentifier; }
void setLastProcessIdentifier(const WebCore::ProcessIdentifier& identifier) { m_lastProcessIdentifier = identifier; }
void setPageState(PageState&& pageState) { m_itemState.pageState = WTFMove(pageState); }
const PageState& pageState() const { return m_itemState.pageState; }
const String& originalURL() const { return m_itemState.pageState.mainFrameState.originalURLString; }
const String& url() const { return m_itemState.pageState.mainFrameState.urlString; }
const String& title() const { return m_itemState.pageState.title; }
const URL& resourceDirectoryURL() const { return m_resourceDirectoryURL; }
void setResourceDirectoryURL(URL&& url) { m_resourceDirectoryURL = WTFMove(url); }
bool itemIsInSameDocument(const WebBackForwardListItem&) const;
bool itemIsClone(const WebBackForwardListItem&);
#if PLATFORM(COCOA) || PLATFORM(GTK)
ViewSnapshot* snapshot() const { return m_itemState.snapshot.get(); }
void setSnapshot(RefPtr<ViewSnapshot>&& snapshot) { m_itemState.snapshot = WTFMove(snapshot); }
#endif
void wasRemovedFromBackForwardList();
WebBackForwardCacheEntry* backForwardCacheEntry() const { return m_backForwardCacheEntry.get(); }
SuspendedPageProxy* suspendedPage() const;
#if !LOG_DISABLED
const char* loggingString();
#endif
private:
WebBackForwardListItem(BackForwardListItemState&&, WebPageProxyIdentifier);
void removeFromBackForwardCache();
friend class WebBackForwardCache;
void setBackForwardCacheEntry(std::unique_ptr<WebBackForwardCacheEntry>&&);
BackForwardListItemState m_itemState;
URL m_resourceDirectoryURL;
WebPageProxyIdentifier m_pageID;
WebCore::ProcessIdentifier m_lastProcessIdentifier;
std::unique_ptr<WebBackForwardCacheEntry> m_backForwardCacheEntry;
};
typedef Vector<Ref<WebBackForwardListItem>> BackForwardListItemVector;
}