Title: [284591] trunk
Revision
284591
Author
beid...@apple.com
Date
2021-10-20 23:51:48 -0700 (Wed, 20 Oct 2021)

Log Message

WebKit Managed Notifications: Skeleton NotificationProvider
https://bugs.webkit.org/show_bug.cgi?id=231786

Reviewed by Alex Christensen.

Source/WebCore:

* page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setBuiltInNotificationsEnabled):
(WebCore::RuntimeEnabledFeatures::builtInNotificationsEnabled const):

Source/WebKit:

Currently, notification messages route from WebContent to the UI process.

When "WebKit-managed built-in notifications" are enabled, notification requests will route from
WebContent to Networking instead.

>From there they will head off to webpushd to be handled.

This patch just sets up the switch where messages can optionally head off to the Networking
process instead of the UIProcess.

(It also lays the SPI groundwork for the webpushd mach service name)

* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::NetworkSession):
(WebKit::NetworkSession::~NetworkSession):
* NetworkProcess/NetworkSession.h:

* NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::encode const):
(WebKit::NetworkSessionCreationParameters::decode):
* NetworkProcess/NetworkSessionCreationParameters.h:

* NetworkProcess/Notifications/NetworkNotificationManager.cpp: Added.
(WebKit::NetworkNotificationManager::NetworkNotificationManager):
(WebKit::NetworkNotificationManager::showNotification):
(WebKit::NetworkNotificationManager::cancelNotification):
(WebKit::NetworkNotificationManager::clearNotifications):
(WebKit::NetworkNotificationManager::didDestroyNotification):
* NetworkProcess/Notifications/NetworkNotificationManager.h: Added.

* NetworkProcess/WebStorage/LocalStorageDatabase.cpp: Unified build fixup.

* Sources.txt:

* UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
* UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
(-[_WKWebsiteDataStoreConfiguration webPushMachServiceName]):
(-[_WKWebsiteDataStoreConfiguration setWebPushMachServiceName:]):

* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::parameters):
* UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
(WebKit::WebsiteDataStoreConfiguration::setWebPushMachServiceName):
(WebKit::WebsiteDataStoreConfiguration::webPushMachServiceName const):

* WebKit.xcodeproj/project.pbxproj:

* WebProcess/Notifications/WebNotificationManager.cpp:
(WebKit::sendNotificationMessage):
(WebKit::WebNotificationManager::show):
(WebKit::WebNotificationManager::cancel):
(WebKit::WebNotificationManager::clearNotifications):
(WebKit::WebNotificationManager::didDestroyNotification):

Source/WTF:

* Scripts/Preferences/WebPreferencesExperimental.yaml:
* wtf/PlatformEnableCocoa.h:

Tools:

* WebKitTestRunner/TestOptions.cpp:
(WTR::TestOptions::defaults): Disable BuiltInNotificationsEnabled for now.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (284590 => 284591)


--- trunk/Source/WTF/ChangeLog	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WTF/ChangeLog	2021-10-21 06:51:48 UTC (rev 284591)
@@ -1,3 +1,13 @@
+2021-10-20  Brady Eidson  <beid...@apple.com>
+
+        WebKit Managed Notifications: Skeleton NotificationProvider
+        https://bugs.webkit.org/show_bug.cgi?id=231786
+
+        Reviewed by Alex Christensen.
+
+        * Scripts/Preferences/WebPreferencesExperimental.yaml:
+        * wtf/PlatformEnableCocoa.h:
+
 2021-10-20  Alex Christensen  <achristen...@webkit.org>
 
         URLParser should reject hosts with C0 control characters or U+007F

Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (284590 => 284591)


--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml	2021-10-21 06:51:48 UTC (rev 284591)
@@ -138,6 +138,18 @@
     WebCore:
       default: true
 
+BuiltInNotificationsEnabled:
+  type: bool
+  humanReadableName: "Built-In Web Notifications"
+  humanReadableDescription: "Enable built-in WebKit managed notifications"
+  webcoreBinding: RuntimeEnabledFeatures
+  condition: ENABLE(BUILT_IN_NOTIFICATIONS)
+  defaultValue:
+    WebCore:
+      default: false
+    WebKit:
+      default: false
+
 CFNetworkNetworkLoaderEnabled:
   type: bool
   humanReadableName: "Experimental network loader"

