Title: [255784] trunk
Revision
255784
Author
[email protected]
Date
2020-02-04 19:45:12 -0800 (Tue, 04 Feb 2020)

Log Message

Remove NSKeyedArchiverSPI.h now that WebKit only uses API
https://bugs.webkit.org/show_bug.cgi?id=207203

Reviewed by Anders Carlsson.

Source/WebCore:

* editing/cocoa/EditorCocoa.mm:
(WebCore::archivedDataForAttributedString): Removed NSKeyedArchiverSPI.h header and use
NSKeyedArchiver methods directly instead of through WebKit functions.
* loader/archive/cf/LegacyWebArchiveMac.mm:
(WebCore::LegacyWebArchive::createResourceResponseFromMacArchivedData): Ditto.
(WebCore::LegacyWebArchive::createPropertyListRepresentation): Ditto.
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::write): Ditto.
(WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const): Ditto. Also added
a missing type check when unarchiving a dictionary.
(WebCore::createItemProviderRegistrationList): Ditto. Also added a missing null check.
* testing/cocoa/WebArchiveDumpSupport.mm:
(WebCoreTestSupport::createCFURLResponseFromResponseData): Ditto.

Source/WebCore/PAL:

* PAL.xcodeproj/project.pbxproj: Remove NSKeyedArchiverSPI.h.
* pal/PlatformMac.cmake: Ditto.
* pal/spi/cocoa/NSKeyedArchiverSPI.h: Removed.

Source/WebKit:

* Platform/ios/AccessibilityIOS.mm:
(WebKit::newAccessibilityRemoteToken): Removed include of NSKeyedArchiverSPI.h;
use NSKeyedArchiver methods directly.
* Shared/Cocoa/ArgumentCodersCocoa.mm:
(IPC::encodeSecureCodingInternal): Ditto.
(IPC::decodeSecureCodingInternal): Ditto.

* Shared/Cocoa/DataDetectionResult.mm: Removed include of NSKeyedArchiverSPI.h.
* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: Ditto.
* Shared/ios/InteractionInformationAtPosition.mm: Ditto.

* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::ArgumentCoder<WebCore::ContentFilterUnblockHandler>::encode): Removed
include of NSKeyedArchiverSPI.h; use NSKeyedArchiver methods directly.
(IPC::ArgumentCoder<WebCore::ContentFilterUnblockHandler>::decode): Ditto.

* Shared/mac/WebHitTestResultData.mm: Removed include of NSKeyedArchiverSPI.h.

* UIProcess/API/Cocoa/APIAttachmentCocoa.mm:
(API::Attachment::createSerializedRepresentation const): Removed
include of NSKeyedArchiverSPI.h; use NSKeyedArchiver methods directly. Also
refactored so the !CAN_SECURELY_ARCHIVE_FILE_WRAPPER path shares more code
with the modern code path. I think we can remove it entirely once we bump
the minimum version of macOS a bit more.
(API::Attachment::updateFromSerializedRepresentation): Ditto.
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _setObject:forBundleParameter:]): Ditto.
(-[WKProcessPool _setObjectsForBundleParametersWithDictionary:]): Ditto.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithCoder:]): Ditto.
(-[WKWebView _setInputDelegate:]): Ditto.
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration initWithCoder:]): Ditto.
* UIProcess/API/Cocoa/_WKApplicationManifest.mm:
(-[_WKApplicationManifest initWithCoder:]): Ditto.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess): Ditto.
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::elementDidFocus): Ditto.
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
(-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]): Ditto.
* WebProcess/InjectedBundle/mac/InjectedBundleMac.mm: Removed include of NSKeyedArchiverSPI.h
(WebKit::createUnarchiver): Added helper function to make the code below less repetitive.
(WebKit::InjectedBundle::initialize): Use the createUnarchiver function above and the
NSKeyedArchiver methods directly.
(WebKit::InjectedBundle::classesForCoder): Ditto.
(WebKit::InjectedBundle::setBundleParameter): Ditto.
(WebKit::InjectedBundle::setBundleParameters): Ditto.

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm: Removed
include of NSKeyedArchiverSPI.h and call methods of NSKeyedArchiver directly.
* TestWebKitAPI/Tests/WebKitCocoa/Coding.mm: Ditto.
* TestWebKitAPI/Tests/ios/WKWebViewOpaque.mm: Ditto.
* TestWebKitAPI/Tests/mac/EarlyKVOCrash.mm: Ditto.

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (255783 => 255784)


--- trunk/Source/WebCore/ChangeLog	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebCore/ChangeLog	2020-02-05 03:45:12 UTC (rev 255784)
@@ -1,3 +1,24 @@
+2020-02-04  Darin Adler  <[email protected]>
+
+        Remove NSKeyedArchiverSPI.h now that WebKit only uses API
+        https://bugs.webkit.org/show_bug.cgi?id=207203
+
+        Reviewed by Anders Carlsson.
+
+        * editing/cocoa/EditorCocoa.mm:
+        (WebCore::archivedDataForAttributedString): Removed NSKeyedArchiverSPI.h header and use
+        NSKeyedArchiver methods directly instead of through WebKit functions.
+        * loader/archive/cf/LegacyWebArchiveMac.mm:
+        (WebCore::LegacyWebArchive::createResourceResponseFromMacArchivedData): Ditto.
+        (WebCore::LegacyWebArchive::createPropertyListRepresentation): Ditto.
+        * platform/ios/PlatformPasteboardIOS.mm:
+        (WebCore::PlatformPasteboard::write): Ditto.
+        (WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const): Ditto. Also added
+        a missing type check when unarchiving a dictionary.
+        (WebCore::createItemProviderRegistrationList): Ditto. Also added a missing null check.
+        * testing/cocoa/WebArchiveDumpSupport.mm:
+        (WebCoreTestSupport::createCFURLResponseFromResponseData): Ditto.
+
 2020-02-04  Alex Christensen  <[email protected]>
 
         Fix internal build after r255709

Modified: trunk/Source/WebCore/PAL/ChangeLog (255783 => 255784)


--- trunk/Source/WebCore/PAL/ChangeLog	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebCore/PAL/ChangeLog	2020-02-05 03:45:12 UTC (rev 255784)
@@ -1,3 +1,14 @@
+2020-02-04  Darin Adler  <[email protected]>
+
+        Remove NSKeyedArchiverSPI.h now that WebKit only uses API
+        https://bugs.webkit.org/show_bug.cgi?id=207203
+
+        Reviewed by Anders Carlsson.
+
+        * PAL.xcodeproj/project.pbxproj: Remove NSKeyedArchiverSPI.h.
+        * pal/PlatformMac.cmake: Ditto.
+        * pal/spi/cocoa/NSKeyedArchiverSPI.h: Removed.
+
 2020-02-04  Alex Christensen  <[email protected]>
 
         Fix Mac CMake build

Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (255783 => 255784)


