Title: [287124] trunk/Source
Revision
287124
Author
beid...@apple.com
Date
2021-12-15 19:46:06 -0800 (Wed, 15 Dec 2021)

Log Message

Add a "NotificationData" object to encompass local Notification-related parameters, instead of passing tons of them around everywhere.
https://bugs.webkit.org/show_bug.cgi?id=234370

Reviewed by Tim Horton.

Source/WebCore:

No behavior change.

* Modules/notifications/Notification.cpp:
(WebCore::Notification::dataWithoutNotificationID const):
* Modules/notifications/Notification.h:

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

Source/WebKit:

* NetworkProcess/Notifications/NetworkNotificationManager.cpp:
(WebKit::NetworkNotificationManager::showNotification):
* NetworkProcess/Notifications/NetworkNotificationManager.h:

* Shared/Notifications/NotificationManagerMessageHandler.h:
* Shared/Notifications/NotificationManagerMessageHandler.messages.in:

* UIProcess/Notifications/WebNotification.cpp:
(WebKit::WebNotification::WebNotification):
* UIProcess/Notifications/WebNotification.h:
(WebKit::WebNotification::create):

* UIProcess/Notifications/WebNotificationManagerMessageHandler.cpp:
(WebKit::WebNotificationManagerMessageHandler::showNotification):
* UIProcess/Notifications/WebNotificationManagerMessageHandler.h:

* UIProcess/Notifications/WebNotificationManagerProxy.cpp:
(WebKit::WebNotificationManagerProxy::show):
* UIProcess/Notifications/WebNotificationManagerProxy.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::showNotification):
* UIProcess/WebPageProxy.h:

* WebProcess/Notifications/WebNotificationManager.cpp:
(WebKit::WebNotificationManager::show):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287123 => 287124)


--- trunk/Source/WebCore/ChangeLog	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebCore/ChangeLog	2021-12-16 03:46:06 UTC (rev 287124)
@@ -1,3 +1,19 @@
+2021-12-15  Brady Eidson  <beid...@apple.com>
+
+        Add a "NotificationData" object to encompass local Notification-related parameters, instead of passing tons of them around everywhere.
+        https://bugs.webkit.org/show_bug.cgi?id=234370
+
+        Reviewed by Tim Horton.
+
+        No behavior change.
+
+        * Modules/notifications/Notification.cpp:
+        (WebCore::Notification::dataWithoutNotificationID const):
+        * Modules/notifications/Notification.h:
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2021-12-15  Alex Christensen  <achristen...@webkit.org>
 
         Remove unreachable code in Plugin and PluginController

Modified: trunk/Source/WebCore/Headers.cmake (287123 => 287124)


--- trunk/Source/WebCore/Headers.cmake	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebCore/Headers.cmake	2021-12-16 03:46:06 UTC (rev 287124)
@@ -280,6 +280,7 @@
     Modules/notifications/Notification.h
     Modules/notifications/NotificationClient.h
     Modules/notifications/NotificationController.h
+    Modules/notifications/NotificationData.h
     Modules/notifications/NotificationDirection.h
     Modules/notifications/NotificationPermission.h
     Modules/notifications/NotificationPermissionCallback.h

Modified: trunk/Source/WebCore/Modules/notifications/Notification.cpp (287123 => 287124)


--- trunk/Source/WebCore/Modules/notifications/Notification.cpp	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebCore/Modules/notifications/Notification.cpp	2021-12-16 03:46:06 UTC (rev 287124)
@@ -41,6 +41,7 @@
 #include "JSDOMPromiseDeferred.h"
 #include "NotificationClient.h"
 #include "NotificationController.h"
+#include "NotificationData.h"
 #include "NotificationPermissionCallback.h"
 #include "WindowEventLoop.h"
 #include "WindowFocusAllowedIndicator.h"
@@ -224,6 +225,20 @@
     return m_state == Showing && m_hasRelevantEventListener;
 }
 