Modified: trunk/Source/WTF/wtf/PlatformEnableCocoa.h (284590 => 284591)


--- trunk/Source/WTF/wtf/PlatformEnableCocoa.h	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WTF/wtf/PlatformEnableCocoa.h	2021-10-21 06:51:48 UTC (rev 284591)
@@ -135,6 +135,10 @@
 #define ENABLE_AVF_CAPTIONS 1
 #endif
 
+#if !defined(ENABLE_BUILT_IN_NOTIFICATIONS) && (PLATFORM(MAC) || PLATFORM(IOS))
+#define ENABLE_BUILT_IN_NOTIFICATIONS 1
+#endif
+
 #if !defined(ENABLE_CACHE_PARTITIONING)
 #define ENABLE_CACHE_PARTITIONING 1
 #endif

Modified: trunk/Source/WebCore/ChangeLog (284590 => 284591)


--- trunk/Source/WebCore/ChangeLog	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebCore/ChangeLog	2021-10-21 06:51:48 UTC (rev 284591)
@@ -1,3 +1,14 @@
+2021-10-20  Brady Eidson  <beid...@apple.com>
+
+        WebKit Managed Notifications: Skeleton NotificationProvider
+        https://bugs.webkit.org/show_bug.cgi?id=231786
+
+        Reviewed by Alex Christensen.
+
+        * page/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setBuiltInNotificationsEnabled):
+        (WebCore::RuntimeEnabledFeatures::builtInNotificationsEnabled const):
+
 2021-10-20  Beth Dakin  <bda...@apple.com> and Dana Estra <des...@apple.com>
 
         macOS key-driven smooth scrolling does not stop when focus changes

Modified: trunk/Source/WebCore/page/RuntimeEnabledFeatures.h (284590 => 284591)


--- trunk/Source/WebCore/page/RuntimeEnabledFeatures.h	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebCore/page/RuntimeEnabledFeatures.h	2021-10-21 06:51:48 UTC (rev 284591)
@@ -262,6 +262,11 @@
     bool mediaSourceInlinePaintingEnabled() const { return m_mediaSourceInlinePaintingEnabled; }
 #endif
 
+#if ENABLE(BUILT_IN_NOTIFICATIONS)
+    void setBuiltInNotificationsEnabled(bool isEnabled) { m_builtInNotificationsEnabled = isEnabled; }
+    bool builtInNotificationsEnabled() const { return m_builtInNotificationsEnabled; }
+#endif
+
 private:
     // Never instantiate.
     RuntimeEnabledFeatures();
@@ -402,6 +407,10 @@
     bool m_mediaSourceInlinePaintingEnabled { false };
 #endif
 
+#if ENABLE(BUILT_IN_NOTIFICATIONS)
+    bool m_builtInNotificationsEnabled { false };
+#endif
+
     friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>;
 };
 

Modified: trunk/Source/WebKit/CMakeLists.txt (284590 => 284591)


--- trunk/Source/WebKit/CMakeLists.txt	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/CMakeLists.txt	2021-10-21 06:51:48 UTC (rev 284591)
@@ -24,6 +24,7 @@
     "${WEBKIT_DIR}/NetworkProcess/Downloads"
     "${WEBKIT_DIR}/NetworkProcess/FileAPI"
     "${WEBKIT_DIR}/NetworkProcess/IndexedDB"
+    "${WEBKIT_DIR}/NetworkProcess/Notifications"
     "${WEBKIT_DIR}/NetworkProcess/PrivateClickMeasurement"
     "${WEBKIT_DIR}/NetworkProcess/ServiceWorker"
     "${WEBKIT_DIR}/NetworkProcess/WebStorage"

Modified: trunk/Source/WebKit/ChangeLog (284590 => 284591)