--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2020-02-05 03:45:12 UTC (rev 255784)
@@ -130,7 +130,6 @@
 		5C7C787423AC3E770065F47E /* ManagedConfigurationSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C7C787223AC3E770065F47E /* ManagedConfigurationSoftLink.mm */; };
 		5C7C787623AC3E850065F47E /* ManagedConfigurationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7C787523AC3E850065F47E /* ManagedConfigurationSPI.h */; };
 		63C7EDC721AFAE04006A7B99 /* NSProgressSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 63E369F921AFA83F001C14BC /* NSProgressSPI.h */; };
-		7A1656441F97B2B900BA3CE4 /* NSKeyedArchiverSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A1656431F97B2B800BA3CE4 /* NSKeyedArchiverSPI.h */; };
 		7A36D0F9223AD9AB00B0522E /* CommonCryptoSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */; };
 		7A3A6A8020CADB4700317AAE /* NSImageSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */; };
 		A10265891F56747A00B4C844 /* HIToolboxSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10265881F56747A00B4C844 /* HIToolboxSPI.h */; };
@@ -306,7 +305,6 @@
 		5C7C787223AC3E770065F47E /* ManagedConfigurationSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ManagedConfigurationSoftLink.mm; sourceTree = "<group>"; };
 		5C7C787523AC3E850065F47E /* ManagedConfigurationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ManagedConfigurationSPI.h; sourceTree = "<group>"; };
 		63E369F921AFA83F001C14BC /* NSProgressSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSProgressSPI.h; sourceTree = "<group>"; };
-		7A1656431F97B2B800BA3CE4 /* NSKeyedArchiverSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSKeyedArchiverSPI.h; sourceTree = "<group>"; };
 		7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoSPI.h; sourceTree = "<group>"; };
 		7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSImageSPI.h; sourceTree = "<group>"; };
 		93E5909C1F93BF1E0067F8CF /* UnencodableHandling.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UnencodableHandling.h; sourceTree = "<group>"; };
@@ -438,7 +436,6 @@
 				0C2DA1321F3BEB4900DBC317 /* NSExtensionSPI.h */,
 				0C2DA1331F3BEB4900DBC317 /* NSFileManagerSPI.h */,
 				F442915D1FA52473002CC93E /* NSFileSizeFormatterSPI.h */,
-				7A1656431F97B2B800BA3CE4 /* NSKeyedArchiverSPI.h */,
 				63E369F921AFA83F001C14BC /* NSProgressSPI.h */,
 				0C2DA1341F3BEB4900DBC317 /* NSStringSPI.h */,
 				0C2DA1351F3BEB4900DBC317 /* NSTouchBarSPI.h */,
@@ -787,7 +784,6 @@
 				A10826FE1F58A433004772AC /* NSGraphicsSPI.h in Headers */,
 				7A3A6A8020CADB4700317AAE /* NSImageSPI.h in Headers */,
 				0C7785911F45130F00F4EBB6 /* NSImmediateActionGestureRecognizerSPI.h in Headers */,
-				7A1656441F97B2B900BA3CE4 /* NSKeyedArchiverSPI.h in Headers */,
 				0C7785921F45130F00F4EBB6 /* NSMenuSPI.h in Headers */,
 				0C7785931F45130F00F4EBB6 /* NSPasteboardSPI.h in Headers */,
 				E5D45D142106A18700D2B738 /* NSPopoverColorWellSPI.h in Headers */,

Modified: trunk/Source/WebCore/PAL/pal/PlatformMac.cmake (255783 => 255784)


--- trunk/Source/WebCore/PAL/pal/PlatformMac.cmake	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebCore/PAL/pal/PlatformMac.cmake	2020-02-05 03:45:12 UTC (rev 255784)
@@ -45,7 +45,6 @@
     spi/cocoa/NSExtensionSPI.h
     spi/cocoa/NSFileManagerSPI.h
     spi/cocoa/NSFileSizeFormatterSPI.h
-    spi/cocoa/NSKeyedArchiverSPI.h
     spi/cocoa/NSProgressSPI.h
     spi/cocoa/NSStringSPI.h
     spi/cocoa/NSTouchBarSPI.h

Deleted: trunk/Source/WebCore/PAL/pal/spi/cocoa/NSKeyedArchiverSPI.h (255783 => 255784)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/NSKeyedArchiverSPI.h	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/NSKeyedArchiverSPI.h	2020-02-05 03:45:12 UTC (rev 255784)
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#import <Availability.h>
-#import <wtf/Assertions.h>
-#import <wtf/RetainPtr.h>
-
-#if USE(APPLE_INTERNAL_SDK)
-#import <Foundation/NSKeyedArchiver_Private.h>
-#else
-#import <Foundation/NSCoder.h>
-#import <Foundation/NSKeyedArchiver.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface NSKeyedArchiver (NSKeyedArchiverSecureCodingInitializers)
-- (instancetype)initRequiringSecureCoding:(BOOL)requiresSecureCoding API_AVAILABLE(macos(10.13), ios(11.0));
-+ (nullable NSData *)archivedDataWithRootObject:(id)object requiringSecureCoding:(BOOL)requiresSecureCoding error:(NSError **)error API_AVAILABLE(macos(10.13), ios(11.0));
-@end
-
-@interface NSKeyedUnarchiver (NSKeyedUnarchiverSecureCodingInitializer)
-- (nullable instancetype)initForReadingFromData:(NSData *)data error:(NSError **)error API_AVAILABLE(macos(10.13), ios(11.0));
-+ (nullable id)unarchivedObjectOfClass:(Class)cls fromData:(NSData *)data error:(NSError **)error API_AVAILABLE(macos(10.13), ios(11.0));
-+ (nullable id)unarchivedObjectOfClasses:(NSSet<Class> *)classes fromData:(NSData *)data error:(NSError **)error API_AVAILABLE(macos(10.13), ios(11.0));
-@end
-
-NS_ASSUME_NONNULL_END
-
-#endif /* USE(APPLE_INTERNAL_SDK) */
-
-inline NSData *_Nullable securelyArchivedDataWithRootObject(id _Nonnull object)
-{
-    NSError *error;
-    NSData *data = "" archivedDataWithRootObject:object requiringSecureCoding:YES error:&error];
-    if (!data)
-        LOG_ERROR("Unable to archive data: %@", error);
-    return data;
-}
-
-inline NSData *_Nullable insecurelyArchivedDataWithRootObject(id _Nonnull object)
-{
-    NSError *error;
-    NSData *data = "" archivedDataWithRootObject:object requiringSecureCoding:NO error:&error];
-    if (!data)
-        LOG_ERROR("Unable to archive data: %@", error);
-    return data;
-}
-
-inline id _Nullable insecurelyUnarchiveObjectFromData(NSData * _Nonnull data)
-{
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
-    ALLOW_DEPRECATED_DECLARATIONS_END
-}
-
-inline id _Nullable unarchivedObjectOfClassesFromData(NSSet<Class> * _Nonnull classes, NSData * _Nonnull data)
-{
-    NSError *error;
-    id value = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:data error:&error];
-    if (!value)
-        LOG_ERROR("Unable to unarchive data: %@", error);
-    return value;
-}
-
-inline RetainPtr<NSKeyedArchiver> secureArchiver()
-{
-    NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initRequiringSecureCoding:YES];
-    return adoptNS(archiver);
-}
-
-inline RetainPtr<NSKeyedUnarchiver> secureUnarchiverFromData(NSData *_Nonnull data)
-{
-    NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:data error:nil];
-    unarchiver.decodingFailurePolicy = NSDecodingFailurePolicyRaiseException;
-    return adoptNS(unarchiver);
-}
-
-inline id _Nullable decodeObjectOfClassForKeyFromCoder(Class _Nonnull cls, NSString * _Nonnull key, NSCoder * _Nonnull coder)
-{
-    return [coder decodeObjectOfClass:cls forKey:key];
-}

