NotificationCenter.h [plain text]
#ifndef NotificationCenter_h
#define NotificationCenter_h
#include "Notification.h"
#include "NotificationContents.h"
#include "ScriptExecutionContext.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#if ENABLE(NOTIFICATIONS)
namespace WebCore {
class NotificationPresenter;
class VoidCallback;
class NotificationCenter : public RefCounted<NotificationCenter>, public ActiveDOMObject {
public:
static PassRefPtr<NotificationCenter> create(ScriptExecutionContext* context, NotificationPresenter* presenter) { return adoptRef(new NotificationCenter(context, presenter)); }
PassRefPtr<Notification> createHTMLNotification(const String& URI, ExceptionCode& ec)
{
if (!presenter()) {
ec = INVALID_STATE_ERR;
return 0;
}
if (URI.isEmpty()) {
ec = SYNTAX_ERR;
return 0;
}
return Notification::create(scriptExecutionContext()->completeURL(URI), scriptExecutionContext(), ec, this);
}
PassRefPtr<Notification> createNotification(const String& iconURI, const String& title, const String& body, ExceptionCode& ec)
{
if (!presenter()) {
ec = INVALID_STATE_ERR;
return 0;
}
NotificationContents contents(iconURI.isEmpty() ? KURL() : scriptExecutionContext()->completeURL(iconURI), title, body);
return Notification::create(contents, scriptExecutionContext(), ec, this);
}
NotificationPresenter* presenter() const { return m_notificationPresenter; }
int checkPermission();
void requestPermission(PassRefPtr<VoidCallback> callback);
void disconnectFrame();
private:
NotificationCenter(ScriptExecutionContext*, NotificationPresenter*);
NotificationPresenter* m_notificationPresenter;
};
}
#endif // ENABLE(NOTIFICATIONS)
#endif // NotificationCenter_h