--- trunk/Source/WebKit/ChangeLog	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/ChangeLog	2021-10-21 06:51:48 UTC (rev 284591)
@@ -1,3 +1,64 @@
+2021-10-20  Brady Eidson  <beid...@apple.com>
+
+        WebKit Managed Notifications: Skeleton NotificationProvider
+        https://bugs.webkit.org/show_bug.cgi?id=231786
+
+        Reviewed by Alex Christensen.
+
+        Currently, notification messages route from WebContent to the UI process.
+
+        When "WebKit-managed built-in notifications" are enabled, notification requests will route from
+        WebContent to Networking instead.
+
+        From there they will head off to webpushd to be handled.
+
+        This patch just sets up the switch where messages can optionally head off to the Networking
+        process instead of the UIProcess.
+
+        (It also lays the SPI groundwork for the webpushd mach service name)
+
+        * NetworkProcess/NetworkSession.cpp:
+        (WebKit::NetworkSession::NetworkSession):
+        (WebKit::NetworkSession::~NetworkSession):
+        * NetworkProcess/NetworkSession.h:
+
+        * NetworkProcess/NetworkSessionCreationParameters.cpp:
+        (WebKit::NetworkSessionCreationParameters::encode const):
+        (WebKit::NetworkSessionCreationParameters::decode):
+        * NetworkProcess/NetworkSessionCreationParameters.h:
+
+        * NetworkProcess/Notifications/NetworkNotificationManager.cpp: Added.
+        (WebKit::NetworkNotificationManager::NetworkNotificationManager):
+        (WebKit::NetworkNotificationManager::showNotification):
+        (WebKit::NetworkNotificationManager::cancelNotification):
+        (WebKit::NetworkNotificationManager::clearNotifications):
+        (WebKit::NetworkNotificationManager::didDestroyNotification):
+        * NetworkProcess/Notifications/NetworkNotificationManager.h: Added.
+
+        * NetworkProcess/WebStorage/LocalStorageDatabase.cpp: Unified build fixup.
+
+        * Sources.txt:
+
+        * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
+        * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
+        (-[_WKWebsiteDataStoreConfiguration webPushMachServiceName]):
+        (-[_WKWebsiteDataStoreConfiguration setWebPushMachServiceName:]):
+
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::parameters):
+        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
+        (WebKit::WebsiteDataStoreConfiguration::setWebPushMachServiceName):
+        (WebKit::WebsiteDataStoreConfiguration::webPushMachServiceName const):
+
+        * WebKit.xcodeproj/project.pbxproj:
+
+        * WebProcess/Notifications/WebNotificationManager.cpp:
+        (WebKit::sendNotificationMessage):
+        (WebKit::WebNotificationManager::show):
+        (WebKit::WebNotificationManager::cancel):
+        (WebKit::WebNotificationManager::clearNotifications):
+        (WebKit::WebNotificationManager::didDestroyNotification):
+
 2021-10-20  Per Arne Vollan <pvol...@apple.com>
 
         Launch Services database is not always sent to GPUP

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (284590 => 284591)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2021-10-21 06:51:48 UTC (rev 284591)
@@ -192,6 +192,9 @@
     // For security reasons, Messages::NetworkProcess IPC is only supposed to come from the UIProcess.
     ASSERT(decoder.messageReceiverName() != Messages::NetworkProcess::messageReceiverName());
 