+NotificationData Notification::dataWithoutNotificationID() const
+{
+    return {
+        m_title,
+        m_body,
+        m_icon.string(),
+        m_tag,
+        m_lang,
+        m_direction,
+        scriptExecutionContext()->securityOrigin()->toString(),
+        0
+    };
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(NOTIFICATIONS)

Modified: trunk/Source/WebCore/Modules/notifications/Notification.h (287123 => 287124)


--- trunk/Source/WebCore/Modules/notifications/Notification.h	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebCore/Modules/notifications/Notification.h	2021-12-16 03:46:06 UTC (rev 287124)
@@ -46,6 +46,8 @@
 class Document;
 class NotificationPermissionCallback;
 
+struct NotificationData;
+
 class Notification final : public RefCounted<Notification>, public ActiveDOMObject, public EventTargetWithInlineData {
     WTF_MAKE_ISO_ALLOCATED_EXPORT(Notification, WEBCORE_EXPORT);
 public:
@@ -87,6 +89,8 @@
 
     ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
 
+    WEBCORE_EXPORT NotificationData dataWithoutNotificationID() const;
+
     using RefCounted::ref;
     using RefCounted::deref;
 

Copied: trunk/Source/WebCore/Modules/notifications/NotificationData.cpp (from rev 287123, trunk/Source/WebKit/UIProcess/Notifications/WebNotification.cpp) (0 => 287124)


--- trunk/Source/WebCore/Modules/notifications/NotificationData.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/notifications/NotificationData.cpp	2021-12-16 03:46:06 UTC (rev 287124)
@@ -0,0 +1,31 @@
+/*
+ * 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 "NotificationData.h"
+
+namespace WebCore {
+
+} // namespace WebCore

Added: trunk/Source/WebCore/Modules/notifications/NotificationData.h (0 => 287124)


--- trunk/Source/WebCore/Modules/notifications/NotificationData.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/notifications/NotificationData.h	2021-12-16 03:46:06 UTC (rev 287124)
@@ -0,0 +1,107 @@
+/*
+ * 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
+
+namespace WebCore {
+
+enum class NotificationDirection : uint8_t;
+
+struct NotificationData {
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static std::optional<NotificationData> decode(Decoder&);
+
+    String title;
+    String body;
+    String iconURL;
+    String tag;
+    String language;
+    WebCore::NotificationDirection direction;
+    String originString;
+    uint64_t notificationID;
+};
+
+template<class Encoder>
+void NotificationData::encode(Encoder& encoder) const
+{
+    encoder << title << body << iconURL << tag << language << direction << originString << notificationID;
+}
+
+template<class Decoder>
+std::optional<NotificationData> NotificationData::decode(Decoder& decoder)
+{
+    std::optional<String> title;
+    decoder >> title;
+    if (!title)
+        return std::nullopt;
+
+    std::optional<String> body;
+    decoder >> body;
+    if (!body)
+        return std::nullopt;
+
+    std::optional<String> iconURL;
+    decoder >> iconURL;
+    if (!iconURL)
+        return std::nullopt;
+
+    std::optional<String> tag;
+    decoder >> tag;
+    if (!tag)
+        return std::nullopt;
+
+    std::optional<String> language;
+    decoder >> language;
+    if (!language)
+        return std::nullopt;
+
+    std::optional<WebCore::NotificationDirection> direction;
+    decoder >> direction;
+    if (!direction)
+        return std::nullopt;
+
+    std::optional<String> originString;
+    decoder >> originString;
+    if (!originString)
+        return std::nullopt;
+
+    std::optional<uint64_t> notificationID;
+    decoder >> notificationID;
+    if (!notificationID)
+        return std::nullopt;
+
+    return { {
+        WTFMove(*title),
+        WTFMove(*body),
+        WTFMove(*iconURL),
+        WTFMove(*tag),
+        WTFMove(*language),
+        WTFMove(*direction),
+        WTFMove(*originString),
+        WTFMove(*notificationID),
+    } };
+}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/Sources.txt (287123 => 287124)


--- trunk/Source/WebCore/Sources.txt	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebCore/Sources.txt	2021-12-16 03:46:06 UTC (rev 287124)
@@ -242,6 +242,7 @@
 Modules/model-element/dummy/DummyModelPlayerProvider.cpp
 Modules/notifications/Notification.cpp
 Modules/notifications/NotificationController.cpp
+Modules/notifications/NotificationData.cpp
 Modules/paymentrequest/MerchantValidationEvent.cpp
 Modules/paymentrequest/PaymentAddress.cpp
 Modules/paymentrequest/PaymentHandler.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (287123 => 287124)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-12-16 03:46:06 UTC (rev 287124)
@@ -1520,6 +1520,7 @@
 		510D4A37103165EE0049EA54 /* SocketStreamHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A31103165EE0049EA54 /* SocketStreamHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		510D4A38103165EE0049EA54 /* SocketStreamHandleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		5110FCFC1E03641D006F8D0B /* IDBCursorRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = 5110FCFB1E0362A5006F8D0B /* IDBCursorRecord.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		51123E2F276940CA00F9D41B /* NotificationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51123E2C27693C3200F9D41B /* NotificationData.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		5117F30E25E61020002A9F1E /* RemoteCommandListenerCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 5117F30C25E6101F002A9F1E /* RemoteCommandListenerCocoa.h */; };
 		511EC1281C50AACA0032F983 /* IDBSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 511EC1261C50AA570032F983 /* IDBSerialization.h */; };
 		511EC12C1C50ABBF0032F983 /* SQLiteIDBTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 511EC12A1C50ABBA0032F983 /* SQLiteIDBTransaction.h */; };
