#ifndef WebHistory_H
#define WebHistory_H
#include "WebKit.h"
#include "COMPtr.h"
#include <CoreFoundation/CoreFoundation.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/RetainPtr.h>
namespace WebCore {
class KURL;
class PageGroup;
class String;
}
class WebPreferences;
class WebHistory : public IWebHistory, public IWebHistoryPrivate {
public:
static WebHistory* createInstance();
private:
WebHistory();
~WebHistory();
public:
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef(void);
virtual ULONG STDMETHODCALLTYPE Release(void);
virtual HRESULT STDMETHODCALLTYPE optionalSharedHistory(
IWebHistory** history);
virtual HRESULT STDMETHODCALLTYPE setOptionalSharedHistory(
IWebHistory* history);
virtual HRESULT STDMETHODCALLTYPE loadFromURL(
BSTR url,
IWebError** error,
BOOL* succeeded);
virtual HRESULT STDMETHODCALLTYPE saveToURL(
BSTR url,
IWebError** error,
BOOL* succeeded);
virtual HRESULT STDMETHODCALLTYPE addItems(
int itemCount,
IWebHistoryItem** items);
virtual HRESULT STDMETHODCALLTYPE removeItems(
int itemCount,
IWebHistoryItem** items);
virtual HRESULT STDMETHODCALLTYPE removeAllItems( void);
virtual HRESULT STDMETHODCALLTYPE orderedLastVisitedDays(
int* count,
DATE* calendarDates);
virtual HRESULT STDMETHODCALLTYPE orderedItemsLastVisitedOnDay(
int* count,
IWebHistoryItem** items,
DATE calendarDate);
virtual HRESULT STDMETHODCALLTYPE itemForURL(
BSTR url,
IWebHistoryItem** item);
virtual HRESULT STDMETHODCALLTYPE setHistoryItemLimit(
int limit);
virtual HRESULT STDMETHODCALLTYPE historyItemLimit(
int* limit);
virtual HRESULT STDMETHODCALLTYPE setHistoryAgeInDaysLimit(
int limit);
virtual HRESULT STDMETHODCALLTYPE historyAgeInDaysLimit(
int* limit);
virtual HRESULT STDMETHODCALLTYPE allItems(
int* count,
IWebHistoryItem** items);
virtual HRESULT STDMETHODCALLTYPE data(IStream**);
virtual HRESULT STDMETHODCALLTYPE setVisitedLinkTrackingEnabled(BOOL visitedLinkTrackingEnable);
virtual HRESULT STDMETHODCALLTYPE removeAllVisitedLinks();
static WebHistory* sharedHistory();
void visitedURL(const WebCore::KURL&, const WebCore::String& title, const WebCore::String& httpMethod, bool wasFailure, bool increaseVisitCount);
void addVisitedLinksToPageGroup(WebCore::PageGroup&);
COMPtr<IWebHistoryItem> itemForURLString(const WebCore::String&) const;
typedef int64_t DateKey;
typedef HashMap<DateKey, RetainPtr<CFMutableArrayRef> > DateToEntriesMap;
private:
enum NotificationType
{
kWebHistoryItemsAddedNotification = 0,
kWebHistoryItemsRemovedNotification = 1,
kWebHistoryAllItemsRemovedNotification = 2,
kWebHistoryLoadedNotification = 3,
kWebHistoryItemsDiscardedWhileLoadingNotification = 4,
kWebHistorySavedNotification = 5
};
HRESULT loadHistoryGutsFromURL(CFURLRef url, CFMutableArrayRef discardedItems, IWebError** error);
HRESULT saveHistoryGuts(CFURLRef url, IWebError** error);
HRESULT postNotification(NotificationType notifyType, IPropertyBag* userInfo = 0);
HRESULT removeItem(IWebHistoryItem* entry);
HRESULT addItem(IWebHistoryItem* entry, bool discardDuplicate, bool* added);
HRESULT removeItemForURLString(CFStringRef urlString);
HRESULT addItemToDateCaches(IWebHistoryItem* entry);
HRESULT removeItemFromDateCaches(IWebHistoryItem* entry);
HRESULT insertItem(IWebHistoryItem* entry, DateKey);
HRESULT ageLimitDate(CFAbsoluteTime* time);
bool findKey(DateKey*, CFAbsoluteTime forDay);
static CFAbsoluteTime timeToDate(CFAbsoluteTime time);
BSTR getNotificationString(NotificationType notifyType);
HRESULT itemForURLString(CFStringRef urlString, IWebHistoryItem** item) const;
RetainPtr<CFDataRef> data() const;
ULONG m_refCount;
RetainPtr<CFMutableDictionaryRef> m_entriesByURL;
DateToEntriesMap m_entriesByDate;
OwnArrayPtr<DATE> m_orderedLastVisitedDays;
COMPtr<WebPreferences> m_preferences;
};
#endif