Changeset 288451 in webkit


Ignore:
Timestamp:
Jan 24, 2022, 9:44:12 AM (4 years ago)
Author:
david_quesada@apple.com
Message:

Simplify accesses to SystemVersion.plist
https://bugs.webkit.org/show_bug.cgi?id=234306

Reviewed by Alexey Proskuryakov.

Source/WebCore:

No new tests since no behavior change is expected.

  • platform/cocoa/SystemVersion.mm:

(WebCore::createSystemMarketingVersion):

Read the SystemVersion.plist file using _CFCopySystemVersionDictionary()
rather than by manually constructing the path and initializing the dictionary.

Source/WebCore/PAL:

  • pal/spi/cf/CFUtilitiesSPI.h:

Forward declare _kCFSystemVersionProductUserVisibleVersionKey, used
by WebCore's SystemVersion.mm

Source/WebKit:

No new tests since no behavior change is expected.

  • UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:

(WebKit::WebInspectorUIProxy::infoForLocalDebuggable):

Use _CFCopySystemVersionDictionary() to locate and load the
SystemVersion.plist file rather than doing that all manually.

(WebKit::systemVersionPlist): Deleted.

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r288450 r288451  
     12022-01-24  David Quesada  <david_quesada@apple.com>
     2
     3        Simplify accesses to SystemVersion.plist
     4        https://bugs.webkit.org/show_bug.cgi?id=234306
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        No new tests since no behavior change is expected.
     9
     10        * platform/cocoa/SystemVersion.mm:
     11        (WebCore::createSystemMarketingVersion):
     12            Read the SystemVersion.plist file using _CFCopySystemVersionDictionary()
     13            rather than by manually constructing the path and initializing the dictionary.
     14
    1152022-01-24  Rob Buis  <rbuis@igalia.com>
    216
  • trunk/Source/WebCore/PAL/ChangeLog

    r288389 r288451  
     12022-01-24  David Quesada  <david_quesada@apple.com>
     2
     3        Simplify accesses to SystemVersion.plist
     4        https://bugs.webkit.org/show_bug.cgi?id=234306
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * pal/spi/cf/CFUtilitiesSPI.h:
     9            Forward declare _kCFSystemVersionProductUserVisibleVersionKey, used
     10            by WebCore's SystemVersion.mm
     11
    1122022-01-21  Sihui Liu  <sihui_liu@apple.com>
    213
  • trunk/Source/WebCore/PAL/pal/spi/cf/CFUtilitiesSPI.h

    r263773 r288451  
    5050extern const CFStringRef kCFWebServicesTypeWebSearch;
    5151extern const CFStringRef _kCFSystemVersionBuildVersionKey;
     52extern const CFStringRef _kCFSystemVersionProductUserVisibleVersionKey;
    5253extern const CFStringRef _kCFSystemVersionProductVersionKey;
    5354
  • trunk/Source/WebCore/platform/cocoa/SystemVersion.mm

    r273848 r288451  
    2525#import "config.h"
    2626#import "SystemVersion.h"
     27#import <pal/spi/cf/CFUtilitiesSPI.h>
    2728
    2829namespace WebCore {
     
    3132{
    3233    // Can't use -[NSProcessInfo operatingSystemVersionString] because it has too much stuff we don't want.
    33     NSString *systemLibraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES) objectAtIndex:0];
    34 #if PLATFORM(IOS_FAMILY_SIMULATOR)
    35     if (char *simulatorRoot = getenv("SIMULATOR_ROOT"))
    36         systemLibraryPath = [NSString stringWithFormat:@"%s/%@", simulatorRoot, systemLibraryPath];
    37 #endif
    38     NSString *systemVersionPlistPath = [systemLibraryPath stringByAppendingPathComponent:@"CoreServices/SystemVersion.plist"];
    39     NSDictionary *systemVersionInfo = [NSDictionary dictionaryWithContentsOfFile:systemVersionPlistPath];
    40     return adoptNS([[systemVersionInfo objectForKey:@"ProductVersion"] copy]);
     34    auto systemVersionDictionary = adoptCF(_CFCopySystemVersionDictionary());
     35    CFStringRef productVersion = static_cast<CFStringRef>(CFDictionaryGetValue(systemVersionDictionary.get(), _kCFSystemVersionProductVersionKey));
     36    return adoptNS([(__bridge NSString *)productVersion copy]);
    4137}
    4238
  • trunk/Source/WebKit/ChangeLog

    r288432 r288451  
     12022-01-24  David Quesada  <david_quesada@apple.com>
     2
     3        Simplify accesses to SystemVersion.plist
     4        https://bugs.webkit.org/show_bug.cgi?id=234306
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        No new tests since no behavior change is expected.
     9
     10        * UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:
     11        (WebKit::WebInspectorUIProxy::infoForLocalDebuggable):
     12            Use _CFCopySystemVersionDictionary() to locate and load the
     13            SystemVersion.plist file rather than doing that all manually.
     14        (WebKit::systemVersionPlist): Deleted.
     15
    1162022-01-24  Said Abou-Hallawa  <said@apple.com>
    217
  • trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm

    r284968 r288451  
    4949#import <WebCore/InspectorFrontendClientLocal.h>
    5050#import <WebCore/LocalizedStrings.h>
     51#import <pal/spi/cf/CFUtilitiesSPI.h>
    5152#import <wtf/text/Base64.h>
    5253
     
    788789}
    789790
    790 static NSDictionary *systemVersionPlist()
    791 {
    792     NSString *systemLibraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES) objectAtIndex:0];
    793     NSString *systemVersionPlistPath = [systemLibraryPath stringByAppendingPathComponent:@"CoreServices/SystemVersion.plist"];
    794     NSDictionary *systemVersionInfo = [NSDictionary dictionaryWithContentsOfFile:systemVersionPlistPath];
    795     return systemVersionInfo;
    796 }
    797 
    798791DebuggableInfoData WebInspectorUIProxy::infoForLocalDebuggable()
    799792{
    800     NSDictionary *plist = systemVersionPlist();
     793    NSDictionary *plist = adoptCF(_CFCopySystemVersionDictionary()).bridgingAutorelease();
    801794
    802795    DebuggableInfoData result;
    803796    result.debuggableType = Inspector::DebuggableType::WebPage;
    804797    result.targetPlatformName = "macOS"_s;
    805     result.targetBuildVersion = plist[@"ProductBuildVersion"];
    806     result.targetProductVersion = plist[@"ProductUserVisibleVersion"];
     798    result.targetBuildVersion = plist[static_cast<NSString *>(_kCFSystemVersionBuildVersionKey)];
     799    result.targetProductVersion = plist[static_cast<NSString *>(_kCFSystemVersionProductUserVisibleVersionKey)];
    807800    result.targetIsSimulator = false;
    808801
Note: See TracChangeset for help on using the changeset viewer.