[webkit-changes] [WebKit/WebKit] 4b36ae: Declarative Web Push: Support `pushnotification` e...

Brady Eidson noreply at github.com
Sat Sep 23 01:54:38 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4b36aea360ae3875d94060a3c6705a7b3857b847
      https://github.com/WebKit/WebKit/commit/4b36aea360ae3875d94060a3c6705a7b3857b847
  Author: Brady Eidson <beidson at apple.com>
  Date:   2023-09-23 (Sat, 23 Sep 2023)

  Changed paths:
    M Source/WebCore/CMakeLists.txt
    M Source/WebCore/DerivedSources-input.xcfilelist
    M Source/WebCore/DerivedSources-output.xcfilelist
    M Source/WebCore/DerivedSources.make
    M Source/WebCore/Headers.cmake
    M Source/WebCore/Modules/notifications/Notification.cpp
    M Source/WebCore/Modules/notifications/Notification.h
    M Source/WebCore/Modules/notifications/NotificationOptionsPayload.h
    M Source/WebCore/Modules/notifications/NotificationPayload.cpp
    M Source/WebCore/Modules/notifications/NotificationPayload.h
    A Source/WebCore/Modules/push-api/PushNotificationEvent.cpp
    A Source/WebCore/Modules/push-api/PushNotificationEvent.h
    A Source/WebCore/Modules/push-api/PushNotificationEvent.idl
    A Source/WebCore/Modules/push-api/PushNotificationEventInit.h
    A Source/WebCore/Modules/push-api/PushNotificationEventInit.idl
    M Source/WebCore/Modules/webcodecs/WebCodecsAudioEncoder.cpp
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/bindings/js/WebCoreBuiltinNames.h
    M Source/WebCore/dom/EventNames.h
    M Source/WebCore/dom/EventNames.in
    M Source/WebCore/page/WorkerNavigator.cpp
    M Source/WebCore/testing/ServiceWorkerInternals.cpp
    M Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp
    M Source/WebCore/workers/service/ServiceWorkerGlobalScope.h
    M Source/WebCore/workers/service/ServiceWorkerRegistration.cpp
    M Source/WebCore/workers/service/context/SWContextManager.cpp
    M Source/WebCore/workers/service/context/SWContextManager.h
    M Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
    M Source/WebCore/workers/service/context/ServiceWorkerThread.h
    M Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp
    M Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h
    M Source/WebCore/workers/service/server/SWServer.cpp
    M Source/WebCore/workers/service/server/SWServer.h
    M Source/WebCore/workers/service/server/SWServerToContextConnection.h
    M Source/WebKit/NetworkProcess/NetworkProcess.cpp
    M Source/WebKit/NetworkProcess/NetworkProcess.h
    M Source/WebKit/NetworkProcess/NetworkProcess.messages.in
    M Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp
    M Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/Shared/Cocoa/WebPushMessageCocoa.mm
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/Shared/WebPushMessage.h
    M Source/WebKit/Shared/WebPushMessage.serialization.in
    M Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
    M Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
    M Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
    M Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
    M Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h
    M Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in
    M Source/WebKit/webpushd/PushService.mm
    M Source/WebKit/webpushd/WebPushDaemon.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm

  Log Message:
  -----------
  Declarative Web Push: Support `pushnotification` event for declarative messages that are mutable
https://bugs.webkit.org/show_bug.cgi?id=261956
rdar://114886688

Reviewed by Brent Fulgham and Chris Dumez.

When a declarative web push message arrives, and the sender has explicitly marked it "mutable",
we fire a new `pushnotification` event at the Service Worker if there is one.

That event handler is given the proposed Notification described by the declarative message, and
has the opportunity to offer a new one instead.

It is also given the proposed AppBadge count described by the declarative message, and can modify
that as well.

If the event takes too long, or does *not* override the proposed Notification or AppBadge count,
then the originals described by the declarative message are used instead.

Implementation-wise, it's amazing how long of a chain of message handlers and completion handlers
exist to get a push message from the UI process to the point where an event can be dispatched
to the ServiceWorker.

This patch changes every single link in that chain to:
1 - Pass along the proposed NotificationPayload if one exists
2 - Change the CompletionHandlers to return the new NotificationPayload to be used.

* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Headers.cmake:
* Source/WebCore/Modules/notifications/Notification.cpp:
(WebCore::Notification::create):
(WebCore::Notification::Notification):
* Source/WebCore/Modules/notifications/Notification.h:
* Source/WebCore/Modules/notifications/NotificationOptionsPayload.h:
(WebCore::NotificationOptionsPayload::isolatedCopy):
* Source/WebCore/Modules/notifications/NotificationPayload.cpp:
(WebCore::NotificationPayload::fromNotificationData):
* Source/WebCore/Modules/notifications/NotificationPayload.h:
(WebCore::NotificationPayload::isolatedCopy):
* Source/WebCore/Modules/push-api/PushNotificationEvent.cpp: Copied from Source/WebCore/Modules/notifications/NotificationPayload.cpp.
(WebCore::PushNotificationEvent::PushNotificationEvent):
(WebCore::PushNotificationEvent::~PushNotificationEvent):
(WebCore::PushNotificationEvent::create):
* Source/WebCore/Modules/push-api/PushNotificationEvent.h: Added.
* Source/WebCore/Modules/push-api/PushNotificationEvent.idl: Copied from Source/WebCore/Modules/notifications/NotificationOptionsPayload.h.
* Source/WebCore/Modules/push-api/PushNotificationEventInit.h: Copied from Source/WebCore/Modules/notifications/NotificationOptionsPayload.h.
* Source/WebCore/Modules/push-api/PushNotificationEventInit.idl: Copied from Source/WebCore/Modules/notifications/NotificationOptionsPayload.h.
* Source/WebCore/Modules/webcodecs/WebCodecsAudioEncoder.cpp:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/dom/EventNames.h:
* Source/WebCore/dom/EventNames.in:
* Source/WebCore/page/WorkerNavigator.cpp:
(WebCore::WorkerNavigator::setAppBadge):
* Source/WebCore/testing/ServiceWorkerInternals.cpp:
(WebCore::ServiceWorkerInternals::schedulePushEvent):
* Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp:
(WebCore::ServiceWorkerGlobalScope::dispatchPushEvent):
(WebCore::ServiceWorkerGlobalScope::dispatchPushNotificationEvent):
(WebCore::ServiceWorkerGlobalScope::clearPushNotificationEvent):
* Source/WebCore/workers/service/ServiceWorkerGlobalScope.h:
* Source/WebCore/workers/service/ServiceWorkerRegistration.cpp:
(WebCore::ServiceWorkerRegistration::showNotification):
* Source/WebCore/workers/service/context/SWContextManager.cpp:
(WebCore::SWContextManager::firePushEvent):
* Source/WebCore/workers/service/context/SWContextManager.h:
* Source/WebCore/workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::queueTaskToFirePushEvent):
(WebCore::ServiceWorkerThread::queueTaskToFirePushNotificationEvent):
(WebCore::ServiceWorkerThread::startNotificationPayloadFunctionalEventMonitoring):
(WebCore::ServiceWorkerThread::heartBeatTimerFired):
* Source/WebCore/workers/service/context/ServiceWorkerThread.h:
(WebCore::ServiceWorkerThread::stopNotificationPayloadFunctionalEventMonitoring):
* Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::ServiceWorkerThreadProxy::firePushEvent):
* Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h:
* Source/WebCore/workers/service/server/SWServer.cpp:
(WebCore::SWServer::processPushMessage):
* Source/WebCore/workers/service/server/SWServer.h:
* Source/WebCore/workers/service/server/SWServerToContextConnection.h:
* Source/WebKit/NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::processPushMessage):
* Source/WebKit/NetworkProcess/NetworkProcess.h:
* Source/WebKit/NetworkProcess/NetworkProcess.messages.in:
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
(WebKit::WebSWServerToContextConnection::firePushEvent):
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:
* Source/WebKit/Scripts/webkit/messages.py:
(types_that_cannot_be_forward_declared):
* Source/WebKit/Shared/Cocoa/WebPushMessageCocoa.mm:
(WebKit::WebPushMessage::fromDictionary):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/Shared/WebPushMessage.h:
* Source/WebKit/Shared/WebPushMessage.serialization.in:
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::processPushMessage):
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.h:
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::processPushMessage):
* Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::firePushEvent):
* Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h:
* Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in:
* Source/WebKit/webpushd/PushService.mm:
(WebPushD::PushService::didReceivePushMessage):
* Source/WebKit/webpushd/WebPushDaemon.mm:
(WebPushD::WebPushDaemon::injectPushMessageForTesting):
(WebPushD::WebPushDaemon::getPendingPushMessages):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:
(-[PushNotificationDelegate clearMostRecents]):

Canonical link: https://commits.webkit.org/268358@main




More information about the webkit-changes mailing list