Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2036)

Unified Diff: third_party/WebKit/Source/modules/notifications/NotificationManager.h

Issue 2003023002: Introduce the Blink NotificationService, move permission checks there (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/notifications/NotificationManager.h
diff --git a/third_party/WebKit/Source/modules/notifications/NotificationManager.h b/third_party/WebKit/Source/modules/notifications/NotificationManager.h
new file mode 100644
index 0000000000000000000000000000000000000000..d4b46f39331fae1e1bc863ffe6878be432526c18
--- /dev/null
+++ b/third_party/WebKit/Source/modules/notifications/NotificationManager.h
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NotificationManager_h
+#define NotificationManager_h
+
+#include "core/dom/ContextLifecycleObserver.h"
+#include "core/dom/ExecutionContext.h"
+#include "public/platform/modules/notifications/notification_service.mojom-blink.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/text/WTFString.h"
+
+namespace blink {
+
+namespace mojom {
+namespace blink {
+enum class PermissionStatus;
+}
+}
+
+// The notification manager, unique to the execution context, is responsible for
+// connecting and communicating with the Mojo notification service.
+//
+// TODO(peter): Make the NotificationManager responsible for resource loading.
+class NotificationManager final
+ : public GarbageCollectedFinalized<NotificationManager>
+ , public ContextLifecycleObserver
+ , public Supplement<ExecutionContext> {
+ USING_GARBAGE_COLLECTED_MIXIN(NotificationManager);
+ WTF_MAKE_NONCOPYABLE(NotificationManager);
+public:
+ static NotificationManager* from(ExecutionContext*);
+ static const char* supplementName();
+
+ ~NotificationManager();
+
+ // Returns the notification permission status of the current origin. This
+ // method is synchronous to support the Notification.permission getter.
+ mojom::blink::PermissionStatus permissionStatus() const;
+
+ // ContextLifecycleObserver implementation.
+ void contextDestroyed() override;
+
+ DECLARE_VIRTUAL_TRACE();
+
+private:
+ explicit NotificationManager(ExecutionContext*);
+
+ mojom::blink::NotificationServicePtr m_service;
+};
+
+} // namespace blink
+
+#endif // NotificationManager_h

Powered by Google App Engine
This is Rietveld 408576698