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

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

Issue 1904163002: Move Web Notifications to use Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@skbitmap-blink
Patch Set: it works \o/ Created 4 years, 8 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..3edfe4b7964e8a9069f16dd0aa5810577ce5f272
--- /dev/null
+++ b/third_party/WebKit/Source/modules/notifications/NotificationManager.h
@@ -0,0 +1,85 @@
+// 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.mojom-blink.h"
+#include "public/platform/modules/notifications/notification_resources.mojom-blink.h"
+#include "public/platform/modules/notifications/notification_service.mojom-blink.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/text/WTFString.h"
+
+#include <stdint.h>
+
+namespace blink {
+
+namespace mojom {
+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::PermissionStatus permissionStatus() const;
+
+ // Requests the embedder to present the non-persistent |notification| to the
+ // user. The |client|
+ void display(mojom::blink::NotificationPtr notification,
+ mojom::blink::NotificationResourcesPtr notificationResources,
+ mojom::blink::NotificationClientPtr notificationClient,
+ const mojom::blink::NotificationService::DisplayCallback& callback);
+
+ // Requests the embedder to present the persistent |notification| to the
+ // user. The |callback| will be invoked with a result code once the
+ // operation has been completed by the embedder.
+ void displayPersistent(int64_t serviceWorkerRegistrationId,
+ mojom::blink::NotificationPtr notification,
+ mojom::blink::NotificationResourcesPtr notificationResources,
+ const mojom::blink::NotificationService::DisplayPersistentCallback& callback);
+
+ // Requests the embedder to return a list of all persistent notifications
+ // that are currently showing for the associated origin.
+ void getNotifications(int64_t serviceWorkerRegistrationId,
+ const String& tag,
+ const mojom::blink::NotificationService::GetNotificationsCallback& callback) const;
+
+ // Closes the notification identified by |id|. The |callback| will be called
+ // when the notification has been closed by the embedder.
+ void close(const String& id, const mojom::blink::NotificationService::CloseCallback& callback);
+
+ // ContextLifecycleObserver implementation.
+ void contextDestroyed() override;
+
+ DECLARE_VIRTUAL_TRACE();
+
+private:
+ NotificationManager(ExecutionContext*);
+
+ // Returns a string containing the security origin of the execution
+ // context this NotificationManager has been associated with.
+ String getOriginString() const;
+
+ mojom::blink::NotificationServicePtr m_service;
+};
+
+} // namespace blink
+
+#endif // NotificationManager_h

Powered by Google App Engine
This is Rietveld 408576698