Modified: trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm (255783 => 255784)


--- trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -58,7 +58,6 @@
 #import "WebContentReader.h"
 #import "markup.h"
 #import <pal/spi/cocoa/NSAttributedStringSPI.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <pal/system/Sound.h>
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/cocoa/NSURLExtras.h>
@@ -76,7 +75,7 @@
     if (!attributedString.length)
         return nullptr;
 
-    return SharedBuffer::create(securelyArchivedDataWithRootObject(attributedString));
+    return SharedBuffer::create([NSKeyedArchiver archivedDataWithRootObject:attributedString requiringSecureCoding:YES error:nullptr]);
 }
 
 String Editor::selectionInHTMLFormat()

Modified: trunk/Source/WebCore/loader/archive/cf/LegacyWebArchiveMac.mm (255783 => 255784)


--- trunk/Source/WebCore/loader/archive/cf/LegacyWebArchiveMac.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebCore/loader/archive/cf/LegacyWebArchiveMac.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -29,8 +29,6 @@
 #import "config.h"
 #import "LegacyWebArchive.h"
 
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
-
 namespace WebCore {
 
 static NSString * const LegacyWebArchiveResourceResponseKey = @"WebResourceResponse";
@@ -44,9 +42,10 @@
         return ResourceResponse();
     
     NSURLResponse *response = nil;
-    auto unarchiver = secureUnarchiverFromData((__bridge NSData *)responseData);
+    auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:(__bridge NSData *)responseData error:nullptr]);
+    unarchiver.get().decodingFailurePolicy = NSDecodingFailurePolicyRaiseException;
     @try {
-        response = [unarchiver decodeObjectOfClass:[NSURLResponse class] forKey:LegacyWebArchiveResourceResponseKey];
+        response = [unarchiver decodeObjectOfClass:NSURLResponse.class forKey:LegacyWebArchiveResourceResponseKey];
         [unarchiver finishDecoding];
     } @catch (NSException *exception) {
         LOG_ERROR("Failed to decode NS(HTTP)URLResponse: %@", exception);
@@ -63,7 +62,7 @@
     if (!nsResponse)
         return nullptr;
 
-    auto archiver = secureArchiver();
+    auto archiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
     [archiver encodeObject:nsResponse forKey:LegacyWebArchiveResourceResponseKey];
     return (__bridge CFDataRef)archiver.get().encodedData;
 }

Modified: trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm (255783 => 255784)


--- trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -40,7 +40,6 @@
 #import <UIKit/UIImage.h>
 #import <UIKit/UIPasteboard.h>
 #import <pal/ios/UIKitSoftLink.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <pal/spi/ios/UIKitSPI.h>
 #import <wtf/ListHashSet.h>
 #import <wtf/URL.h>
@@ -436,8 +435,7 @@
     }
 
     if (content.dataInAttributedStringFormat) {
-        NSAttributedString *attributedString = unarchivedObjectOfClassesFromData([NSSet setWithObject:[NSAttributedString class]], content.dataInAttributedStringFormat->createNSData().get());
-        if (attributedString)
+        if (NSAttributedString *attributedString = [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithObject:NSAttributedString.class] fromData:content.dataInAttributedStringFormat->createNSData().get() error:nullptr])
             [representationsToRegister addRepresentingObject:attributedString];
     }
 
@@ -542,18 +540,19 @@
         if (!provider.teamData.length)
             continue;
 
-        NSDictionary *teamDataObject = unarchivedObjectOfClassesFromData([NSSet setWithObjects:[NSDictionary class], [NSString class], [NSArray class], nil], provider.teamData);
-        if (!teamDataObject)
+        NSSet *classes = [NSSet setWithObjects:NSDictionary.class, NSString.class, NSArray.class, nil];
+        id teamDataObject = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:provider.teamData error:nullptr];
+        if (![teamDataObject isKindOfClass:NSDictionary.class])
             continue;
 
         id originInTeamData = [teamDataObject objectForKey:@(originKeyForTeamData)];
-        if (![originInTeamData isKindOfClass:[NSString class]])
+        if (![originInTeamData isKindOfClass:NSString.class])
             continue;
         if (String((NSString *)originInTeamData) != origin)
             continue;
 
-        id customTypes = [(NSDictionary *)teamDataObject objectForKey:@(customTypesKeyForTeamData)];
-        if (![customTypes isKindOfClass:[NSArray class]])
+        id customTypes = [teamDataObject objectForKey:@(customTypesKeyForTeamData)];
+        if (![customTypes isKindOfClass:NSArray.class])
             continue;
 
         for (NSString *type in customTypes)
@@ -596,8 +595,11 @@
             NSMutableArray<NSString *> *typesAsNSArray = [NSMutableArray array];
             for (auto& type : data.orderedTypes())
                 [typesAsNSArray addObject:type];
