Title: [286878] trunk/Source
- Revision
- 286878
- Author
- beid...@apple.com
- Date
- 2021-12-10 14:19:03 -0800 (Fri, 10 Dec 2021)
Log Message
Teach webpushd to launch an app in response to an injected message.
https://bugs.webkit.org/show_bug.cgi?id=234122
Reviewed by Alex Christensen.
Source/WebCore/PAL:
* pal/spi/cocoa/LaunchServicesSPI.h:
Source/WebKit:
To by covered by future API test.
When a message comes in, webpushd knows which code signing identifier it was targetted for.
It launches that app in a special mode so the app can then "take it from there"
* webpushd/WebPushDaemon.h:
* webpushd/WebPushDaemon.mm:
(WebPushD::Daemon::injectPushMessageForTesting):
(WebPushD::Daemon::notifyClientPushMessageIsAvailable):
Modified Paths
Diff
Modified: trunk/Source/WebCore/PAL/ChangeLog (286877 => 286878)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-12-10 22:17:27 UTC (rev 286877)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-12-10 22:19:03 UTC (rev 286878)
@@ -1,3 +1,12 @@
+2021-12-10 Brady Eidson <beid...@apple.com>
+
+ Teach webpushd to launch an app in response to an injected message.
+ https://bugs.webkit.org/show_bug.cgi?id=234122
+
+ Reviewed by Alex Christensen.
+
+ * pal/spi/cocoa/LaunchServicesSPI.h:
+
2021-12-10 Antoine Quint <grao...@webkit.org>
Expose the maximum device frame rate to the Web Animations model
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h (286877 => 286878)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h 2021-12-10 22:17:27 UTC (rev 286877)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/LaunchServicesSPI.h 2021-12-10 22:19:03 UTC (rev 286878)
@@ -50,6 +50,9 @@
WTF_EXTERN_C_END
#endif // PLATFORM(MACCATALYST)
#else // USE(APPLE_INTERNAL_SDK)
+
+const uint8_t kLSOpenRunningInstanceBehaviorUseRunningProcess = 1;
+
@interface LSResourceProxy : NSObject <NSCopying, NSSecureCoding>
@property (nonatomic, copy, readonly) NSString *localizedName;
@end
@@ -130,6 +133,11 @@
WTF_EXTERN_C_BEGIN
extern const CFStringRef _kLSDisplayNameKey;
+extern const CFStringRef _kLSOpenOptionActivateKey;
+extern const CFStringRef _kLSOpenOptionAddToRecentsKey;
+extern const CFStringRef _kLSOpenOptionBackgroundLaunchKey;
+extern const CFStringRef _kLSOpenOptionHideKey;
+extern const CFStringRef _kLSOpenOptionPreferRunningInstanceKey;
extern const CFStringRef _kLSPersistenceSuppressRelaunchAtLoginKey;
LSASNRef _LSGetCurrentApplicationASN();
@@ -139,6 +147,9 @@
OSStatus _RegisterApplication(CFDictionaryRef, ProcessSerialNumber*);
+typedef void (^ _LSOpenCompletionHandler)(LSASNRef, Boolean, CFErrorRef);
+void _LSOpenURLsUsingBundleIdentifierWithCompletionHandler(CFArrayRef, CFStringRef, CFDictionaryRef, _LSOpenCompletionHandler);
+
WTF_EXTERN_C_END
#endif // PLATFORM(MAC)
Modified: trunk/Source/WebKit/ChangeLog (286877 => 286878)
--- trunk/Source/WebKit/ChangeLog 2021-12-10 22:17:27 UTC (rev 286877)
+++ trunk/Source/WebKit/ChangeLog 2021-12-10 22:19:03 UTC (rev 286878)
@@ -1,3 +1,20 @@
+2021-12-10 Brady Eidson <beid...@apple.com>
+
+ Teach webpushd to launch an app in response to an injected message.
+ https://bugs.webkit.org/show_bug.cgi?id=234122
+
+ Reviewed by Alex Christensen.
+
+ To by covered by future API test.
+
+ When a message comes in, webpushd knows which code signing identifier it was targetted for.
+ It launches that app in a special mode so the app can then "take it from there"
+
+ * webpushd/WebPushDaemon.h:
+ * webpushd/WebPushDaemon.mm:
+ (WebPushD::Daemon::injectPushMessageForTesting):
+ (WebPushD::Daemon::notifyClientPushMessageIsAvailable):
+
2021-12-10 Antoine Quint <grao...@webkit.org>
Expose the maximum device frame rate to the Web Animations model
Modified: trunk/Source/WebKit/webpushd/WebPushDaemon.h (286877 => 286878)
--- trunk/Source/WebKit/webpushd/WebPushDaemon.h 2021-12-10 22:17:27 UTC (rev 286877)
+++ trunk/Source/WebKit/webpushd/WebPushDaemon.h 2021-12-10 22:19:03 UTC (rev 286878)
@@ -79,6 +79,8 @@
bool canRegisterForNotifications(ClientConnection&);
+ void notifyClientPushMessageIsAvailable(const String& clientCodeSigningIdentifier);
+
ClientConnection* toClientConnection(xpc_connection_t);
HashMap<xpc_connection_t, Ref<ClientConnection>> m_connectionMap;
Modified: trunk/Source/WebKit/webpushd/WebPushDaemon.mm (286877 => 286878)
--- trunk/Source/WebKit/webpushd/WebPushDaemon.mm 2021-12-10 22:17:27 UTC (rev 286877)
+++ trunk/Source/WebKit/webpushd/WebPushDaemon.mm 2021-12-10 22:19:03 UTC (rev 286878)
@@ -33,6 +33,7 @@
#import "HandleMessage.h"
#import "MockAppBundleRegistry.h"
+#import <pal/spi/cocoa/LaunchServicesSPI.h>
#import <wtf/CompletionHandler.h>
#import <wtf/HexNumber.h>
#import <wtf/NeverDestroyed.h>
@@ -349,9 +350,32 @@
});
addResult.iterator->value.append(message);
+ notifyClientPushMessageIsAvailable(message.targetAppCodeSigningIdentifier);
+
replySender(true);
}
+void Daemon::notifyClientPushMessageIsAvailable(const String& clientCodeSigningIdentifier)
+{
+#if PLATFORM(MAC)
+ CFArrayRef urls = (__bridge CFArrayRef)@[ [NSURL URLWithString:@"webkit-app-launch://1"] ];
+ CFStringRef identifier = (__bridge CFStringRef)((NSString *)clientCodeSigningIdentifier);
+
+ CFDictionaryRef options = (__bridge CFDictionaryRef)@{
+ (id)_kLSOpenOptionPreferRunningInstanceKey: @(kLSOpenRunningInstanceBehaviorUseRunningProcess),
+ (id)_kLSOpenOptionActivateKey: @NO,
+ (id)_kLSOpenOptionAddToRecentsKey: @NO,
+ (id)_kLSOpenOptionBackgroundLaunchKey: @YES,
+ (id)_kLSOpenOptionHideKey: @YES,
+ };
+
+ _LSOpenURLsUsingBundleIdentifierWithCompletionHandler(urls, identifier, options, ^(LSASNRef newProcessSerialNumber, Boolean processWasLaunched, CFErrorRef cfError) { });
+#else
+ // FIXME: Figure out equivalent iOS code here
+ UNUSED_PARAM(clientCodeSigningIdentifier);
+#endif // PLATFORM(MAC)
+}
+
void Daemon::getPendingPushMessages(ClientConnection* connection, CompletionHandler<void(const Vector<WebKit::WebPushMessage>&)>&& replySender)
{
auto hostAppCodeSigningIdentifier = connection->hostAppCodeSigningIdentifier();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes