#ifndef WebIconDatabase_h
#define WebIconDatabase_h
#include "APIObject.h"
#include "Connection.h"
#include "WebIconDatabaseClient.h"
#include <WebCore/IconDatabaseClient.h>
#include <WebCore/ImageSource.h>
#include <WebCore/IntSize.h>
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
namespace CoreIPC {
class ArgumentDecoder;
class DataReference;
}
namespace WebCore {
class IconDatabase;
class Image;
}
namespace WebKit {
class WebContext;
class WebIconDatabase : public TypedAPIObject<APIObject::TypeIconDatabase>, public WebCore::IconDatabaseClient, private CoreIPC::MessageReceiver {
public:
static PassRefPtr<WebIconDatabase> create(WebContext*);
virtual ~WebIconDatabase();
void invalidate();
void clearContext() { m_webContext = 0; }
void setDatabasePath(const String&);
void enableDatabaseCleanup();
void retainIconForPageURL(const String&);
void releaseIconForPageURL(const String&);
void setIconURLForPageURL(const String&, const String&);
void setIconDataForIconURL(const CoreIPC::DataReference&, const String&);
void synchronousIconDataForPageURL(const String&, CoreIPC::DataReference&);
void synchronousIconURLForPageURL(const String&, String&);
void synchronousIconDataKnownForIconURL(const String&, bool&) const;
void synchronousLoadDecisionForIconURL(const String&, int&) const;
void getLoadDecisionForIconURL(const String&, uint64_t callbackID);
void didReceiveIconForPageURL(const String&);
WebCore::Image* imageForPageURL(const String&, const WebCore::IntSize& iconSize = WebCore::IntSize(32, 32));
WebCore::NativeImagePtr nativeImageForPageURL(const String&, const WebCore::IntSize& iconSize = WebCore::IntSize(32, 32));
bool isOpen();
bool isUrlImportCompleted();
void removeAllIcons();
void checkIntegrityBeforeOpening();
void close();
void initializeIconDatabaseClient(const WKIconDatabaseClient*);
void setPrivateBrowsingEnabled(bool);
private:
WebIconDatabase(WebContext*);
virtual void didImportIconURLForPageURL(const String&);
virtual void didImportIconDataForPageURL(const String&);
virtual void didChangeIconForPageURL(const String&);
virtual void didRemoveAllIcons();
virtual void didFinishURLImport();
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&) OVERRIDE;
void notifyIconDataReadyForPageURL(const String&);
WebContext* m_webContext;
OwnPtr<WebCore::IconDatabase> m_iconDatabaseImpl;
bool m_urlImportCompleted;
bool m_databaseCleanupDisabled;
HashMap<uint64_t, String> m_pendingLoadDecisionURLMap;
WebIconDatabaseClient m_iconDatabaseClient;
};
}
#endif // WebIconDatabase_h