summaryrefslogtreecommitdiff
path: root/Source/WebCore/Modules/notifications/NotificationCenter.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/Modules/notifications/NotificationCenter.h')
-rw-r--r--Source/WebCore/Modules/notifications/NotificationCenter.h63
1 files changed, 19 insertions, 44 deletions
diff --git a/Source/WebCore/Modules/notifications/NotificationCenter.h b/Source/WebCore/Modules/notifications/NotificationCenter.h
index d27b45e4f..4646e182e 100644
--- a/Source/WebCore/Modules/notifications/NotificationCenter.h
+++ b/Source/WebCore/Modules/notifications/NotificationCenter.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
- * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012, 2015 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
@@ -29,75 +29,50 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef NotificationCenter_h
-#define NotificationCenter_h
+#pragma once
-#include "ExceptionCode.h"
-#include "Notification.h"
-#include "ScriptExecutionContext.h"
+#include "ActiveDOMObject.h"
+#include "ExceptionOr.h"
#include "Timer.h"
-#include "VoidCallback.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
namespace WebCore {
+class Notification;
class NotificationClient;
class VoidCallback;
-class NotificationCenter : public RefCounted<NotificationCenter>, public ActiveDOMObject {
+class NotificationCenter final : public RefCounted<NotificationCenter>, private ActiveDOMObject {
public:
- static PassRefPtr<NotificationCenter> create(ScriptExecutionContext*, NotificationClient*);
+ static Ref<NotificationCenter> create(ScriptExecutionContext&, NotificationClient*);
#if ENABLE(LEGACY_NOTIFICATIONS)
- PassRefPtr<Notification> createNotification(const String& iconURI, const String& title, const String& body, ExceptionCode& ec)
- {
- if (!client()) {
- ec = INVALID_STATE_ERR;
- return 0;
- }
- return Notification::create(title, body, iconURI, scriptExecutionContext(), ec, this);
- }
-#endif
-
- NotificationClient* client() const { return m_client; }
+ ExceptionOr<Ref<Notification>> createNotification(const String& iconURL, const String& title, const String& body);
-#if ENABLE(LEGACY_NOTIFICATIONS)
int checkPermission();
- void requestPermission(PassRefPtr<VoidCallback> = 0);
+ void requestPermission(RefPtr<VoidCallback>&&);
#endif
-private:
- NotificationCenter(ScriptExecutionContext*, NotificationClient*);
+ NotificationClient* client() const { return m_client; }
- // ActiveDOMObject
- virtual void stop() override;
+ using ActiveDOMObject::hasPendingActivity;
- class NotificationRequestCallback : public RefCounted<NotificationRequestCallback> {
- public:
- static PassRefPtr<NotificationRequestCallback> createAndStartTimer(NotificationCenter*, PassRefPtr<VoidCallback>);
- void startTimer();
- void timerFired(Timer<NotificationRequestCallback>&);
- private:
- NotificationRequestCallback(NotificationCenter*, PassRefPtr<VoidCallback>);
+private:
+ NotificationCenter(ScriptExecutionContext&, NotificationClient*);
- RefPtr<NotificationCenter> m_notificationCenter;
- Timer<NotificationRequestCallback> m_timer;
- RefPtr<VoidCallback> m_callback;
- };
+ void stop() final;
+ const char* activeDOMObjectName() const final;
+ bool canSuspendForDocumentSuspension() const final;
- void requestTimedOut(NotificationRequestCallback*);
+ void timerFired();
NotificationClient* m_client;
- HashSet<RefPtr<NotificationRequestCallback>> m_callbacks;
+ Vector<std::function<void ()>> m_callbacks;
+ Timer m_timer;
};
} // namespace WebCore
#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
-
-#endif // NotificationCenter_h