WebNotificationManager.h [plain text]
#ifndef WebNotificationManager_h
#define WebNotificationManager_h
#include "MessageID.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 CoreIPC {
class ArgumentDecoder;
class Connection;
}
namespace WebCore {
class Notification;
class SecurityOrigin;
}
namespace WebKit {
class WebPage;
class WebProcess;
class WebNotificationManager {
WTF_MAKE_NONCOPYABLE(WebNotificationManager);
public:
explicit WebNotificationManager(WebProcess*);
~WebNotificationManager();
void initialize(const HashMap<String, bool>& permissions);
bool show(WebCore::Notification*, WebPage*);
void cancel(WebCore::Notification*, WebPage*);
void clearNotifications(WebCore::ScriptExecutionContext*, WebPage*);
void didDestroyNotification(WebCore::Notification*, WebPage*);
void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
WebCore::NotificationClient::Permission policyForOrigin(WebCore::SecurityOrigin*) const;
private:
void didReceiveWebNotificationManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
void didShowNotification(uint64_t notificationID);
void didClickNotification(uint64_t notificationID);
void didCloseNotifications(const Vector<uint64_t>& notificationIDs);
void didUpdateNotificationDecision(const String& originString, bool allowed);
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