-            [representationsToRegister setTeamData:securelyArchivedDataWithRootObject(@{ @(originKeyForTeamData) : data.origin(), @(customTypesKeyForTeamData) : typesAsNSArray })];
-            [representationsToRegister addData:serializedSharedBuffer.get() forType:@(PasteboardCustomData::cocoaType())];
+            NSDictionary *teamDataDictionary = @{ @(originKeyForTeamData) : data.origin(), @(customTypesKeyForTeamData) : typesAsNSArray };
+            if (NSData *teamData = [NSKeyedArchiver archivedDataWithRootObject:teamDataDictionary requiringSecureCoding:YES error:nullptr]) {
+                [representationsToRegister setTeamData:teamData];
+                [representationsToRegister addData:serializedSharedBuffer.get() forType:@(PasteboardCustomData::cocoaType())];
+            }
         }
     }
 

Modified: trunk/Source/WebCore/testing/cocoa/WebArchiveDumpSupport.mm (255783 => 255784)


--- trunk/Source/WebCore/testing/cocoa/WebArchiveDumpSupport.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebCore/testing/cocoa/WebArchiveDumpSupport.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -30,7 +30,6 @@
 #import <CFNetwork/CFHTTPMessage.h>
 #import <CFNetwork/CFNetwork.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/NeverDestroyed.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Vector.h>
@@ -43,7 +42,8 @@
 static CFURLResponseRef createCFURLResponseFromResponseData(CFDataRef responseData)
 {
     NSURLResponse *response;
-    auto unarchiver = secureUnarchiverFromData((__bridge NSData *)responseData);
+    auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:(__bridge NSData *)responseData error:nullptr]);
+    unarchiver.get().decodingFailurePolicy = NSDecodingFailurePolicyRaiseException;
     @try {
         response = [unarchiver decodeObjectOfClass:[NSURLResponse class] forKey:@"WebResourceResponse"]; // WebResourceResponseKey in WebResource.m
         [unarchiver finishDecoding];

Modified: trunk/Source/WebKit/ChangeLog (255783 => 255784)


--- trunk/Source/WebKit/ChangeLog	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/ChangeLog	2020-02-05 03:45:12 UTC (rev 255784)
@@ -1,3 +1,59 @@
+2020-02-04  Darin Adler  <[email protected]>
+
+        Remove NSKeyedArchiverSPI.h now that WebKit only uses API
+        https://bugs.webkit.org/show_bug.cgi?id=207203
+
+        Reviewed by Anders Carlsson.
+
+        * Platform/ios/AccessibilityIOS.mm:
+        (WebKit::newAccessibilityRemoteToken): Removed include of NSKeyedArchiverSPI.h;
+        use NSKeyedArchiver methods directly.
+        * Shared/Cocoa/ArgumentCodersCocoa.mm:
+        (IPC::encodeSecureCodingInternal): Ditto.
+        (IPC::decodeSecureCodingInternal): Ditto.
+
+        * Shared/Cocoa/DataDetectionResult.mm: Removed include of NSKeyedArchiverSPI.h.
+        * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: Ditto.
+        * Shared/ios/InteractionInformationAtPosition.mm: Ditto.
+
+        * Shared/mac/WebCoreArgumentCodersMac.mm:
+        (IPC::ArgumentCoder<WebCore::ContentFilterUnblockHandler>::encode): Removed
+        include of NSKeyedArchiverSPI.h; use NSKeyedArchiver methods directly.
+        (IPC::ArgumentCoder<WebCore::ContentFilterUnblockHandler>::decode): Ditto.
+
+        * Shared/mac/WebHitTestResultData.mm: Removed include of NSKeyedArchiverSPI.h.
+
+        * UIProcess/API/Cocoa/APIAttachmentCocoa.mm:
+        (API::Attachment::createSerializedRepresentation const): Removed
+        include of NSKeyedArchiverSPI.h; use NSKeyedArchiver methods directly. Also
+        refactored so the !CAN_SECURELY_ARCHIVE_FILE_WRAPPER path shares more code
+        with the modern code path. I think we can remove it entirely once we bump
+        the minimum version of macOS a bit more.
+        (API::Attachment::updateFromSerializedRepresentation): Ditto.
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (-[WKProcessPool _setObject:forBundleParameter:]): Ditto.
+        (-[WKProcessPool _setObjectsForBundleParametersWithDictionary:]): Ditto.
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView initWithCoder:]): Ditto.
+        (-[WKWebView _setInputDelegate:]): Ditto.
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration initWithCoder:]): Ditto.
+        * UIProcess/API/Cocoa/_WKApplicationManifest.mm:
+        (-[_WKApplicationManifest initWithCoder:]): Ditto.
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess): Ditto.
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::elementDidFocus): Ditto.
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
+        (-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]): Ditto.
+        * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm: Removed include of NSKeyedArchiverSPI.h
+        (WebKit::createUnarchiver): Added helper function to make the code below less repetitive.
+        (WebKit::InjectedBundle::initialize): Use the createUnarchiver function above and the
+        NSKeyedArchiver methods directly.
+        (WebKit::InjectedBundle::classesForCoder): Ditto.
+        (WebKit::InjectedBundle::setBundleParameter): Ditto.
+        (WebKit::InjectedBundle::setBundleParameters): Ditto.
+
 2020-02-04  Tim Horton  <[email protected]>
 
         macCatalyst: Shouldn't get text cursor on checkboxes

Modified: trunk/Source/WebKit/Platform/ios/AccessibilityIOS.mm (255783 => 255784)


--- trunk/Source/WebKit/Platform/ios/AccessibilityIOS.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/Platform/ios/AccessibilityIOS.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -25,7 +25,6 @@
 
 #import "config.h"
 #import "AccessibilityIOS.h"
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 
 #if PLATFORM(IOS_FAMILY)
 
