WebNotificationManager.h [plain text]
#ifndef WebNotificationManager_h
#define WebNotificationManager_h
#include "MessageReceiver.h"
#include "WebProcessSupplement.h"
#include <WebCore/NotificationClient.h>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
namespace WebCore {
class Notification;
class SecurityOrigin;
}
namespace WebKit {
class WebPage;
class WebProcess;
class WebNotificationManager : public WebProcessSupplement, public IPC::MessageReceiver {
WTF_MAKE_NONCOPYABLE(WebNotificationManager);
public:
explicit WebNotificationManager(WebProcess*);
~WebNotificationManager();
static const char* supplementName();
bool show(WebCore::Notification*, WebPage*);
void cancel(WebCore::Notification*, WebPage*);
void clearNotifications(WebCore::ScriptExecutionContext*, WebPage*);
void didDestroyNotification(WebCore::Notification*, WebPage*);
void didUpdateNotificationDecision(const String& originString, bool allowed);
WebCore::NotificationClient::Permission policyForOrigin(WebCore::SecurityOrigin*) const;
void removeAllPermissionsForTesting();
uint64_t notificationIDForTesting(WebCore::Notification*);
private:
void initialize(const WebProcessCreationParameters&) override;
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
void didShowNotification(uint64_t notificationID);
void didClickNotification(uint64_t notificationID);
void didCloseNotifications(const Vector<uint64_t>& notificationIDs);
void didRemoveNotificationDecisions(const Vector<String>& originStrings);
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
void removeNotificationFromContextMap(uint64_t notificationID, WebCore::Notification*);
#endif
WebProcess* m_process;
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
typedef HashMap<RefPtr<WebCore::Notification>, uint64_t> NotificationMap;
NotificationMap m_notificationMap;
typedef HashMap<uint64_t, RefPtr<WebCore::Notification>> NotificationIDMap;
NotificationIDMap m_notificationIDMap;
typedef HashMap<RefPtr<WebCore::ScriptExecutionContext>, Vector<uint64_t>> NotificationContextMap;
NotificationContextMap m_notificationContextMap;
HashMap<String, bool> m_permissionsMap;
#endif
};
}
#endif