| 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" |
| 11 #include "wtf/Noncopyable.h" | 12 #include "wtf/Noncopyable.h" |
| 12 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 17 class NotificationPermissionCallback; |
| 18 class ScriptPromise; |
| 19 class ScriptPromiseResolver; |
| 20 class ScriptState; |
| 21 |
| 16 // The notification manager, unique to the execution context, is responsible for | 22 // The notification manager, unique to the execution context, is responsible for |
| 17 // connecting and communicating with the Mojo notification service. | 23 // connecting and communicating with the Mojo notification service. |
| 18 // | 24 // |
| 19 // TODO(peter): Make the NotificationManager responsible for resource loading. | 25 // TODO(peter): Make the NotificationManager responsible for resource loading. |
| 20 class NotificationManager final | 26 class NotificationManager final |
| 21 : public GarbageCollectedFinalized<NotificationManager> | 27 : public GarbageCollectedFinalized<NotificationManager> |
| 22 , public ContextLifecycleObserver | 28 , public ContextLifecycleObserver |
| 23 , public Supplement<ExecutionContext> { | 29 , public Supplement<ExecutionContext> { |
| 24 USING_GARBAGE_COLLECTED_MIXIN(NotificationManager); | 30 USING_GARBAGE_COLLECTED_MIXIN(NotificationManager); |
| 25 WTF_MAKE_NONCOPYABLE(NotificationManager); | 31 WTF_MAKE_NONCOPYABLE(NotificationManager); |
| 26 public: | 32 public: |
| 27 static NotificationManager* from(ExecutionContext*); | 33 static NotificationManager* from(ExecutionContext*); |
| 28 static const char* supplementName(); | 34 static const char* supplementName(); |
| 29 | 35 |
| 30 ~NotificationManager(); | 36 ~NotificationManager(); |
| 31 | 37 |
| 32 // Returns the notification permission status of the current origin. This | 38 // Returns the notification permission status of the current origin. This |
| 33 // method is synchronous to support the Notification.permission getter. | 39 // method is synchronous to support the Notification.permission getter. |
| 34 mojom::blink::PermissionStatus permissionStatus() const; | 40 mojom::blink::PermissionStatus permissionStatus(); |
| 41 |
| 42 ScriptPromise requestPermission(ScriptState*, NotificationPermissionCallback
* deprecatedCallback); |
| 35 | 43 |
| 36 // ContextLifecycleObserver implementation. | 44 // ContextLifecycleObserver implementation. |
| 37 void contextDestroyed() override; | 45 void contextDestroyed() override; |
| 38 | 46 |
| 39 DECLARE_VIRTUAL_TRACE(); | 47 DECLARE_VIRTUAL_TRACE(); |
| 40 | 48 |
| 41 private: | 49 private: |
| 42 explicit NotificationManager(ExecutionContext*); | 50 explicit NotificationManager(ExecutionContext*); |
| 43 | 51 |
| 44 mojom::blink::NotificationServicePtr m_service; | 52 void onPermissionRequestComplete(ScriptPromiseResolver*, NotificationPermiss
ionCallback*, mojom::blink::PermissionStatus); |
| 53 void onPermissionServiceConnectionError(); |
| 54 |
| 55 mojom::blink::NotificationServicePtr m_notificationService; |
| 56 mojom::blink::PermissionServicePtr m_permissionService; |
| 45 }; | 57 }; |
| 46 | 58 |
| 47 } // namespace blink | 59 } // namespace blink |
| 48 | 60 |
| 49 #endif // NotificationManager_h | 61 #endif // NotificationManager_h |
| OLD | NEW |