@@ -35,7 +34,7 @@
 {
     if (!uuid)
         return nil;
-    return securelyArchivedDataWithRootObject(@{ @"ax-pid" : @(getpid()), @"ax-uuid" : [uuid UUIDString], @"ax-register" : @YES });
+    return [NSKeyedArchiver archivedDataWithRootObject:@{ @"ax-pid" : @(getpid()), @"ax-uuid" : uuid.UUIDString, @"ax-register" : @YES } requiringSecureCoding:YES error:nullptr];
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm (255783 => 255784)


--- trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -32,7 +32,6 @@
 #import "CoreTextHelpers.h"
 #import <CoreText/CTFont.h>
 #import <CoreText/CTFontDescriptor.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/HashSet.h>
 
@@ -359,7 +358,7 @@
 
 static void encodeSecureCodingInternal(Encoder& encoder, id <NSObject, NSSecureCoding> object)
 {
-    auto archiver = secureArchiver();
+    auto archiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
     [archiver encodeObject:object forKey:NSKeyedArchiveRootObjectKey];
     [archiver finishEncoding];
 
@@ -376,7 +375,8 @@
     if (!decode(decoder, data))
         return WTF::nullopt;
 
-    auto unarchiver = secureUnarchiverFromData((__bridge NSData *)data.get());
+    auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:(__bridge NSData *)data.get() error:nullptr]);
+    unarchiver.get().decodingFailurePolicy = NSDecodingFailurePolicyRaiseException;
     @try {
         id result = [unarchiver decodeObjectOfClasses:[NSSet setWithArray:allowedClasses] forKey:NSKeyedArchiveRootObjectKey];
         ASSERT(!result || [result conformsToProtocol:@protocol(NSSecureCoding)]);

Modified: trunk/Source/WebKit/Shared/Cocoa/DataDetectionResult.mm (255783 => 255784)


--- trunk/Source/WebKit/Shared/Cocoa/DataDetectionResult.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/Shared/Cocoa/DataDetectionResult.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -29,7 +29,6 @@
 #import "ArgumentCodersCocoa.h"
 #import "WebCoreArgumentCoders.h"
 #import <pal/spi/cocoa/DataDetectorsCoreSPI.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/SoftLinking.h>
 
 SOFT_LINK_PRIVATE_FRAMEWORK(DataDetectorsCore)

Modified: trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (255783 => 255784)


--- trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -35,7 +35,6 @@
 #import "DataReference.h"
 #import <WebCore/PaymentAuthorizationStatus.h>
 #import <pal/cocoa/PassKitSoftLink.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #endif
 
 #if PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm (255783 => 255784)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -29,7 +29,6 @@
 #import "ArgumentCodersCocoa.h"
 #import "WebCoreArgumentCoders.h"
 #import <pal/spi/cocoa/DataDetectorsCoreSPI.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/SoftLinking.h>
 
 SOFT_LINK_PRIVATE_FRAMEWORK(DataDetectorsCore)

Modified: trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm (255783 => 255784)


--- trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -38,7 +38,6 @@
 #import <WebCore/ResourceError.h>
 #import <WebCore/ResourceRequest.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/MachSendRight.h>
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
@@ -625,7 +624,7 @@
 
 void ArgumentCoder<WebCore::ContentFilterUnblockHandler>::encode(Encoder& encoder, const WebCore::ContentFilterUnblockHandler& contentFilterUnblockHandler)
 {
-    auto archiver = secureArchiver();
+    auto archiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
     contentFilterUnblockHandler.encode(archiver.get());
     IPC::encode(encoder, (__bridge CFDataRef)archiver.get().encodedData);
 }
@@ -636,7 +635,8 @@
     if (!IPC::decode(decoder, data))
         return false;
 
-    auto unarchiver = secureUnarchiverFromData((__bridge NSData *)data.get());
+    auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:(__bridge NSData *)data.get() error:nullptr]);
+    unarchiver.get().decodingFailurePolicy = NSDecodingFailurePolicyRaiseException;
     if (!WebCore::ContentFilterUnblockHandler::decode(unarchiver.get(), contentFilterUnblockHandler))
         return false;
 

Modified: trunk/Source/WebKit/Shared/mac/WebHitTestResultData.mm (255783 => 255784)


