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

Changeset 290146 in webkit


Ignore:
Timestamp:
Feb 18, 2022, 11:01:21 AM (5 years ago)
Author:
beidson@apple.com
Message:

Add an InstallCoordination webpushd backend
​https://bugs.webkit.org/show_bug.cgi?id=233714

Reviewed by Alex Christensen.

Source/WebCore/PAL:

Expose "toHexString" so we can SHA256 an arbitrary string to a hex representation.

  • pal/crypto/CryptoDigest.h:
  • pal/crypto/commoncrypto/CryptoDigestCommonCrypto.cpp:

(PAL::CryptoDigest::toHexString):

Source/WebKit:

Covered by API tests.

This patch lets the iOS build create a placeholder app bundle to represent a registration using InstallCoordination.

  • Configurations/webpushd.xcconfig:
  • WebKit.xcodeproj/project.pbxproj:
  • webpushd/AppBundleRequest.mm:

(WebPushD::AppBundleRequest::start): Use the ICAppBundle implementation when appropriate.

  • webpushd/ICAppBundle.h: Copied from Source/WebKit/webpushd/PushAppBundle.h.

(WebPushD::ICAppBundle::create):

  • webpushd/ICAppBundle.mm: Added.

(-[WebAppInstallCoordinatorObserver initWithICAppBundle:]):
(-[WebAppInstallCoordinatorObserver coordinatorDidCompleteSuccessfully:forApplicationRecord:]):
(-[WebAppInstallCoordinatorObserver coordinator:canceledWithReason:client:]):
(WebPushD::broadcastDebugMessage):
(WebPushD::ICAppBundle::ICAppBundle):
(WebPushD::encodeOriginStringForBundleIdentifier):
(WebPushD::originStringFromEncodedBundleIdentifier):
(WebPushD::bundlePrefixForHostAppIdentifier):
(WebPushD::bundleNameForOriginStringAndHostAppIdentifier):
(WebPushD::ICAppBundle::getOriginsWithRegistrations):
(WebPushD::ICAppBundle::getBundleIdentifier):
(WebPushD::ICAppBundle::checkForExistingBundle):
(WebPushD::ICAppBundle::deleteExistingBundle):
(WebPushD::ICAppBundle::didDeleteExistingBundleWithError):
(WebPushD::ICAppBundle::stop):
(WebPushD::ICAppBundle::createBundle):
(WebPushD::ICAppBundle::bundleCreationSucceeded):
(WebPushD::ICAppBundle::bundleCreationFailed):

  • webpushd/InstallCoordinationSPI.h: Added.
  • webpushd/LaunchServicesSPI.h: Copied from Source/WebKit/webpushd/PushAppBundle.h.
  • webpushd/PushAppBundle.h:
  • webpushd/WebPushDaemon.mm:

(WebPushD::Daemon::getOriginsWithPushAndNotificationPermissions): Use the ICAppBundle implementation when appropriate.

Source/WTF:

  • wtf/PlatformEnableCocoa.h:

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:

WebKitLibraries:

  • WebKitPrivateFrameworkStubs/iOS/15/InstallCoordination.framework/InstallCoordination.tbd: Added.