@@ -9551,6 +9552,8 @@
 		510D4A31103165EE0049EA54 /* SocketStreamHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandle.h; sourceTree = "<group>"; };
 		510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandleClient.h; sourceTree = "<group>"; };
 		5110FCFB1E0362A5006F8D0B /* IDBCursorRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBCursorRecord.h; sourceTree = "<group>"; };
+		51123E2C27693C3200F9D41B /* NotificationData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationData.h; sourceTree = "<group>"; };
+		51123E2E27693C3300F9D41B /* NotificationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotificationData.cpp; sourceTree = "<group>"; };
 		5117F30A25E6101E002A9F1E /* RemoteCommandListenerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteCommandListenerCocoa.mm; sourceTree = "<group>"; };
 		5117F30C25E6101F002A9F1E /* RemoteCommandListenerCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCommandListenerCocoa.h; sourceTree = "<group>"; };
 		511EC1251C50AA570032F983 /* IDBSerialization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBSerialization.cpp; sourceTree = "<group>"; };
@@ -20708,6 +20711,8 @@
 				33503C9910179A74003B47E1 /* NotificationClient.h */,
 				3128CA67147331520074C72A /* NotificationController.cpp */,
 				3128CA6A147331630074C72A /* NotificationController.h */,
+				51123E2E27693C3300F9D41B /* NotificationData.cpp */,
+				51123E2C27693C3200F9D41B /* NotificationData.h */,
 				7CC2DE021ECA04A50027B774 /* NotificationDirection.h */,
 				7CC2DDF81EC9415A0027B774 /* NotificationPermission.h */,
 				7CC2DDFA1EC9415A0027B774 /* NotificationPermission.idl */,
@@ -37061,6 +37066,7 @@
 				7E474E1E12494DC900235364 /* SQLiteDatabaseTrackerClient.h in Headers */,
 				B5A684220FFABE9800D24689 /* SQLiteFileSystem.h in Headers */,
 				512BDB4B1C456FFA006494DF /* SQLiteIDBBackingStore.h in Headers */,
+				51123E2F276940CA00F9D41B /* NotificationData.h in Headers */,
 				511EC1301C50ABF50032F983 /* SQLiteIDBCursor.h in Headers */,
 				511EC12C1C50ABBF0032F983 /* SQLiteIDBTransaction.h in Headers */,
 				1A22464C0CC98DDB00C05240 /* SQLiteStatement.h in Headers */,

Modified: trunk/Source/WebKit/ChangeLog (287123 => 287124)


