Title: [295528] trunk/Source
Revision
295528
Author
pvol...@apple.com
Date
2022-06-14 11:02:18 -0700 (Tue, 14 Jun 2022)

Log Message

Adopt SPI to get default content of Launch Services database
https://bugs.webkit.org/show_bug.cgi?id=241286
<rdar://64528683>

Reviewed by Geoffrey Garen.

Adopt SPI to get system content of Launch Services database. If this SPI is available,
it will replace the SPI we currently use to retrieve the database in the Network process.

* Source/WTF/wtf/PlatformHave.h:
* Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm:
(WebKit::LaunchServicesDatabaseObserver::LaunchServicesDatabaseObserver):
(WebKit::LaunchServicesDatabaseObserver::startObserving):
(WebKit::LaunchServicesDatabaseObserver::~LaunchServicesDatabaseObserver):

Canonical link: https://commits.webkit.org/251533@main

Modified Paths

Diff

Modified: trunk/Source/WTF/wtf/PlatformHave.h (295527 => 295528)


--- trunk/Source/WTF/wtf/PlatformHave.h	2022-06-14 17:51:22 UTC (rev 295527)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2022-06-14 18:02:18 UTC (rev 295528)
@@ -1229,6 +1229,11 @@
 #define HAVE_DDRESULT_DISABLE_URL_SCHEME_CHECKING 1
 #endif
 
+#if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000) \
+    || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 160000))
+#define HAVE_SYSTEM_CONTENT_LS_DATABASE 1
+#endif
+
 #if !defined(HAVE_VK_IMAGE_TRANSLATION_SUPPORT) \
     && ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 130000) \
     || ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 160000))

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm (295527 => 295528)


--- trunk/Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm	2022-06-14 17:51:22 UTC (rev 295527)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm	2022-06-14 18:02:18 UTC (rev 295528)
@@ -36,7 +36,7 @@
 
 LaunchServicesDatabaseObserver::LaunchServicesDatabaseObserver(NetworkProcess&)
 {
-#if HAVE(LSDATABASECONTEXT)
+#if HAVE(LSDATABASECONTEXT) && !HAVE(SYSTEM_CONTENT_LS_DATABASE)
     m_observer = [LSDatabaseContext.sharedDatabaseContext addDatabaseChangeObserver4WebKit:^(xpc_object_t change) {
         auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
         xpc_dictionary_set_string(message.get(), XPCEndpoint::xpcMessageNameKey, LaunchServicesDatabaseXPCConstants::xpcUpdateLaunchServicesDatabaseMessageName);
@@ -63,7 +63,18 @@
         m_connections.append(connection);
     }
 
-#if HAVE(LSDATABASECONTEXT)
+#if HAVE(SYSTEM_CONTENT_LS_DATABASE)
+    [LSDatabaseContext.sharedDatabaseContext getSystemContentDatabaseObject4WebKit:makeBlockPtr([connection = connection] (xpc_object_t _Nullable object, NSError * _Nullable error) {
+        if (!object)
+            return;
+        auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
+        xpc_dictionary_set_string(message.get(), XPCEndpoint::xpcMessageNameKey, LaunchServicesDatabaseXPCConstants::xpcUpdateLaunchServicesDatabaseMessageName);
+        xpc_dictionary_set_value(message.get(), LaunchServicesDatabaseXPCConstants::xpcLaunchServicesDatabaseKey, object);
+
+        xpc_connection_send_message(connection.get(), message.get());
+
+    }).get()];
+#elif HAVE(LSDATABASECONTEXT)
     RetainPtr<id> observer = [LSDatabaseContext.sharedDatabaseContext addDatabaseChangeObserver4WebKit:^(xpc_object_t change) {
         auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
         xpc_dictionary_set_string(message.get(), XPCEndpoint::xpcMessageNameKey, LaunchServicesDatabaseXPCConstants::xpcUpdateLaunchServicesDatabaseMessageName);
@@ -82,7 +93,7 @@
 
 LaunchServicesDatabaseObserver::~LaunchServicesDatabaseObserver()
 {
-#if HAVE(LSDATABASECONTEXT)
+#if HAVE(LSDATABASECONTEXT) && !HAVE(SYSTEM_CONTENT_LS_DATABASE)
     [LSDatabaseContext.sharedDatabaseContext removeDatabaseChangeObserver4WebKit:m_observer.get()];
 #endif
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to