Changeset 293296 in webkit
- Timestamp:
- Apr 23, 2022, 3:26:57 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 30 edited
- 3 copied
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/notifications/NotificationData.h (modified) (2 diffs)
-
Source/WebCore/Modules/notifications/NotificationDataCocoa.mm (added)
-
Source/WebCore/SourcesCocoa.txt (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (2 diffs)
-
Source/WebCore/workers/service/server/SWServer.cpp (modified) (3 diffs)
-
Source/WebCore/workers/service/server/SWServer.h (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.cpp (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.h (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.messages.in (modified) (1 diff)
-
Source/WebKit/Shared/ModelIdentifier.h (modified) (1 diff)
-
Source/WebKit/SourcesCocoa.txt (modified) (1 diff)
-
Source/WebKit/UIProcess/API/C/WKNotification.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/API/C/WKNotification.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/C/mac/WKNotificationPrivateMac.h (copied) (copied from trunk/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadInternal.h ) (2 diffs)
-
Source/WebKit/UIProcess/API/C/mac/WKNotificationPrivateMac.mm (copied) (copied from trunk/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadInternal.h ) (2 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (modified) (3 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/_WKDownload.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/_WKDownloadInternal.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm (modified) (3 diffs)
-
Source/WebKit/UIProcess/ModelElementController.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Notifications/WebNotification.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/Notifications/WebNotification.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp (modified) (2 diffs)
-
Source/WebKit/WebKit.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/WebKitTestRunner/WebNotificationProvider.cpp (modified) (5 diffs)
-
Tools/WebKitTestRunner/WebNotificationProvider.h (modified) (1 diff)
-
Tools/WebKitTestRunner/cocoa/WebNotificationProviderCocoa.mm (copied) (copied from trunk/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadInternal.h ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r293295 r293296 1 2022-04-23 Brady Eidson <beidson@apple.com> 2 3 Add WKNotification and WKWebsiteDataStore SPI for handling click/close of persistent notifications 4 https://bugs.webkit.org/show_bug.cgi 5 6 Reviewed by Chris Dumez. 7 8 Covered by existing tests with WKTR changes. 9 10 In Cocoa, expose the dictionary representation of a notification as an NSDictionary, 11 as it is meant to be used as an NSUserNotification userInfo value. 12 13 * Modules/notifications/NotificationData.h: 14 * Modules/notifications/NotificationDataCocoa.mm: Added. 15 (WebCore::NotificationData::fromDictionary): 16 (WebCore::NotificationData::dictionaryRepresentation const): 17 18 * SourcesCocoa.txt: 19 * WebCore.xcodeproj/project.pbxproj: 20 21 * workers/service/server/SWServer.cpp: 22 (WebCore::SWServer::processNotificationEvent): 23 * workers/service/server/SWServer.h: 24 1 25 2022-04-23 Justin Michaud <justin_michaud@apple.com> 2 26 -
trunk/Source/WebCore/Modules/notifications/NotificationData.h
r292218 r293296 33 33 #include <wtf/text/WTFString.h> 34 34 35 OBJC_CLASS NSDictionary; 36 35 37 namespace WebCore { 36 38 … … 43 45 NotificationData isolatedCopy() const &; 44 46 NotificationData isolatedCopy() &&; 47 48 #if PLATFORM(COCOA) 49 WEBCORE_EXPORT static std::optional<NotificationData> fromDictionary(NSDictionary *dictionaryRepresentation); 50 WEBCORE_EXPORT NSDictionary *dictionaryRepresentation() const; 51 #endif 45 52 46 53 String title; -
trunk/Source/WebCore/SourcesCocoa.txt
r292914 r293296 115 115 Modules/model-element/scenekit/SceneKitModelLoaderUSD.mm 116 116 Modules/model-element/scenekit/SceneKitModelPlayer.mm 117 Modules/notifications/NotificationDataCocoa.mm 117 118 Modules/push-api/cocoa/PushCryptoCocoa.cpp 118 119 Modules/plugins/YouTubePluginReplacement.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r293285 r293296 9910 9910 518F97001BE94C5B0023187C /* MemoryIndex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryIndex.cpp; sourceTree = "<group>"; }; 9911 9911 518F97011BE94C5B0023187C /* MemoryIndex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryIndex.h; sourceTree = "<group>"; }; 9912 5194C26827FFD7C200AEF3CF /* NotificationDataCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NotificationDataCocoa.mm; sourceTree = "<group>"; }; 9912 9913 519755F71BFD7DBC003DE980 /* MemoryIndexCursor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryIndexCursor.cpp; sourceTree = "<group>"; }; 9913 9914 519755F81BFD7DBC003DE980 /* MemoryIndexCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryIndexCursor.h; sourceTree = "<group>"; }; … … 21003 21004 51123E2E27693C3300F9D41B /* NotificationData.cpp */, 21004 21005 51123E2C27693C3200F9D41B /* NotificationData.h */, 21006 5194C26827FFD7C200AEF3CF /* NotificationDataCocoa.mm */, 21005 21007 7CC2DE021ECA04A50027B774 /* NotificationDirection.h */, 21006 21008 51E3AF0C276B0602009B429D /* NotificationDirection.idl */, -
trunk/Source/WebCore/workers/service/server/SWServer.cpp
r293195 r293296 1366 1366 } 1367 1367 1368 void SWServer::processNotificationEvent(NotificationData&& data, NotificationEventType type) 1369 { 1370 whenImportIsCompletedIfNeeded([this, weakThis = WeakPtr { *this }, data = WTFMove(data), type]() mutable { 1371 if (!weakThis) 1372 return; 1368 void SWServer::processNotificationEvent(NotificationData&& data, NotificationEventType type, CompletionHandler<void(bool)>&& callback) 1369 { 1370 whenImportIsCompletedIfNeeded([this, weakThis = WeakPtr { *this }, data = WTFMove(data), type, callback = WTFMove(callback)]() mutable { 1371 if (!weakThis) { 1372 callback(false); 1373 return; 1374 } 1373 1375 1374 1376 auto origin = SecurityOriginData::fromURL(data.serviceWorkerRegistrationURL); 1375 1377 ServiceWorkerRegistrationKey registrationKey { WTFMove(origin), URL { data.serviceWorkerRegistrationURL } }; 1376 1378 auto registration = m_scopeToRegistrationMap.get(registrationKey); 1377 if (!registration) 1378 return; 1379 if (!registration) { 1380 RELEASE_LOG_ERROR(Push, "Cannot process notification event: Failed to find SW registration for scope %" PRIVATE_LOG_STRING, registrationKey.scope().string().utf8().data()); 1381 callback(true); 1382 return; 1383 } 1379 1384 1380 1385 auto* worker = registration->activeWorker(); 1381 if (!worker) 1382 return; 1383 1384 fireFunctionalEvent(*registration, [worker = Ref { *worker }, weakThis = WTFMove(weakThis), data = WTFMove(data), type](auto&& connectionOrStatus) mutable { 1385 if (!connectionOrStatus.has_value()) 1386 if (!worker) { 1387 RELEASE_LOG_ERROR(Push, "Cannot process notification event: No active worker for scope %" PRIVATE_LOG_STRING, registrationKey.scope().string().utf8().data()); 1388 callback(true); 1389 return; 1390 } 1391 1392 fireFunctionalEvent(*registration, [worker = Ref { *worker }, weakThis = WTFMove(weakThis), data = WTFMove(data), type, callback = WTFMove(callback)](auto&& connectionOrStatus) mutable { 1393 if (!connectionOrStatus.has_value()) { 1394 callback(connectionOrStatus.error() == ShouldSkipEvent::Yes); 1386 1395 return; 1396 } 1387 1397 1388 1398 auto serviceWorkerIdentifier = worker->identifier(); … … 1394 1404 }); 1395 1405 terminateWorkerTimer->startOneShot(weakThis && weakThis->m_isProcessTerminationDelayEnabled ? defaultTerminationDelay : defaultFunctionalEventDuration); 1396 connectionOrStatus.value()->fireNotificationEvent(serviceWorkerIdentifier, data, type, [ terminateWorkerTimer = WTFMove(terminateWorkerTimer), worker = WTFMove(worker)](bool succeeded) mutable {1406 connectionOrStatus.value()->fireNotificationEvent(serviceWorkerIdentifier, data, type, [callback = WTFMove(callback), terminateWorkerTimer = WTFMove(terminateWorkerTimer), worker = WTFMove(worker)] (bool succeeded) mutable { 1397 1407 RELEASE_LOG_ERROR_IF(!succeeded, ServiceWorker, "Service Worker notification event handler did not succeed"); 1408 1398 1409 // FIXME: if succeeded is false, should we implement a default action like opening a new page? 1399 1410 if (terminateWorkerTimer->isActive()) { … … 1401 1412 terminateWorkerTimer->stop(); 1402 1413 } 1414 1415 callback(succeeded); 1403 1416 }); 1404 1417 }); -
trunk/Source/WebCore/workers/service/server/SWServer.h
r293195 r293296 231 231 232 232 WEBCORE_EXPORT void processPushMessage(std::optional<Vector<uint8_t>>&&, URL&&, CompletionHandler<void(bool)>&&); 233 WEBCORE_EXPORT void processNotificationEvent(NotificationData&&, NotificationEventType );233 WEBCORE_EXPORT void processNotificationEvent(NotificationData&&, NotificationEventType, CompletionHandler<void(bool)>&&); 234 234 235 235 enum class ShouldSkipEvent : bool { No, Yes }; -
trunk/Source/WebKit/ChangeLog
r293285 r293296 1 2022-04-23 Brady Eidson <beidson@apple.com> 2 3 Add WKNotification and WKWebsiteDataStore SPI for handling click/close of persistent notifications 4 https://bugs.webkit.org/show_bug.cgi 5 6 Reviewed by Chris Dumez. 7 8 For notifications that are persistent, add WKWebsiteDataStore SPI to handle click/close operations, 9 as the WKNotificationManager's runtime record of such notifications might be gone. 10 11 WebKitTestRunner exercises this new SPI in existing tests. 12 13 * NetworkProcess/NetworkProcess.cpp: 14 (WebKit::NetworkProcess::processNotificationEvent): 15 * NetworkProcess/NetworkProcess.h: 16 * NetworkProcess/NetworkProcess.messages.in: 17 18 * SourcesCocoa.txt: 19 20 * UIProcess/API/C/WKNotification.cpp: 21 (WKNotificationGetIsPersistent): 22 * UIProcess/API/C/WKNotification.h: 23 24 * UIProcess/API/C/mac/WKNotificationPrivateMac.h: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKDownloadInternal.h. 25 * UIProcess/API/C/mac/WKNotificationPrivateMac.mm: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKDownloadInternal.h. 26 (WKNotificationCopyDictionaryRepresentation): 27 28 * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: 29 (-[WKWebsiteDataStore _processPersistentNotificationClick:completionHandler:]): 30 (-[WKWebsiteDataStore _processPersistentNotificationClose:completionHandler:]): 31 * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h: 32 33 * UIProcess/API/Cocoa/_WKDownload.mm: 34 * UIProcess/API/Cocoa/_WKDownloadInternal.h: 35 36 * UIProcess/Network/NetworkProcessProxy.cpp: 37 (WebKit::NetworkProcessProxy::processNotificationEvent): 38 * UIProcess/Network/NetworkProcessProxy.h: 39 40 * UIProcess/Notifications/WebNotification.cpp: 41 * UIProcess/Notifications/WebNotification.h: 42 * UIProcess/Notifications/WebNotificationManagerProxy.cpp: 43 (WebKit::dispatchDidClickNotification): 44 (WebKit::WebNotificationManagerProxy::providerDidCloseNotifications): 45 46 * WebKit.xcodeproj/project.pbxproj: 47 1 48 2022-04-22 Chris Dumez <cdumez@apple.com> 2 49 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r293285 r293296 2302 2302 2303 2303 #if ENABLE(SERVICE_WORKER) 2304 void NetworkProcess::processNotificationEvent(NotificationData&& data, NotificationEventType eventType )2304 void NetworkProcess::processNotificationEvent(NotificationData&& data, NotificationEventType eventType, CompletionHandler<void(bool)>&& callback) 2305 2305 { 2306 2306 if (auto* session = networkSession(data.sourceSession)) 2307 session->ensureSWServer().processNotificationEvent(WTFMove(data), eventType );2307 session->ensureSWServer().processNotificationEvent(WTFMove(data), eventType, WTFMove(callback)); 2308 2308 } 2309 2309 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r292158 r293296 378 378 void getPendingPushMessages(PAL::SessionID, CompletionHandler<void(const Vector<WebPushMessage>&)>&&); 379 379 void processPushMessage(PAL::SessionID, WebPushMessage&&, WebCore::PushPermissionState, CompletionHandler<void(bool)>&&); 380 void processNotificationEvent(WebCore::NotificationData&&, WebCore::NotificationEventType );380 void processNotificationEvent(WebCore::NotificationData&&, WebCore::NotificationEventType, CompletionHandler<void(bool)>&&); 381 381 #endif 382 382 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r292624 r293296 211 211 GetPendingPushMessages(PAL::SessionID sessionID) -> (Vector<WebKit::WebPushMessage> messages) 212 212 ProcessPushMessage(PAL::SessionID sessionID, struct WebKit::WebPushMessage pushMessage, enum:uint8_t WebCore::PushPermissionState pushPermissionState) -> (bool didSucceed) 213 ProcessNotificationEvent(struct WebCore::NotificationData data, enum:bool WebCore::NotificationEventType eventType) 213 ProcessNotificationEvent(struct WebCore::NotificationData data, enum:bool WebCore::NotificationEventType eventType) -> (bool didSucceed) 214 214 #endif 215 215 DeletePushAndNotificationRegistration(PAL::SessionID sessionID, struct WebCore::SecurityOriginData origin) -> (String errorMessage) -
trunk/Source/WebKit/Shared/ModelIdentifier.h
r291019 r293296 28 28 #import <wtf/text/WTFString.h> 29 29 30 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS) 31 #import <WebCore/GraphicsLayer.h> 32 #endif 33 30 34 namespace WebKit { 31 35 32 36 #if ENABLE(ARKIT_INLINE_PREVIEW) 33 34 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS)35 #import <WebCore/GraphicsLayer.h>36 #endif37 37 38 38 struct ModelIdentifier { -
trunk/Source/WebKit/SourcesCocoa.txt
r293266 r293296 268 268 269 269 UIProcess/API/C/mac/WKContextPrivateMac.mm 270 UIProcess/API/C/mac/WKNotificationPrivateMac.mm 270 271 UIProcess/API/C/mac/WKPagePrivateMac.mm 271 272 UIProcess/API/C/mac/WKProtectionSpaceNS.mm -
trunk/Source/WebKit/UIProcess/API/C/WKNotification.cpp
r287412 r293296 96 96 return WKDataCreate(span.data(), span.size()); 97 97 } 98 99 bool WKNotificationGetIsPersistent(WKNotificationRef notification) 100 { 101 return toImpl(notification)->isPersistentNotification(); 102 } -
trunk/Source/WebKit/UIProcess/API/C/WKNotification.h
r287412 r293296 44 44 WK_EXPORT uint64_t WKNotificationGetID(WKNotificationRef notification); 45 45 WK_EXPORT WKDataRef WKNotificationCopyCoreIDForTesting(WKNotificationRef notification); 46 WK_EXPORT bool WKNotificationGetIsPersistent(WKNotificationRef notification); 46 47 47 48 #ifdef __cplusplus -
trunk/Source/WebKit/UIProcess/API/C/mac/WKNotificationPrivateMac.h
r293295 r293296 1 1 /* 2 * Copyright (C) 20 14Apple Inc. All rights reserved.2 * Copyright (C) 2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #import "_WKDownload.h" 26 #ifndef WKNotificationPrivateMac_h 27 #define WKNotificationPrivateMac_h 27 28 28 #i mport <wtf/RetainPtr.h>29 #include <WebKit/WKBase.h> 29 30 30 @class WKDownload; 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 31 34 32 @interface _WKDownload () <WKObject> { 33 @package 34 RetainPtr<WKDownload> _download; 35 #ifdef __OBJC__ 36 37 @class NSDictionary; 38 39 WK_EXPORT NSDictionary *WKNotificationCopyDictionaryRepresentation(WKNotificationRef notification) NS_RETURNS_RETAINED; 40 41 #endif // __OBJC__ 42 43 #ifdef __cplusplus 35 44 } 36 @end 45 #endif 46 47 #endif /* WKNotificationPrivateMac_h */ -
trunk/Source/WebKit/UIProcess/API/C/mac/WKNotificationPrivateMac.mm
r293295 r293296 1 1 /* 2 * Copyright (C) 20 14Apple Inc. All rights reserved.2 * Copyright (C) 2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #import "_WKDownload.h" 26 #import "config.h" 27 #import "WKNotificationPrivateMac.h" 27 28 28 #import <wtf/RetainPtr.h> 29 #import "WebNotification.h" 30 #import <WebCore/NotificationData.h> 29 31 30 @class WKDownload; 31 32 @interface _WKDownload () <WKObject> { 33 @package 34 RetainPtr<WKDownload> _download; 32 NSDictionary *WKNotificationCopyDictionaryRepresentation(WKNotificationRef notification) 33 { 34 return [WebKit::toImpl(notification)->data().dictionaryRepresentation() retain]; 35 35 } 36 @end -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r292793 r293296 39 39 #import "WKWebViewInternal.h" 40 40 #import "WKWebsiteDataRecordInternal.h" 41 #import "WebNotification.h" 41 42 #import "WebNotificationManagerProxy.h" 42 43 #import "WebPageProxy.h" … … 58 59 class WebsiteDataStoreClient final : public WebKit::WebsiteDataStoreClient { 59 60 public: 60 explicitWebsiteDataStoreClient(WKWebsiteDataStore *dataStore, id<_WKWebsiteDataStoreDelegate> delegate)61 WebsiteDataStoreClient(WKWebsiteDataStore *dataStore, id<_WKWebsiteDataStoreDelegate> delegate) 61 62 : m_dataStore(dataStore) 62 63 , m_delegate(delegate) … … 832 833 } 833 834 835 -(void)_processPersistentNotificationClick:(NSDictionary *)notificationDictionaryRepresentation completionHandler:(void(^)(bool))completionHandler 836 { 837 #if ENABLE(SERVICE_WORKER) 838 auto notificationData = WebCore::NotificationData::fromDictionary(notificationDictionaryRepresentation); 839 if (!notificationData) { 840 RELEASE_LOG_ERROR(Push, "Asked to handle a persistent notification click with an invalid notification dictionary representation"); 841 completionHandler(false); 842 return; 843 } 844 845 RELEASE_LOG(Push, "Sending persistent notification click from origin %" PRIVATE_LOG_STRING " to network process to handle", notificationData->originString.utf8().data()); 846 847 notificationData->sourceSession = _websiteDataStore->sessionID(); 848 _websiteDataStore->networkProcess().processNotificationEvent(*notificationData, WebCore::NotificationEventType::Click, [completionHandler = makeBlockPtr(completionHandler)] (bool wasProcessed) { 849 RELEASE_LOG(Push, "Notification click event processing complete. Callback result: %d", wasProcessed); 850 completionHandler(wasProcessed); 851 }); 852 #endif 853 } 854 855 -(void)_processPersistentNotificationClose:(NSDictionary *)notificationDictionaryRepresentation completionHandler:(void(^)(bool))completionHandler 856 { 857 #if ENABLE(SERVICE_WORKER) 858 auto notificationData = WebCore::NotificationData::fromDictionary(notificationDictionaryRepresentation); 859 if (!notificationData) { 860 RELEASE_LOG_ERROR(Push, "Asked to handle a persistent notification click with an invalid notification dictionary representation"); 861 completionHandler(false); 862 return; 863 } 864 865 RELEASE_LOG(Push, "Sending persistent notification close from origin %" PRIVATE_LOG_STRING " to network process to handle", notificationData->originString.utf8().data()); 866 867 _websiteDataStore->networkProcess().processNotificationEvent(*notificationData, WebCore::NotificationEventType::Close, [completionHandler = makeBlockPtr(completionHandler)] (bool wasProcessed) { 868 RELEASE_LOG(Push, "Notification close event processing complete. Callback result: %d", wasProcessed); 869 completionHandler(wasProcessed); 870 }); 871 #endif 872 } 873 834 874 -(void)_deletePushAndNotificationRegistration:(WKSecurityOrigin *)securityOrigin completionHandler:(void(^)(NSError *))completionHandler 835 875 { -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h
r292126 r293296 112 112 -(void)_getPendingPushMessages:(void(^)(NSArray<NSDictionary *> *))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 113 113 -(void)_processPushMessage:(NSDictionary *)pushMessage completionHandler:(void(^)(bool))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 114 -(void)_processPersistentNotificationClick:(NSDictionary *)notificationDictionaryRepresentation completionHandler:(void(^)(bool))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 115 -(void)_processPersistentNotificationClose:(NSDictionary *)notificationDictionaryRepresentation completionHandler:(void(^)(bool))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 114 116 -(void)_deletePushAndNotificationRegistration:(WKSecurityOrigin *)securityOrigin completionHandler:(void(^)(NSError *))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 115 117 -(void)_getOriginsWithPushAndNotificationPermissions:(void(^)(NSSet<WKSecurityOrigin *> *))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKDownload.mm
r282882 r293296 34 34 #import "WKWebViewInternal.h" 35 35 #import <wtf/WeakObjCPtr.h> 36 #import <wtf/cocoa/VectorCocoa.h> 37 36 38 37 39 ALLOW_DEPRECATED_DECLARATIONS_BEGIN -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadInternal.h
r270638 r293296 26 26 #import "_WKDownload.h" 27 27 28 #import "WKObject.h" 28 29 #import <wtf/RetainPtr.h> 29 30 -
trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm
r293063 r293296 143 143 } 144 144 145 #endif 145 #endif // ENABLE(ARKIT_INLINE_PREVIEW_IOS) 146 146 147 147 #if ENABLE(ARKIT_INLINE_PREVIEW_MAC) … … 313 313 })); 314 314 } 315 #endif 315 #endif // ENABLE(ARKIT_INLINE_PREVIEW_MAC) 316 316 317 317 #if ENABLE(ARKIT_INLINE_PREVIEW) … … 546 546 } 547 547 548 #endif 549 550 } 551 552 #endif 548 #endif // ENABLE(ARKIT_INLINE_PREVIEW) 549 550 } // namespace WebKit 551 552 #endif // ENABLE(ARKIT_INLINE_PREVIEW) -
trunk/Source/WebKit/UIProcess/ModelElementController.h
r293063 r293296 100 100 }; 101 101 102 } 102 } // namespace WebKit 103 103 104 104 #endif -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r293017 r293296 1780 1780 } 1781 1781 1782 void NetworkProcessProxy::processNotificationEvent(const NotificationData& data, NotificationEventType eventType) 1783 { 1784 send(Messages::NetworkProcess::ProcessNotificationEvent { data, eventType }, 0); 1782 void NetworkProcessProxy::processNotificationEvent(const NotificationData& data, NotificationEventType eventType, CompletionHandler<void(bool wasProcessed)>&& callback) 1783 { 1784 RELEASE_ASSERT(!!callback); 1785 sendWithAsyncReply(Messages::NetworkProcess::ProcessNotificationEvent { data, eventType }, WTFMove(callback)); 1785 1786 } 1786 1787 #endif // ENABLE(SERVICE_WORKER) -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r293017 r293296 287 287 void getPendingPushMessages(PAL::SessionID, CompletionHandler<void(const Vector<WebPushMessage>&)>&&); 288 288 void processPushMessage(PAL::SessionID, const WebPushMessage&, CompletionHandler<void(bool wasProcessed)>&&); 289 void processNotificationEvent(const WebCore::NotificationData&, WebCore::NotificationEventType );289 void processNotificationEvent(const WebCore::NotificationData&, WebCore::NotificationEventType, CompletionHandler<void(bool wasProcessed)>&&); 290 290 #endif 291 291 -
trunk/Source/WebKit/UIProcess/Notifications/WebNotification.cpp
r292110 r293296 27 27 #include "WebNotification.h" 28 28 29 #include "APIDictionary.h" 29 30 #include <WebCore/NotificationData.h> 30 31 -
trunk/Source/WebKit/UIProcess/Notifications/WebNotification.h
r292110 r293296 26 26 #pragma once 27 27 28 #include "API Object.h"28 #include "APIDictionary.h" 29 29 #include "APISecurityOrigin.h" 30 30 #include "Connection.h" -
trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp
r292771 r293296 195 195 if (notification->isPersistentNotification()) { 196 196 if (auto* dataStore = WebsiteDataStore::existingDataStoreForSessionID(notification->sessionID())) 197 dataStore->networkProcess().processNotificationEvent(notification->data(), NotificationEventType::Click );197 dataStore->networkProcess().processNotificationEvent(notification->data(), NotificationEventType::Click, [](bool) { }); 198 198 else 199 199 RELEASE_LOG_ERROR(Notifications, "WebsiteDataStore not found from sessionID %" PRIu64 ", dropping notification click", notification->sessionID().toUInt64()); … … 258 258 if (notification->isPersistentNotification()) { 259 259 if (auto* dataStore = WebsiteDataStore::existingDataStoreForSessionID(notification->sessionID())) 260 dataStore->networkProcess().processNotificationEvent(notification->data(), NotificationEventType::Close );260 dataStore->networkProcess().processNotificationEvent(notification->data(), NotificationEventType::Close, [](bool) { }); 261 261 else 262 262 RELEASE_LOG_ERROR(Notifications, "WebsiteDataStore not found from sessionID %" PRIu64 ", dropping notification close", notification->sessionID().toUInt64()); -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r293266 r293296 1038 1038 518E8EF916B2091C00E91429 /* AuthenticationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 518E8EF416B2091C00E91429 /* AuthenticationManager.h */; }; 1039 1039 51933DEF1965EB31008AC3EA /* MenuUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 51933DEB1965EB24008AC3EA /* MenuUtilities.h */; }; 1040 519DFBE7281387C1003FF6AD /* WKNotificationPrivateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 519DFBE528138756003FF6AD /* WKNotificationPrivateMac.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1040 1041 51A555F6128C6C47009ABCEC /* WKContextMenuItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A555F4128C6C47009ABCEC /* WKContextMenuItem.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1041 1042 51A55601128C6D92009ABCEC /* WKContextMenuItemTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A55600128C6D92009ABCEC /* WKContextMenuItemTypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4857 4858 51933DEC1965EB24008AC3EA /* MenuUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MenuUtilities.mm; sourceTree = "<group>"; }; 4858 4859 5194B3861F192FB900FA4708 /* CookieStorageUtilsCF.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CookieStorageUtilsCF.h; sourceTree = "<group>"; }; 4860 519DFBE528138756003FF6AD /* WKNotificationPrivateMac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKNotificationPrivateMac.h; path = mac/WKNotificationPrivateMac.h; sourceTree = "<group>"; }; 4861 519DFBE628138756003FF6AD /* WKNotificationPrivateMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKNotificationPrivateMac.mm; path = mac/WKNotificationPrivateMac.mm; sourceTree = "<group>"; }; 4859 4862 51A555F3128C6C47009ABCEC /* WKContextMenuItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKContextMenuItem.cpp; sourceTree = "<group>"; }; 4860 4863 51A555F4128C6C47009ABCEC /* WKContextMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContextMenuItem.h; sourceTree = "<group>"; }; … … 10978 10981 9FB5F392169E6A80002C25BF /* WKContextPrivateMac.mm */, 10979 10982 6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */, 10983 519DFBE528138756003FF6AD /* WKNotificationPrivateMac.h */, 10984 519DFBE628138756003FF6AD /* WKNotificationPrivateMac.mm */, 10980 10985 BCE17B7C1381F1170012A641 /* WKPagePrivateMac.h */, 10981 10986 BCE17B7B1381F1170012A641 /* WKPagePrivateMac.mm */, … … 14822 14827 DDA0A2B527E55E4E005E086E /* WebFormDelegate.h in Headers */, 14823 14828 DDA0A30127E55E4E005E086E /* WebFormDelegatePrivate.h in Headers */, 14829 519DFBE7281387C1003FF6AD /* WKNotificationPrivateMac.h in Headers */, 14824 14830 BCE469561214E6CB000B98EB /* WebFormSubmissionListenerProxy.h in Headers */, 14825 14831 E5227D8427A11261008EAB57 /* WebFoundTextRange.h in Headers */, -
trunk/Tools/ChangeLog
r293294 r293296 1 2022-04-23 Brady Eidson <beidson@apple.com> 2 3 Add WKNotification and WKWebsiteDataStore SPI for handling click/close of persistent notifications 4 https://bugs.webkit.org/show_bug.cgi 5 6 Reviewed by Chris Dumez. 7 8 Teach WKTR to use the new SPI by keeping a set of notifications that are persistent. 9 10 * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: 11 12 * WebKitTestRunner/WebNotificationProvider.cpp: 13 (WTR::WebNotificationProvider::showWebNotification): 14 (WTR::WebNotificationProvider::closeWebNotification): 15 (WTR::WebNotificationProvider::reset): 16 * WebKitTestRunner/WebNotificationProvider.h: 17 18 * WebKitTestRunner/cocoa/WebNotificationProviderCocoa.mm: 19 (WTR::WebNotificationProvider::simulateWebNotificationClickForServiceWorkerNotifications): 20 1 21 2022-04-23 Elliott Williams <emw@apple.com> 2 22 -
trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
r292959 r293296 106 106 51058AD51D678820009A538C /* libWebCoreTestSupport.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 41230E16138C78BF00BCCFCA /* libWebCoreTestSupport.dylib */; }; 107 107 51058AD61D678825009A538C /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5169CA1445222D00E0A9D7 /* WebKit.framework */; }; 108 51998A082810FBD1009D68EB /* WebNotificationProviderCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51998A072810FBD1009D68EB /* WebNotificationProviderCocoa.mm */; }; 108 109 5641E2D014335E95008307E5 /* JSTextInputController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5641E2CE14335E95008307E5 /* JSTextInputController.cpp */; }; 109 110 5664A49A14326384008881BE /* TextInputController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5664A49814326384008881BE /* TextInputController.cpp */; }; … … 331 332 49AEEF692407278200C87E4C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 332 333 510E2F3827741F8300809333 /* DataFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataFunctions.h; sourceTree = "<group>"; }; 334 51998A072810FBD1009D68EB /* WebNotificationProviderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNotificationProviderCocoa.mm; sourceTree = "<group>"; }; 333 335 5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CyclicRedundancyCheck.cpp; sourceTree = "<group>"; }; 334 336 5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CyclicRedundancyCheck.h; sourceTree = "<group>"; }; … … 646 648 2D058E0822E2EE2200E4C145 /* UIScriptControllerCocoa.h */, 647 649 F46240AF2170128300917B16 /* UIScriptControllerCocoa.mm */, 650 51998A072810FBD1009D68EB /* WebNotificationProviderCocoa.mm */, 648 651 ); 649 652 path = cocoa; … … 1282 1285 0F18E6E51D6B9B9E0027E547 /* UIScriptContext.cpp in Sources */, 1283 1286 F46240B1217013E500917B16 /* UIScriptControllerCocoa.mm in Sources */, 1287 51998A082810FBD1009D68EB /* WebNotificationProviderCocoa.mm in Sources */, 1284 1288 277CCEDD250F300A0050C572 /* UIScriptControllerCommon.cpp in Sources */, 1285 1289 0F73B55C1BA89042004B3EF4 /* UIScriptControllerIOS.mm in Sources */, -
trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp
r289721 r293296 99 99 void WebNotificationProvider::showWebNotification(WKPageRef page, WKNotificationRef notification) 100 100 { 101 if (WKNotificationGetIsPersistent(notification)) 102 m_knownPersistentNotifications.add(notification); 103 101 104 auto notificationManager = notificationManagerForPage(page); 102 105 ASSERT(m_knownManagers.contains(notificationManager)); … … 113 116 void WebNotificationProvider::closeWebNotification(WKNotificationRef notification) 114 117 { 118 if (WKNotificationGetIsPersistent(notification)) 119 m_knownPersistentNotifications.remove(notification); 120 115 121 auto identifier = adoptWK(WKNotificationCopyCoreIDForTesting(notification)); 116 122 … … 172 178 } 173 179 180 #if !PLATFORM(COCOA) 174 181 void WebNotificationProvider::simulateWebNotificationClickForServiceWorkerNotifications() 175 182 { … … 181 188 } 182 189 } 190 #endif 183 191 184 192 void WebNotificationProvider::reset() … … 190 198 } 191 199 200 m_knownPersistentNotifications.clear(); 192 201 m_owningManager.clear(); 193 202 m_permissions = adoptWK(WKMutableDictionaryCreate()); -
trunk/Tools/WebKitTestRunner/WebNotificationProvider.h
r289721 r293296 60 60 HashMap<UUID, WKNotificationManagerRef> m_owningManager; 61 61 WKRetainPtr<WKMutableDictionaryRef> m_permissions; 62 63 HashSet<WKRetainPtr<WKNotificationRef>> m_knownPersistentNotifications; 62 64 }; 63 65 -
trunk/Tools/WebKitTestRunner/cocoa/WebNotificationProviderCocoa.mm
r293295 r293296 1 1 /* 2 * Copyright (C) 20 14Apple Inc. All rights reserved.2 * Copyright (C) 2022 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #import "_WKDownload.h" 26 #import "config.h" 27 #import "WebNotificationProvider.h" 27 28 29 #import "TestController.h" 30 #import <WebKit/WKNotificationPrivateMac.h> 31 #import <WebKit/WKWebsiteDataStorePrivate.h> 28 32 #import <wtf/RetainPtr.h> 29 33 30 @class WKDownload; 34 namespace WTR { 31 35 32 @interface _WKDownload () <WKObject> { 33 @package 34 RetainPtr<WKDownload> _download; 36 void WebNotificationProvider::simulateWebNotificationClickForServiceWorkerNotifications() 37 { 38 for (auto& notification : m_knownPersistentNotifications) { 39 auto dictionaryRepresentation = adoptNS(WKNotificationCopyDictionaryRepresentation(notification.get())); 40 [(__bridge WKWebsiteDataStore *)TestController::defaultWebsiteDataStore() _processPersistentNotificationClick:dictionaryRepresentation.get() completionHandler:^(bool) { }]; 41 } 35 42 } 36 @end 43 44 } // namespace WTR
Note:
See TracChangeset
for help on using the changeset viewer.