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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NotificationManager_h
6 #define NotificationManager_h
7
8 #include "core/dom/ContextLifecycleObserver.h"
9 #include "core/dom/ExecutionContext.h"
10 #include "public/platform/modules/notifications/notification.mojom-blink.h"
11 #include "public/platform/modules/notifications/notification_resources.mojom-bli nk.h"
12 #include "public/platform/modules/notifications/notification_service.mojom-blink .h"
13 #include "wtf/Noncopyable.h"
14 #include "wtf/text/WTFString.h"
15
16 #include <stdint.h>
17
18 namespace blink {
19
20 namespace mojom {
21 enum class PermissionStatus;
22 }
23
24 // The notification manager, unique to the execution context, is responsible for
25 // connecting and communicating with the Mojo notification service.
26 //
27 // TODO(peter): Make the NotificationManager responsible for resource loading.
28 class NotificationManager final : public GarbageCollectedFinalized<NotificationM anager>,
29 public ContextLifecycleObserver,
30 public Supplement<ExecutionContext> {
31 USING_GARBAGE_COLLECTED_MIXIN(NotificationManager);
32 WTF_MAKE_NONCOPYABLE(NotificationManager);
33 public:
34 static NotificationManager* from(ExecutionContext*);
35 static const char* supplementName();
36
37 ~NotificationManager();
38
39 // Returns the notification permission status of the current origin. This
40 // method is synchronous to support the Notification.permission getter.
41 mojom::PermissionStatus permissionStatus() const;
42
43 // Requests the embedder to present the non-persistent |notification| to the
44 // user. The |client|
45 void display(mojom::blink::NotificationPtr notification,
46 mojom::blink::NotificationResourcesPtr notificationResources,
47 mojom::blink::NotificationClientPtr notificationClient,
48 const mojom::blink::NotificationService::DisplayCallback& callb ack);
49
50 // Requests the embedder to present the persistent |notification| to the
51 // user. The |callback| will be invoked with a result code once the
52 // operation has been completed by the embedder.
53 void displayPersistent(int64_t serviceWorkerRegistrationId,
54 mojom::blink::NotificationPtr notification,
55 mojom::blink::NotificationResourcesPtr notificationRe sources,
56 const mojom::blink::NotificationService::DisplayPersi stentCallback& callback);
57
58 // Requests the embedder to return a list of all persistent notifications
59 // that are currently showing for the associated origin.
60 void getNotifications(int64_t serviceWorkerRegistrationId,
61 const String& tag,
62 const mojom::blink::NotificationService::GetNotificati onsCallback& callback) const;
63
64 // Closes the notification identified by |id|. The |callback| will be called
65 // when the notification has been closed by the embedder.
66 void close(const String& id, const mojom::blink::NotificationService::CloseC allback& callback);
67
68 // ContextLifecycleObserver implementation.
69 void contextDestroyed() override;
70
71 DECLARE_VIRTUAL_TRACE();
72
73 private:
74 NotificationManager(ExecutionContext*);
75
76 // Returns a string containing the security origin of the execution
77 // context this NotificationManager has been associated with.
78 String getOriginString() const;
79
80 mojom::blink::NotificationServicePtr m_service;
81 };
82
83 } // namespace blink
84
85 #endif // NotificationManager_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698