⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286613 in webkit


Ignore:
Timestamp:
Dec 7, 2021, 1:19:34 PM (5 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r286273. rdar://problem/86052131

Make webpushd "fake registration for testing" much more complicated by adding a "mock app bundle" install
https://bugs.webkit.org/show_bug.cgi?id=233454

Reviewed by Alex Christensen.

Covered by API tests.

Before this patch, webpushd remembered "registrations" using a simple in-memory HashMap.

In the near future, registrations will actually be represented with a placeholder app bundle on disk.

The process of installing placeholders (and checking for existing ones) is complicated and asynchronous.

This patch shifts the in-memory testing implementation from a simple HashMap to a "complicated and asynchronous"
registration mechanism that simulates how app-bundle installs will work.

Once the "real" mechanisms are in place there will be much more in-depth testing that we can do.
For now, this is a "no behavior change" patch.

  • NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm: (WebKit::WebPushD::Connection::connectionReceivedEvent const):
  • UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
  • WebKit.xcodeproj/project.pbxproj:

"PushAppBundle" is an abstract base class for representing a placeholder application bundle for a registration.
Eventually there will be a native one for each platform that actually does system operations.
For now, the concrete implementation is the in-memory "Mock" app bundle.

  • webpushd/PushAppBundle.h: Copied from Source/WebKit/webpushd/PushClientConnection.h.
  • webpushd/PushAppBundle.mm: Copied from Source/WebKit/webpushd/PushClientConnection.h. (WebPushD::PushAppBundleClient::~PushAppBundleClient): (WebPushD::PushAppBundle::PushAppBundle): (WebPushD::PushAppBundle::~PushAppBundle): (WebPushD::PushAppBundle::detachFromClient):

An "AppBundleRequest" is a queable operation meant to do something with an "App bundle".
For now the operations are "create" and "delete"

  • webpushd/AppBundleRequest.h: Added. (WebPushD::AppBundleRequestImpl::AppBundleRequestImpl): (WebPushD::AppBundleRequestImpl::~AppBundleRequestImpl): (WebPushD::AppBundleRequestImpl::callCompletionHandlerAndCleanup): (WebPushD::AppBundlePermissionsRequest::AppBundlePermissionsRequest): (WebPushD::AppBundleDeletionRequest::AppBundleDeletionRequest):
  • webpushd/AppBundleRequest.mm: Added. (WebPushD::AppBundleRequest::AppBundleRequest): (WebPushD::AppBundleRequest::~AppBundleRequest): (WebPushD::AppBundleRequest::start): (WebPushD::AppBundleRequest::cancel): (WebPushD::AppBundleRequest::cleanupAfterCompletionHandler): (WebPushD::AppBundlePermissionsRequest::startInternal): (WebPushD::AppBundlePermissionsRequest::didCheckForExistingBundle): (WebPushD::AppBundlePermissionsRequest::didCreateAppBundle): (WebPushD::AppBundleDeletionRequest::startInternal): (WebPushD::AppBundleDeletionRequest::didDeleteExistingBundleWithError):
  • webpushd/MockAppBundleForTesting.h: Copied from Source/WebKit/webpushd/PushClientConnection.h. (WebPushD::MockAppBundleForTesting::create):
  • webpushd/MockAppBundleForTesting.mm: Added. (WebPushD::MockAppBundleForTesting::MockAppBundleForTesting): (WebPushD::MockAppBundleForTesting::~MockAppBundleForTesting): (WebPushD::MockAppBundleForTesting::checkForExistingBundle): (WebPushD::MockAppBundleForTesting::deleteExistingBundle): (WebPushD::MockAppBundleForTesting::createBundle): (WebPushD::MockAppBundleForTesting::stop):
  • webpushd/MockAppBundleRegistry.h: Copied from Source/WebKit/webpushd/PushClientConnection.h.
  • webpushd/MockAppBundleRegistry.mm: Added. (WebPushD::MockAppBundleRegistry::singleton): (WebPushD::MockAppBundleRegistry::getOriginsWithRegistrations): (WebPushD::MockAppBundleRegistry::doesBundleExist): (WebPushD::MockAppBundleRegistry::createBundle): (WebPushD::MockAppBundleRegistry::deleteBundle):
  • webpushd/PushClientConnection.h:
  • webpushd/PushClientConnection.mm: (WebPushD::ClientConnection::create): (WebPushD::ClientConnection::enqueueAppBundleRequest): (WebPushD::ClientConnection::maybeStartNextAppBundleRequest): (WebPushD::ClientConnection::didCompleteAppBundleRequest): (WebPushD::ClientConnection::connectionClosed):
  • webpushd/WebPushDaemon.h:
  • webpushd/WebPushDaemon.mm: (WebPushD::Daemon::connectionAdded): (WebPushD::Daemon::connectionRemoved): (WebPushD::Daemon::requestSystemNotificationPermission): (WebPushD::Daemon::getOriginsWithPushAndNotificationPermissions): (WebPushD::Daemon::deletePushAndNotificationRegistration):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286273 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-613.1.10-branch
Files:
4 added
9 edited
4 copied

Legend:

Unmodified
Added
Removed
  • branches/safari-613.1.10-branch/Source/WebKit/ChangeLog

    r286436 r286613  
     12021-12-06  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r286273. rdar://problem/86052131
     4
     5    Make webpushd "fake registration for testing" much more complicated by adding a "mock app bundle" install
     6    https://bugs.webkit.org/show_bug.cgi?id=233454
     7   
     8    Reviewed by Alex Christensen.
     9   
     10    Covered by API tests.
     11   
     12    Before this patch, webpushd remembered "registrations" using a simple in-memory HashMap.
     13   
     14    In the near future, registrations will actually be represented with a placeholder app bundle on disk.
     15   
     16    The process of installing placeholders (and checking for existing ones) is complicated and asynchronous.
     17   
     18    This patch shifts the in-memory testing implementation from a simple HashMap to a "complicated and asynchronous"
     19    registration mechanism that simulates how app-bundle installs will work.
     20   
     21    Once the "real" mechanisms are in place there will be much more in-depth testing that we can do.
     22    For now, this is a "no behavior change" patch.
     23   
     24    * NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm:
     25    (WebKit::WebPushD::Connection::connectionReceivedEvent const):
     26    * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
     27   
     28    * WebKit.xcodeproj/project.pbxproj:
     29   
     30    "PushAppBundle" is an abstract base class for representing a placeholder application bundle for a registration.
     31    Eventually there will be a native one for each platform that actually does system operations.
     32    For now, the concrete implementation is the in-memory "Mock" app bundle.
     33   
     34    * webpushd/PushAppBundle.h: Copied from Source/WebKit/webpushd/PushClientConnection.h.
     35    * webpushd/PushAppBundle.mm: Copied from Source/WebKit/webpushd/PushClientConnection.h.
     36    (WebPushD::PushAppBundleClient::~PushAppBundleClient):
     37    (WebPushD::PushAppBundle::PushAppBundle):
     38    (WebPushD::PushAppBundle::~PushAppBundle):
     39    (WebPushD::PushAppBundle::detachFromClient):
     40   
     41    An "AppBundleRequest" is a queable operation meant to do something with an "App bundle".
     42    For now the operations are "create" and "delete"
     43   
     44    * webpushd/AppBundleRequest.h: Added.
     45    (WebPushD::AppBundleRequestImpl::AppBundleRequestImpl):
     46    (WebPushD::AppBundleRequestImpl::~AppBundleRequestImpl):
     47    (WebPushD::AppBundleRequestImpl::callCompletionHandlerAndCleanup):
     48    (WebPushD::AppBundlePermissionsRequest::AppBundlePermissionsRequest):
     49    (WebPushD::AppBundleDeletionRequest::AppBundleDeletionRequest):
     50    * webpushd/AppBundleRequest.mm: Added.
     51    (WebPushD::AppBundleRequest::AppBundleRequest):
     52    (WebPushD::AppBundleRequest::~AppBundleRequest):
     53    (WebPushD::AppBundleRequest::start):
     54    (WebPushD::AppBundleRequest::cancel):
     55    (WebPushD::AppBundleRequest::cleanupAfterCompletionHandler):
     56    (WebPushD::AppBundlePermissionsRequest::startInternal):
     57    (WebPushD::AppBundlePermissionsRequest::didCheckForExistingBundle):
     58    (WebPushD::AppBundlePermissionsRequest::didCreateAppBundle):
     59    (WebPushD::AppBundleDeletionRequest::startInternal):
     60    (WebPushD::AppBundleDeletionRequest::didDeleteExistingBundleWithError):
     61   
     62    * webpushd/MockAppBundleForTesting.h: Copied from Source/WebKit/webpushd/PushClientConnection.h.
     63    (WebPushD::MockAppBundleForTesting::create):
     64    * webpushd/MockAppBundleForTesting.mm: Added.
     65    (WebPushD::MockAppBundleForTesting::MockAppBundleForTesting):
     66    (WebPushD::MockAppBundleForTesting::~MockAppBundleForTesting):
     67    (WebPushD::MockAppBundleForTesting::checkForExistingBundle):
     68    (WebPushD::MockAppBundleForTesting::deleteExistingBundle):
     69    (WebPushD::MockAppBundleForTesting::createBundle):
     70    (WebPushD::MockAppBundleForTesting::stop):
     71   
     72    * webpushd/MockAppBundleRegistry.h: Copied from Source/WebKit/webpushd/PushClientConnection.h.
     73    * webpushd/MockAppBundleRegistry.mm: Added.
     74    (WebPushD::MockAppBundleRegistry::singleton):
     75    (WebPushD::MockAppBundleRegistry::getOriginsWithRegistrations):
     76    (WebPushD::MockAppBundleRegistry::doesBundleExist):
     77    (WebPushD::MockAppBundleRegistry::createBundle):
     78    (WebPushD::MockAppBundleRegistry::deleteBundle):
     79   
     80    * webpushd/PushClientConnection.h:
     81    * webpushd/PushClientConnection.mm:
     82    (WebPushD::ClientConnection::create):
     83    (WebPushD::ClientConnection::enqueueAppBundleRequest):
     84    (WebPushD::ClientConnection::maybeStartNextAppBundleRequest):
     85    (WebPushD::ClientConnection::didCompleteAppBundleRequest):
     86    (WebPushD::ClientConnection::connectionClosed):
     87   
     88    * webpushd/WebPushDaemon.h:
     89    * webpushd/WebPushDaemon.mm:
     90    (WebPushD::Daemon::connectionAdded):
     91    (WebPushD::Daemon::connectionRemoved):
     92    (WebPushD::Daemon::requestSystemNotificationPermission):
     93    (WebPushD::Daemon::getOriginsWithPushAndNotificationPermissions):
     94    (WebPushD::Daemon::deletePushAndNotificationRegistration):
     95   
     96   
     97    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286273 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     98
     99    2021-11-29  Brady Eidson  <beidson@apple.com>
     100
     101            Make webpushd "fake registration for testing" much more complicated by adding a "mock app bundle" install
     102            https://bugs.webkit.org/show_bug.cgi?id=233454
     103
     104            Reviewed by Alex Christensen.
     105
     106            Covered by API tests.
     107
     108            Before this patch, webpushd remembered "registrations" using a simple in-memory HashMap.
     109
     110            In the near future, registrations will actually be represented with a placeholder app bundle on disk.
     111
     112            The process of installing placeholders (and checking for existing ones) is complicated and asynchronous.
     113
     114            This patch shifts the in-memory testing implementation from a simple HashMap to a "complicated and asynchronous"
     115            registration mechanism that simulates how app-bundle installs will work.
     116
     117            Once the "real" mechanisms are in place there will be much more in-depth testing that we can do.
     118            For now, this is a "no behavior change" patch.
     119
     120            * NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm:
     121            (WebKit::WebPushD::Connection::connectionReceivedEvent const):
     122            * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
     123
     124            * WebKit.xcodeproj/project.pbxproj:
     125
     126            "PushAppBundle" is an abstract base class for representing a placeholder application bundle for a registration.
     127            Eventually there will be a native one for each platform that actually does system operations.
     128            For now, the concrete implementation is the in-memory "Mock" app bundle.
     129
     130            * webpushd/PushAppBundle.h: Copied from Source/WebKit/webpushd/PushClientConnection.h.
     131            * webpushd/PushAppBundle.mm: Copied from Source/WebKit/webpushd/PushClientConnection.h.
     132            (WebPushD::PushAppBundleClient::~PushAppBundleClient):
     133            (WebPushD::PushAppBundle::PushAppBundle):
     134            (WebPushD::PushAppBundle::~PushAppBundle):
     135            (WebPushD::PushAppBundle::detachFromClient):
     136
     137            An "AppBundleRequest" is a queable operation meant to do something with an "App bundle".
     138            For now the operations are "create" and "delete"
     139
     140            * webpushd/AppBundleRequest.h: Added.
     141            (WebPushD::AppBundleRequestImpl::AppBundleRequestImpl):
     142            (WebPushD::AppBundleRequestImpl::~AppBundleRequestImpl):
     143            (WebPushD::AppBundleRequestImpl::callCompletionHandlerAndCleanup):
     144            (WebPushD::AppBundlePermissionsRequest::AppBundlePermissionsRequest):
     145            (WebPushD::AppBundleDeletionRequest::AppBundleDeletionRequest):
     146            * webpushd/AppBundleRequest.mm: Added.
     147            (WebPushD::AppBundleRequest::AppBundleRequest):
     148            (WebPushD::AppBundleRequest::~AppBundleRequest):
     149            (WebPushD::AppBundleRequest::start):
     150            (WebPushD::AppBundleRequest::cancel):
     151            (WebPushD::AppBundleRequest::cleanupAfterCompletionHandler):
     152            (WebPushD::AppBundlePermissionsRequest::startInternal):
     153            (WebPushD::AppBundlePermissionsRequest::didCheckForExistingBundle):
     154            (WebPushD::AppBundlePermissionsRequest::didCreateAppBundle):
     155            (WebPushD::AppBundleDeletionRequest::startInternal):
     156            (WebPushD::AppBundleDeletionRequest::didDeleteExistingBundleWithError):
     157
     158            * webpushd/MockAppBundleForTesting.h: Copied from Source/WebKit/webpushd/PushClientConnection.h.
     159            (WebPushD::MockAppBundleForTesting::create):
     160            * webpushd/MockAppBundleForTesting.mm: Added.
     161            (WebPushD::MockAppBundleForTesting::MockAppBundleForTesting):
     162            (WebPushD::MockAppBundleForTesting::~MockAppBundleForTesting):
     163            (WebPushD::MockAppBundleForTesting::checkForExistingBundle):
     164            (WebPushD::MockAppBundleForTesting::deleteExistingBundle):
     165            (WebPushD::MockAppBundleForTesting::createBundle):
     166            (WebPushD::MockAppBundleForTesting::stop):
     167
     168            * webpushd/MockAppBundleRegistry.h: Copied from Source/WebKit/webpushd/PushClientConnection.h.
     169            * webpushd/MockAppBundleRegistry.mm: Added.
     170            (WebPushD::MockAppBundleRegistry::singleton):
     171            (WebPushD::MockAppBundleRegistry::getOriginsWithRegistrations):
     172            (WebPushD::MockAppBundleRegistry::doesBundleExist):
     173            (WebPushD::MockAppBundleRegistry::createBundle):
     174            (WebPushD::MockAppBundleRegistry::deleteBundle):
     175
     176            * webpushd/PushClientConnection.h:
     177            * webpushd/PushClientConnection.mm:
     178            (WebPushD::ClientConnection::create):
     179            (WebPushD::ClientConnection::enqueueAppBundleRequest):
     180            (WebPushD::ClientConnection::maybeStartNextAppBundleRequest):
     181            (WebPushD::ClientConnection::didCompleteAppBundleRequest):
     182            (WebPushD::ClientConnection::connectionClosed):
     183
     184            * webpushd/WebPushDaemon.h:
     185            * webpushd/WebPushDaemon.mm:
     186            (WebPushD::Daemon::connectionAdded):
     187            (WebPushD::Daemon::connectionRemoved):
     188            (WebPushD::Daemon::requestSystemNotificationPermission):
     189            (WebPushD::Daemon::getOriginsWithPushAndNotificationPermissions):
     190            (WebPushD::Daemon::deletePushAndNotificationRegistration):
     191
    11922021-12-02  Russell Epstein  <repstein@apple.com>
    2193
  • branches/safari-613.1.10-branch/Source/WebKit/NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm

    r284887 r286613  
    6262        return;
    6363    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));
    6565}
    6666
  • branches/safari-613.1.10-branch/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r285799 r286613  
    160160
    161161- (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));
    163163
    164164#if TARGET_OS_IPHONE
  • branches/safari-613.1.10-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r286407 r286613  
    10051005                515BE1B31D5902DD00DD7C68 /* GamepadData.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE1B01D59006900DD7C68 /* GamepadData.h */; };
    10061006                515BE1B51D5917FF00DD7C68 /* UIGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE1AD1D555C5100DD7C68 /* UIGamepad.h */; };
     1007                5160E955274B887200567388 /* AppBundleRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160E953274B887100567388 /* AppBundleRequest.mm */; };
     1008                5160E956274B887200567388 /* AppBundleRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 5160E954274B887100567388 /* AppBundleRequest.h */; };
     1009                5160E959274C0D8900567388 /* PushAppBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = 5160E957274C0D8800567388 /* PushAppBundle.h */; };
     1010                5160E95A274C0D8900567388 /* PushAppBundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160E958274C0D8800567388 /* PushAppBundle.mm */; };
     1011                5160E95E274C2A0300567388 /* MockAppBundleRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 5160E95C274C2A0300567388 /* MockAppBundleRegistry.h */; };
     1012                5160E960274C2A4000567388 /* MockAppBundleRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160E95F274C2A3F00567388 /* MockAppBundleRegistry.mm */; };
    10071013                5163199416289A6000E22F00 /* NetworkProcessMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51ACC9341628064800342550 /* NetworkProcessMessageReceiver.cpp */; };
    10081014                5163199516289A6300E22F00 /* NetworkProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51ACC9351628064800342550 /* NetworkProcessMessages.h */; };
     
    10561062                51F060E11654318500F3282F /* WebMDNSRegisterMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3282F /* WebMDNSRegisterMessageReceiver.cpp */; };
    10571063                51F060E11654318500F3283F /* NetworkMDNSRegisterMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F060DD1654317500F3283F /* NetworkMDNSRegisterMessageReceiver.cpp */; };
     1064                51F7BB76274498BB00C45A72 /* MockAppBundleForTesting.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51F7BB74274498BA00C45A72 /* MockAppBundleForTesting.mm */; };
     1065                51F7BB77274498BB00C45A72 /* MockAppBundleForTesting.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F7BB75274498BB00C45A72 /* MockAppBundleForTesting.h */; };
    10581066                51F7BB7B2744C50700C45A72 /* PushClientConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F7BB792744C50700C45A72 /* PushClientConnection.h */; };
    10591067                51F7BB7C2744C50700C45A72 /* PushClientConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51F7BB7A2744C50700C45A72 /* PushClientConnection.mm */; };
     
    42934301                515C415B207D74E100726E02 /* SuspendedPageProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SuspendedPageProxy.h; sourceTree = "<group>"; };
    42944302                5160BFE013381DF900918999 /* LoggingFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoggingFoundation.mm; sourceTree = "<group>"; };
     4303                5160E953274B887100567388 /* AppBundleRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppBundleRequest.mm; sourceTree = "<group>"; };
     4304                5160E954274B887100567388 /* AppBundleRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppBundleRequest.h; sourceTree = "<group>"; };
     4305                5160E957274C0D8800567388 /* PushAppBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PushAppBundle.h; sourceTree = "<group>"; };
     4306                5160E958274C0D8800567388 /* PushAppBundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PushAppBundle.mm; sourceTree = "<group>"; };
     4307                5160E95C274C2A0300567388 /* MockAppBundleRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockAppBundleRegistry.h; sourceTree = "<group>"; };
     4308                5160E95F274C2A3F00567388 /* MockAppBundleRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MockAppBundleRegistry.mm; sourceTree = "<group>"; };
    42954309                5164C0941B05B757004F102A /* AuxiliaryProcess.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AuxiliaryProcess.messages.in; sourceTree = "<group>"; };
    42964310                516A4A5B120A2CCD00C05B7F /* APIError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIError.h; sourceTree = "<group>"; };
     
    44004414                51F060DD1654317500F3283F /* NetworkMDNSRegisterMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkMDNSRegisterMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkMDNSRegisterMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
    44014415                51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebResourceLoaderMessages.h; path = DerivedSources/WebKit2/WebResourceLoaderMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
     4416                51F7BB74274498BA00C45A72 /* MockAppBundleForTesting.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MockAppBundleForTesting.mm; sourceTree = "<group>"; };
     4417                51F7BB75274498BB00C45A72 /* MockAppBundleForTesting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockAppBundleForTesting.h; sourceTree = "<group>"; };
    44024418                51F7BB792744C50700C45A72 /* PushClientConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PushClientConnection.h; sourceTree = "<group>"; };
    44034419                51F7BB7A2744C50700C45A72 /* PushClientConnection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PushClientConnection.mm; sourceTree = "<group>"; };
     
    97989814                        children = (
    97999815                                5CBB6D4D271F67CC00FD1A5D /* com.apple.webkit.webpushd.plist */,
     9816                                5160E954274B887100567388 /* AppBundleRequest.h */,
     9817                                5160E953274B887100567388 /* AppBundleRequest.mm */,
     9818                                51F7BB75274498BB00C45A72 /* MockAppBundleForTesting.h */,
     9819                                51F7BB74274498BA00C45A72 /* MockAppBundleForTesting.mm */,
     9820                                5160E95C274C2A0300567388 /* MockAppBundleRegistry.h */,
     9821                                5160E95F274C2A3F00567388 /* MockAppBundleRegistry.mm */,
     9822                                5160E957274C0D8800567388 /* PushAppBundle.h */,
     9823                                5160E958274C0D8800567388 /* PushAppBundle.mm */,
    98009824                                51F7BB792744C50700C45A72 /* PushClientConnection.h */,
    98019825                                51F7BB7A2744C50700C45A72 /* PushClientConnection.mm */,
     
    1233912363                        buildActionMask = 2147483647;
    1234012364                        files = (
     12365                                5160E959274C0D8900567388 /* PushAppBundle.h in Headers */,
     12366                                51F7BB7B2744C50700C45A72 /* PushClientConnection.h in Headers */,
     12367                                5160E95E274C2A0300567388 /* MockAppBundleRegistry.h in Headers */,
    1234112368                                5C1579FC2717AF5000ED5280 /* DaemonUtilities.h in Headers */,
    12342                                 51F7BB7B2744C50700C45A72 /* PushClientConnection.h in Headers */,
     12369                                5160E956274B887200567388 /* AppBundleRequest.h in Headers */,
    1234312370                                512CD69F2723393A00F7F8EC /* WebPushDaemon.h in Headers */,
     12371                                51F7BB77274498BB00C45A72 /* MockAppBundleForTesting.h in Headers */,
    1234412372                        );
    1234512373                        runOnlyForDeploymentPostprocessing = 0;
     
    1483014858                                51F7BB7D2745640400C45A72 /* CodeSigning.mm in Sources */,
    1483114859                                5C1579FF2717B6D200ED5280 /* DaemonDecoder.cpp in Sources */,
     14860                                51F7BB76274498BB00C45A72 /* MockAppBundleForTesting.mm in Sources */,
     14861                                5160E955274B887200567388 /* AppBundleRequest.mm in Sources */,
     14862                                5160E95A274C0D8900567388 /* PushAppBundle.mm in Sources */,
     14863                                5160E960274C2A4000567388 /* MockAppBundleRegistry.mm in Sources */,
     14864                                51F7BB7C2744C50700C45A72 /* PushClientConnection.mm in Sources */,
    1483214865                                5C1579FE2717B6C100ED5280 /* DaemonEncoder.cpp in Sources */,
    1483314866                                5C1579FB2717AF5000ED5280 /* DaemonUtilities.mm in Sources */,
    14834                                 51F7BB7C2744C50700C45A72 /* PushClientConnection.mm in Sources */,
    1483514867                                512CD6A02723393A00F7F8EC /* WebPushDaemon.mm in Sources */,
    1483614868                                5C157A0C2717CA1D00ED5280 /* WebPushDaemonMain.mm in Sources */,
  • branches/safari-613.1.10-branch/Source/WebKit/webpushd/MockAppBundleForTesting.h

    r286559 r286613  
    2626#pragma once
    2727
    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>
    3230#include <wtf/text/WTFString.h>
    3331
    3432namespace WebPushD {
    3533
    36 class ClientConnection {
     34class MockAppBundleForTesting : public PushAppBundle {
    3735    WTF_MAKE_FAST_ALLOCATED;
    3836public:
    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    }
    4041
    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;
    4943
    5044private:
    51     OSObjectPtr<xpc_connection_t> m_xpcConnection;
     45    MockAppBundleForTesting(const String& originString, const String& hostAppBundleIdentifier, PushAppBundleClient&);
    5246
    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;
    5651
    57     bool m_debugModeEnabled { false };
     52    String m_originString;
     53    String m_hostAppBundleIdentifier;
    5854};
    5955
     56
    6057} // namespace WebPushD
  • branches/safari-613.1.10-branch/Source/WebKit/webpushd/MockAppBundleRegistry.h

    r286559 r286613  
    2626#pragma once
    2727
    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>
    3231#include <wtf/text/WTFString.h>
    3332
    3433namespace WebPushD {
    3534
    36 class ClientConnection {
    37     WTF_MAKE_FAST_ALLOCATED;
     35class MockAppBundleForTesting;
     36
     37class MockAppBundleRegistry {
     38    friend class MockAppBundleForTesting;
    3839public:
    39     ClientConnection(xpc_connection_t);
     40    static MockAppBundleRegistry& singleton();
    4041
    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);
    4943
    5044private:
    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);
    5248
    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;
    5850};
    5951
  • branches/safari-613.1.10-branch/Source/WebKit/webpushd/PushAppBundle.h

    r286559 r286613  
    2626#pragma once
    2727
    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;
    3331
    3432namespace WebPushD {
    3533
    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 };
     34enum class PushAppBundleExists : bool {
     35    No,
     36    Yes,
    5837};
    5938
     39enum class PushAppBundleCreationResult : bool {
     40    Failure,
     41    Success,
     42};
     43
     44class PushAppBundle;
     45
     46class PushAppBundleClient {
     47public:
     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
     55class PushAppBundle : public RefCounted<PushAppBundle> {
     56public:
     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
     65protected:
     66    PushAppBundle(PushAppBundleClient&);
     67
     68    PushAppBundleClient* m_client;
     69};
     70
     71
    6072} // namespace WebPushD
  • branches/safari-613.1.10-branch/Source/WebKit/webpushd/PushAppBundle.mm

    r286559 r286613  
    2424 */
    2525
    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"
    3328
    3429namespace WebPushD {
    3530
    36 class ClientConnection {
    37     WTF_MAKE_FAST_ALLOCATED;
    38 public:
    39     ClientConnection(xpc_connection_t);
     31PushAppBundleClient::~PushAppBundleClient()
     32{
     33}
    4034
    41     bool hasHostAppAuditToken() const { return !!m_hostAppAuditToken; }
    42     void setHostAppAuditTokenData(const Vector<uint8_t>&);
     35PushAppBundle::PushAppBundle(PushAppBundleClient& client)
     36    : m_client(&client)
     37{
     38}
    4339
    44     const String& hostAppCodeSigningIdentifier();
    45     bool hostAppHasPushEntitlement();
     40PushAppBundle::~PushAppBundle()
     41{
     42    ASSERT(!m_client);
     43}
    4644
    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 };
     45void PushAppBundle::detachFromClient()
     46{
     47    stop();
     48    m_client = nullptr;
     49}
    5950
    6051} // namespace WebPushD
  • branches/safari-613.1.10-branch/Source/WebKit/webpushd/PushClientConnection.h

    r286075 r286613  
    2727
    2828#include <optional>
     29#include <wtf/Deque.h>
    2930#include <wtf/Forward.h>
    3031#include <wtf/OSObjectPtr.h>
     32#include <wtf/RefCounted.h>
     33#include <wtf/WeakPtr.h>
    3134#include <wtf/spi/darwin/XPCSPI.h>
    3235#include <wtf/text/WTFString.h>
     
    3437namespace WebPushD {
    3538
    36 class ClientConnection {
     39class AppBundleRequest;
     40
     41class ClientConnection : public RefCounted<ClientConnection>, public CanMakeWeakPtr<ClientConnection> {
    3742    WTF_MAKE_FAST_ALLOCATED;
    3843public:
    39     ClientConnection(xpc_connection_t);
     44    static Ref<ClientConnection> create(xpc_connection_t);
    4045
    4146    bool hasHostAppAuditToken() const { return !!m_hostAppAuditToken; }
     
    4853    void setDebugModeIsEnabled(bool);
    4954
     55    void enqueueAppBundleRequest(std::unique_ptr<AppBundleRequest>&&);
     56    void didCompleteAppBundleRequest(AppBundleRequest&);
     57
     58    void connectionClosed();
     59
    5060private:
     61    ClientConnection(xpc_connection_t);
     62
     63    void maybeStartNextAppBundleRequest();
     64   
    5165    OSObjectPtr<xpc_connection_t> m_xpcConnection;
    5266
     
    5569    std::optional<bool> m_hostAppHasPushEntitlement;
    5670
     71    Deque<std::unique_ptr<AppBundleRequest>> m_pendingBundleRequests;
     72    std::unique_ptr<AppBundleRequest> m_currentBundleRequest;
     73
    5774    bool m_debugModeEnabled { false };
    5875};
  • branches/safari-613.1.10-branch/Source/WebKit/webpushd/PushClientConnection.mm

    r286075 r286613  
    2727#import "PushClientConnection.h"
    2828
     29#import "AppBundleRequest.h"
    2930#import "CodeSigning.h"
    3031#import "WebPushDaemon.h"
     
    3435
    3536namespace WebPushD {
     37
     38Ref<ClientConnection> ClientConnection::create(xpc_connection_t connection)
     39{
     40    return adoptRef(*new ClientConnection(connection));
     41}
    3642
    3743ClientConnection::ClientConnection(xpc_connection_t connection)
     
    94100}
    95101
     102void ClientConnection::enqueueAppBundleRequest(std::unique_ptr<AppBundleRequest>&& request)
     103{
     104    RELEASE_ASSERT(m_xpcConnection);
     105    m_pendingBundleRequests.append(WTFMove(request));
     106    maybeStartNextAppBundleRequest();
     107}
     108
     109void 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
     120void 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
     131void 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
    96147} // namespace WebPushD
  • branches/safari-613.1.10-branch/Source/WebKit/webpushd/WebPushDaemon.h

    r286075 r286613  
    7272
    7373    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;
    7875};
    7976
  • branches/safari-613.1.10-branch/Source/WebKit/webpushd/WebPushDaemon.mm

    r286075 r286613  
    2727#import "WebPushDaemon.h"
    2828
     29#import "AppBundleRequest.h"
    2930#import "DaemonDecoder.h"
    3031#import "DaemonEncoder.h"
    3132#import "DaemonUtilities.h"
    3233#import "HandleMessage.h"
     34#import "MockAppBundleRegistry.h"
    3335#import "WebPushDaemonConstants.h"
    3436
     
    181183{
    182184    RELEASE_ASSERT(!m_connectionMap.contains(connection));
    183     m_connectionMap.set(connection, WTF::makeUnique<ClientConnection>(connection));
     185    m_connectionMap.set(connection, ClientConnection::create(connection));
    184186}
    185187
     
    187189{
    188190    RELEASE_ASSERT(m_connectionMap.contains(connection));
    189     m_connectionMap.remove(connection);
     191    auto clientConnection = m_connectionMap.take(connection);
     192    clientConnection->connectionClosed();
    190193}
    191194
     
    254257    }
    255258
    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)));
    260260}
    261261
     
    267267    }
    268268
    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()));
    272271}
    273272
     
    279278    }
    280279
    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)));
    287281}
    288282
  • branches/safari-613.1.10-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm

    r286075 r286613  
    159159
    160160// 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 >= 120000
     161#if PLATFORM(MAC) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 110000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000)
    162162TEST(WebPushD, DISABLED_BasicCommunication)
    163163#else
     
    256256
    257257// 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 >= 120000
     258#if PLATFORM(MAC) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 110000 || __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000)
    259259TEST(WebPushD, DISABLED_PermissionManagement)
    260260#else
Note: See TracChangeset for help on using the changeset viewer.