+    if (m_networkProcess->messageReceiverMap().dispatchMessage(connection, decoder))
+        return;
+
     if (decoder.messageReceiverName() == Messages::NetworkConnectionToWebProcess::messageReceiverName()) {
         didReceiveNetworkConnectionToWebProcessMessage(connection, decoder);
         return;

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (284590 => 284591)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2021-10-21 06:51:48 UTC (rev 284591)
@@ -34,6 +34,7 @@
 #include "NetworkResourceLoadParameters.h"
 #include "NetworkResourceLoader.h"
 #include "NetworkSessionCreationParameters.h"
+#include "NotificationManagerMessageHandlerMessages.h"
 #include "PingLoad.h"
 #include "PrivateClickMeasurementClientImpl.h"
 #include "PrivateClickMeasurementManager.h"
@@ -122,6 +123,9 @@
     , m_testSpeedMultiplier(parameters.testSpeedMultiplier)
     , m_allowsServerPreconnect(parameters.allowsServerPreconnect)
     , m_shouldRunServiceWorkersOnMainThreadForTesting(parameters.shouldRunServiceWorkersOnMainThreadForTesting)
+#if ENABLE(BUILT_IN_NOTIFICATIONS)
+    , m_notificationManager(*this, parameters.webPushMachServiceName)
+#endif
 {
     if (!m_sessionID.isEphemeral()) {
         String networkCacheDirectory = parameters.networkCacheDirectory;
@@ -153,6 +157,10 @@
 #if ENABLE(INTELLIGENT_TRACKING_PREVENTION)
     setResourceLoadStatisticsEnabled(parameters.resourceLoadStatisticsParameters.enabled);
 #endif
+
+#if ENABLE(BUILT_IN_NOTIFICATIONS)
+    m_networkProcess->addMessageReceiver(Messages::NotificationManagerMessageHandler::messageReceiverName(), m_sessionID.toUInt64(), m_notificationManager);
+#endif
 }
 
 NetworkSession::~NetworkSession()
@@ -162,6 +170,10 @@
 #endif
     for (auto& loader : std::exchange(m_keptAliveLoads, { }))
         loader->abort();
+
+#if ENABLE(BUILT_IN_NOTIFICATIONS)
+    m_networkProcess->removeMessageReceiver(Messages::NotificationManagerMessageHandler::messageReceiverName(), m_sessionID.toUInt64());
+#endif
 }
 
 #if ENABLE(INTELLIGENT_TRACKING_PREVENTION)

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (284590 => 284591)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2021-10-21 06:51:48 UTC (rev 284591)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,6 +27,7 @@
 
 #include "AppPrivacyReport.h"
 #include "NavigatingToAppBoundDomain.h"
+#include "NetworkNotificationManager.h"
 #include "NetworkResourceLoadIdentifier.h"
 #include "PrefetchCache.h"
 #include "PrivateClickMeasurementManagerInterface.h"
@@ -257,6 +258,10 @@
 #endif
 
     HashMap<WebPageProxyIdentifier, String> m_attributedBundleIdentifierFromPageIdentifiers;
+
+#if ENABLE(BUILT_IN_NOTIFICATIONS)
+    NetworkNotificationManager m_notificationManager;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp (284590 => 284591)


--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp	2021-10-21 06:51:48 UTC (rev 284591)
@@ -89,6 +89,7 @@
     encoder << useNetworkLoader;
     encoder << allowsHSTSWithUntrustedRootCertificate;
     encoder << pcmMachServiceName;
+    encoder << webPushMachServiceName;
     encoder << enablePrivateClickMeasurementDebugMode;
     encoder << resourceLoadStatisticsParameters;
 }
@@ -306,6 +307,11 @@
     decoder >> pcmMachServiceName;
     if (!pcmMachServiceName)
         return std::nullopt;
+
+    std::optional<String> webPushMachServiceName;
+    decoder >> webPushMachServiceName;
+    if (!webPushMachServiceName)
+        return std::nullopt;
     
     std::optional<bool> enablePrivateClickMeasurementDebugMode;
     decoder >> enablePrivateClickMeasurementDebugMode;
@@ -367,6 +373,7 @@
         , WTFMove(*useNetworkLoader)
         , WTFMove(*allowsHSTSWithUntrustedRootCertificate)
         , WTFMove(*pcmMachServiceName)
+        , WTFMove(*webPushMachServiceName)
         , WTFMove(*enablePrivateClickMeasurementDebugMode)
         , WTFMove(*resourceLoadStatisticsParameters)
     }};

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h (284590 => 284591)


--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h	2021-10-21 06:51:48 UTC (rev 284591)
@@ -104,6 +104,7 @@
     bool useNetworkLoader { false };
     bool allowsHSTSWithUntrustedRootCertificate { false };
     String pcmMachServiceName;
+    String webPushMachServiceName;
     bool enablePrivateClickMeasurementDebugMode { false };
 
     ResourceLoadStatisticsParameters resourceLoadStatisticsParameters;

Added: trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp (0 => 284591)


--- trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp	                        (rev 0)
+++ trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp	2021-10-21 06:51:48 UTC (rev 284591)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NetworkNotificationManager.h"
+
+#if ENABLE(BUILT_IN_NOTIFICATIONS)
+
+namespace WebKit {
+using namespace WebCore;
+
+NetworkNotificationManager::NetworkNotificationManager(NetworkSession& networkSession, const String&)
+    : m_networkSession(networkSession)
+{
+}
+
+void NetworkNotificationManager::showNotification(const String&, const String&, const String&, const String&, const String&, WebCore::NotificationDirection, const String&, uint64_t)
+{
+}
+
+void NetworkNotificationManager::cancelNotification(uint64_t)
+{
+}
+
+void NetworkNotificationManager::clearNotifications(const Vector<uint64_t>&)
+{
+}
+
+void NetworkNotificationManager::didDestroyNotification(uint64_t)
+{
+}
+
+} // namespace WebKit
+#endif // ENABLE(BUILT_IN_NOTIFICATIONS)