Location:
trunk
Files:
5 added
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r290111 r290146  
     12022-02-18  Brady Eidson  <beidson@apple.com>
     2
     3        Add an InstallCoordination webpushd backend
     4        https://bugs.webkit.org/show_bug.cgi?id=233714
     5
     6        Reviewed by Alex Christensen.
     7
     8        * wtf/PlatformEnableCocoa.h:
     9
    1102022-02-17  Matt Woodrow  <mattwoodrow@apple.com>
    211
  • trunk/Source/WTF/wtf/PlatformEnableCocoa.h

    r289894 r290146  
    144144#endif
    145145
     146#if !defined(ENABLE_INSTALL_COORDINATION_BUNDLES) && PLATFORM(IOS)
     147#define ENABLE_INSTALL_COORDINATION_BUNDLES 1
     148#endif
     149
    146150#if !defined(ENABLE_CACHE_PARTITIONING)
    147151#define ENABLE_CACHE_PARTITIONING 1
  • trunk/Source/WebCore/PAL/ChangeLog

    r290117 r290146  
     12022-02-18  Brady Eidson  <beidson@apple.com>
     2
     3        Add an InstallCoordination webpushd backend
     4        https://bugs.webkit.org/show_bug.cgi?id=233714
     5
     6        Reviewed by Alex Christensen.
     7
     8        Expose "toHexString" so we can SHA256 an arbitrary string to a hex representation.
     9
     10        * pal/crypto/CryptoDigest.h:
     11        * pal/crypto/commoncrypto/CryptoDigestCommonCrypto.cpp:
     12        (PAL::CryptoDigest::toHexString):
     13
    1142022-02-18  Saam Barati  <sbarati@apple.com>
    215
  • trunk/Source/WebCore/PAL/pal/crypto/CryptoDigest.h

    r218843 r290146  
    2828#include <wtf/Noncopyable.h>
    2929#include <wtf/Vector.h>
     30#include <wtf/text/WTFString.h>
    3031
    3132namespace PAL {
    … …  
    4849    PAL_EXPORT void addBytes(const void* input, size_t length);
    4950    PAL_EXPORT Vector<uint8_t> computeHash();
     51    PAL_EXPORT String toHexString();
    5052
    5153private:
  • trunk/Source/WebCore/PAL/pal/crypto/commoncrypto/CryptoDigestCommonCrypto.cpp

    r235935 r290146  
    183183}
    184184
     185String CryptoDigest::toHexString()
     186{
     187    auto hash = computeHash();
     188
     189    char* start = 0;
     190    unsigned hashLength = hash.size();
     191    CString result = CString::newUninitialized(hashLength * 2, start);
     192    char* buffer = start;
     193    for (size_t i = 0; i < hashLength; ++i) {
     194        snprintf(buffer, 3, "%02X", hash.at(i));
     195        buffer += 2;
     196    }
     197    return String::fromUTF8(result);
     198}
     199
    185200} // namespace PAL
  • trunk/Source/WebKit/ChangeLog

    r290144 r290146  
     12022-02-18  Brady Eidson  <beidson@apple.com>
     2
     3        Add an InstallCoordination webpushd backend
     4        https://bugs.webkit.org/show_bug.cgi?id=233714
     5
     6        Reviewed by Alex Christensen.
     7
     8        Covered by API tests.
     9       
     10        This patch lets the iOS build create a placeholder app bundle to represent a registration using InstallCoordination.
     11       
     12        * Configurations/webpushd.xcconfig:
     13        * WebKit.xcodeproj/project.pbxproj:
     14       
     15        * webpushd/AppBundleRequest.mm:
     16        (WebPushD::AppBundleRequest::start): Use the ICAppBundle implementation when appropriate.
     17       
     18        * webpushd/ICAppBundle.h: Copied from Source/WebKit/webpushd/PushAppBundle.h.
     19        (WebPushD::ICAppBundle::create):
     20       
     21        * webpushd/ICAppBundle.mm: Added.
     22        (-[WebAppInstallCoordinatorObserver initWithICAppBundle:]):
     23        (-[WebAppInstallCoordinatorObserver coordinatorDidCompleteSuccessfully:forApplicationRecord:]):
     24        (-[WebAppInstallCoordinatorObserver coordinator:canceledWithReason:client:]):
     25        (WebPushD::broadcastDebugMessage):
     26        (WebPushD::ICAppBundle::ICAppBundle):
     27        (WebPushD::encodeOriginStringForBundleIdentifier):
     28        (WebPushD::originStringFromEncodedBundleIdentifier):
     29        (WebPushD::bundlePrefixForHostAppIdentifier):
     30        (WebPushD::bundleNameForOriginStringAndHostAppIdentifier):
     31        (WebPushD::ICAppBundle::getOriginsWithRegistrations):
     32        (WebPushD::ICAppBundle::getBundleIdentifier):
     33        (WebPushD::ICAppBundle::checkForExistingBundle):
     34        (WebPushD::ICAppBundle::deleteExistingBundle):
     35        (WebPushD::ICAppBundle::didDeleteExistingBundleWithError):
     36        (WebPushD::ICAppBundle::stop):
     37        (WebPushD::ICAppBundle::createBundle):
     38        (WebPushD::ICAppBundle::bundleCreationSucceeded):
     39        (WebPushD::ICAppBundle::bundleCreationFailed):
     40       
     41        * webpushd/InstallCoordinationSPI.h: Added.
     42        * webpushd/LaunchServicesSPI.h: Copied from Source/WebKit/webpushd/PushAppBundle.h.
     43        * webpushd/PushAppBundle.h:
     44       
     45        * webpushd/WebPushDaemon.mm:
     46        (WebPushD::Daemon::getOriginsWithPushAndNotificationPermissions): Use the ICAppBundle implementation when appropriate.
     47
    1482022-02-18  Gavin Phillips  <gavin.p@apple.com>
    249
  • trunk/Source/WebKit/Configurations/WebKit.xcconfig

    r290117 r290146  
    153153WK_LIBNETWORKEXTENSION_LDFLAGS_tvos = ;
    154154
    155 FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -lnetwork -framework Metal $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_BACKBOARD_SERVICES_LDFLAGS) $(WK_RUNNINGBOARD_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CONTACTS_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBNETWORKEXTENSION_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_PROTOTYPE_TOOLS_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS) $(WK_COORDINATOR_LDFLAGS);
     155WK_INSTALL_COORDINATION_LDFLAGS = $(WK_INSTALL_COORDINATION_LDFLAGS_$(WK_PLATFORM_NAME));
     156WK_INSTALL_COORDINATION_LDFLAGS_iphoneos = -framework InstallCoordination;
     157WK_INSTALL_COORDINATION_LDFLAGS_iphonesimulator = $(WK_INSTALL_COORDINATION_LDFLAGS_iphoneos)
     158
     159FRAMEWORK_AND_LIBRARY_LDFLAGS = -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework IOSurface -framework WebKitLegacy -lnetwork -framework Metal $(WK_ACCESSIBILITY_LDFLAGS) $(WK_APPKIT_LDFLAGS) $(WK_BACKBOARD_SERVICES_LDFLAGS) $(WK_RUNNINGBOARD_SERVICES_LDFLAGS) $(WK_AUTHKIT_LDFLAGS) $(WK_CARBON_LDFLAGS) $(WK_CONTACTS_LDFLAGS) $(WK_CORE_PREDICTION_LDFLAGS) $(WK_CORE_SERVICES_LDFLAGS) $(WK_GRAPHICS_SERVICES_LDFLAGS) $(WK_LIBNETWORKEXTENSION_LDFLAGS) $(WK_LIBSANDBOX_LDFLAGS) $(WK_LIBWEBRTC_LDFLAGS) $(WK_MOBILE_CORE_SERVICES_LDFLAGS) $(WK_MOBILE_GESTALT_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_PROTOTYPE_TOOLS_LDFLAGS) $(WK_SAFE_BROWSING_LDFLAGS) $(WK_SECURITY_INTERFACE_LDFLAGS) $(WK_UIKIT_LDFLAGS) $(WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS) $(WK_URL_FORMATTING_LDFLAGS) $(WK_WEBINSPECTORUI_LDFLAGS) $(WK_COORDINATOR_LDFLAGS) $(WK_INSTALL_COORDINATION_LDFLAGS);
    156160
    157161// Prevent C++ standard library basic_stringstream, operator new, delete and their related exception types from being exported as weak symbols.
  • trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp

    r289721 r290146  
    7171void NetworkNotificationManager::requestSystemNotificationPermission(const String& originString, CompletionHandler<void(bool)>&& completionHandler)
    7272{
     73    LOG(Push, "Network process passing permission request to webpushd");
    7374    sendMessageWithReply<WebPushD::MessageType::RequestSystemNotificationPermission>(WTFMove(completionHandler), originString);
    7475}
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm

    r289694 r290146  
    668668            return;
    669669        checker->didCallCompletionHandler();
     670
    670671        completionHandler(result);
    671672    }).get()];
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r290030 r290146  
    10601060                51DD9F2916367DA2001578E9 /* NetworkConnectionToWebProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51DD9F2716367DA2001578E9 /* NetworkConnectionToWebProcessMessages.h */; };
    10611061                51E351CB180F2CCC00E53BE9 /* IDBUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E351C9180F2CCC00E53BE9 /* IDBUtilities.h */; };
     1062                51E9049527BCB3C900929E7E /* ICAppBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E9049327BCB3C600929E7E /* ICAppBundle.h */; };
     1063                51E9049727BCB3D900929E7E /* ICAppBundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E9049427BCB3C800929E7E /* ICAppBundle.mm */; };
     1064                51E9049A27BCB9D400929E7E /* LaunchServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E9049827BCB9D100929E7E /* LaunchServicesSPI.h */; };
     1065                51E9049B27BCB9D400929E7E /* LaunchServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E9049827BCB9D100929E7E /* LaunchServicesSPI.h */; };
     1066                51E9049C27BCB9D400929E7E /* InstallCoordinationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E9049927BCB9D300929E7E /* InstallCoordinationSPI.h */; };
     1067                51E9049D27BCB9D400929E7E /* InstallCoordinationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E9049927BCB9D300929E7E /* InstallCoordinationSPI.h */; };
    10621068                51EFC1CF1524E62500C9A938 /* WKBundleDOMWindowExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FA2D541521118600C1BA0B /* WKBundleDOMWindowExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10631069                51F060E01654317F00F3281B /* WebResourceLoaderMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */; };
    … …  
    45994605                51E399051D6F54C5009C8831 /* UIGamepadProviderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIGamepadProviderCocoa.mm; sourceTree = "<group>"; };
    46004606                51E8B68D1E712873001B7132 /* WebURLSchemeTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebURLSchemeTask.cpp; sourceTree = "<group>"; };
     4607                51E9049327BCB3C600929E7E /* ICAppBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ICAppBundle.h; sourceTree = "<group>"; };
     4608                51E9049427BCB3C800929E7E /* ICAppBundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ICAppBundle.mm; sourceTree = "<group>"; };
     4609                51E9049827BCB9D100929E7E /* LaunchServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LaunchServicesSPI.h; sourceTree = "<group>"; };
     4610                51E9049927BCB9D300929E7E /* InstallCoordinationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstallCoordinationSPI.h; sourceTree = "<group>"; };
    46014611                51E949961D761CC700EC9EB9 /* UIGamepadProviderIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIGamepadProviderIOS.mm; sourceTree = "<group>"; };
    46024612                51F060DD1654317500F3281B /* WebResourceLoaderMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WebResourceLoaderMessageReceiver.cpp; path = DerivedSources/WebKit/WebResourceLoaderMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
    … …  
    1021910229                                EB0D312E275AE13300863D8F /* com.apple.webkit.webpushd.ios.plist */,
    1022010230                                EB0D312D275AE13300863D8F /* com.apple.webkit.webpushd.mac.plist */,
     10231                                51E9049327BCB3C600929E7E /* ICAppBundle.h */,
     10232                                51E9049427BCB3C800929E7E /* ICAppBundle.mm */,
     10233                                51E9049927BCB9D300929E7E /* InstallCoordinationSPI.h */,
     10234                                51E9049827BCB9D100929E7E /* LaunchServicesSPI.h */,
    1022110235                                51F7BB75274498BB00C45A72 /* MockAppBundleForTesting.h */,
    1022210236                                51F7BB74274498BA00C45A72 /* MockAppBundleForTesting.mm */,
    … …  
    1282312837                        buildActionMask = 2147483647;
    1282412838                        files = (
     12839                                51E9049B27BCB9D400929E7E /* LaunchServicesSPI.h in Headers */,
     12840                                51E9049527BCB3C900929E7E /* ICAppBundle.h in Headers */,
     12841                                51E9049D27BCB9D400929E7E /* InstallCoordinationSPI.h in Headers */,
    1282512842                        );
    1282612843                        runOnlyForDeploymentPostprocessing = 0;
    … …  
    1335713374                                41DD72AB2682167300A90C71 /* NWSPI.h in Headers */,
    1335813375                                BC8ACA1316670D89004C1941 /* ObjCObjectGraph.h in Headers */,
     13376                                51E9049A27BCB9D400929E7E /* LaunchServicesSPI.h in Headers */,
    1335913377                                93085DCA26E29775000EC6A7 /* OriginStorageManager.h in Headers */,
    1336013378                                F4EB4AFD269CD7F300D297AE /* OSStateSPI.h in Headers */,
    … …  
    1357013588                                F48570A32644BEC500C05F71 /* Timeout.h in Headers */,
    1357113589                                2F8336861FA139DF00C6E080 /* TouchBarMenuData.h in Headers */,
     13590                                51E9049C27BCB9D400929E7E /* InstallCoordinationSPI.h in Headers */,
    1357213591                                46BEB6E322FBB21A00269867 /* TransientLocalStorageNamespace.h in Headers */,
    1357313592                                57EB2E3A21E1983E00B89CDF /* U2fAuthenticator.h in Headers */,
    … …  
    1565515674                                1DF29E64257F37A3003C28AF /* MediaSourcePrivateRemoteMessageReceiver.cpp in Sources */,
    1565615675                                9B4790912531563200EC11AB /* MessageArgumentDescriptions.cpp in Sources */,
     15676                                51E9049727BCB3D900929E7E /* ICAppBundle.mm in Sources */,
    1565715677                                517B5F84275E97B6002DC22D /* MockAppBundleForTesting.mm in Sources */,
    1565815678                                517B5F86275E97B6002DC22D /* MockAppBundleRegistry.mm in Sources */,
  • trunk/Source/WebKit/webpushd/AppBundleRequest.mm

    r287009 r290146  
    2727#import "AppBundleRequest.h"
    2828
     29#import "ICAppBundle.h"
    2930#import "MockAppBundleForTesting.h"
    3031#import "WebPushDaemon.h"
    … …  
    5556        m_appBundle = MockAppBundleForTesting::create(m_originString, m_connection->hostAppCodeSigningIdentifier(), *this);
    5657    else {
     58#if ENABLE(INSTALL_COORDINATION_BUNDLES)
     59        m_appBundle = ICAppBundle::create(*m_connection, m_originString, *this);
     60#else
    5761        m_connection->broadcastDebugMessage("Client is trying to initiate app bundle request without having configured mock app bundles for testing. About to crash...");
    5862        RELEASE_ASSERT_NOT_REACHED();
     63#endif
    5964    }
    6065
  • trunk/Source/WebKit/webpushd/LaunchServicesSPI.h

    r290145 r290146  
    11/*
    2  * Copyright (C) 2021 Apple Inc. All rights reserved.
     2 * Copyright (C) 2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    2424 */
    2525
    26 #pragma once
     26#if PLATFORM(IOS)
     27#if USE(APPLE_INTERNAL_SDK)
    2728
    28 #include <wtf/RefCounted.h>
     29// This space intentionally left blank
    2930
    30 @class NSError;
     31#else
    3132
    32 namespace WebPushD {
     33NS_ASSUME_NONNULL_BEGIN
    3334
    34 enum class PushAppBundleExists : bool {
    35     No,
    36     Yes,
     35typedef NS_ENUM(NSUInteger, LSInstallType) {
     36    LSInstallTypeIntentionalDowngrade = 8
    3737};
    3838
    39 enum class PushAppBundleCreationResult : bool {
    40     Failure,
    41     Success,
     39@interface LSRecord : NSObject
     40@end
     41
     42@interface LSBundleRecord : LSRecord
     43@property (readonly, nullable) NSString *bundleIdentifier;
     44@end
     45
     46@interface LSApplicationRecord : LSBundleRecord
     47@property (readonly) BOOL placeholder;
     48@property (readonly) NSString *managementDomain;
     49
     50- (instancetype)initWithBundleIdentifier:(NSString *)bundleIdentifier allowPlaceholder:(BOOL)allowPlaceholder error:(NSError **)outError;
     51@end
     52
     53@interface LSEnumerator<__covariant ObjectType> : NSEnumerator<ObjectType>
     54@end
     55
     56typedef NS_OPTIONS(uint64_t, LSApplicationEnumerationOptions) {
     57    LSApplicationEnumerationOptionsEnumeratePlaceholders = (1 << 6)
    4258};
    4359
    44 class PushAppBundle;
     60@interface LSApplicationRecord (Enumeration)
     61+ (LSEnumerator<LSApplicationRecord *> *)enumeratorWithOptions:(LSApplicationEnumerationOptions)options;
     62@end
    4563
    46 class PushAppBundleClient {
    47 public:
    48     virtual ~PushAppBundleClient();
     64NS_ASSUME_NONNULL_END
    4965
    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 
    72 } // namespace WebPushD
     66#endif // USE(APPLE_INTERNAL_SDK)
     67#endif // PLATFORM(IOS)
  • trunk/Source/WebKit/webpushd/PushAppBundle.h

    r286273 r290146  
    2626#pragma once
    2727
    28 #include <wtf/RefCounted.h>
     28#include <wtf/ThreadSafeRefCounted.h>
    2929
    3030@class NSError;
    … …  
    5353};
    5454
    55 class PushAppBundle : public RefCounted<PushAppBundle> {
     55class PushAppBundle : public ThreadSafeRefCounted<PushAppBundle> {
    5656public:
    5757    virtual ~PushAppBundle();
  • trunk/Source/WebKit/webpushd/WebPushDaemon.mm

    r289353 r290146  
    3232#import "DaemonUtilities.h"
    3333#import "HandleMessage.h"
     34#import "ICAppBundle.h"
    3435#import "MockAppBundleRegistry.h"
    3536
    … …  
    442443    }
    443444
    444     // FIXME: This will need platform-specific implementations for real world bundles once implemented.
    445     replySender({ });
     445#if ENABLE(INSTALL_COORDINATION_BUNDLES)
     446    ICAppBundle::getOriginsWithRegistrations(*connection, WTFMove(replySender));
     447#else
     448    RELEASE_ASSERT_NOT_REACHED();
     449#endif
    446450}
    447451
  • trunk/Tools/ChangeLog

    r290126 r290146  
     12022-02-18  Brady Eidson  <beidson@apple.com>
     2
     3        Add an InstallCoordination webpushd backend
     4        https://bugs.webkit.org/show_bug.cgi?id=233714
     5
     6        Reviewed by Alex Christensen.
     7
     8        * TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:
     9
    1102022-02-07  Jonathan Bedard  <jbedard@apple.com>
    211
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm

    r289353 r290146  
    708708}
    709709
     710#if ENABLE(INSTALL_COORDINATION_BUNDLES)
     711#if USE(APPLE_INTERNAL_SDK)
     712static void deleteAllRegistrationsForDataStore(WKWebsiteDataStore *dataStore)
     713{
     714    __block bool originOperationDone = false;
     715    __block RetainPtr<NSSet<WKSecurityOrigin *>> originSet;
     716    [dataStore _getOriginsWithPushAndNotificationPermissions:^(NSSet<WKSecurityOrigin *> *origins) {
     717        originSet = origins;
     718        originOperationDone = true;
     719    }];
     720    TestWebKitAPI::Util::run(&originOperationDone);
     721
     722    if (![originSet count])
     723        return;
     724
     725    __block size_t deletedOrigins = 0;
     726    originOperationDone = false;
     727    for (WKSecurityOrigin *origin in originSet.get()) {
     728        [dataStore _deletePushAndNotificationRegistration:origin completionHandler:^(NSError *error) {
     729            EXPECT_FALSE(!!error);
     730            if (++deletedOrigins == [originSet count])
     731                originOperationDone = true;
     732        }];
     733    }
     734    TestWebKitAPI::Util::run(&originOperationDone);
     735
     736    originOperationDone = false;
     737    [dataStore _getOriginsWithPushAndNotificationPermissions:^(NSSet<WKSecurityOrigin *> *origins) {
     738        EXPECT_EQ([origins count], 0u);
     739        originOperationDone = true;
     740    }];
     741    TestWebKitAPI::Util::run(&originOperationDone);
     742
     743}
     744
     745TEST(WebPushD, InstallCoordinationBundles)
     746{
     747    NSURL *tempDirectory = setUpTestWebPushD();
     748
     749    auto dataStoreConfiguration = adoptNS([_WKWebsiteDataStoreConfiguration new]);
     750    dataStoreConfiguration.get().webPushMachServiceName = @"org.webkit.webpushtestdaemon.service";
     751    auto dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()]);
     752
     753    deleteAllRegistrationsForDataStore(dataStore.get());
     754
     755    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     756    configuration.get().websiteDataStore = dataStore.get();
     757    [configuration.get().preferences _setNotificationsEnabled:YES];
     758    for (_WKExperimentalFeature *feature in [WKPreferences _experimentalFeatures]) {
     759        if ([feature.key isEqualToString:@"BuiltInNotificationsEnabled"])
     760            [[configuration preferences] _setEnabled:YES forFeature:feature];
     761    }
     762
     763    auto handler = adoptNS([[TestURLSchemeHandler alloc] init]);
     764    [configuration setURLSchemeHandler:handler.get() forURLScheme:@"testing"];
     765
     766    [handler setStartURLSchemeTaskHandler:^(WKWebView *, id<WKURLSchemeTask> task) {
     767        auto response = adoptNS([[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"text/html" expectedContentLength:0 textEncodingName:nil]);
     768        [task didReceiveResponse:response.get()];
     769        [task didReceiveData:[NSData dataWithBytes:mainBytes length:strlen(mainBytes)]];
     770        [task didFinish];
     771    }];
     772
     773    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]);
     774    auto uiDelegate = adoptNS([[NotificationPermissionDelegate alloc] init]);
     775    [webView setUIDelegate:uiDelegate.get()];
     776
     777    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"testing://main/index.html"]]];
     778    TestWebKitAPI::Util::run(&alertReceived);
     779
     780    alertReceived = false;
     781    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"testing://secondary/index.html"]]];
     782    TestWebKitAPI::Util::run(&alertReceived);
     783
     784    static bool originOperationDone = false;
     785    static RetainPtr<NSSet<WKSecurityOrigin *>> origins;
     786    [dataStore _getOriginsWithPushAndNotificationPermissions:^(NSSet<WKSecurityOrigin *> *rawOrigins) {
     787        EXPECT_EQ([rawOrigins count], 2u);
     788        origins = rawOrigins;
     789        originOperationDone = true;
     790    }];
     791    TestWebKitAPI::Util::run(&originOperationDone);
     792
     793    for (WKSecurityOrigin *origin in origins.get()) {
     794        EXPECT_TRUE([origin.protocol isEqualToString:@"testing"]);
     795        EXPECT_TRUE([origin.host isEqualToString:@"main"] || [origin.host isEqualToString:@"secondary"]);
     796    }
     797
     798    deleteAllRegistrationsForDataStore(dataStore.get());
     799    cleanUpTestWebPushD(tempDirectory);
     800}
     801#endif // #if USE(APPLE_INTERNAL_SDK)
     802#endif // ENABLE(INSTALL_COORDINATION_BUNDLES)
     803
    710804} // namespace TestWebKitAPI
    711805
  • trunk/WebKitLibraries/ChangeLog

    r289073 r290146  
     12022-02-18  Brady Eidson  <beidson@apple.com>
     2
     3        Add an InstallCoordination webpushd backend
     4        https://bugs.webkit.org/show_bug.cgi?id=233714
     5
     6        Reviewed by Alex Christensen.
     7
     8        * WebKitPrivateFrameworkStubs/iOS/15/InstallCoordination.framework/InstallCoordination.tbd: Added.
     9
    1102022-02-03  Robert Jenner  <Jenner@apple.com>
    211
Note: See TracChangeset for help on using the changeset viewer.