Changeset 286273 in webkit
- Timestamp:
- Nov 29, 2021, 4:20:57 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 9 edited
- 4 copied
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (modified) (1 diff)
-
Source/WebKit/WebKit.xcodeproj/project.pbxproj (modified) (7 diffs)
-
Source/WebKit/webpushd/AppBundleRequest.h (added)
-
Source/WebKit/webpushd/AppBundleRequest.mm (added)
-
Source/WebKit/webpushd/MockAppBundleForTesting.h (copied) (copied from trunk/Source/WebKit/webpushd/PushClientConnection.h ) (1 diff)
-
Source/WebKit/webpushd/MockAppBundleForTesting.mm (added)
-
Source/WebKit/webpushd/MockAppBundleRegistry.h (copied) (copied from trunk/Source/WebKit/webpushd/PushClientConnection.h ) (1 diff)
-
Source/WebKit/webpushd/MockAppBundleRegistry.mm (added)
-
Source/WebKit/webpushd/PushAppBundle.h (copied) (copied from trunk/Source/WebKit/webpushd/PushClientConnection.h ) (1 diff)
-
Source/WebKit/webpushd/PushAppBundle.mm (copied) (copied from trunk/Source/WebKit/webpushd/PushClientConnection.h ) (1 diff)
-
Source/WebKit/webpushd/PushClientConnection.h (modified) (4 diffs)
-
Source/WebKit/webpushd/PushClientConnection.mm (modified) (3 diffs)
-
Source/WebKit/webpushd/WebPushDaemon.h (modified) (1 diff)
-
Source/WebKit/webpushd/WebPushDaemon.mm (modified) (6 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r286272 r286273 1 2021-11-29 Brady Eidson <beidson@apple.com> 2 3 Make webpushd "fake registration for testing" much more complicated by adding a "mock app bundle" install 4 https://bugs.webkit.org/show_bug.cgi?id=233454 5 6 Reviewed by Alex Christensen. 7 8 Covered by API tests. 9 10 Before this patch, webpushd remembered "registrations" using a simple in-memory HashMap. 11 12 In the near future, registrations will actually be represented with a placeholder app bundle on disk. 13 14 The process of installing placeholders (and checking for existing ones) is complicated and asynchronous. 15 16 This patch shifts the in-memory testing implementation from a simple HashMap to a "complicated and asynchronous" 17 registration mechanism that simulates how app-bundle installs will work. 18 19 Once the "real" mechanisms are in place there will be much more in-depth testing that we can do. 20 For now, this is a "no behavior change" patch. 21 22 * NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm: 23 (WebKit::WebPushD::Connection::connectionReceivedEvent const): 24 * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: 25 26 * WebKit.xcodeproj/project.pbxproj: 27 28 "PushAppBundle" is an abstract base class for representing a placeholder application bundle for a registration. 29 Eventually there will be a native one for each platform that actually does system operations. 30 For now, the concrete implementation is the in-memory "Mock" app bundle. 31 32 * webpushd/PushAppBundle.h: Copied from Source/WebKit/webpushd/PushClientConnection.h. 33 * webpushd/PushAppBundle.mm: Copied from Source/WebKit/webpushd/PushClientConnection.h. 34 (WebPushD::PushAppBundleClient::~PushAppBundleClient): 35 (WebPushD::PushAppBundle::PushAppBundle): 36 (WebPushD::PushAppBundle::~PushAppBundle): 37 (WebPushD::PushAppBundle::detachFromClient): 38 39 An "AppBundleRequest" is a queable operation meant to do something with an "App bundle". 40 For now the operations are "create" and "delete" 41 42 * webpushd/AppBundleRequest.h: Added. 43 (WebPushD::AppBundleRequestImpl::AppBundleRequestImpl): 44 (WebPushD::AppBundleRequestImpl::~AppBundleRequestImpl): 45 (WebPushD::AppBundleRequestImpl::callCompletionHandlerAndCleanup): 46 (WebPushD::AppBundlePermissionsRequest::AppBundlePermissionsRequest): 47 (WebPushD::AppBundleDeletionRequest::AppBundleDeletionRequest): 48 * webpushd/AppBundleRequest.mm: Added. 49 (WebPushD::AppBundleRequest::AppBundleRequest): 50 (WebPushD::AppBundleRequest::~AppBundleRequest): 51 (WebPushD::AppBundleRequest::start): 52 (WebPushD::AppBundleRequest::cancel): 53 (WebPushD::AppBundleRequest::cleanupAfterCompletionHandler): 54 (WebPushD::AppBundlePermissionsRequest::startInternal): 55 (WebPushD::AppBundlePermissionsRequest::didCheckForExistingBundle): 56 (WebPushD::AppBundlePermissionsRequest::didCreateAppBundle): 57 (WebPushD::AppBundleDeletionRequest::startInternal): 58 (WebPushD::AppBundleDeletionRequest::didDeleteExistingBundleWithError): 59 60 * webpushd/MockAppBundleForTesting.h: Copied from Source/WebKit/webpushd/PushClientConnection.h. 61 (WebPushD::MockAppBundleForTesting::create): 62 * webpushd/MockAppBundleForTesting.mm: Added. 63 (WebPushD::MockAppBundleForTesting::MockAppBundleForTesting): 64 (WebPushD::MockAppBundleForTesting::~MockAppBundleForTesting): 65 (WebPushD::MockAppBundleForTesting::checkForExistingBundle): 66 (WebPushD::MockAppBundleForTesting::deleteExistingBundle): 67 (WebPushD::MockAppBundleForTesting::createBundle): 68 (WebPushD::MockAppBundleForTesting::stop): 69 70 * webpushd/MockAppBundleRegistry.h: Copied from Source/WebKit/webpushd/PushClientConnection.h. 71 * webpushd/MockAppBundleRegistry.mm: Added. 72 (WebPushD::MockAppBundleRegistry::singleton): 73 (WebPushD::MockAppBundleRegistry::getOriginsWithRegistrations): 74 (WebPushD::MockAppBundleRegistry::doesBundleExist): 75 (WebPushD::MockAppBundleRegistry::createBundle): 76 (WebPushD::MockAppBundleRegistry::deleteBundle): 77 78 * webpushd/PushClientConnection.h: 79 * webpushd/PushClientConnection.mm: 80 (WebPushD::ClientConnection::create): 81 (WebPushD::ClientConnection::enqueueAppBundleRequest): 82 (WebPushD::ClientConnection::maybeStartNextAppBundleRequest): 83 (WebPushD::ClientConnection::didCompleteAppBundleRequest): 84 (WebPushD::ClientConnection::connectionClosed): 85 86 * webpushd/WebPushDaemon.h: 87 * webpushd/WebPushDaemon.mm: 88 (WebPushD::Daemon::connectionAdded): 89 (WebPushD::Daemon::connectionRemoved): 90 (WebPushD::Daemon::requestSystemNotificationPermission): 91 (WebPushD::Daemon::getOriginsWithPushAndNotificationPermissions): 92 (WebPushD::Daemon::deletePushAndNotificationRegistration): 93 1 94 2021-11-29 David Kilzer <ddkilzer@apple.com> 2 95 -
trunk/Source/WebKit/NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm
r284887 r286273 62 62 return; 63 63 auto messageLevel = static_cast<JSC::MessageLevel>(xpc_dictionary_get_uint64(request, protocolDebugMessageLevelKey)); 64 networkSession().networkProcess().broadcastConsoleMessage(networkSession().sessionID(), MessageSource:: PrivateClickMeasurement, messageLevel, String::fromUTF8(debugMessage));64 networkSession().networkProcess().broadcastConsoleMessage(networkSession().sessionID(), MessageSource::Other, messageLevel, String::fromUTF8(debugMessage)); 65 65 } 66 66 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
r285799 r286273 160 160 161 161 - (void)_webView:(WKWebView *)webView startXRSessionWithCompletionHandler:(void (^)(id))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0)); 162 - (void)_webView:(WKWebView *)webView requestNotificationPermissionForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(macos(10.13.4) );162 - (void)_webView:(WKWebView *)webView requestNotificationPermissionForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(macos(10.13.4), ios(WK_IOS_TBA)); 163 163 164 164 #if TARGET_OS_IPHONE -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r286258 r286273 1006 1006 515BE1B31D5902DD00DD7C68 /* GamepadData.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE1B01D59006900DD7C68 /* GamepadData.h */; }; 1007 1007 515BE1B51D5917FF00DD7C68 /* UIGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE1AD1D555C5100DD7C68 /* UIGamepad.h */; }; 1008 5160E955274B887200567388 /* AppBundleRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160E953274B887100567388 /* AppBundleRequest.mm */; }; 1009 5160E956274B887200567388 /* AppBundleRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 5160E954274B887100567388 /* AppBundleRequest.h */; }; 1010 5160E959274C0D8900567388 /* PushAppBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = 5160E957274C0D8800567388 /* PushAppBundle.h */; }; 1011 5160E95A274C0D8900567388 /* PushAppBundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160E958274C0D8800567388 /* PushAppBundle.mm */; }; 1012 5160E95E274C2A0300567388 /* MockAppBundleRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 5160E95C274C2A0300567388 /* MockAppBundleRegistry.h */; }; 1013 5160E960274C2A4000567388 /* MockAppBundleRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160E95F274C2A3F00567388 /* MockAppBundleRegistry.mm */; }; 1008 1014 5163199416289A6000E22F00 /* NetworkProcessMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51ACC9341628064800342550 /* NetworkProcessMessageReceiver.cpp */; }; 1009 1015 5163199516289A6300E22F00 /* NetworkProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ACC9351628064800342550 /* NetworkProcessMessages.h */; }; … … 1057 1063 51F060E11654318500F3282F /* WebMDNSRegisterMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3282F /* WebMDNSRegisterMessageReceiver.cpp */; }; 1058 1064 51F060E11654318500F3283F /* NetworkMDNSRegisterMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3283F /* NetworkMDNSRegisterMessageReceiver.cpp */; }; 1065 51F7BB76274498BB00C45A72 /* MockAppBundleForTesting.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51F7BB74274498BA00C45A72 /* MockAppBundleForTesting.mm */; }; 1066 51F7BB77274498BB00C45A72 /* MockAppBundleForTesting.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F7BB75274498BB00C45A72 /* MockAppBundleForTesting.h */; }; 1059 1067 51F7BB7B2744C50700C45A72 /* PushClientConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F7BB792744C50700C45A72 /* PushClientConnection.h */; }; 1060 1068 51F7BB7C2744C50700C45A72 /* PushClientConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51F7BB7A2744C50700C45A72 /* PushClientConnection.mm */; }; … … 4339 4347 515C415B207D74E100726E02 /* SuspendedPageProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuspendedPageProxy.h; sourceTree = "<group>"; }; 4340 4348 5160BFE013381DF900918999 /* LoggingFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingFoundation.mm; sourceTree = "<group>"; }; 4349 5160E953274B887100567388 /* AppBundleRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppBundleRequest.mm; sourceTree = "<group>"; }; 4350 5160E954274B887100567388 /* AppBundleRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppBundleRequest.h; sourceTree = "<group>"; }; 4351 5160E957274C0D8800567388 /* PushAppBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PushAppBundle.h; sourceTree = "<group>"; }; 4352 5160E958274C0D8800567388 /* PushAppBundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PushAppBundle.mm; sourceTree = "<group>"; }; 4353 5160E95C274C2A0300567388 /* MockAppBundleRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockAppBundleRegistry.h; sourceTree = "<group>"; }; 4354 5160E95F274C2A3F00567388 /* MockAppBundleRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MockAppBundleRegistry.mm; sourceTree = "<group>"; }; 4341 4355 5164C0941B05B757004F102A /* AuxiliaryProcess.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AuxiliaryProcess.messages.in; sourceTree = "<group>"; }; 4342 4356 516A4A5B120A2CCD00C05B7F /* APIError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIError.h; sourceTree = "<group>"; }; … … 4446 4460 51F060DD1654317500F3283F /* NetworkMDNSRegisterMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkMDNSRegisterMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkMDNSRegisterMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; 4447 4461 51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebResourceLoaderMessages.h; path = DerivedSources/WebKit2/WebResourceLoaderMessages.h; sourceTree = BUILT_PRODUCTS_DIR; }; 4462 51F7BB74274498BA00C45A72 /* MockAppBundleForTesting.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MockAppBundleForTesting.mm; sourceTree = "<group>"; }; 4463 51F7BB75274498BB00C45A72 /* MockAppBundleForTesting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockAppBundleForTesting.h; sourceTree = "<group>"; }; 4448 4464 51F7BB792744C50700C45A72 /* PushClientConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PushClientConnection.h; sourceTree = "<group>"; }; 4449 4465 51F7BB7A2744C50700C45A72 /* PushClientConnection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PushClientConnection.mm; sourceTree = "<group>"; }; … … 9859 9875 children = ( 9860 9876 5CBB6D4D271F67CC00FD1A5D /* com.apple.webkit.webpushd.plist */, 9877 5160E954274B887100567388 /* AppBundleRequest.h */, 9878 5160E953274B887100567388 /* AppBundleRequest.mm */, 9879 51F7BB75274498BB00C45A72 /* MockAppBundleForTesting.h */, 9880 51F7BB74274498BA00C45A72 /* MockAppBundleForTesting.mm */, 9881 5160E95C274C2A0300567388 /* MockAppBundleRegistry.h */, 9882 5160E95F274C2A3F00567388 /* MockAppBundleRegistry.mm */, 9883 5160E957274C0D8800567388 /* PushAppBundle.h */, 9884 5160E958274C0D8800567388 /* PushAppBundle.mm */, 9861 9885 51F7BB792744C50700C45A72 /* PushClientConnection.h */, 9862 9886 51F7BB7A2744C50700C45A72 /* PushClientConnection.mm */, … … 12400 12424 buildActionMask = 2147483647; 12401 12425 files = ( 12426 5160E959274C0D8900567388 /* PushAppBundle.h in Headers */, 12427 51F7BB7B2744C50700C45A72 /* PushClientConnection.h in Headers */, 12428 5160E95E274C2A0300567388 /* MockAppBundleRegistry.h in Headers */, 12402 12429 5C1579FC2717AF5000ED5280 /* DaemonUtilities.h in Headers */, 12403 51 F7BB7B2744C50700C45A72 /* PushClientConnection.h in Headers */,12430 5160E956274B887200567388 /* AppBundleRequest.h in Headers */, 12404 12431 512CD69F2723393A00F7F8EC /* WebPushDaemon.h in Headers */, 12432 51F7BB77274498BB00C45A72 /* MockAppBundleForTesting.h in Headers */, 12405 12433 ); 12406 12434 runOnlyForDeploymentPostprocessing = 0; … … 14939 14967 51F7BB7D2745640400C45A72 /* CodeSigning.mm in Sources */, 14940 14968 5C1579FF2717B6D200ED5280 /* DaemonDecoder.cpp in Sources */, 14969 51F7BB76274498BB00C45A72 /* MockAppBundleForTesting.mm in Sources */, 14970 5160E955274B887200567388 /* AppBundleRequest.mm in Sources */, 14971 5160E95A274C0D8900567388 /* PushAppBundle.mm in Sources */, 14972 5160E960274C2A4000567388 /* MockAppBundleRegistry.mm in Sources */, 14973 51F7BB7C2744C50700C45A72 /* PushClientConnection.mm in Sources */, 14941 14974 5C1579FE2717B6C100ED5280 /* DaemonEncoder.cpp in Sources */, 14942 14975 5C1579FB2717AF5000ED5280 /* DaemonUtilities.mm in Sources */, 14943 51F7BB7C2744C50700C45A72 /* PushClientConnection.mm in Sources */,14944 14976 512CD6A02723393A00F7F8EC /* WebPushDaemon.mm in Sources */, 14945 14977 5C157A0C2717CA1D00ED5280 /* WebPushDaemonMain.mm in Sources */, -
trunk/Source/WebKit/webpushd/MockAppBundleForTesting.h
r286272 r286273 26 26 #pragma once 27 27 28 #include <optional> 29 #include <wtf/Forward.h> 30 #include <wtf/OSObjectPtr.h> 31 #include <wtf/spi/darwin/XPCSPI.h> 28 #include "PushAppBundle.h" 29 #include <wtf/Vector.h> 32 30 #include <wtf/text/WTFString.h> 33 31 34 32 namespace WebPushD { 35 33 36 class ClientConnection{34 class MockAppBundleForTesting : public PushAppBundle { 37 35 WTF_MAKE_FAST_ALLOCATED; 38 36 public: 39 ClientConnection(xpc_connection_t); 37 static Ref<MockAppBundleForTesting> create(const String& originString, const String& hostAppBundleIdentifier, PushAppBundleClient& client) 38 { 39 return adoptRef(*new MockAppBundleForTesting(originString, hostAppBundleIdentifier, client)); 40 } 40 41 41 bool hasHostAppAuditToken() const { return !!m_hostAppAuditToken; } 42 void setHostAppAuditTokenData(const Vector<uint8_t>&); 43 44 const String& hostAppCodeSigningIdentifier(); 45 bool hostAppHasPushEntitlement(); 46 47 bool debugModeIsEnabled() const { return m_debugModeEnabled; } 48 void setDebugModeIsEnabled(bool); 42 ~MockAppBundleForTesting() final = default; 49 43 50 44 private: 51 OSObjectPtr<xpc_connection_t> m_xpcConnection;45 MockAppBundleForTesting(const String& originString, const String& hostAppBundleIdentifier, PushAppBundleClient&); 52 46 53 std::optional<audit_token_t> m_hostAppAuditToken; 54 std::optional<String> m_hostAppCodeSigningIdentifier; 55 std::optional<bool> m_hostAppHasPushEntitlement; 47 void checkForExistingBundle() final; 48 void deleteExistingBundle() final; 49 void createBundle() final; 50 void stop() final; 56 51 57 bool m_debugModeEnabled { false }; 52 String m_originString; 53 String m_hostAppBundleIdentifier; 58 54 }; 59 55 56 60 57 } // namespace WebPushD -
trunk/Source/WebKit/webpushd/MockAppBundleRegistry.h
r286272 r286273 26 26 #pragma once 27 27 28 #include <optional> 29 #include <wtf/Forward.h> 30 #include <wtf/OSObjectPtr.h> 31 #include <wtf/spi/darwin/XPCSPI.h> 28 #include <wtf/HashMap.h> 29 #include <wtf/HashSet.h> 30 #include <wtf/text/StringHash.h> 32 31 #include <wtf/text/WTFString.h> 33 32 34 33 namespace WebPushD { 35 34 36 class ClientConnection { 37 WTF_MAKE_FAST_ALLOCATED; 35 class MockAppBundleForTesting; 36 37 class MockAppBundleRegistry { 38 friend class MockAppBundleForTesting; 38 39 public: 39 ClientConnection(xpc_connection_t);40 static MockAppBundleRegistry& singleton(); 40 41 41 bool hasHostAppAuditToken() const { return !!m_hostAppAuditToken; } 42 void setHostAppAuditTokenData(const Vector<uint8_t>&); 43 44 const String& hostAppCodeSigningIdentifier(); 45 bool hostAppHasPushEntitlement(); 46 47 bool debugModeIsEnabled() const { return m_debugModeEnabled; } 48 void setDebugModeIsEnabled(bool); 42 Vector<String> getOriginsWithRegistrations(const String& hostAppBundleIdentifier); 49 43 50 44 private: 51 OSObjectPtr<xpc_connection_t> m_xpcConnection; 45 bool doesBundleExist(const String& hostAppBundleIdentifier, const String& originString); 46 void createBundle(const String& hostAppBundleIdentifier, const String& originString); 47 void deleteBundle(const String& hostAppBundleIdentifier, const String& originString); 52 48 53 std::optional<audit_token_t> m_hostAppAuditToken; 54 std::optional<String> m_hostAppCodeSigningIdentifier; 55 std::optional<bool> m_hostAppHasPushEntitlement; 56 57 bool m_debugModeEnabled { false }; 49 HashMap<String, HashSet<String>> m_registeredBundleMap; 58 50 }; 59 51 -
trunk/Source/WebKit/webpushd/PushAppBundle.h
r286272 r286273 26 26 #pragma once 27 27 28 #include <optional> 29 #include <wtf/Forward.h> 30 #include <wtf/OSObjectPtr.h> 31 #include <wtf/spi/darwin/XPCSPI.h> 32 #include <wtf/text/WTFString.h> 28 #include <wtf/RefCounted.h> 29 30 @class NSError; 33 31 34 32 namespace WebPushD { 35 33 36 class ClientConnection { 37 WTF_MAKE_FAST_ALLOCATED; 38 public: 39 ClientConnection(xpc_connection_t); 40 41 bool hasHostAppAuditToken() const { return !!m_hostAppAuditToken; } 42 void setHostAppAuditTokenData(const Vector<uint8_t>&); 43 44 const String& hostAppCodeSigningIdentifier(); 45 bool hostAppHasPushEntitlement(); 46 47 bool debugModeIsEnabled() const { return m_debugModeEnabled; } 48 void setDebugModeIsEnabled(bool); 49 50 private: 51 OSObjectPtr<xpc_connection_t> m_xpcConnection; 52 53 std::optional<audit_token_t> m_hostAppAuditToken; 54 std::optional<String> m_hostAppCodeSigningIdentifier; 55 std::optional<bool> m_hostAppHasPushEntitlement; 56 57 bool m_debugModeEnabled { false }; 34 enum class PushAppBundleExists : bool { 35 No, 36 Yes, 58 37 }; 59 38 39 enum class PushAppBundleCreationResult : bool { 40 Failure, 41 Success, 42 }; 43 44 class PushAppBundle; 45 46 class PushAppBundleClient { 47 public: 48 virtual ~PushAppBundleClient(); 49 50 virtual void didCheckForExistingBundle(PushAppBundle&, PushAppBundleExists) = 0; 51 virtual void didDeleteExistingBundleWithError(PushAppBundle&, NSError *) = 0; 52 virtual void didCreateAppBundle(PushAppBundle&, PushAppBundleCreationResult) = 0; 53 }; 54 55 class PushAppBundle : public RefCounted<PushAppBundle> { 56 public: 57 virtual ~PushAppBundle(); 58 void detachFromClient(); 59 60 virtual void checkForExistingBundle() = 0; 61 virtual void deleteExistingBundle() = 0; 62 virtual void createBundle() = 0; 63 virtual void stop() = 0; 64 65 protected: 66 PushAppBundle(PushAppBundleClient&); 67 68 PushAppBundleClient* m_client; 69 }; 70 71 60 72 } // namespace WebPushD -
trunk/Source/WebKit/webpushd/PushAppBundle.mm
r286272 r286273 24 24 */ 25 25 26 #pragma once 27 28 #include <optional> 29 #include <wtf/Forward.h> 30 #include <wtf/OSObjectPtr.h> 31 #include <wtf/spi/darwin/XPCSPI.h> 32 #include <wtf/text/WTFString.h> 26 #import "config.h" 27 #import "PushAppBundle.h" 33 28 34 29 namespace WebPushD { 35 30 36 class ClientConnection { 37 WTF_MAKE_FAST_ALLOCATED; 38 public: 39 ClientConnection(xpc_connection_t); 31 PushAppBundleClient::~PushAppBundleClient() 32 { 33 } 40 34 41 bool hasHostAppAuditToken() const { return !!m_hostAppAuditToken; } 42 void setHostAppAuditTokenData(const Vector<uint8_t>&); 35 PushAppBundle::PushAppBundle(PushAppBundleClient& client) 36 : m_client(&client) 37 { 38 } 43 39 44 const String& hostAppCodeSigningIdentifier(); 45 bool hostAppHasPushEntitlement(); 40 PushAppBundle::~PushAppBundle() 41 { 42 ASSERT(!m_client); 43 } 46 44 47 bool debugModeIsEnabled() const { return m_debugModeEnabled; } 48 void setDebugModeIsEnabled(bool); 49 50 private: 51 OSObjectPtr<xpc_connection_t> m_xpcConnection; 52 53 std::optional<audit_token_t> m_hostAppAuditToken; 54 std::optional<String> m_hostAppCodeSigningIdentifier; 55 std::optional<bool> m_hostAppHasPushEntitlement; 56 57 bool m_debugModeEnabled { false }; 58 }; 45 void PushAppBundle::detachFromClient() 46 { 47 stop(); 48 m_client = nullptr; 49 } 59 50 60 51 } // namespace WebPushD -
trunk/Source/WebKit/webpushd/PushClientConnection.h
r286075 r286273 27 27 28 28 #include <optional> 29 #include <wtf/Deque.h> 29 30 #include <wtf/Forward.h> 30 31 #include <wtf/OSObjectPtr.h> 32 #include <wtf/RefCounted.h> 33 #include <wtf/WeakPtr.h> 31 34 #include <wtf/spi/darwin/XPCSPI.h> 32 35 #include <wtf/text/WTFString.h> … … 34 37 namespace WebPushD { 35 38 36 class ClientConnection { 39 class AppBundleRequest; 40 41 class ClientConnection : public RefCounted<ClientConnection>, public CanMakeWeakPtr<ClientConnection> { 37 42 WTF_MAKE_FAST_ALLOCATED; 38 43 public: 39 ClientConnection(xpc_connection_t);44 static Ref<ClientConnection> create(xpc_connection_t); 40 45 41 46 bool hasHostAppAuditToken() const { return !!m_hostAppAuditToken; } … … 48 53 void setDebugModeIsEnabled(bool); 49 54 55 void enqueueAppBundleRequest(std::unique_ptr<AppBundleRequest>&&); 56 void didCompleteAppBundleRequest(AppBundleRequest&); 57 58 void connectionClosed(); 59 50 60 private: 61 ClientConnection(xpc_connection_t); 62 63 void maybeStartNextAppBundleRequest(); 64 51 65 OSObjectPtr<xpc_connection_t> m_xpcConnection; 52 66 … … 55 69 std::optional<bool> m_hostAppHasPushEntitlement; 56 70 71 Deque<std::unique_ptr<AppBundleRequest>> m_pendingBundleRequests; 72 std::unique_ptr<AppBundleRequest> m_currentBundleRequest; 73 57 74 bool m_debugModeEnabled { false }; 58 75 }; -
trunk/Source/WebKit/webpushd/PushClientConnection.mm
r286075 r286273 27 27 #import "PushClientConnection.h" 28 28 29 #import "AppBundleRequest.h" 29 30 #import "CodeSigning.h" 30 31 #import "WebPushDaemon.h" … … 34 35 35 36 namespace WebPushD { 37 38 Ref<ClientConnection> ClientConnection::create(xpc_connection_t connection) 39 { 40 return adoptRef(*new ClientConnection(connection)); 41 } 36 42 37 43 ClientConnection::ClientConnection(xpc_connection_t connection) … … 94 100 } 95 101 102 void ClientConnection::enqueueAppBundleRequest(std::unique_ptr<AppBundleRequest>&& request) 103 { 104 RELEASE_ASSERT(m_xpcConnection); 105 m_pendingBundleRequests.append(WTFMove(request)); 106 maybeStartNextAppBundleRequest(); 107 } 108 109 void ClientConnection::maybeStartNextAppBundleRequest() 110 { 111 RELEASE_ASSERT(m_xpcConnection); 112 113 if (m_currentBundleRequest || m_pendingBundleRequests.isEmpty()) 114 return; 115 116 m_currentBundleRequest = m_pendingBundleRequests.takeFirst(); 117 m_currentBundleRequest->start(); 118 } 119 120 void ClientConnection::didCompleteAppBundleRequest(AppBundleRequest& request) 121 { 122 // If our connection was closed there should be no in-progress bundle requests. 123 RELEASE_ASSERT(m_xpcConnection); 124 125 ASSERT(m_currentBundleRequest.get() == &request); 126 m_currentBundleRequest = nullptr; 127 128 maybeStartNextAppBundleRequest(); 129 } 130 131 void ClientConnection::connectionClosed() 132 { 133 RELEASE_ASSERT(m_xpcConnection); 134 m_xpcConnection = nullptr; 135 136 if (m_currentBundleRequest) { 137 m_currentBundleRequest->cancel(); 138 m_currentBundleRequest = nullptr; 139 } 140 141 Deque<std::unique_ptr<AppBundleRequest>> pendingBundleRequests; 142 pendingBundleRequests.swap(m_pendingBundleRequests); 143 for (auto& requst : pendingBundleRequests) 144 requst->cancel(); 145 } 146 96 147 } // namespace WebPushD -
trunk/Source/WebKit/webpushd/WebPushDaemon.h
r286075 r286273 72 72 73 73 ClientConnection* toClientConnection(xpc_connection_t); 74 75 HashSet<String> m_inMemoryOriginStringsWithPermissionForTesting; 76 77 HashMap<xpc_connection_t, std::unique_ptr<ClientConnection>> m_connectionMap; 74 HashMap<xpc_connection_t, Ref<ClientConnection>> m_connectionMap; 78 75 }; 79 76 -
trunk/Source/WebKit/webpushd/WebPushDaemon.mm
r286075 r286273 27 27 #import "WebPushDaemon.h" 28 28 29 #import "AppBundleRequest.h" 29 30 #import "DaemonDecoder.h" 30 31 #import "DaemonEncoder.h" 31 32 #import "DaemonUtilities.h" 32 33 #import "HandleMessage.h" 34 #import "MockAppBundleRegistry.h" 33 35 #import "WebPushDaemonConstants.h" 34 36 … … 181 183 { 182 184 RELEASE_ASSERT(!m_connectionMap.contains(connection)); 183 m_connectionMap.set(connection, WTF::makeUnique<ClientConnection>(connection));185 m_connectionMap.set(connection, ClientConnection::create(connection)); 184 186 } 185 187 … … 187 189 { 188 190 RELEASE_ASSERT(m_connectionMap.contains(connection)); 189 m_connectionMap.remove(connection); 191 auto clientConnection = m_connectionMap.take(connection); 192 clientConnection->connectionClosed(); 190 193 } 191 194 … … 254 257 } 255 258 256 // FIXME: This is for an API testing checkpoint 257 // Next step is actually perform a persistent permissions request on a per-platform basis 258 m_inMemoryOriginStringsWithPermissionForTesting.add(originString); 259 replySender(true); 259 connection->enqueueAppBundleRequest(makeUnique<AppBundlePermissionsRequest>(*connection, originString, WTFMove(replySender))); 260 260 } 261 261 … … 267 267 } 268 268 269 // FIXME: This is for an API testing checkpoint 270 // Next step is actually gather persistent permissions from the system on a per-platform basis 271 replySender(copyToVector(m_inMemoryOriginStringsWithPermissionForTesting)); 269 // FIXME: This will need platform-specific implementations for real world bundles once implemented. 270 replySender(MockAppBundleRegistry::singleton().getOriginsWithRegistrations(connection->hostAppCodeSigningIdentifier())); 272 271 } 273 272 … … 279 278 } 280 279 281 // FIXME: This is for an API testing checkpoint 282 // Next step is actually delete any persistent permissions on a per-platform basis 283 if (m_inMemoryOriginStringsWithPermissionForTesting.remove(originString)) 284 replySender(""); 285 else 286 replySender(makeString("Origin ", originString, " not registered for push or notifications")); 280 connection->enqueueAppBundleRequest(makeUnique<AppBundleDeletionRequest>(*connection, originString, WTFMove(replySender))); 287 281 } 288 282 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm
r286075 r286273 159 159 160 160 // FIXME: Re-enable this test for Monterey+ once webkit.org/232857 is resolved. 161 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 110000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000161 #if PLATFORM(MAC) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 110000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000) 162 162 TEST(WebPushD, DISABLED_BasicCommunication) 163 163 #else … … 256 256 257 257 // FIXME: Re-enable this test for Monterey+ once webkit.org/232857 is resolved. 258 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 110000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000258 #if PLATFORM(MAC) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 110000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000) 259 259 TEST(WebPushD, DISABLED_PermissionManagement) 260 260 #else
Note:
See TracChangeset
for help on using the changeset viewer.