Added: trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h (0 => 284591)


--- trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h	                        (rev 0)
+++ trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h	2021-10-21 06:51:48 UTC (rev 284591)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(BUILT_IN_NOTIFICATIONS)
+
+#include "NotificationManagerMessageHandler.h"
+#include <WebCore/NotificationDirection.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+class NetworkSession;
+
+class NetworkNotificationManager : public NotificationManagerMessageHandler {
+    WTF_MAKE_FAST_ALLOCATED;
+    friend class NetworkSession;
+private:
+    NetworkNotificationManager(NetworkSession&, const String& webPushMachServiceName);
+
+    void showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection, const String& originString, uint64_t notificationID) final;
+    void cancelNotification(uint64_t notificationID) final;
+    void clearNotifications(const Vector<uint64_t>& notificationIDs) final;
+    void didDestroyNotification(uint64_t notificationID) final;
+
+    NetworkSession& m_networkSession;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(BUILT_IN_NOTIFICATIONS)

Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp (284590 => 284591)


--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp	2021-10-21 06:51:48 UTC (rev 284591)
@@ -34,6 +34,7 @@
 #include <wtf/FileSystem.h>
 #include <wtf/HashMap.h>
 #include <wtf/RefPtr.h>
+#include <wtf/RunLoop.h>
 #include <wtf/SuspendableWorkQueue.h>
 
 namespace WebKit {

Modified: trunk/Source/WebKit/Sources.txt (284590 => 284591)


--- trunk/Source/WebKit/Sources.txt	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/Sources.txt	2021-10-21 06:51:48 UTC (rev 284591)
@@ -97,6 +97,8 @@
 NetworkProcess/IndexedDB/WebIDBConnectionToClient.cpp
 NetworkProcess/IndexedDB/WebIDBServer.cpp
 
+NetworkProcess/Notifications/NetworkNotificationManager.cpp
+
 NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementClientImpl.cpp
 NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp
 NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDebugInfo.cpp

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h (284590 => 284591)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h	2021-10-21 06:51:48 UTC (rev 284591)
@@ -78,6 +78,7 @@
 @property (nonatomic) BOOL enableInAppBrowserPrivacyForTesting WK_API_AVAILABLE(macos(12.0), ios(15.0));
 @property (nonatomic) BOOL allowsHSTSWithUntrustedRootCertificate WK_API_AVAILABLE(macos(12.0), ios(15.0));
 @property (nonatomic, nullable, copy, setter=setPCMMachServiceName:) NSString *pcmMachServiceName WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, nullable, copy, setter=setWebPushMachServiceName:) NSString *webPushMachServiceName WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @property (nonatomic, nullable, copy) NSURL *alternativeServicesStorageDirectory WK_API_AVAILABLE(macos(11.0), ios(14.0));
 @property (nonatomic, nullable, copy) NSURL *standaloneApplicationURL WK_API_AVAILABLE(macos(11.0), ios(14.0));

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm (284590 => 284591)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm	2021-10-21 06:51:48 UTC (rev 284591)
@@ -541,6 +541,16 @@
     _configuration->setPCMMachServiceName(name);
 }
 
