NavigatorStorageQuota.cpp [plain text]
#include "config.h"
#include "NavigatorStorageQuota.h"
#if ENABLE(QUOTA)
#include "Frame.h"
#include "Navigator.h"
#include "StorageQuota.h"
namespace WebCore {
NavigatorStorageQuota::NavigatorStorageQuota(Frame* frame)
: DOMWindowProperty(frame)
{
}
NavigatorStorageQuota::~NavigatorStorageQuota()
{
}
const char* NavigatorStorageQuota::supplementName()
{
return "NavigatorStorageQuota";
}
NavigatorStorageQuota* NavigatorStorageQuota::from(Navigator* navigator)
{
NavigatorStorageQuota* supplement = static_cast<NavigatorStorageQuota*>(Supplement<Navigator>::from(navigator, supplementName()));
if (!supplement) {
auto newSupplement = std::make_unique<NavigatorStorageQuota>(window);
supplement = newSupplement.get();
provideTo(navigator, supplementName(), WTFMove(newSupplement));
}
return supplement;
}
StorageQuota* NavigatorStorageQuota::webkitTemporaryStorage(Navigator* navigator)
{
return NavigatorStorageQuota::from(navigator)->webkitTemporaryStorage();
}
StorageQuota* NavigatorStorageQuota::webkitPersistentStorage(Navigator* navigator)
{
return NavigatorStorageQuota::from(navigator)->webkitPersistentStorage();
}
StorageQuota* NavigatorStorageQuota::webkitTemporaryStorage() const
{
if (!m_temporaryStorage && frame())
m_temporaryStorage = StorageQuota::create(StorageQuota::Temporary);
return m_temporaryStorage.get();
}
StorageQuota* NavigatorStorageQuota::webkitPersistentStorage() const
{
if (!m_persistentStorage && frame())
m_persistentStorage = StorageQuota::create(StorageQuota::Persistent);
return m_persistentStorage.get();
}
}
#endif // ENABLE(QUOTA)