[macOS, iOS] Adopt new secure coding APIs in WebKit
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Jan 2018 05:10:37 +0000 (05:10 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Jan 2018 05:10:37 +0000 (05:10 +0000)
commit2b10b898a9f7760ee5d8310a530151562008ece2
tree1efafe870a2504d167952cee639226b3f4a0cff0
parent9d2c9103e40be3149d1d2df1c0a302d756f17a1d
[macOS, iOS] Adopt new secure coding APIs in WebKit
https://bugs.webkit.org/show_bug.cgi?id=181085
<rdar://problem/34837397>

Reviewed by Tim Horton.

Source/WebCore/PAL:

Add a new helper function to allow WebKit code to use NSSecureCoding in more
places when the underlying operating system supports it.

* pal/spi/cocoa/NSKeyedArchiverSPI.h:
(decodeObjectOfClassForKeyFromCoder): New wrapper method.

Source/WebKit:

Update WebKit code to use NSSecureCoding when the underlying operating system supports it. Use new
wrapper functions so the same code can be built on all supported OS releases, while enabling
seure coding when possible.

Note that NSView-based classes cannot be migrated at present due to AppKit not supporting NSSecureCoding
in its class hierarchy.

Tested by exising TestWebKitAPI tests for Coding and data transfer.

* Platform/ios/AccessibilityIOS.mm:
(WebKit::newAccessibilityRemoteToken): Encode using NSSecureCoding.
* UIProcess/API/Cocoa/WKPreferences.h:
* UIProcess/API/Cocoa/WKPreferences.mm:
(+[WKPreferences supportsSecureCoding]): Added to enable NSSecureCoding.
* UIProcess/API/Cocoa/WKProcessPool.h:
* UIProcess/API/Cocoa/WKProcessPool.mm:
(+[WKProcessPool supportsSecureCoding]): Ditto.
* UIProcess/API/Cocoa/WKUserContentController.h:
* UIProcess/API/Cocoa/WKUserContentController.mm:
(+[WKUserContentController supportsSecureCoding]): Ditto.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithCoder:]): Use coding initialization that supports secure coding if
it is available in the supplied class.
* UIProcess/API/Cocoa/WKWebViewConfiguration.h:
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(+[WKWebViewConfiguration supportsSecureCoding]): Added to enable NSSecureCoding.
(-[WKWebViewConfiguration initWithCoder:]): Use secure coding when possible.
* UIProcess/API/Cocoa/WKWebsiteDataStore.h:
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(+[WKWebsiteDataStore supportsSecureCoding]): Added to enable NSSecureCoding.
* UIProcess/API/Cocoa/_WKApplicationManifest.h:
* UIProcess/API/Cocoa/_WKApplicationManifest.mm:
(+[_WKApplicationManifest supportsSecureCoding]): Added to enable NSSecureCoding.
(-[_WKApplicationManifest initWithCoder:]): Use secure coding when possible.

Tools:

Update API tests to use secure coding wherever possible. Currently, NSView/UIView-based classes are not
capable of supporting NSSecureCoding, so pass through the current coding routines.

* TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm: Updated for NSSecureCoding.
* TestWebKitAPI/Tests/WebKitCocoa/Coding.mm:
(encodeAndDecode): Check if class supports the NSSecureCoding protocol and use non-secure coding
routines if necessary.
(TEST): Updated for NSSecureCoding.
* TestWebKitAPI/Tests/mac/EarlyKVOCrash.mm:
(TestWebKitAPI::TEST): Updated for NSSecureCoding.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226353 268f45cc-cd09-0410-ab3c-d52691b4dbfc
21 files changed:
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cocoa/NSKeyedArchiverSPI.h
Source/WebKit/ChangeLog
Source/WebKit/Platform/ios/AccessibilityIOS.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.h
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.h
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/API/Cocoa/WKUserContentController.h
Source/WebKit/UIProcess/API/Cocoa/WKUserContentController.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.h
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.h
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.h
Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplicationManifest.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/Coding.mm
Tools/TestWebKitAPI/Tests/mac/EarlyKVOCrash.mm