#ifndef WebIconDatabase_h
#define WebIconDatabase_h
#include "APIObject.h"
#include "Connection.h"
#include "WebIconDatabaseClient.h"
#include <WebCore/IconDatabaseClient.h>
#include <WebCore/IntSize.h>
#include <WebCore/NativeImagePtr.h>
namespace API {
class Data;
}
namespace WebCore {
class IconDatabase;
class Image;
}
namespace WebKit {
class WebContext;
class WebIconDatabase : public API::ObjectImpl<API::Object::Type::IconDatabase>, private WebCore::IconDatabaseClient, private IPC::MessageReceiver {
public:
static PassRefPtr<WebIconDatabase> create(WebContext*);
virtual ~WebIconDatabase();
void invalidate();
void clearContext() { m_webContext = nullptr; }
void setDatabasePath(const String&);
void enableDatabaseCleanup();
void retainIconForPageURL(const String&);
void releaseIconForPageURL(const String&);
void setIconURLForPageURL(const String&, const String&);
void setIconDataForIconURL(const IPC::DataReference&, const String&);
void synchronousIconDataForPageURL(const String&, IPC::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));
PassRefPtr<API::Data> iconDataForPageURL(const String& pageURL);
bool isOpen();
bool isUrlImportCompleted();
void removeAllIcons();
void checkIntegrityBeforeOpening();
void close();
void initializeIconDatabaseClient(const WKIconDatabaseClientBase*);
void setPrivateBrowsingEnabled(bool);
void derefWhenAppropriate();
private:
explicit WebIconDatabase(WebContext&);
virtual void didImportIconURLForPageURL(const String&) override;
virtual void didImportIconDataForPageURL(const String&) override;
virtual void didChangeIconForPageURL(const String&) override;
virtual void didRemoveAllIcons() override;
virtual void didFinishURLImport() override;
virtual void didClose() override;
virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
virtual void didReceiveSyncMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&) override;
void notifyIconDataReadyForPageURL(const String&);
WebContext* m_webContext;
std::unique_ptr<WebCore::IconDatabase> m_iconDatabaseImpl;
bool m_urlImportCompleted;
bool m_databaseCleanupDisabled;
bool m_shouldDerefWhenAppropriate;
HashMap<uint64_t, String> m_pendingLoadDecisionURLMap;
WebIconDatabaseClient m_iconDatabaseClient;
};
}
#endif // WebIconDatabase_h