--- trunk/Source/WebKit/ChangeLog	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/ChangeLog	2021-12-16 03:46:06 UTC (rev 287124)
@@ -1,3 +1,37 @@
+2021-12-15  Brady Eidson  <beid...@apple.com>
+
+        Add a "NotificationData" object to encompass local Notification-related parameters, instead of passing tons of them around everywhere.
+        https://bugs.webkit.org/show_bug.cgi?id=234370
+
+        Reviewed by Tim Horton.
+
+        * NetworkProcess/Notifications/NetworkNotificationManager.cpp:
+        (WebKit::NetworkNotificationManager::showNotification):
+        * NetworkProcess/Notifications/NetworkNotificationManager.h:
+
+        * Shared/Notifications/NotificationManagerMessageHandler.h:
+        * Shared/Notifications/NotificationManagerMessageHandler.messages.in:
+
+        * UIProcess/Notifications/WebNotification.cpp:
+        (WebKit::WebNotification::WebNotification):
+        * UIProcess/Notifications/WebNotification.h:
+        (WebKit::WebNotification::create):
+
+        * UIProcess/Notifications/WebNotificationManagerMessageHandler.cpp:
+        (WebKit::WebNotificationManagerMessageHandler::showNotification):
+        * UIProcess/Notifications/WebNotificationManagerMessageHandler.h:
+
+        * UIProcess/Notifications/WebNotificationManagerProxy.cpp:
+        (WebKit::WebNotificationManagerProxy::show):
+        * UIProcess/Notifications/WebNotificationManagerProxy.h:
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::showNotification):
+        * UIProcess/WebPageProxy.h:
+
+        * WebProcess/Notifications/WebNotificationManager.cpp:
+        (WebKit::WebNotificationManager::show):
+
 2021-12-15  Alex Christensen  <achristen...@webkit.org>
 
         Remove unreachable code in Plugin and PluginController

Modified: trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp (287123 => 287124)


--- trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp	2021-12-16 03:46:06 UTC (rev 287124)
@@ -98,7 +98,7 @@
     sendMessageWithReply<WebPushD::MessageType::GetPendingPushMessages>(WTFMove(replyHandler));
 }
 