--- trunk/Source/WebKit/Shared/mac/WebHitTestResultData.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/Shared/mac/WebHitTestResultData.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -34,7 +34,6 @@
 #import "Encoder.h"
 #import "WebCoreArgumentCoders.h"
 #import <WebCore/TextIndicator.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <pal/spi/mac/DataDetectorsSPI.h>
 
 namespace WebKit {

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm (255783 => 255784)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -29,12 +29,12 @@
 #import "PageClient.h"
 #import <WebCore/MIMETypeRegistry.h>
 #import <WebCore/SharedBuffer.h>
+
 #if PLATFORM(IOS_FAMILY)
 #import <MobileCoreServices/MobileCoreServices.h>
 #else
 #import <CoreServices/CoreServices.h>
 #endif
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 
 #define CAN_SECURELY_ARCHIVE_FILE_WRAPPER (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)
 
@@ -161,11 +161,11 @@
         return nullptr;
 
 #if CAN_SECURELY_ARCHIVE_FILE_WRAPPER
-    NSData *serializedData = securelyArchivedDataWithRootObject(fileWrapper);
+    constexpr BOOL secureCoding = YES;
 #else
-    NSData *serializedData = insecurelyArchivedDataWithRootObject(fileWrapper);
+    constexpr BOOL secureCoding = NO;
 #endif
-
+    NSData *serializedData = [NSKeyedArchiver archivedDataWithRootObject:fileWrapper requiringSecureCoding:secureCoding error:nullptr];
     if (!serializedData)
         return nullptr;
 
@@ -182,11 +182,12 @@
         return;
 
 #if CAN_SECURELY_ARCHIVE_FILE_WRAPPER
-    NSFileWrapper *fileWrapper = unarchivedObjectOfClassesFromData(m_webPage->pageClient().serializableFileWrapperClasses(), serializedData.get());
+    NSFileWrapper *fileWrapper = [NSKeyedUnarchiver unarchivedObjectOfClasses:m_webPage->pageClient().serializableFileWrapperClasses() fromData:serializedData.get() error:nullptr];
 #else
-    NSFileWrapper *fileWrapper = insecurelyUnarchiveObjectFromData(serializedData.get());
+    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+    NSFileWrapper *fileWrapper = [NSKeyedUnarchiver unarchiveObjectWithData:serializedData.get()];
+    ALLOW_DEPRECATED_DECLARATIONS_END
 #endif
-
     if (![fileWrapper isKindOfClass:NSFileWrapper.class])
         return;
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm (255783 => 255784)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -52,7 +52,6 @@
 #import <WebCore/PluginData.h>
 #import <WebCore/RegistrableDomain.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/BlockPtr.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/WeakObjCPtr.h>
@@ -214,7 +213,7 @@
 - (void)_setObject:(id <NSCopying, NSSecureCoding>)object forBundleParameter:(NSString *)parameter
 {
     auto copy = adoptNS([(NSObject *)object copy]);
-    auto keyedArchiver = secureArchiver();
+    auto keyedArchiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
 
     @try {
         [keyedArchiver encodeObject:copy.get() forKey:@"parameter"];
@@ -235,7 +234,7 @@
 - (void)_setObjectsForBundleParametersWithDictionary:(NSDictionary *)dictionary
 {
     auto copy = adoptNS([[NSDictionary alloc] initWithDictionary:dictionary copyItems:YES]);
-    auto keyedArchiver = secureArchiver();
+    auto keyedArchiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
 
     @try {
         [keyedArchiver encodeObject:copy.get() forKey:@"parameters"];

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (255783 => 255784)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -123,7 +123,6 @@
 #import <WebCore/TextManipulationController.h>
 #import <WebCore/ViewportArguments.h>
 #import <WebCore/WritingMode.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/BlockPtr.h>
 #import <wtf/HashMap.h>
 #import <wtf/MathExtras.h>
@@ -551,11 +550,11 @@
     if (!(self = [super initWithCoder:coder]))
         return nil;
 
-    WKWebViewConfiguration *configuration = decodeObjectOfClassForKeyFromCoder([WKWebViewConfiguration class], @"configuration", coder);
+    WKWebViewConfiguration *configuration = [coder decodeObjectOfClass:[WKWebViewConfiguration class] forKey:@"configuration"];
     [self _initializeWithConfiguration:configuration];
 
     self.allowsBackForwardNavigationGestures = [coder decodeBoolForKey:@"allowsBackForwardNavigationGestures"];
-    self.customUserAgent = decodeObjectOfClassForKeyFromCoder([NSString class], @"customUserAgent", coder);
+    self.customUserAgent = [coder decodeObjectOfClass:[NSString class] forKey:@"customUserAgent"];
     self.allowsLinkPreview = [coder decodeBoolForKey:@"allowsLinkPreview"];
 
 #if PLATFORM(MAC)
@@ -2574,8 +2573,9 @@
 
             NSObject <NSSecureCoding> *userObject = nil;
             if (API::Data* data = "" {
-                auto nsData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(data->bytes())) length:data->size() freeWhenDone:NO]);
-                auto unarchiver = secureUnarchiverFromData(nsData.get());
+                auto nsData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<unsigned char*>(data->bytes()) length:data->size() freeWhenDone:NO]);
+                auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:nsData.get() error:nullptr]);
+                unarchiver.get().decodingFailurePolicy = NSDecodingFailurePolicyRaiseException;
                 @try {
                     if (auto* allowedClasses = m_webView->_page->process().processPool().allowedClassesForParameterCoding())
                         userObject = [unarchiver decodeObjectOfClasses:allowedClasses forKey:@"userObject"];

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (255783 => 255784)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -25,7 +25,6 @@
 
 #import "config.h"
 #import "WKWebViewConfigurationInternal.h"
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 
 #import "APIPageConfiguration.h"
 #import "VersionChecks.h"
@@ -319,15 +318,15 @@
     if (!(self = [self init]))
         return nil;
 
-    self.processPool = decodeObjectOfClassForKeyFromCoder([WKProcessPool class], @"processPool", coder);
-    self.preferences = decodeObjectOfClassForKeyFromCoder([WKPreferences class], @"preferences", coder);
-    self.userContentController = decodeObjectOfClassForKeyFromCoder([WKUserContentController class], @"userContentController", coder);
-    self.websiteDataStore = decodeObjectOfClassForKeyFromCoder([WKWebsiteDataStore class], @"websiteDataStore", coder);
+    self.processPool = [coder decodeObjectOfClass:[WKProcessPool class] forKey:@"processPool"];
+    self.preferences = [coder decodeObjectOfClass:[WKPreferences class] forKey:@"preferences"];
+    self.userContentController = [coder decodeObjectOfClass:[WKUserContentController class] forKey:@"userContentController"];
+    self.websiteDataStore = [coder decodeObjectOfClass:[WKWebsiteDataStore class] forKey:@"websiteDataStore"];
 
     self.suppressesIncrementalRendering = [coder decodeBoolForKey:@"suppressesIncrementalRendering"];
 
     if ([coder containsValueForKey:@"applicationNameForUserAgent"])
-        self.applicationNameForUserAgent = decodeObjectOfClassForKeyFromCoder([NSString class], @"applicationNameForUserAgent", coder);
+        self.applicationNameForUserAgent = [coder decodeObjectOfClass:[NSString class] forKey:@"applicationNameForUserAgent"];
 
     self.allowsAirPlayForMediaPlayback = [coder decodeBoolForKey:@"allowsAirPlayForMediaPlayback"];
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm (255783 => 255784)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -28,7 +28,6 @@
 
 #import <WebCore/ApplicationManifest.h>
 #import <WebCore/ApplicationManifestParser.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 
 @implementation _WKApplicationManifest
 
@@ -41,12 +40,12 @@
 
 - (instancetype)initWithCoder:(NSCoder *)aDecoder
 {
-    NSString *name = decodeObjectOfClassForKeyFromCoder([NSString class], @"name", aDecoder);
-    NSString *shortName = decodeObjectOfClassForKeyFromCoder([NSString class], @"short_name", aDecoder);
-    NSString *description = decodeObjectOfClassForKeyFromCoder([NSString class], @"description", aDecoder);
-    NSURL *scopeURL = decodeObjectOfClassForKeyFromCoder([NSURL class], @"scope", aDecoder);
+    NSString *name = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"name"];
+    NSString *shortName = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"short_name"];
+    NSString *description = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"description"];
+    NSURL *scopeURL = [aDecoder decodeObjectOfClass:[NSURL class] forKey:@"scope"];
     NSInteger display = [aDecoder decodeIntegerForKey:@"display"];
