WorkerGlobalScopeNotifications.cpp [plain text]
#include "config.h"
#include "WorkerGlobalScopeNotifications.h"
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
#include "NotificationCenter.h"
#include "WorkerGlobalScope.h"
#include "WorkerThread.h"
namespace WebCore {
WorkerGlobalScopeNotifications::WorkerGlobalScopeNotifications(WorkerGlobalScope* context)
: m_context(context)
{
}
WorkerGlobalScopeNotifications::~WorkerGlobalScopeNotifications()
{
}
const char* WorkerGlobalScopeNotifications::supplementName()
{
return "WorkerGlobalScopeNotifications";
}
WorkerGlobalScopeNotifications* WorkerGlobalScopeNotifications::from(WorkerGlobalScope* context)
{
WorkerGlobalScopeNotifications* supplement = static_cast<WorkerGlobalScopeNotifications*>(Supplement<ScriptExecutionContext>::from(context, supplementName()));
if (!supplement) {
auto newSupplement = std::make_unique<WorkerGlobalScopeNotifications>(context);
supplement = newSupplement.get();
provideTo(context, supplementName(), WTF::move(newSupplement));
}
return supplement;
}
NotificationCenter* WorkerGlobalScopeNotifications::webkitNotifications(WorkerGlobalScope* context)
{
return WorkerGlobalScopeNotifications::from(context)->webkitNotifications();
}
NotificationCenter* WorkerGlobalScopeNotifications::webkitNotifications()
{
if (!m_notificationCenter)
m_notificationCenter = NotificationCenter::create(m_context, m_context->thread().getNotificationClient());
return m_notificationCenter.get();
}
}
#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)