-void NetworkNotificationManager::showNotification(const String&, const String&, const String&, const String&, const String&, WebCore::NotificationDirection, const String&, uint64_t)
+void NetworkNotificationManager::showNotification(const WebCore::NotificationData&)
 {
     if (!m_connection)
         return;

Modified: trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h (287123 => 287124)


--- trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h	2021-12-16 03:46:06 UTC (rev 287124)
@@ -59,7 +59,7 @@
     NetworkNotificationManager(NetworkSession&, const String& webPushMachServiceName);
 
     void requestSystemNotificationPermission(const String& originString, CompletionHandler<void(bool)>&&) final;
-    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 showNotification(const WebCore::NotificationData&) final;
     void cancelNotification(uint64_t notificationID) final;
     void clearNotifications(const Vector<uint64_t>& notificationIDs) final;
     void didDestroyNotification(uint64_t notificationID) final;

Modified: trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.h (287123 => 287124)


--- trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.h	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.h	2021-12-16 03:46:06 UTC (rev 287124)
@@ -29,6 +29,10 @@
 #include "WebPageProxyIdentifier.h"
 #include <WebCore/NotificationDirection.h>
 
+namespace WebCore {
+struct NotificationData;
+}
+
 namespace WebKit {
 
 class NotificationManagerMessageHandler : public IPC::MessageReceiver {
@@ -36,7 +40,7 @@
     virtual ~NotificationManagerMessageHandler() = default;
 
     virtual void requestSystemNotificationPermission(const String& securityOrigin, CompletionHandler<void(bool)>&&) = 0;
-    virtual void showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& language, WebCore::NotificationDirection, const String& originString, uint64_t notificationID) = 0;
+    virtual void showNotification(const WebCore::NotificationData&) = 0;
     virtual void cancelNotification(uint64_t notificationID) = 0;
     virtual void clearNotifications(const Vector<uint64_t>& notificationIDs) = 0;
     virtual void didDestroyNotification(uint64_t notificationID) = 0;

Modified: trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.messages.in (287123 => 287124)


--- trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.messages.in	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.messages.in	2021-12-16 03:46:06 UTC (rev 287124)
@@ -22,7 +22,7 @@
 
 messages -> NotificationManagerMessageHandler NotRefCounted {
     RequestSystemNotificationPermission(String originIdentifier) -> (bool allowed) Async
-    ShowNotification(String title, String body, String iconURL, String tag, String language, enum:uint8_t WebCore::NotificationDirection direction, String originIdentifier, uint64_t notificationID)
+    ShowNotification(struct WebCore::NotificationData notificationData)
     CancelNotification(uint64_t notificationID)
     ClearNotifications(Vector<uint64_t> notificationIDs)
     DidDestroyNotification(uint64_t notificationID)

Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotification.cpp (287123 => 287124)


--- trunk/Source/WebKit/UIProcess/Notifications/WebNotification.cpp	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotification.cpp	2021-12-16 03:46:06 UTC (rev 287124)
@@ -26,17 +26,19 @@
 #include "config.h"
 #include "WebNotification.h"
 
+#include <WebCore/NotificationData.h>
+
 namespace WebKit {
 
-WebNotification::WebNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection dir, const String& originString, uint64_t notificationID)
-    : m_title(title)
-    , m_body(body)
-    , m_iconURL(iconURL)
-    , m_tag(tag)
-    , m_lang(lang)
-    , m_dir(dir)
-    , m_origin(API::SecurityOrigin::createFromString(originString))
-    , m_notificationID(notificationID)
+WebNotification::WebNotification(const WebCore::NotificationData& data)
+    : m_title(data.title)
+    , m_body(data.body)
+    , m_iconURL(data.iconURL)
+    , m_tag(data.tag)
+    , m_lang(data.language)
+    , m_dir(data.direction)
+    , m_origin(API::SecurityOrigin::createFromString(data.originString))
+    , m_notificationID(data.notificationID)
 {
 }
 

Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotification.h (287123 => 287124)


--- trunk/Source/WebKit/UIProcess/Notifications/WebNotification.h	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotification.h	2021-12-16 03:46:06 UTC (rev 287124)
@@ -32,6 +32,7 @@
 
 namespace WebCore {
 enum class NotificationDirection : uint8_t;
+struct NotificationData;
 }
 
 namespace WebKit {
@@ -38,9 +39,9 @@
 
 class WebNotification : public API::ObjectImpl<API::Object::Type::Notification> {
 public:
-    static Ref<WebNotification> create(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection dir, const String& originString, uint64_t notificationID)
+    static Ref<WebNotification> create(const WebCore::NotificationData& data)
     {
-        return adoptRef(*new WebNotification(title, body, iconURL, tag, lang, dir, originString, notificationID));
+        return adoptRef(*new WebNotification(data));
     }
 
     const String& title() const { return m_title; }
@@ -54,7 +55,7 @@
     uint64_t notificationID() const { return m_notificationID; }
 
 private:
-    WebNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection, const String& originString, uint64_t notificationID);
+    WebNotification(const WebCore::NotificationData&);
 
     String m_title;
     String m_body;

Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.cpp (287123 => 287124)


--- trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.cpp	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.cpp	2021-12-16 03:46:06 UTC (rev 287124)
@@ -40,9 +40,9 @@
     RELEASE_ASSERT_NOT_REACHED();
 }
 
-void WebNotificationManagerMessageHandler::showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& language, WebCore::NotificationDirection direction, const String& originString, uint64_t notificationID)
+void WebNotificationManagerMessageHandler::showNotification(const WebCore::NotificationData& data)
 {
-    m_webPageProxy.showNotification(title, body, iconURL, tag, language, direction, originString, notificationID);
+    m_webPageProxy.showNotification(data);
 }
 
 void WebNotificationManagerMessageHandler::cancelNotification(uint64_t notificationID)

Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.h (287123 => 287124)


--- trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.h	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.h	2021-12-16 03:46:06 UTC (rev 287124)
@@ -37,7 +37,7 @@
     explicit WebNotificationManagerMessageHandler(WebPageProxy&);
 
     void requestSystemNotificationPermission(const String&, CompletionHandler<void(bool)>&&) final;
-    void showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& language, WebCore::NotificationDirection, const String& originString, uint64_t notificationID) final;
+    void showNotification(const WebCore::NotificationData&) final;
     void cancelNotification(uint64_t notificationID) final;
     void clearNotifications(const Vector<uint64_t>& notificationIDs) final;
     void didDestroyNotification(uint64_t notificationID) final;

Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp (287123 => 287124)


--- trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp	2021-12-16 03:46:06 UTC (rev 287124)
@@ -93,11 +93,11 @@
     return m_provider->notificationPermissions();
 }
 