+- (NSString *)webPushMachServiceName
+{
+    return _configuration->webPushMachServiceName();
+}
+
+- (void)setWebPushMachServiceName:(NSString *)name
+{
+    _configuration->setWebPushMachServiceName(name);
+}
+
 - (BOOL)allLoadsBlockedByDeviceManagementRestrictionsForTesting
 {
     return _configuration->allLoadsBlockedByDeviceManagementRestrictionsForTesting();

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (284590 => 284591)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2021-10-21 06:51:48 UTC (rev 284591)
@@ -2071,6 +2071,7 @@
     networkSessionParameters.preventsSystemHTTPProxyAuthentication = m_configuration->preventsSystemHTTPProxyAuthentication();
     networkSessionParameters.allowsHSTSWithUntrustedRootCertificate = m_configuration->allowsHSTSWithUntrustedRootCertificate();
     networkSessionParameters.pcmMachServiceName = m_configuration->pcmMachServiceName();
+    networkSessionParameters.webPushMachServiceName = m_configuration->webPushMachServiceName();
 
     parameters.networkSessionParameters = WTFMove(networkSessionParameters);
 

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h (284590 => 284591)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h	2021-10-21 06:51:48 UTC (rev 284591)
@@ -186,6 +186,9 @@
     void setPCMMachServiceName(String&& name) { m_pcmMachServiceName = WTFMove(name); }
     const String& pcmMachServiceName() const { return m_pcmMachServiceName; }
 
+    void setWebPushMachServiceName(String&& name) { m_webPushMachServiceName = WTFMove(name); }
+    const String& webPushMachServiceName() const { return m_webPushMachServiceName; }
+
 private:
     IsPersistent m_isPersistent { IsPersistent::No };
 
@@ -240,6 +243,7 @@
     bool m_enableInAppBrowserPrivacyForTesting { false };
     bool m_allowsHSTSWithUntrustedRootCertificate { false };
     String m_pcmMachServiceName;
+    String m_webPushMachServiceName;
 #if PLATFORM(COCOA)
     RetainPtr<CFDictionaryRef> m_proxyConfiguration;
 #endif

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (284590 => 284591)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-10-21 06:51:48 UTC (rev 284591)
@@ -1036,6 +1036,7 @@
 		512935E41288D97800A4B695 /* InjectedBundlePageContextMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 512935E21288D97800A4B695 /* InjectedBundlePageContextMenuClient.h */; };
 		5129EB1223D0DE7B00AF1CD7 /* ContentWorldShared.h in Headers */ = {isa = PBXBuildFile; fileRef = 5129EB1123D0DE7800AF1CD7 /* ContentWorldShared.h */; };
 		512E34E5130B4D0500ABD19A /* WKApplicationCacheManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A33B4130B308C00F80CB5 /* WKApplicationCacheManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		512ECC3527196ADB00089B66 /* PrivateClickMeasurementConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB930FE26E802160032B1C0 /* PrivateClickMeasurementConnection.h */; };
 		512F589712A8838800629530 /* AuthenticationChallengeProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 512F588F12A8838800629530 /* AuthenticationChallengeProxy.h */; };
 		512F589912A8838800629530 /* AuthenticationDecisionListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 512F589112A8838800629530 /* AuthenticationDecisionListener.h */; };
 		512F589B12A8838800629530 /* WebCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 512F589312A8838800629530 /* WebCredential.h */; };
@@ -1059,6 +1060,7 @@
 		51452704271FBA40000467B6 /* NotificationManagerMessageHandlerMessagesReplies.h in Headers */ = {isa = PBXBuildFile; fileRef = 51452700271FBA34000467B6 /* NotificationManagerMessageHandlerMessagesReplies.h */; };
 		51452705271FBA40000467B6 /* NotificationManagerMessageHandlerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51452701271FBA35000467B6 /* NotificationManagerMessageHandlerMessages.h */; };
 		51452708271FBEC6000467B6 /* WebNotificationManagerMessageHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 51452707271FBEC1000467B6 /* WebNotificationManagerMessageHandler.h */; };
+		514526ED271E1647000467B6 /* NetworkNotificationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 514526EB271E1626000467B6 /* NetworkNotificationManager.h */; };
 		51489CC32370DBFA0044E68A /* WKFindResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 51489CC12370DACC0044E68A /* WKFindResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		51489CC7237237800044E68A /* WKFindResultInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 51489CC6237237780044E68A /* WKFindResultInternal.h */; };
 		514AB9F02360D2A900EDC396 /* WKFindConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 514AB9EF235FA59B00EDC396 /* WKFindConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -4172,6 +4174,8 @@
 		51452702271FBA36000467B6 /* NotificationManagerMessageHandlerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotificationManagerMessageHandlerMessageReceiver.cpp; sourceTree = "<group>"; };
 		51452706271FBEC1000467B6 /* WebNotificationManagerMessageHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNotificationManagerMessageHandler.cpp; sourceTree = "<group>"; };
 		51452707271FBEC1000467B6 /* WebNotificationManagerMessageHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotificationManagerMessageHandler.h; sourceTree = "<group>"; };
+		514526EB271E1626000467B6 /* NetworkNotificationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkNotificationManager.h; sourceTree = "<group>"; };
+		514526EC271E1627000467B6 /* NetworkNotificationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkNotificationManager.cpp; sourceTree = "<group>"; };
 		51489CC12370DACC0044E68A /* WKFindResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFindResult.h; sourceTree = "<group>"; };
 		51489CC22370DACC0044E68A /* WKFindResult.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKFindResult.mm; sourceTree = "<group>"; };
 		51489CC6237237780044E68A /* WKFindResultInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFindResultInternal.h; sourceTree = "<group>"; };
@@ -8887,6 +8891,7 @@
 				939288E021404DF000EBBA33 /* IndexedDB */,
 				2DA944BB188511DD00ED86DB /* ios */,
 				510CC7DC16138E2900D03ED3 /* mac */,
