OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NotificationManager_h | 5 #ifndef NotificationManager_h |
6 #define NotificationManager_h | 6 #define NotificationManager_h |
7 | 7 |
8 #include "core/dom/ContextLifecycleObserver.h" | 8 #include "core/dom/ContextLifecycleObserver.h" |
9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
10 #include "public/platform/modules/notifications/notification_service.mojom-blink
.h" | 10 #include "public/platform/modules/notifications/notification_service.mojom-blink
.h" |
11 #include "public/platform/modules/permissions/permission.mojom-blink.h" | |
12 #include "wtf/Noncopyable.h" | 11 #include "wtf/Noncopyable.h" |
13 #include "wtf/text/WTFString.h" | 12 #include "wtf/text/WTFString.h" |
14 | 13 |
15 namespace blink { | 14 namespace blink { |
16 | 15 |
17 namespace mojom { | 16 namespace mojom { |
18 namespace blink { | 17 namespace blink { |
19 enum class PermissionStatus; | 18 enum class PermissionStatus; |
20 } | 19 } |
21 } | 20 } |
22 | 21 |
23 class NotificationPermissionCallback; | |
24 class ScriptPromise; | |
25 class ScriptPromiseResolver; | |
26 class ScriptState; | |
27 | |
28 // The notification manager, unique to the execution context, is responsible for | 22 // The notification manager, unique to the execution context, is responsible for |
29 // connecting and communicating with the Mojo notification service. | 23 // connecting and communicating with the Mojo notification service. |
30 // | 24 // |
31 // TODO(peter): Make the NotificationManager responsible for resource loading. | 25 // TODO(peter): Make the NotificationManager responsible for resource loading. |
32 class NotificationManager final | 26 class NotificationManager final |
33 : public GarbageCollectedFinalized<NotificationManager> | 27 : public GarbageCollectedFinalized<NotificationManager> |
34 , public ContextLifecycleObserver | 28 , public ContextLifecycleObserver |
35 , public Supplement<ExecutionContext> { | 29 , public Supplement<ExecutionContext> { |
36 USING_GARBAGE_COLLECTED_MIXIN(NotificationManager); | 30 USING_GARBAGE_COLLECTED_MIXIN(NotificationManager); |
37 WTF_MAKE_NONCOPYABLE(NotificationManager); | 31 WTF_MAKE_NONCOPYABLE(NotificationManager); |
38 public: | 32 public: |
39 static NotificationManager* from(ExecutionContext*); | 33 static NotificationManager* from(ExecutionContext*); |
40 static const char* supplementName(); | 34 static const char* supplementName(); |
41 | 35 |
42 ~NotificationManager(); | 36 ~NotificationManager(); |
43 | 37 |
44 // Returns the notification permission status of the current origin. This | 38 // Returns the notification permission status of the current origin. This |
45 // method is synchronous to support the Notification.permission getter. | 39 // method is synchronous to support the Notification.permission getter. |
46 mojom::blink::PermissionStatus permissionStatus(); | 40 mojom::blink::PermissionStatus permissionStatus() const; |
47 | |
48 ScriptPromise requestPermission(ScriptState*, NotificationPermissionCallback
* deprecatedCallback); | |
49 | 41 |
50 // ContextLifecycleObserver implementation. | 42 // ContextLifecycleObserver implementation. |
51 void contextDestroyed() override; | 43 void contextDestroyed() override; |
52 | 44 |
53 DECLARE_VIRTUAL_TRACE(); | 45 DECLARE_VIRTUAL_TRACE(); |
54 | 46 |
55 private: | 47 private: |
56 explicit NotificationManager(ExecutionContext*); | 48 explicit NotificationManager(ExecutionContext*); |
57 | 49 |
58 void onPermissionRequestComplete(ScriptPromiseResolver*, NotificationPermiss
ionCallback*, mojom::blink::PermissionStatus); | 50 mojom::blink::NotificationServicePtr m_service; |
59 | |
60 mojom::blink::NotificationServicePtr m_notificationService; | |
61 mojom::blink::PermissionServicePtr m_permissionService; | |
62 }; | 51 }; |
63 | 52 |
64 } // namespace blink | 53 } // namespace blink |
65 | 54 |
66 #endif // NotificationManager_h | 55 #endif // NotificationManager_h |
OLD | NEW |