-void WebNotificationManagerProxy::show(WebPageProxy* webPage, const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection dir, const String& originString, uint64_t pageNotificationID)
+void WebNotificationManagerProxy::show(WebPageProxy* webPage, const WebCore::NotificationData& notificationData)
 {
     uint64_t globalNotificationID = generateGlobalNotificationID();
-    auto notification = WebNotification::create(title, body, iconURL, tag, lang, dir, originString, globalNotificationID);
-    auto notificationIDPair = std::make_pair(webPage->identifier(), pageNotificationID);
+    auto notification = WebNotification::create(notificationData);
+    auto notificationIDPair = std::make_pair(webPage->identifier(), notificationData.notificationID);
     m_globalNotificationMap.set(globalNotificationID, notificationIDPair);
     m_notifications.set(notificationIDPair, std::make_pair(globalNotificationID, notification.copyRef()));
     m_provider->show(*webPage, notification.get());

Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.h (287123 => 287124)


--- trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.h	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.h	2021-12-16 03:46:06 UTC (rev 287124)
@@ -34,7 +34,7 @@
 #include <wtf/text/StringHash.h>
 
 namespace WebCore {
-enum class NotificationDirection : uint8_t;
+struct NotificationData;
 }
 
 namespace API {
@@ -59,7 +59,7 @@
     void setProvider(std::unique_ptr<API::NotificationProvider>&&);
     HashMap<String, bool> notificationPermissions();
 
-    void show(WebPageProxy*, const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection, const String& originString, uint64_t pageNotificationID);
+    void show(WebPageProxy*, const WebCore::NotificationData&);
     void cancel(WebPageProxy*, uint64_t pageNotificationID);
     void clearNotifications(WebPageProxy*);
     void clearNotifications(WebPageProxy*, const Vector<uint64_t>& pageNotificationIDs);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (287123 => 287124)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-12-16 03:46:06 UTC (rev 287124)
@@ -8733,9 +8733,9 @@
     m_uiClient->decidePolicyForNotificationPermissionRequest(*this, origin.get(), WTFMove(completionHandler));
 }
 
-void WebPageProxy::showNotification(const String& title, const String& body, const String& iconURL, const String& tag, const String& lang, WebCore::NotificationDirection dir, const String& originString, uint64_t notificationID)
+void WebPageProxy::showNotification(const WebCore::NotificationData& notificationData)
 {
-    m_process->processPool().supplement<WebNotificationManagerProxy>()->show(this, title, body, iconURL, tag, lang, dir, originString, notificationID);
+    m_process->processPool().supplement<WebNotificationManagerProxy>()->show(this, notificationData);
 }
 
 void WebPageProxy::cancelNotification(uint64_t notificationID)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (287123 => 287124)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-12-16 03:46:06 UTC (rev 287124)
@@ -2032,7 +2032,7 @@
     bool isQuarantinedAndNotUserApproved(const String&);
 #endif
 
-    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);
+    void showNotification(const WebCore::NotificationData&);
     void cancelNotification(uint64_t notificationID);
     void clearNotifications(const Vector<uint64_t>& notificationIDs);
     void didDestroyNotification(uint64_t notificationID);

Modified: trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp (287123 => 287124)


--- trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp	2021-12-16 03:33:41 UTC (rev 287123)
+++ trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp	2021-12-16 03:46:06 UTC (rev 287124)
@@ -39,6 +39,7 @@
 #include "WebPageProxyMessages.h"
 #include <WebCore/Document.h>
 #include <WebCore/Notification.h>
+#include <WebCore/NotificationData.h>
 #include <WebCore/Page.h>
 #include <WebCore/RuntimeEnabledFeatures.h>
 #include <WebCore/ScriptExecutionContext.h>
@@ -163,7 +164,9 @@
     auto it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<uint64_t>()).iterator;
     it->value.append(notificationID);
 
-    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);
+    auto notificationData = notification->dataWithoutNotificationID();
+    notificationData.notificationID = notificationID;
+    sendNotificationMessage(m_process, Messages::NotificationManagerMessageHandler::ShowNotification(WTFMove(notificationData)), *page);
     return true;
 #else
     UNUSED_PARAM(notification);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to