-    NSURL *startURL = decodeObjectOfClassForKeyFromCoder([NSURL class], @"start_url", aDecoder);
+    NSURL *startURL = [aDecoder decodeObjectOfClass:[NSURL class] forKey:@"start_url"];
 
     WebCore::ApplicationManifest coreApplicationManifest {
         WTF::String(name),

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (255783 => 255784)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -55,7 +55,6 @@
 #import <WebCore/SharedBuffer.h>
 #import <objc/runtime.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <sys/param.h>
 #import <wtf/FileSystem.h>
 #import <wtf/ProcessPrivilege.h>
@@ -262,7 +261,7 @@
     parameters.fontWhitelist = m_fontWhitelist;
 
     if (m_bundleParameters) {
-        auto keyedArchiver = secureArchiver();
+        auto keyedArchiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
 
         @try {
             [keyedArchiver encodeObject:m_bundleParameters.get() forKey:@"parameters"];

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (255783 => 255784)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -67,7 +67,6 @@
 #import <WebCore/SharedBuffer.h>
 #import <WebCore/TextIndicator.h>
 #import <WebCore/ValidationBubble.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/BlockPtr.h>
 
 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_webView.get()->_page->process().connection())
@@ -564,8 +563,9 @@
 
     NSObject <NSSecureCoding> *userObject = nil;
     if (API::Data* data = "" {
-        auto nsData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(data->bytes())) length:data->size() freeWhenDone:NO]);
-        auto unarchiver = secureUnarchiverFromData(nsData.get());
+        auto nsData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<unsigned char*>(data->bytes()) length:data->size() freeWhenDone:NO]);
+        auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:nsData.get() error:nullptr]);
+        unarchiver.get().decodingFailurePolicy = NSDecodingFailurePolicyRaiseException;
         @try {
             if (auto* allowedClasses = m_webView.get()->_page->process().processPool().allowedClassesForParameterCoding())
                 userObject = [unarchiver decodeObjectOfClasses:allowedClasses forKey:@"userObject"];

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm (255783 => 255784)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -61,7 +61,6 @@
 #import <WebCore/Frame.h>
 #import <WebCore/HTMLFormElement.h>
 #import <WebCore/HTMLInputElement.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/WeakObjCPtr.h>
 
 @interface NSObject (WKDeprecatedDelegateMethods)
@@ -465,7 +464,7 @@
             if (!userObject)
                 return;
 
-            auto archiver = secureArchiver();
+            auto archiver = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
             @try {
                 [archiver encodeObject:userObject forKey:@"userObject"];
             } @catch (NSException *exception) {

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm (255783 => 255784)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -39,7 +39,6 @@
 #import <WebCore/PlatformKeyboardEvent.h>
 #import <dlfcn.h>
 #import <objc/runtime.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <stdio.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/text/CString.h>
@@ -53,6 +52,7 @@
 using namespace WebCore;
 
 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
+
 static NSEventModifierFlags currentModifierFlags(id self, SEL _cmd)
 {
     auto currentModifiers = PlatformKeyboardEvent::currentStateOfModifierKeys();
@@ -71,8 +71,27 @@
     
     return modifiers;
 }
+
 #endif
 
+static RetainPtr<NSKeyedUnarchiver> createUnarchiver(const unsigned char* bytes, NSUInteger length)
+{
+    auto data = "" alloc] initWithBytesNoCopy:const_cast<unsigned char*>(bytes) length:length freeWhenDone:NO]);
+    auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:data.get() error:nullptr]);
+    unarchiver.get().decodingFailurePolicy = NSDecodingFailurePolicyRaiseException;
+    return unarchiver;
+}
+
+static RetainPtr<NSKeyedUnarchiver> createUnarchiver(const API::Data& data)
+{
+    return createUnarchiver(data.bytes(), data.size());
+}
+
+static RetainPtr<NSKeyedUnarchiver> createUnarchiver(const IPC::DataReference& data)
+{
+    return createUnarchiver(data.data(), data.size());
+}
+
 bool InjectedBundle::initialize(const WebProcessCreationParameters& parameters, API::Object* initializationUserData)
 {
     if (m_sandboxExtension) {
@@ -121,13 +140,10 @@
     }
 
     if (parameters.bundleParameterData) {
-        auto bundleParameterData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(parameters.bundleParameterData->bytes())) length:parameters.bundleParameterData->size() freeWhenDone:NO]);
-
-        auto unarchiver = secureUnarchiverFromData(bundleParameterData.get());
-
         NSDictionary *dictionary = nil;
+        auto unarchiver = createUnarchiver(*parameters.bundleParameterData);
         @try {
-            dictionary = [unarchiver.get() decodeObjectOfClass:[NSObject class] forKey:@"parameters"];
+            dictionary = [unarchiver decodeObjectOfClass:[NSObject class] forKey:@"parameters"];
             ASSERT([dictionary isKindOfClass:[NSDictionary class]]);
         } @catch (NSException *exception) {
             LOG_ERROR("Failed to decode bundle parameters: %@", exception);
@@ -222,7 +238,7 @@
 NSSet* InjectedBundle::classesForCoder()
 {
     if (!m_classesForCoder)
-        m_classesForCoder = retainPtr([NSSet setWithObjects:[NSArray class], [NSData class], [NSDate class], [NSDictionary class], [NSNull class], [NSNumber class], [NSSet class], [NSString class], [NSTimeZone class], [NSURL class], [NSUUID class], nil]);
+        m_classesForCoder = [NSSet setWithObjects:[NSArray class], [NSData class], [NSDate class], [NSDictionary class], [NSNull class], [NSNumber class], [NSSet class], [NSString class], [NSTimeZone class], [NSURL class], [NSUUID class], nil];
 
     return m_classesForCoder.get();
 }
@@ -229,11 +245,8 @@
 
 void InjectedBundle::setBundleParameter(const String& key, const IPC::DataReference& value)
 {
-    auto bundleParameterData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(value.data())) length:value.size() freeWhenDone:NO]);
-
-    auto unarchiver = secureUnarchiverFromData(bundleParameterData.get());
-
     id parameter = nil;
+    auto unarchiver = createUnarchiver(value);
     @try {
         parameter = [unarchiver decodeObjectOfClasses:classesForCoder() forKey:@"parameter"];
     } @catch (NSException *exception) {
@@ -249,11 +262,8 @@
 
 void InjectedBundle::setBundleParameters(const IPC::DataReference& value)
 {
-    auto bundleParametersData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(value.data())) length:value.size() freeWhenDone:NO]);
-
-    auto unarchiver = secureUnarchiverFromData(bundleParametersData.get());
-
     NSDictionary *parameters = nil;
