| OLD | NEW |
| (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/frame/LocalFrame.h" |
| 10 #include "core/workers/WorkerGlobalScope.h" |
| 11 #include "public/platform/modules/notifications/notification.mojom-wtf.h" |
| 12 #include "public/platform/modules/notifications/notification_resources.mojom-wtf
.h" |
| 13 #include "public/platform/modules/notifications/notification_service.mojom-wtf.h
" |
| 14 #include "wtf/Noncopyable.h" |
| 15 #include "wtf/text/WTFString.h" |
| 16 |
| 17 namespace blink { |
| 18 |
| 19 namespace mojom { |
| 20 enum class PermissionStatus; |
| 21 } |
| 22 |
| 23 class NotificationManager final : public GarbageCollectedFinalized<NotificationM
anager>, |
| 24 public ContextLifecycleObserver, |
| 25 public Supplement<LocalFrame>, |
| 26 public Supplement<WorkerGlobalScope> { |
| 27 USING_GARBAGE_COLLECTED_MIXIN(NotificationManager); |
| 28 WTF_MAKE_NONCOPYABLE(NotificationManager); |
| 29 public: |
| 30 static NotificationManager* from(ExecutionContext*); |
| 31 static const char* supplementName(); |
| 32 |
| 33 ~NotificationManager(); |
| 34 |
| 35 // Returns the notification permission status of the current origin. This |
| 36 // method is synchronous to support the Notification.permission getter. |
| 37 mojom::PermissionStatus permissionStatus() const; |
| 38 |
| 39 // Requests the embedder to present the non-persistent |notification| to the |
| 40 // user. |
| 41 // TODO: Pass the client. |
| 42 void show(mojom::wtf::NotificationPtr notification, |
| 43 mojom::wtf::NotificationResourcesPtr notificationResources); |
| 44 |
| 45 // Requests the embedder to present the persistent |notification| to the |
| 46 // user. The |callback| will be invoked with a result code once the |
| 47 // operation has been completed by the embedder. |
| 48 void showPersistent(mojom::wtf::NotificationPtr notification, |
| 49 mojom::wtf::NotificationResourcesPtr notificationResourc
es, |
| 50 const mojom::wtf::NotificationService::ShowPersistentCal
lback& callback); |
| 51 |
| 52 // ContextLifecycleObserver implementation. |
| 53 void contextDestroyed() override; |
| 54 |
| 55 DECLARE_VIRTUAL_TRACE(); |
| 56 |
| 57 private: |
| 58 NotificationManager(ExecutionContext*); |
| 59 |
| 60 // Returns a string containing the security origin of the execution |
| 61 // context this NotificationManager has been associated with. |
| 62 String getOriginString() const; |
| 63 |
| 64 mojom::wtf::NotificationServicePtr m_service; |
| 65 }; |
| 66 |
| 67 } // namespace blink |
| 68 |
| 69 #endif // NotificationManager_h |
| OLD | NEW |