+				514526EA271E1610000467B6 /* Notifications */,
 				5C01BC3526D46AD400FEB42F /* PrivateClickMeasurement */,
 				93BA04D92151ADCD007F455F /* ServiceWorker */,
 				93085DC226E1BB65000EC6A7 /* storage */,
@@ -9046,6 +9051,15 @@
 			path = Authentication;
 			sourceTree = "<group>";
 		};
+		514526EA271E1610000467B6 /* Notifications */ = {
+			isa = PBXGroup;
+			children = (
+				514526EC271E1627000467B6 /* NetworkNotificationManager.cpp */,
+				514526EB271E1626000467B6 /* NetworkNotificationManager.h */,
+			);
+			path = Notifications;
+			sourceTree = "<group>";
+		};
 		515BE1721D53FDB900DD7C68 /* Gamepad */ = {
 			isa = PBXGroup;
 			children = (
@@ -12740,6 +12754,7 @@
 				F4517D7B26FBCD39004C8475 /* RemoteRenderingBackendMessagesReplies.h in Headers */,
 				F414CE2D269DE6EA00BD216A /* RemoteRenderingBackendState.h in Headers */,
 				0F594790187B3B3A00437857 /* RemoteScrollingCoordinator.h in Headers */,
+				512ECC3527196ADB00089B66 /* PrivateClickMeasurementConnection.h in Headers */,
 				0F5947A8187B517600437857 /* RemoteScrollingCoordinatorMessages.h in Headers */,
 				0F59479B187B3B6000437857 /* RemoteScrollingCoordinatorProxy.h in Headers */,
 				0F5947A4187B3B7D00437857 /* RemoteScrollingCoordinatorTransaction.h in Headers */,
@@ -12880,6 +12895,7 @@
 				5742A318253648E500B7BA14 /* WebAuthnProcess.h in Headers */,
 				572EBBD52536C885000552B3 /* WebAuthnProcessConnection.h in Headers */,
 				572EBBCC2536B04F000552B3 /* WebAuthnProcessConnectionInfo.h in Headers */,
+				514526ED271E1647000467B6 /* NetworkNotificationManager.h in Headers */,
 				5742A30825358A0400B7BA14 /* WebAuthnProcessCreationParameters.h in Headers */,
 				572EBBC22536A60A000552B3 /* WebAuthnProcessMessages.h in Headers */,
 				572EBBC92536AFD5000552B3 /* WebAuthnProcessProxy.h in Headers */,

Modified: trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp (284590 => 284591)


--- trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp	2021-10-21 06:51:48 UTC (rev 284591)
@@ -32,6 +32,7 @@
 #include "WebProcessCreationParameters.h"
 
 #if ENABLE(NOTIFICATIONS)
+#include "NetworkProcessConnection.h"
 #include "NotificationManagerMessageHandlerMessages.h"
 #include "WebNotification.h"
 #include "WebNotificationManagerMessages.h"
@@ -39,6 +40,7 @@
 #include <WebCore/Document.h>
 #include <WebCore/Notification.h>
 #include <WebCore/Page.h>
+#include <WebCore/RuntimeEnabledFeatures.h>
 #include <WebCore/ScriptExecutionContext.h>
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/Settings.h>
@@ -137,6 +139,17 @@
 #endif
 }
 
+#if ENABLE(NOTIFICATIONS)
+template<typename U> bool sendNotificationMessage(WebProcess& process, U&& message, WebPage& page)
+{
+#if ENABLE(BUILT_IN_NOTIFICATIONS)
+    if (RuntimeEnabledFeatures::sharedFeatures().builtInNotificationsEnabled())
+        return process.ensureNetworkProcessConnection().connection().send(WTFMove(message), page.sessionID().toUInt64());
+#endif
+    return process.parentProcessConnection()->send(WTFMove(message), page.identifier());
+}
+#endif // ENABLE(NOTIFICATIONS)
+
 bool WebNotificationManager::show(Notification* notification, WebPage* page)
 {
 #if ENABLE(NOTIFICATIONS)
@@ -150,7 +163,7 @@
     auto it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).iterator;
     it->value.append(notificationID);
 
-    m_process.parentProcessConnection()->send(Messages::NotificationManagerMessageHandler::ShowNotification(notification->title(), notification->body(), notification->icon().string(), notification->tag(), notification->lang(), notification->dir(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), page->identifier());
+    sendNotificationMessage(m_process, Messages::NotificationManagerMessageHandler::ShowNotification(notification->title(), notification->body(), notification->icon().string(), notification->tag(), notification->lang(), notification->dir(), notification->scriptExecutionContext()->securityOrigin()->toString(), notificationID), *page);
     return true;
 #else
     UNUSED_PARAM(notification);
@@ -169,7 +182,7 @@
     if (!notificationID)
         return;
     
-    m_process.parentProcessConnection()->send(Messages::NotificationManagerMessageHandler::CancelNotification(notificationID), page->identifier());
+    sendNotificationMessage(m_process, Messages::NotificationManagerMessageHandler::CancelNotification(notificationID), *page);
 #else
     UNUSED_PARAM(notification);
     UNUSED_PARAM(page);
@@ -184,7 +197,7 @@
         return;
 
     Vector<uint64_t>& notificationIDs = it->value;
-    m_process.parentProcessConnection()->send(Messages::NotificationManagerMessageHandler::ClearNotifications(notificationIDs), page->identifier());
+    sendNotificationMessage(m_process, Messages::NotificationManagerMessageHandler::ClearNotifications(notificationIDs), *page);
     size_t count = notificationIDs.size();
     for (size_t i = 0; i < count; ++i) {
         RefPtr<Notification> notification = m_notificationIDMap.take(notificationIDs[i]);
@@ -212,7 +225,7 @@
 
     m_notificationIDMap.remove(notificationID);
     removeNotificationFromContextMap(notificationID, notification);
-    m_process.parentProcessConnection()->send(Messages::NotificationManagerMessageHandler::DidDestroyNotification(notificationID), page->identifier());
+    sendNotificationMessage(m_process, Messages::NotificationManagerMessageHandler::DidDestroyNotification(notificationID), *page);
 #else
     UNUSED_PARAM(notification);
     UNUSED_PARAM(page);

Modified: trunk/Tools/ChangeLog (284590 => 284591)


--- trunk/Tools/ChangeLog	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Tools/ChangeLog	2021-10-21 06:51:48 UTC (rev 284591)
@@ -1,3 +1,13 @@
+2021-10-20  Brady Eidson  <beid...@apple.com>
+
+        WebKit Managed Notifications: Skeleton NotificationProvider
+        https://bugs.webkit.org/show_bug.cgi?id=231786
+
+        Reviewed by Alex Christensen.
+
+        * WebKitTestRunner/TestOptions.cpp:
+        (WTR::TestOptions::defaults): Disable BuiltInNotificationsEnabled for now.
+
 2021-10-20  Beth Dakin  <bda...@apple.com> and Dana Estra <des...@apple.com>
 
         macOS key-driven smooth scrolling does not stop when focus changes

Modified: trunk/Tools/WebKitTestRunner/TestOptions.cpp (284590 => 284591)


--- trunk/Tools/WebKitTestRunner/TestOptions.cpp	2021-10-21 06:27:53 UTC (rev 284590)
+++ trunk/Tools/WebKitTestRunner/TestOptions.cpp	2021-10-21 06:51:48 UTC (rev 284591)
@@ -65,6 +65,7 @@
             { "AsyncFrameScrollingEnabled", false },
             { "AsyncOverflowScrollingEnabled", false },
             { "BroadcastChannelOriginPartitioningEnabled", false },
+            { "BuiltInNotificationsEnabled", false },
             { "CSSOMViewScrollingAPIEnabled", true },
             { "CaptureAudioInGPUProcessEnabled", captureAudioInGPUProcessEnabledValue },
             { "CaptureAudioInUIProcessEnabled", false },
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to