+    auto unarchiver = createUnarchiver(value);
     @try {
         parameters = [unarchiver decodeObjectOfClass:[NSDictionary class] forKey:@"parameters"];
     } @catch (NSException *exception) {

Modified: trunk/Tools/ChangeLog (255783 => 255784)


--- trunk/Tools/ChangeLog	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Tools/ChangeLog	2020-02-05 03:45:12 UTC (rev 255784)
@@ -1,3 +1,16 @@
+2020-02-04  Darin Adler  <[email protected]>
+
+        Remove NSKeyedArchiverSPI.h now that WebKit only uses API
+        https://bugs.webkit.org/show_bug.cgi?id=207203
+
+        Reviewed by Anders Carlsson.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm: Removed
+        include of NSKeyedArchiverSPI.h and call methods of NSKeyedArchiver directly.
+        * TestWebKitAPI/Tests/WebKitCocoa/Coding.mm: Ditto.
+        * TestWebKitAPI/Tests/ios/WKWebViewOpaque.mm: Ditto.
+        * TestWebKitAPI/Tests/mac/EarlyKVOCrash.mm: Ditto.
+
 2020-02-04  Jonathan Bedard  <[email protected]>
 
         results.webkit.org: Support Internal in run-_javascript_core-tests

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm (255783 => 255784)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -34,7 +34,6 @@
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WKWebViewPrivate.h>
 #import <WebKit/_WKApplicationManifest.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 
 namespace TestWebKitAPI {
 
@@ -42,9 +41,10 @@
 {
     auto jsonString = @"{ \"name\": \"TestName\", \"short_name\": \"TestShortName\", \"description\": \"TestDescription\", \"scope\": \"https://test.com/app\", \"start_url\": \"https://test.com/app/index.html\", \"display\": \"minimal-ui\" }";
     RetainPtr<_WKApplicationManifest> manifest { [_WKApplicationManifest applicationManifestFromJSON:jsonString manifestURL:[NSURL URLWithString:@"https://test.com/manifest.json"] documentURL:[NSURL URLWithString:@"https://test.com/"]] };
-    
-    manifest = unarchivedObjectOfClassesFromData([NSSet setWithObject:[_WKApplicationManifest class]], securelyArchivedDataWithRootObject(manifest.get()));
-    
+
+    NSData *data = "" archivedDataWithRootObject:manifest.get() requiringSecureCoding:YES error:nullptr];
+    manifest = [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithObject:[_WKApplicationManifest class]] fromData:data error:nullptr];
+
     EXPECT_TRUE([manifest isKindOfClass:[_WKApplicationManifest class]]);
     EXPECT_STREQ("TestName", manifest.get().name.UTF8String);
     EXPECT_STREQ("TestShortName", manifest.get().shortName.UTF8String);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Coding.mm (255783 => 255784)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Coding.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Coding.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -26,7 +26,6 @@
 #import "config.h"
 
 #import <WebKit/WKProcessPoolPrivate.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/RetainPtr.h>
 
 template<typename T>
@@ -33,12 +32,14 @@
 RetainPtr<T> encodeAndDecode(T* t)
 {
     if ([t conformsToProtocol:@protocol(NSSecureCoding)]) {
-        auto data = ""
-        return unarchivedObjectOfClassesFromData([NSSet setWithObjects:[t class], nil], data);
+        NSData *data = "" archivedDataWithRootObject:t requiringSecureCoding:YES error:nullptr];
+        return [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithObject:[t class]] fromData:data error:nullptr];
     }
 
-    auto data = ""
-    return insecurelyUnarchiveObjectFromData(data);
+    NSData *data = "" archivedDataWithRootObject:t requiringSecureCoding:NO error:nullptr];
+    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+    ALLOW_DEPRECATED_DECLARATIONS_END
 }
 
 TEST(Coding, WKPreferences)
@@ -164,11 +165,11 @@
         auto a = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]);
         auto b = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]);
 
-        data = "" b.get()]);
+        data = "" archivedDataWithRootObject:@[a.get(), b.get()] requiringSecureCoding:YES error:nullptr];
     }
 
     // Then, decode and verify that the important configuration properties are the same.
-    NSArray *array = unarchivedObjectOfClassesFromData([NSSet setWithObject:[NSArray class]], data.get());
+    NSArray *array = [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithObject:[NSArray class]] fromData:data.get() error:nullptr];
 
     WKWebView *aView = array[0];
     WKWebView *bView = array[1];

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewOpaque.mm (255783 => 255784)


--- trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewOpaque.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewOpaque.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -30,7 +30,6 @@
 #import "Test.h"
 #import "TestWKWebView.h"
 #import <WebKit/WKWebViewConfigurationPrivate.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 
 @interface OpaqueTestWKWebView : TestWKWebView
 @end
@@ -112,8 +111,10 @@
 
     [webView setOpaque:YES];
 
-    auto data = ""
-    TestWKWebView *decodedWebView = insecurelyUnarchiveObjectFromData(data);
+    NSData *data = "" archivedDataWithRootObject:webView.get() requiringSecureCoding:NO error:nullptr];
+    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+    TestWKWebView *decodedWebView = [NSKeyedUnarchiver unarchiveObjectWithData:data];
+    ALLOW_DEPRECATED_DECLARATIONS_END
 
     isOpaque(decodedWebView, YES);
 }
@@ -124,8 +125,10 @@
 
     [webView setOpaque:NO];
 
-    auto data = ""
-    TestWKWebView *decodedWebView = insecurelyUnarchiveObjectFromData(data);
+    NSData *data = "" archivedDataWithRootObject:webView.get() requiringSecureCoding:NO error:nullptr];
+    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+    TestWKWebView *decodedWebView = [NSKeyedUnarchiver unarchiveObjectWithData:data];
+    ALLOW_DEPRECATED_DECLARATIONS_END
 
     isOpaque(decodedWebView, NO);
 }

Modified: trunk/Tools/TestWebKitAPI/Tests/mac/EarlyKVOCrash.mm (255783 => 255784)


--- trunk/Tools/TestWebKitAPI/Tests/mac/EarlyKVOCrash.mm	2020-02-05 02:04:09 UTC (rev 255783)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/EarlyKVOCrash.mm	2020-02-05 03:45:12 UTC (rev 255784)
@@ -26,7 +26,6 @@
 #import "config.h"
 
 #import <WebKit/WebView.h>
-#import <pal/spi/cocoa/NSKeyedArchiverSPI.h>
 #import <wtf/RetainPtr.h>
 
 @interface EarlyKVOCrashResponder : NSResponder {
@@ -86,12 +85,15 @@
 
     [webView setNextResponder:earlyKVOCrashResponder.get()];
 
-    auto data = "" earlyKVOCrashResponder.get()]);
+    NSData *data = "" archivedDataWithRootObject:@[webView.get(), earlyKVOCrashResponder.get()] requiringSecureCoding:YES error:nullptr];
 
     if ([webView conformsToProtocol:@protocol(NSSecureCoding)])
-        unarchivedObjectOfClassesFromData([NSSet setWithObjects:[NSArray class], [WebView class], [EarlyKVOCrashResponder class], nil], data);
-    else
-        insecurelyUnarchiveObjectFromData(data);
+        [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithObjects:[NSArray class], [WebView class], [EarlyKVOCrashResponder class], nil] fromData:data error:nullptr];
+    else {
+        ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+        [NSKeyedUnarchiver unarchiveObjectWithData:data];
+        ALLOW_DEPRECATED_DECLARATIONS_END
+    }
 }
 
 } // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to