#ifndef WebIconDatabase_H
#define WebIconDatabase_H
#include "WebKit.h"
#include <WebCore/IconDatabaseClient.h>
#include <WebCore/IntSize.h>
#include <WebCore/IntSizeHash.h>
#include <wtf/Vector.h>
#include <wtf/Threading.h>
#include <windows.h>
namespace WebCore
{
class IconDatabase;
}; using namespace WebCore;
using namespace WTF;
class WebIconDatabase : public IWebIconDatabase, public WebCore::IconDatabaseClient
{
public:
static WebIconDatabase* createInstance();
static WebIconDatabase* sharedWebIconDatabase();
private:
WebIconDatabase();
~WebIconDatabase();
void init();
void startUpIconDatabase();
void shutDownIconDatabase();
public:
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef(void);
virtual ULONG STDMETHODCALLTYPE Release(void);
virtual HRESULT STDMETHODCALLTYPE sharedIconDatabase(
IWebIconDatabase **result);
virtual HRESULT STDMETHODCALLTYPE iconForURL(BSTR url, LPSIZE, BOOL cache, HBITMAP* image);
virtual HRESULT STDMETHODCALLTYPE defaultIconWithSize( LPSIZE size, HBITMAP* result);
virtual HRESULT STDMETHODCALLTYPE retainIconForURL(
BSTR url);
virtual HRESULT STDMETHODCALLTYPE releaseIconForURL(
BSTR url);
virtual HRESULT STDMETHODCALLTYPE removeAllIcons( void);
virtual HRESULT STDMETHODCALLTYPE delayDatabaseCleanup( void);
virtual HRESULT STDMETHODCALLTYPE allowDatabaseCleanup( void);
virtual HRESULT STDMETHODCALLTYPE iconURLForURL(
BSTR url,
BSTR *iconURL);
virtual HRESULT STDMETHODCALLTYPE isEnabled(
BOOL *result);
virtual HRESULT STDMETHODCALLTYPE setEnabled(
BOOL );
virtual HRESULT STDMETHODCALLTYPE hasIconForURL(
BSTR url,
BOOL* result);
virtual void didRemoveAllIcons();
virtual void didImportIconURLForPageURL(const WTF::String&);
virtual void didImportIconDataForPageURL(const WTF::String&);
virtual void didChangeIconForPageURL(const WTF::String&);
virtual void didFinishURLImport();
static BSTR iconDatabaseDidAddIconNotification();
static BSTR iconDatabaseDidRemoveAllIconsNotification();
static BSTR iconDatabaseNotificationUserInfoURLKey();
protected:
ULONG m_refCount;
static WebIconDatabase* m_sharedWebIconDatabase;
HBITMAP getOrCreateSharedBitmap(const IntSize&);
HBITMAP getOrCreateDefaultIconBitmap(const IntSize&);
HashMap<IntSize, HBITMAP> m_defaultIconMap;
HashMap<IntSize, HBITMAP> m_sharedIconMap;
Mutex m_notificationMutex;
Vector<String> m_notificationQueue;
void scheduleNotificationDelivery();
bool m_deliveryRequested;
static void deliverNotifications(void*);
};
#endif