Changeset 295528 in webkit


Ignore:
Timestamp:
Jun 14, 2022 11:02:18 AM (2 years ago)
Author:
pvollan@apple.com
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

Location:
trunk/Source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/wtf/PlatformHave.h

    r295522 r295528  
    12301230#endif
    12311231
     1232#if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000) \
     1233    || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 160000))
     1234#define HAVE_SYSTEM_CONTENT_LS_DATABASE 1
     1235#endif
     1236
    12321237#if !defined(HAVE_VK_IMAGE_TRANSLATION_SUPPORT) \
    12331238    && ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 130000) \
  • trunk/Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm

    r295445 r295528  
    3737LaunchServicesDatabaseObserver::LaunchServicesDatabaseObserver(NetworkProcess&)
    3838{
    39 #if HAVE(LSDATABASECONTEXT)
     39#if HAVE(LSDATABASECONTEXT) && !HAVE(SYSTEM_CONTENT_LS_DATABASE)
    4040    m_observer = [LSDatabaseContext.sharedDatabaseContext addDatabaseChangeObserver4WebKit:^(xpc_object_t change) {
    4141        auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
     
    6464    }
    6565
    66 #if HAVE(LSDATABASECONTEXT)
     66#if HAVE(SYSTEM_CONTENT_LS_DATABASE)
     67    [LSDatabaseContext.sharedDatabaseContext getSystemContentDatabaseObject4WebKit:makeBlockPtr([connection = connection] (xpc_object_t _Nullable object, NSError * _Nullable error) {
     68        if (!object)
     69            return;
     70        auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
     71        xpc_dictionary_set_string(message.get(), XPCEndpoint::xpcMessageNameKey, LaunchServicesDatabaseXPCConstants::xpcUpdateLaunchServicesDatabaseMessageName);
     72        xpc_dictionary_set_value(message.get(), LaunchServicesDatabaseXPCConstants::xpcLaunchServicesDatabaseKey, object);
     73
     74        xpc_connection_send_message(connection.get(), message.get());
     75
     76    }).get()];
     77#elif HAVE(LSDATABASECONTEXT)
    6778    RetainPtr<id> observer = [LSDatabaseContext.sharedDatabaseContext addDatabaseChangeObserver4WebKit:^(xpc_object_t change) {
    6879        auto message = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
     
    8394LaunchServicesDatabaseObserver::~LaunchServicesDatabaseObserver()
    8495{
    85 #if HAVE(LSDATABASECONTEXT)
     96#if HAVE(LSDATABASECONTEXT) && !HAVE(SYSTEM_CONTENT_LS_DATABASE)
    8697    [LSDatabaseContext.sharedDatabaseContext removeDatabaseChangeObserver4WebKit:m_observer.get()];
    8798#endif
Note: See TracChangeset for help on using the changeset viewer.