Chromium Code Reviews| 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" | |
| 9 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 10 #include "public/platform/modules/notifications/notification_service.mojom-blink .h" | 9 #include "public/platform/modules/notifications/notification_service.mojom-blink .h" |
| 11 #include "public/platform/modules/permissions/permission.mojom-blink.h" | 10 #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 class NotificationPermissionCallback; | 16 class NotificationPermissionCallback; |
| 18 class ScriptPromise; | 17 class ScriptPromise; |
| 19 class ScriptPromiseResolver; | 18 class ScriptPromiseResolver; |
| 20 class ScriptState; | 19 class ScriptState; |
| 21 | 20 |
| 22 // The notification manager, unique to the execution context, is responsible for | 21 // The notification manager, unique to the execution context, is responsible for |
| 23 // connecting and communicating with the Mojo notification service. | 22 // connecting and communicating with the Mojo notification service. |
| 24 // | 23 // |
| 25 // TODO(peter): Make the NotificationManager responsible for resource loading. | 24 // TODO(peter): Make the NotificationManager responsible for resource loading. |
| 26 class NotificationManager final | 25 class NotificationManager final |
| 27 : public GarbageCollectedFinalized<NotificationManager>, | 26 : public GarbageCollectedFinalized<NotificationManager>, |
| 28 public ContextLifecycleObserver, | |
| 29 public Supplement<ExecutionContext> { | 27 public Supplement<ExecutionContext> { |
| 30 USING_GARBAGE_COLLECTED_MIXIN(NotificationManager); | 28 USING_GARBAGE_COLLECTED_MIXIN(NotificationManager); |
| 31 WTF_MAKE_NONCOPYABLE(NotificationManager); | 29 WTF_MAKE_NONCOPYABLE(NotificationManager); |
| 32 | 30 |
| 33 public: | 31 public: |
| 34 static NotificationManager* from(ExecutionContext*); | 32 static NotificationManager* from(ExecutionContext*); |
| 35 static const char* supplementName(); | 33 static const char* supplementName(); |
| 36 | 34 |
| 37 ~NotificationManager(); | 35 ~NotificationManager(); |
| 38 | 36 |
| 39 // Returns the notification permission status of the current origin. This | 37 // Returns the notification permission status of the current origin. This |
| 40 // method is synchronous to support the Notification.permission getter. | 38 // method is synchronous to support the Notification.permission getter. |
| 41 mojom::blink::PermissionStatus permissionStatus(); | 39 mojom::blink::PermissionStatus permissionStatus(ExecutionContext*); |
|
Peter Beverloo
2016/12/07 13:25:36
For future reference -
All potential methods that
haraken
2016/12/07 15:27:13
It should be safe. The fact that NotificationManag
| |
| 42 | 40 |
| 43 ScriptPromise requestPermission( | 41 ScriptPromise requestPermission( |
| 44 ScriptState*, | 42 ScriptState*, |
| 45 NotificationPermissionCallback* deprecatedCallback); | 43 NotificationPermissionCallback* deprecatedCallback); |
| 46 | 44 |
| 47 // ContextLifecycleObserver interface. | |
| 48 void contextDestroyed() override; | |
| 49 | |
| 50 DECLARE_VIRTUAL_TRACE(); | 45 DECLARE_VIRTUAL_TRACE(); |
| 51 | 46 |
| 52 private: | 47 private: |
| 53 explicit NotificationManager(ExecutionContext*); | 48 NotificationManager(); |
| 54 | 49 |
| 55 void onPermissionRequestComplete(ScriptPromiseResolver*, | 50 void onPermissionRequestComplete(ScriptPromiseResolver*, |
| 56 NotificationPermissionCallback*, | 51 NotificationPermissionCallback*, |
| 57 mojom::blink::PermissionStatus); | 52 mojom::blink::PermissionStatus); |
| 58 void onPermissionServiceConnectionError(); | 53 void onPermissionServiceConnectionError(); |
| 59 | 54 |
| 60 mojom::blink::NotificationServicePtr m_notificationService; | 55 mojom::blink::NotificationServicePtr m_notificationService; |
| 61 mojom::blink::PermissionServicePtr m_permissionService; | 56 mojom::blink::PermissionServicePtr m_permissionService; |
| 62 }; | 57 }; |
| 63 | 58 |
| 64 } // namespace blink | 59 } // namespace blink |
| 65 | 60 |
| 66 #endif // NotificationManager_h | 61 #endif // NotificationManager_h |
| OLD | NEW |