/*
* Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
#ifndef NotificationCenter_h
#define NotificationCenter_h
+#include "ExceptionCode.h"
#include "Notification.h"
#include "NotificationContents.h"
#include "ScriptExecutionContext.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);
+
+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);
+ 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; }
+ NotificationPresenter* presenter() const { return m_notificationPresenter; }
- int checkPermission();
- void requestPermission(PassRefPtr<VoidCallback> callback);
+ int checkPermission();
+ void requestPermission(PassRefPtr<VoidCallback>);
- void disconnectFrame();
+ void disconnectFrame();
- private:
- NotificationCenter(ScriptExecutionContext*, NotificationPresenter*);
+private:
+ NotificationCenter(ScriptExecutionContext*, NotificationPresenter*);
- NotificationPresenter* m_notificationPresenter;
- };
+ NotificationPresenter* m_notificationPresenter;
+};
} // namespace WebCore