Diff
Modified: trunk/LayoutTests/ChangeLog (288928 => 288929)
--- trunk/LayoutTests/ChangeLog 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/LayoutTests/ChangeLog 2022-02-02 00:47:27 UTC (rev 288929)
@@ -1,3 +1,16 @@
+2022-02-01 Ben Nham <[email protected]>
+
+ Forward messages from NetworkProcess to webpushd
+ https://bugs.webkit.org/show_bug.cgi?id=235855
+
+ Reviewed by Brent Fulgham.
+
+ Update existing tests to test for AbortError, since that's the exception type specified in
+ the spec.
+
+ * http/wpt/push-api/pushManager.any.js:
+ (promise_test.async test):
+
2022-02-01 Alan Bujtas <[email protected]>
[LFC][IFC] Using Fontcascade::spaceWidth to subtract the trailing space width may result in incorrect layout
Modified: trunk/LayoutTests/http/wpt/push-api/pushManager.any.js (288928 => 288929)
--- trunk/LayoutTests/http/wpt/push-api/pushManager.any.js 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/LayoutTests/http/wpt/push-api/pushManager.any.js 2022-02-02 00:47:27 UTC (rev 288929)
@@ -99,7 +99,7 @@
promise_test(async (test) => {
// TODO: change this to make sure that subscription is valid once we fully implement subscribe.
- return promise_rejects_dom(test, "NotAllowedError", pushManager.subscribe({
+ return promise_rejects_dom(test, "AbortError", pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: VALID_SERVER_KEY
}));
@@ -107,7 +107,7 @@
promise_test(async (test) => {
// TODO: change this to make sure that subscription is valid once we fully implement subscribe.
- return promise_rejects_dom(test, "NotAllowedError", pushManager.subscribe({
+ return promise_rejects_dom(test, "AbortError", pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: VALID_BASE64_SERVER_KEY
}));
Modified: trunk/LayoutTests/platform/glib/http/wpt/push-api/pushManager.any-expected.txt (288928 => 288929)
--- trunk/LayoutTests/platform/glib/http/wpt/push-api/pushManager.any-expected.txt 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/LayoutTests/platform/glib/http/wpt/push-api/pushManager.any-expected.txt 2022-02-02 00:47:27 UTC (rev 288929)
@@ -9,7 +9,7 @@
PASS applicationServerKey string should be base64url-encoded
PASS applicationServerKey buffer should be a valid point on the P-256 curve
PASS applicationServerKey string should be a valid point on the P-256 curve
-FAIL can subscribe with valid applicationServerKey buffer promise_rejects_dom: function "function () { throw e }" threw object "InvalidAccessError: applicationServerKey must contain a valid P-256 public key" that is not a DOMException NotAllowedError: property "code" is equal to 15, expected 0
-FAIL can subscribe with valid applicationServerKey string promise_rejects_dom: function "function () { throw e }" threw object "InvalidAccessError: applicationServerKey must contain a valid P-256 public key" that is not a DOMException NotAllowedError: property "code" is equal to 15, expected 0
+FAIL can subscribe with valid applicationServerKey buffer promise_rejects_dom: function "function () { throw e }" threw object "InvalidAccessError: applicationServerKey must contain a valid P-256 public key" that is not a DOMException AbortError: property "code" is equal to 15, expected 20
+FAIL can subscribe with valid applicationServerKey string promise_rejects_dom: function "function () { throw e }" threw object "InvalidAccessError: applicationServerKey must contain a valid P-256 public key" that is not a DOMException AbortError: property "code" is equal to 15, expected 20
PASS unregister service worker
Modified: trunk/LayoutTests/platform/glib/http/wpt/push-api/pushManager.any.serviceworker-expected.txt (288928 => 288929)
--- trunk/LayoutTests/platform/glib/http/wpt/push-api/pushManager.any.serviceworker-expected.txt 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/LayoutTests/platform/glib/http/wpt/push-api/pushManager.any.serviceworker-expected.txt 2022-02-02 00:47:27 UTC (rev 288929)
@@ -9,6 +9,6 @@
PASS applicationServerKey string should be base64url-encoded
PASS applicationServerKey buffer should be a valid point on the P-256 curve
PASS applicationServerKey string should be a valid point on the P-256 curve
-FAIL can subscribe with valid applicationServerKey buffer promise_rejects_dom: function "function () { throw e }" threw object "InvalidAccessError: applicationServerKey must contain a valid P-256 public key" that is not a DOMException NotAllowedError: property "code" is equal to 15, expected 0
-FAIL can subscribe with valid applicationServerKey string promise_rejects_dom: function "function () { throw e }" threw object "InvalidAccessError: applicationServerKey must contain a valid P-256 public key" that is not a DOMException NotAllowedError: property "code" is equal to 15, expected 0
+FAIL can subscribe with valid applicationServerKey buffer promise_rejects_dom: function "function () { throw e }" threw object "InvalidAccessError: applicationServerKey must contain a valid P-256 public key" that is not a DOMException AbortError: property "code" is equal to 15, expected 20
+FAIL can subscribe with valid applicationServerKey string promise_rejects_dom: function "function () { throw e }" threw object "InvalidAccessError: applicationServerKey must contain a valid P-256 public key" that is not a DOMException AbortError: property "code" is equal to 15, expected 20
Modified: trunk/Source/WebCore/ChangeLog (288928 => 288929)
--- trunk/Source/WebCore/ChangeLog 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/Source/WebCore/ChangeLog 2022-02-02 00:47:27 UTC (rev 288929)
@@ -1,3 +1,16 @@
+2022-02-01 Ben Nham <[email protected]>
+
+ Forward messages from NetworkProcess to webpushd
+ https://bugs.webkit.org/show_bug.cgi?id=235855
+
+ Reviewed by Brent Fulgham.
+
+ Make ExceptionData use modern encoding since the daemon IPC encoder doesn't support legacy
+ encoding.
+
+ * dom/ExceptionData.h:
+ (WebCore::ExceptionData::decode):
+
2022-02-01 Per Arne Vollan <[email protected]>
[WP] Remove PostScript conversion code
Modified: trunk/Source/WebCore/dom/ExceptionData.h (288928 => 288929)
--- trunk/Source/WebCore/dom/ExceptionData.h 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/Source/WebCore/dom/ExceptionData.h 2022-02-02 00:47:27 UTC (rev 288929)
@@ -37,7 +37,7 @@
WEBCORE_EXPORT ExceptionData isolatedCopy() const;
template<class Encoder> void encode(Encoder&) const;
- template<class Decoder> static WARN_UNUSED_RETURN bool decode(Decoder&, ExceptionData&);
+ template<class Decoder> static std::optional<ExceptionData> decode(Decoder&);
Exception toException() const
{
@@ -53,15 +53,19 @@
}
template<class Decoder>
-bool ExceptionData::decode(Decoder& decoder, ExceptionData& data)
+std::optional<ExceptionData> ExceptionData::decode(Decoder& decoder)
{
- if (!decoder.decode(data.code))
- return false;
+ std::optional<ExceptionCode> code;
+ decoder >> code;
+ if (!code)
+ return std::nullopt;
- if (!decoder.decode(data.message))
- return false;
+ std::optional<String> message;
+ decoder >> message;
+ if (!message)
+ return std::nullopt;
- return true;
+ return ExceptionData { WTFMove(*code), WTFMove(*message) };
}
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (288928 => 288929)
--- trunk/Source/WebKit/ChangeLog 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/Source/WebKit/ChangeLog 2022-02-02 00:47:27 UTC (rev 288929)
@@ -1,3 +1,39 @@
+2022-02-01 Ben Nham <[email protected]>
+
+ Forward messages from NetworkProcess to webpushd
+ https://bugs.webkit.org/show_bug.cgi?id=235855
+
+ Reviewed by Brent Fulgham.
+
+ This forwards PushManager and PushSubscription-related IPC from NetworkProcess to webpushd.
+ The implementations in webpushd are stubs in this patch, and as a result there are no new
+ tests. The implementations and tests will be filled out in a future patch.
+
+ * NetworkProcess/Notifications/NetworkNotificationManager.cpp:
+ (WebKit::NetworkNotificationManager::subscribeToPushService):
+ (WebKit::NetworkNotificationManager::unsubscribeFromPushService):
+ (WebKit::NetworkNotificationManager::getPushSubscription):
+ (WebKit::NetworkNotificationManager::getPushPermissionState):
+ * NetworkProcess/Notifications/NetworkNotificationManager.h:
+ * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::subscribeToPushService):
+ (WebKit::WebSWServerConnection::unsubscribeFromPushService):
+ (WebKit::WebSWServerConnection::getPushSubscription):
+ (WebKit::WebSWServerConnection::getPushPermissionState):
+ * Shared/WebPushDaemonConstants.h:
+ (WebKit::WebPushD::messageTypeSendsReply):
+ * webpushd/WebPushDaemon.h:
+ * webpushd/WebPushDaemon.mm:
+ (WebPushD::MessageInfo::subscribeToPushService::encodeReply):
+ (WebPushD::MessageInfo::unsubscribeFromPushService::encodeReply):
+ (WebPushD::MessageInfo::getPushSubscription::encodeReply):
+ (WebPushD::MessageInfo::getPushPermissionState::encodeReply):
+ (WebPushD::Daemon::decodeAndHandleMessage):
+ (WebPushD::Daemon::subscribeToPushService):
+ (WebPushD::Daemon::unsubscribeFromPushService):
+ (WebPushD::Daemon::getPushSubscription):
+ (WebPushD::Daemon::getPushPermissionState):
+
2022-02-01 Wenson Hsieh <[email protected]>
Mitigate hangs underneath -requestAutocorrectionContextWithCompletionHandler: when focusing text fields
Modified: trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp (288928 => 288929)
--- trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp 2022-02-02 00:47:27 UTC (rev 288929)
@@ -30,6 +30,7 @@
#include "DaemonDecoder.h"
#include "DaemonEncoder.h"
+#include "Logging.h"
#include "NetworkSession.h"
#include "WebPushDaemonConnectionConfiguration.h"
#include "WebPushMessage.h"
@@ -132,6 +133,46 @@
return;
}
+void NetworkNotificationManager::subscribeToPushService(URL&& scopeURL, Vector<uint8_t>&& applicationServerKey, CompletionHandler<void(Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData>&&)>&& completionHandler)
+{
+ if (!m_connection) {
+ completionHandler(makeUnexpected(ExceptionData { AbortError, "No connection to push daemon"_s }));
+ return;
+ }
+
+ sendMessageWithReply<WebPushD::MessageType::SubscribeToPushService>(WTFMove(completionHandler), WTFMove(scopeURL), WTFMove(applicationServerKey));
+}
+
+void NetworkNotificationManager::unsubscribeFromPushService(URL&& scopeURL, PushSubscriptionIdentifier pushSubscriptionIdentifier, CompletionHandler<void(Expected<bool, WebCore::ExceptionData>&&)>&& completionHandler)
+{
+ if (!m_connection) {
+ completionHandler(makeUnexpected(ExceptionData { AbortError, "No connection to push daemon"_s }));
+ return;
+ }
+
+ sendMessageWithReply<WebPushD::MessageType::UnsubscribeFromPushService>(WTFMove(completionHandler), WTFMove(scopeURL), pushSubscriptionIdentifier);
+}
+
+void NetworkNotificationManager::getPushSubscription(URL&& scopeURL, CompletionHandler<void(Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData>&&)>&& completionHandler)
+{
+ if (!m_connection) {
+ completionHandler(makeUnexpected(ExceptionData { AbortError, "No connection to push daemon"_s }));
+ return;
+ }
+
+ sendMessageWithReply<WebPushD::MessageType::GetPushSubscription>(WTFMove(completionHandler), WTFMove(scopeURL));
+}
+
+void NetworkNotificationManager::getPushPermissionState(URL&& scopeURL, CompletionHandler<void(Expected<uint8_t, WebCore::ExceptionData>&&)>&& completionHandler)
+{
+ if (!m_connection) {
+ completionHandler(makeUnexpected(ExceptionData { AbortError, "No connection to push daemon"_s }));
+ return;
+ }
+
+ sendMessageWithReply<WebPushD::MessageType::GetPushPermissionState>(WTFMove(completionHandler), WTFMove(scopeURL));
+}
+
template<WebPushD::MessageType messageType, typename... Args>
void NetworkNotificationManager::sendMessage(Args&&... args) const
{
@@ -207,6 +248,58 @@
}
};
+template<> struct ReplyCaller<Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData>&&> {
+ static void callReply(Daemon::Decoder&& decoder, CompletionHandler<void(Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData>&&)>&& completionHandler)
+ {
+ std::optional<Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData>> data;
+ decoder >> data;
+
+ if (!data)
+ completionHandler(makeUnexpected(ExceptionData { AbortError, "Couldn't decode message"_s }));
+ else
+ completionHandler(WTFMove(*data));
+ }
+};
+
+template<> struct ReplyCaller<Expected<bool, WebCore::ExceptionData>&&> {
+ static void callReply(Daemon::Decoder&& decoder, CompletionHandler<void(Expected<bool, WebCore::ExceptionData>&&)>&& completionHandler)
+ {
+ std::optional<Expected<bool, WebCore::ExceptionData>> data;
+ decoder >> data;
+
+ if (!data)
+ completionHandler(makeUnexpected(ExceptionData { AbortError, "Couldn't decode message"_s }));
+ else
+ completionHandler(WTFMove(*data));
+ }
+};
+
+template<> struct ReplyCaller<Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData>&&> {
+ static void callReply(Daemon::Decoder&& decoder, CompletionHandler<void(Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData>&&)>&& completionHandler)
+ {
+ std::optional<Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData>> data;
+ decoder >> data;
+
+ if (!data)
+ completionHandler(makeUnexpected(ExceptionData { AbortError, "Couldn't decode message"_s }));
+ else
+ completionHandler(WTFMove(*data));
+ }
+};
+
+template<> struct ReplyCaller<Expected<uint8_t, WebCore::ExceptionData>&&> {
+ static void callReply(Daemon::Decoder&& decoder, CompletionHandler<void(Expected<uint8_t, WebCore::ExceptionData>&&)>&& completionHandler)
+ {
+ std::optional<Expected<uint8_t, WebCore::ExceptionData>> data;
+ decoder >> data;
+
+ if (!data)
+ completionHandler(makeUnexpected(ExceptionData { AbortError, "Couldn't decode message"_s }));
+ else
+ completionHandler(WTFMove(*data));
+ }
+};
+
template<WebPushD::MessageType messageType, typename... Args, typename... ReplyArgs>
void NetworkNotificationManager::sendMessageWithReply(CompletionHandler<void(ReplyArgs...)>&& completionHandler, Args&&... args) const
{
Modified: trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h (288928 => 288929)
--- trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h 2022-02-02 00:47:27 UTC (rev 288929)
@@ -30,7 +30,9 @@
#include "NotificationManagerMessageHandler.h"
#include "WebPushDaemonConnection.h"
#include "WebPushMessage.h"
+#include <WebCore/ExceptionData.h>
#include <WebCore/NotificationDirection.h>
+#include <WebCore/PushSubscriptionData.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -55,6 +57,11 @@
void getOriginsWithPushAndNotificationPermissions(CompletionHandler<void(const Vector<WebCore::SecurityOriginData>&)>&&);
void getPendingPushMessages(CompletionHandler<void(const Vector<WebPushMessage>&)>&&);
+ void subscribeToPushService(URL&& scopeURL, Vector<uint8_t>&& applicationServerKey, CompletionHandler<void(Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData>&&)>&&);
+ void unsubscribeFromPushService(URL&& scopeURL, WebCore::PushSubscriptionIdentifier, CompletionHandler<void(Expected<bool, WebCore::ExceptionData>&&)>&&);
+ void getPushSubscription(URL&& scopeURL, CompletionHandler<void(Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData>&&)>&&);
+ void getPushPermissionState(URL&& scopeURL, CompletionHandler<void(Expected<uint8_t, WebCore::ExceptionData>&&)>&&);
+
private:
NetworkNotificationManager(NetworkSession&, const String& webPushMachServiceName);
Modified: trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp (288928 => 288929)
--- trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp 2022-02-02 00:47:27 UTC (rev 288929)
@@ -32,6 +32,7 @@
#include "FormDataReference.h"
#include "Logging.h"
#include "NetworkConnectionToWebProcessMessages.h"
+#include "NetworkNotificationManager.h"
#include "NetworkProcess.h"
#include "NetworkProcessProxyMessages.h"
#include "NetworkResourceLoader.h"
@@ -448,24 +449,93 @@
}
}
-void WebSWServerConnection::subscribeToPushService(WebCore::ServiceWorkerRegistrationIdentifier, Vector<uint8_t>&&, CompletionHandler<void(Expected<PushSubscriptionData, ExceptionData>&&)>&& completionHandler)
+void WebSWServerConnection::subscribeToPushService(WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, Vector<uint8_t>&& applicationServerKey, CompletionHandler<void(Expected<PushSubscriptionData, ExceptionData>&&)>&& completionHandler)
{
- completionHandler(makeUnexpected(ExceptionData { NotAllowedError, "Push permission was denied"_s }));
+#if !ENABLE(BUILT_IN_NOTIFICATIONS)
+ UNUSED_PARAM(registrationIdentifier);
+ UNUSED_PARAM(applicationServerKey);
+ completionHandler(makeUnexpected(ExceptionData { AbortError, "Push service not implemented"_s }));
+#else
+ auto registration = server().getRegistration(registrationIdentifier);
+ if (!registration) {
+ completionHandler(makeUnexpected(ExceptionData { InvalidStateError, "Subscribing for push requires an active service worker"_s }));
+ return;
+ }
+
+ if (!session()) {
+ completionHandler(makeUnexpected(ExceptionData { InvalidStateError, "No active network session"_s }));
+ return;
+ }
+
+ session()->notificationManager().subscribeToPushService(registration->scopeURLWithoutFragment(), WTFMove(applicationServerKey), WTFMove(completionHandler));
+#endif
}
-void WebSWServerConnection::unsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier, WebCore::PushSubscriptionIdentifier, CompletionHandler<void(Expected<bool, ExceptionData>&&)>&& completionHandler)
+void WebSWServerConnection::unsubscribeFromPushService(WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, WebCore::PushSubscriptionIdentifier subscriptionIdentifier, CompletionHandler<void(Expected<bool, ExceptionData>&&)>&& completionHandler)
{
+#if !ENABLE(BUILT_IN_NOTIFICATIONS)
+ UNUSED_PARAM(registrationIdentifier);
+ UNUSED_PARAM(subscriptionIdentifier);
+
completionHandler(false);
+#else
+ auto registration = server().getRegistration(registrationIdentifier);
+ if (!registration) {
+ completionHandler(makeUnexpected(ExceptionData { InvalidStateError, "Unsubscribing from push requires a service worker"_s }));
+ return;
+ }
+
+ if (!session()) {
+ completionHandler(makeUnexpected(ExceptionData { InvalidStateError, "No active network session"_s }));
+ return;
+ }
+
+ session()->notificationManager().unsubscribeFromPushService(registration->scopeURLWithoutFragment(), subscriptionIdentifier, WTFMove(completionHandler));
+#endif
}
-void WebSWServerConnection::getPushSubscription(WebCore::ServiceWorkerRegistrationIdentifier, CompletionHandler<void(Expected<std::optional<PushSubscriptionData>, ExceptionData>&&)>&& completionHandler)
+void WebSWServerConnection::getPushSubscription(WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, CompletionHandler<void(Expected<std::optional<PushSubscriptionData>, ExceptionData>&&)>&& completionHandler)
{
+#if !ENABLE(BUILT_IN_NOTIFICATIONS)
+ UNUSED_PARAM(registrationIdentifier);
+
completionHandler(std::optional<PushSubscriptionData>(std::nullopt));
+#else
+ auto registration = server().getRegistration(registrationIdentifier);
+ if (!registration) {
+ completionHandler(makeUnexpected(ExceptionData { InvalidStateError, "Getting push subscription requires a service worker"_s }));
+ return;
+ }
+
+ if (!session()) {
+ completionHandler(makeUnexpected(ExceptionData { InvalidStateError, "No active network session"_s }));
+ return;
+ }
+
+ session()->notificationManager().getPushSubscription(registration->scopeURLWithoutFragment(), WTFMove(completionHandler));
+#endif
}
-void WebSWServerConnection::getPushPermissionState(WebCore::ServiceWorkerRegistrationIdentifier, CompletionHandler<void(Expected<uint8_t, ExceptionData>&&)>&& completionHandler)
+void WebSWServerConnection::getPushPermissionState(WebCore::ServiceWorkerRegistrationIdentifier registrationIdentifier, CompletionHandler<void(Expected<uint8_t, ExceptionData>&&)>&& completionHandler)
{
+#if !ENABLE(BUILT_IN_NOTIFICATIONS)
+ UNUSED_PARAM(registrationIdentifier);
+
completionHandler(static_cast<uint8_t>(PushPermissionState::Denied));
+#else
+ auto registration = server().getRegistration(registrationIdentifier);
+ if (!registration) {
+ completionHandler(makeUnexpected(ExceptionData { InvalidStateError, "Getting push permission state requires a service worker"_s }));
+ return;
+ }
+
+ if (!session()) {
+ completionHandler(makeUnexpected(ExceptionData { InvalidStateError, "No active network session"_s }));
+ return;
+ }
+
+ session()->notificationManager().getPushPermissionState(registration->scopeURLWithoutFragment(), WTFMove(completionHandler));
+#endif
}
void WebSWServerConnection::contextConnectionCreated(SWServerToContextConnection& contextConnection)
Modified: trunk/Source/WebKit/Shared/WebPushDaemonConstants.h (288928 => 288929)
--- trunk/Source/WebKit/Shared/WebPushDaemonConstants.h 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/Source/WebKit/Shared/WebPushDaemonConstants.h 2022-02-02 00:47:27 UTC (rev 288929)
@@ -44,6 +44,10 @@
UpdateConnectionConfiguration,
InjectPushMessageForTesting,
GetPendingPushMessages,
+ SubscribeToPushService,
+ UnsubscribeFromPushService,
+ GetPushSubscription,
+ GetPushPermissionState
};
inline bool messageTypeSendsReply(MessageType messageType)
@@ -55,6 +59,10 @@
case MessageType::RequestSystemNotificationPermission:
case MessageType::GetPendingPushMessages:
case MessageType::InjectPushMessageForTesting:
+ case MessageType::SubscribeToPushService:
+ case MessageType::UnsubscribeFromPushService:
+ case MessageType::GetPushSubscription:
+ case MessageType::GetPushPermissionState:
return true;
case MessageType::SetDebugModeIsEnabled:
case MessageType::UpdateConnectionConfiguration:
Modified: trunk/Source/WebKit/webpushd/WebPushDaemon.h (288928 => 288929)
--- trunk/Source/WebKit/webpushd/WebPushDaemon.h 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/Source/WebKit/webpushd/WebPushDaemon.h 2022-02-02 00:47:27 UTC (rev 288929)
@@ -30,6 +30,8 @@
#include "WebPushDaemonConnectionConfiguration.h"
#include "WebPushDaemonConstants.h"
#include "WebPushMessage.h"
+#include <WebCore/ExceptionData.h>
+#include <WebCore/PushSubscriptionData.h>
#include <wtf/Deque.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
@@ -68,6 +70,10 @@
void updateConnectionConfiguration(ClientConnection*, const WebPushDaemonConnectionConfiguration&);
void injectPushMessageForTesting(ClientConnection*, const PushMessageForTesting&, CompletionHandler<void(bool)>&&);
void getPendingPushMessages(ClientConnection*, CompletionHandler<void(const Vector<WebKit::WebPushMessage>&)>&& replySender);
+ void subscribeToPushService(ClientConnection*, const URL& scopeURL, const Vector<uint8_t>& applicationServerKey, CompletionHandler<void(const Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData>&)>&& replySender);
+ void unsubscribeFromPushService(ClientConnection*, const URL& scopeURL, WebCore::PushSubscriptionIdentifier, CompletionHandler<void(const Expected<bool, WebCore::ExceptionData>&)>&& replySender);
+ void getPushSubscription(ClientConnection*, const URL& scopeURL, CompletionHandler<void(const Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData>&)>&& replySender);
+ void getPushPermissionState(ClientConnection*, const URL& scopeURL, CompletionHandler<void(const Expected<uint8_t, WebCore::ExceptionData>&)>&& replySender);
void broadcastDebugMessage(JSC::MessageLevel, const String&);
void broadcastAllConnectionIdentities();
Modified: trunk/Source/WebKit/webpushd/WebPushDaemon.mm (288928 => 288929)
--- trunk/Source/WebKit/webpushd/WebPushDaemon.mm 2022-02-02 00:46:32 UTC (rev 288928)
+++ trunk/Source/WebKit/webpushd/WebPushDaemon.mm 2022-02-02 00:47:27 UTC (rev 288929)
@@ -33,11 +33,13 @@
#import "HandleMessage.h"
#import "MockAppBundleRegistry.h"
+#import <WebCore/PushPermissionState.h>
#import <pal/spi/cocoa/LaunchServicesSPI.h>
#import <wtf/CompletionHandler.h>
#import <wtf/HexNumber.h>
#import <wtf/NeverDestroyed.h>
#import <wtf/Span.h>
+#import <wtf/URL.h>
using namespace WebKit::WebPushD;
@@ -89,6 +91,26 @@
REPLY(bool)
END
+FUNCTION(subscribeToPushService)
+ARGUMENTS(URL, Vector<uint8_t>)
+REPLY(const Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData>&)
+END
+
+FUNCTION(unsubscribeFromPushService)
+ARGUMENTS(URL, WebCore::PushSubscriptionIdentifier)
+REPLY(const Expected<bool, WebCore::ExceptionData>&)
+END
+
+FUNCTION(getPushSubscription)
+ARGUMENTS(URL)
+REPLY(const Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData>&)
+END
+
+FUNCTION(getPushPermissionState)
+ARGUMENTS(URL)
+REPLY(const Expected<uint8_t, WebCore::ExceptionData>&)
+END
+
#undef FUNCTION
#undef ARGUMENTS
#undef REPLY
@@ -136,6 +158,34 @@
return encoder.takeBuffer();
}
+WebPushD::EncodedMessage subscribeToPushService::encodeReply(const Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData>& reply)
+{
+ WebKit::Daemon::Encoder encoder;
+ encoder << reply;
+ return encoder.takeBuffer();
+}
+
+WebPushD::EncodedMessage unsubscribeFromPushService::encodeReply(const Expected<bool, WebCore::ExceptionData>& reply)
+{
+ WebKit::Daemon::Encoder encoder;
+ encoder << reply;
+ return encoder.takeBuffer();
+}
+
+WebPushD::EncodedMessage getPushSubscription::encodeReply(const Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData>& reply)
+{
+ WebKit::Daemon::Encoder encoder;
+ encoder << reply;
+ return encoder.takeBuffer();
+}
+
+WebPushD::EncodedMessage getPushPermissionState::encodeReply(const Expected<uint8_t, WebCore::ExceptionData>& reply)
+{
+ WebKit::Daemon::Encoder encoder;
+ encoder << reply;
+ return encoder.takeBuffer();
+}
+
} // namespace MessageInfo
template<typename Info>
@@ -278,6 +328,18 @@
case MessageType::GetPendingPushMessages:
handleWebPushDMessageWithReply<MessageInfo::getPendingPushMessages>(clientConnection, encodedMessage, WTFMove(replySender));
break;
+ case MessageType::SubscribeToPushService:
+ handleWebPushDMessageWithReply<MessageInfo::subscribeToPushService>(clientConnection, encodedMessage, WTFMove(replySender));
+ break;
+ case MessageType::UnsubscribeFromPushService:
+ handleWebPushDMessageWithReply<MessageInfo::unsubscribeFromPushService>(clientConnection, encodedMessage, WTFMove(replySender));
+ break;
+ case MessageType::GetPushSubscription:
+ handleWebPushDMessageWithReply<MessageInfo::getPushSubscription>(clientConnection, encodedMessage, WTFMove(replySender));
+ break;
+ case MessageType::GetPushPermissionState:
+ handleWebPushDMessageWithReply<MessageInfo::getPushPermissionState>(clientConnection, encodedMessage, WTFMove(replySender));
+ break;
}
}
@@ -414,6 +476,27 @@
replySender(WTFMove(resultMessages));
}
+void Daemon::subscribeToPushService(ClientConnection* connection, const URL& scopeURL, const Vector<uint8_t>& applicationServerKey, CompletionHandler<void(const Expected<WebCore::PushSubscriptionData, WebCore::ExceptionData>&)>&& replySender)
+{
+ UNUSED_PARAM(applicationServerKey);
+ replySender(makeUnexpected(WebCore::ExceptionData { WebCore::NotAllowedError, "Lack permission"_s }));
+}
+
+void Daemon::unsubscribeFromPushService(ClientConnection* connection, const URL& scopeURL, WebCore::PushSubscriptionIdentifier pushSubscriptionIdentifier, CompletionHandler<void(const Expected<bool, WebCore::ExceptionData>&)>&& replySender)
+{
+ replySender(false);
+}
+
+void Daemon::getPushSubscription(ClientConnection* connection, const URL& scopeURL, CompletionHandler<void(const Expected<std::optional<WebCore::PushSubscriptionData>, WebCore::ExceptionData>&)>&& replySender)
+{
+ replySender(std::optional<WebCore::PushSubscriptionData> { });
+}
+
+void Daemon::getPushPermissionState(ClientConnection* connection, const URL& scopeURL, CompletionHandler<void(const Expected<uint8_t, WebCore::ExceptionData>&)>&& replySender)
+{
+ replySender(static_cast<uint8_t>(WebCore::PushPermissionState::Denied));
+}
+
ClientConnection* Daemon::toClientConnection(xpc_connection_t connection)
{
auto clientConnection = m_connectionMap.get(connection);