Changeset 225309 in webkit
- Timestamp:
- Nov 29, 2017 5:40:56 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/PAL/ChangeLog
r225290 r225309 1 2017-11-29 Brent Fulgham <bfulgham@apple.com> 2 3 Part 2: Adopt updated NSKeyed[Un]Archiver API when available 4 https://bugs.webkit.org/show_bug.cgi?id=180127 5 <rdar://problem/35710738> 6 7 Reviewed by Simon Fraser. 8 9 The API that accepts a user-allocated NSMutableData is deprecated. Switch (for macOS 10.12 and newer) 10 to the modern API. Use the original API for macOS builds prior to 10.12. 11 12 * pal/spi/cocoa/NSKeyedArchiverSPI.h: 13 (secureArchiver): Added. 14 (secureArchiverFromMutableData): Deleted. 15 1 16 2017-11-29 Alex Christensen <achristensen@webkit.org> 2 17 -
trunk/Source/WebCore/PAL/pal/spi/cocoa/NSKeyedArchiverSPI.h
r225264 r225309 105 105 } 106 106 107 inline RetainPtr<NSKeyedArchiver> secureArchiver FromMutableData(NSMutableData *_Nonnull mutableData)107 inline RetainPtr<NSKeyedArchiver> secureArchiver() 108 108 { 109 NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:mutableData]; 109 #if USE(SECURE_ARCHIVER_API) 110 NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]; 111 #else 112 NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] init]; 110 113 [archiver setRequiresSecureCoding:YES]; 114 #endif 111 115 return adoptNS(archiver); 112 116 } -
trunk/Source/WebCore/loader/archive/cf/LegacyWebArchiveMac.mm
r225264 r225309 73 73 return nullptr; 74 74 75 #if USE(SECURE_ARCHIVER_API) 76 auto archiver = secureArchiver(); 77 [archiver encodeObject:nsResponse forKey:LegacyWebArchiveResourceResponseKey]; 78 return retainPtr((__bridge CFDataRef)archiver.get().encodedData); 79 #else 80 // Because of <rdar://problem/34063313> we can't use this for encoding in older OS's. 75 81 CFMutableDataRef responseData = CFDataCreateMutable(0, 0); 76 77 82 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:(NSMutableData *)responseData]); 78 #if USE(SECURE_ARCHIVER_API)79 // Because of <rdar://problem/34063313> we can't use this for encoding in older OS's.80 [archiver setRequiresSecureCoding:YES];81 #endif82 83 [archiver encodeObject:nsResponse forKey:LegacyWebArchiveResourceResponseKey]; 83 84 [archiver finishEncoding]; 84 85 85 86 return adoptCF(responseData); 87 #endif 86 88 } 87 89 -
trunk/Source/WebKit/ChangeLog
r225298 r225309 1 2017-11-29 Brent Fulgham <bfulgham@apple.com> 2 3 Part 2: Adopt updated NSKeyed[Un]Archiver API when available 4 https://bugs.webkit.org/show_bug.cgi?id=180127 5 <rdar://problem/35710738> 6 7 Reviewed by Simon Fraser. 8 9 The API that accepts a user-allocated NSMutableData is deprecated. Switch (for macOS 10.12 and newer) 10 to the modern API. Use the original API for macOS builds prior to 10.12. 11 12 * Shared/Cocoa/DataDetectionResult.mm: 13 (WebKit::DataDetectionResult::encode const): 14 * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: 15 (IPC::ArgumentCoder<WebCore::Payment>::encode): 16 (IPC::ArgumentCoder<WebCore::PaymentContact>::encode): 17 (IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::encode): 18 (IPC::ArgumentCoder<WebCore::PaymentMethod>::encode): 19 * Shared/ios/InteractionInformationAtPosition.mm: 20 (WebKit::InteractionInformationAtPosition::encode const): 21 * Shared/mac/WebCoreArgumentCodersMac.mm: 22 (IPC::ArgumentCoder<ProtectionSpace>::encodePlatformData): 23 (IPC::ArgumentCoder<Credential>::encodePlatformData): 24 (IPC::ArgumentCoder<ContentFilterUnblockHandler>::encode): 25 (IPC::ArgumentCoder<MediaPlaybackTargetContext>::encodePlatformData): 26 * Shared/mac/WebHitTestResultData.mm: 27 (WebKit::WebHitTestResultData::platformEncode const): 28 * UIProcess/API/Cocoa/WKProcessPool.mm: 29 (-[WKProcessPool _setObject:forBundleParameter:]): 30 (-[WKProcessPool _setObjectsForBundleParametersWithDictionary:]): 31 * UIProcess/Cocoa/WebProcessPoolCocoa.mm: 32 (WebKit::WebProcessPool::platformInitializeWebProcess): 33 * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: 34 (-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]): 35 1 36 2017-11-29 Brady Eidson <beidson@apple.com> 2 37 -
trunk/Source/WebKit/Shared/Cocoa/DataDetectionResult.mm
r225264 r225309 42 42 void DataDetectionResult::encode(IPC::Encoder& encoder) const 43 43 { 44 RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]); 45 auto archiver = secureArchiverFromMutableData(data.get()); 44 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 45 auto data = adoptNS([[NSMutableData alloc] init]); 46 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 47 [archiver setRequiresSecureCoding:YES]; 46 48 [archiver encodeObject:results.get() forKey:@"dataDetectorResults"]; 47 49 [archiver finishEncoding]; 48 49 IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get())); 50 51 IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get())); 52 #else 53 auto archiver = secureArchiver(); 54 [archiver encodeObject:results.get() forKey:@"dataDetectorResults"]; 55 IPC::encode(encoder, reinterpret_cast<CFDataRef>(archiver.get().encodedData)); 56 #endif 50 57 } 51 58 -
trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
r225264 r225309 52 52 void ArgumentCoder<WebCore::Payment>::encode(Encoder& encoder, const WebCore::Payment& payment) 53 53 { 54 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 54 55 auto data = adoptNS([[NSMutableData alloc] init]); 55 auto archiver = secureArchiverFromMutableData(data.get()); 56 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 57 58 [archiver setRequiresSecureCoding:YES]; 59 #else 60 auto archiver = secureArchiver(); 61 #endif 56 62 57 63 [archiver encodeObject:payment.pkPayment() forKey:NSKeyedArchiveRootObjectKey]; 58 64 [archiver finishEncoding]; 65 66 #if (!PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) 67 auto data = archiver.get().encodedData; 68 #endif 59 69 60 70 encoder << DataReference(static_cast<const uint8_t*>([data bytes]), [data length]); … … 104 114 void ArgumentCoder<WebCore::PaymentContact>::encode(Encoder& encoder, const WebCore::PaymentContact& paymentContact) 105 115 { 116 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 106 117 auto data = adoptNS([[NSMutableData alloc] init]); 107 auto archiver = secureArchiverFromMutableData(data.get()); 118 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 119 120 [archiver setRequiresSecureCoding:YES]; 121 #else 122 auto archiver = secureArchiver(); 123 #endif 108 124 109 125 [archiver encodeObject:paymentContact.pkContact() forKey:NSKeyedArchiveRootObjectKey]; 110 126 [archiver finishEncoding]; 127 128 #if (!PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) 129 auto data = archiver.get().encodedData; 130 #endif 111 131 112 132 encoder << DataReference(static_cast<const uint8_t*>([data bytes]), [data length]); … … 162 182 void ArgumentCoder<WebCore::PaymentMerchantSession>::encode(Encoder& encoder, const WebCore::PaymentMerchantSession& paymentMerchantSession) 163 183 { 184 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 164 185 auto data = adoptNS([[NSMutableData alloc] init]); 165 auto archiver = secureArchiverFromMutableData(data.get()); 186 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 187 188 [archiver setRequiresSecureCoding:YES]; 189 #else 190 auto archiver = secureArchiver(); 191 #endif 166 192 167 193 [archiver encodeObject:paymentMerchantSession.pkPaymentMerchantSession() forKey:NSKeyedArchiveRootObjectKey]; 168 194 [archiver finishEncoding]; 195 196 #if (!PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) 197 auto data = archiver.get().encodedData; 198 #endif 169 199 170 200 encoder << DataReference(static_cast<const uint8_t*>([data bytes]), [data length]); … … 193 223 void ArgumentCoder<WebCore::PaymentMethod>::encode(Encoder& encoder, const WebCore::PaymentMethod& paymentMethod) 194 224 { 225 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 195 226 auto data = adoptNS([[NSMutableData alloc] init]); 196 auto archiver = secureArchiverFromMutableData(data.get()); 227 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 228 229 [archiver setRequiresSecureCoding:YES]; 230 #else 231 auto archiver = secureArchiver(); 232 #endif 197 233 198 234 [archiver encodeObject:paymentMethod.pkPaymentMethod() forKey:NSKeyedArchiveRootObjectKey]; 199 235 [archiver finishEncoding]; 236 237 #if (!PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) 238 auto data = archiver.get().encodedData; 239 #endif 200 240 201 241 encoder << DataReference(static_cast<const uint8_t*>([data bytes]), [data length]); -
trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm
r225264 r225309 74 74 if (isDataDetectorLink) { 75 75 encoder << dataDetectorIdentifier; 76 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 76 77 RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]); 77 78 auto archiver = secureArchiverFromMutableData(data.get()); … … 79 80 [archiver finishEncoding]; 80 81 81 IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get())); 82 IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get())); 83 #else 84 auto archiver = secureArchiver(); 85 [archiver encodeObject:dataDetectorResults.get() forKey:@"dataDetectorResults"]; 86 87 IPC::encode(encoder, reinterpret_cast<CFDataRef>(archiver.get().encodedData)); 88 #endif 82 89 } 83 90 #endif -
trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm
r225264 r225309 430 430 void ArgumentCoder<ProtectionSpace>::encodePlatformData(Encoder& encoder, const ProtectionSpace& space) 431 431 { 432 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 432 433 auto data = adoptNS([[NSMutableData alloc] init]); 433 auto archiver = secureArchiverFromMutableData(data.get()); 434 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 435 [archiver setRequiresSecureCoding:YES]; 434 436 [archiver encodeObject:space.nsSpace() forKey:@"protectionSpace"]; 435 437 [archiver finishEncoding]; 436 438 IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get())); 439 #else 440 auto archiver = secureArchiver(); 441 [archiver encodeObject:space.nsSpace() forKey:@"protectionSpace"]; 442 IPC::encode(encoder, reinterpret_cast<CFDataRef>(archiver.get().encodedData)); 443 #endif 437 444 } 438 445 … … 475 482 476 483 encoder << false; 484 485 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 477 486 auto data = adoptNS([[NSMutableData alloc] init]); 478 auto archiver = secureArchiverFromMutableData(data.get()); 487 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 488 [archiver setRequiresSecureCoding:YES]; 479 489 [archiver encodeObject:nsCredential forKey:@"credential"]; 480 490 [archiver finishEncoding]; 481 491 IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get())); 492 #else 493 auto archiver = secureArchiver(); 494 [archiver encodeObject:nsCredential forKey:@"credential"]; 495 IPC::encode(encoder, reinterpret_cast<CFDataRef>(archiver.get().encodedData)); 496 #endif 482 497 } 483 498 … … 576 591 void ArgumentCoder<ContentFilterUnblockHandler>::encode(Encoder& encoder, const ContentFilterUnblockHandler& contentFilterUnblockHandler) 577 592 { 593 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 578 594 auto data = adoptNS([[NSMutableData alloc] init]); 579 auto archiver = secureArchiverFromMutableData(data.get()); 595 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 596 [archiver setRequiresSecureCoding:YES]; 580 597 contentFilterUnblockHandler.encode(archiver.get()); 581 598 [archiver finishEncoding]; 582 599 IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get())); 600 #else 601 auto archiver = secureArchiver(); 602 contentFilterUnblockHandler.encode(archiver.get()); 603 IPC::encode(encoder, reinterpret_cast<CFDataRef>(archiver.get().encodedData)); 604 #endif 583 605 } 584 606 … … 608 630 void ArgumentCoder<MediaPlaybackTargetContext>::encodePlatformData(Encoder& encoder, const MediaPlaybackTargetContext& target) 609 631 { 632 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 610 633 auto data = adoptNS([[NSMutableData alloc] init]); 611 auto archiver = secureArchiverFromMutableData(data.get()); 634 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 635 [archiver setRequiresSecureCoding:YES]; 612 636 613 637 if ([getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)]) … … 616 640 [archiver finishEncoding]; 617 641 IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get())); 618 642 #else 643 auto archiver = secureArchiver(); 644 645 if ([getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)]) 646 [archiver encodeObject:target.avOutputContext() forKey:deviceContextKey()]; 647 648 IPC::encode(encoder, reinterpret_cast<CFDataRef>(archiver.get().encodedData)); 649 #endif 619 650 } 620 651 -
trunk/Source/WebKit/Shared/mac/WebHitTestResultData.mm
r225264 r225309 46 46 return; 47 47 48 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 48 49 auto data = adoptNS([[NSMutableData alloc] init]); 49 auto archiver = secureArchiverFromMutableData(data.get()); 50 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 51 [archiver setRequiresSecureCoding:YES]; 50 52 [archiver encodeObject:detectedDataActionContext.get() forKey:@"actionContext"]; 51 53 [archiver finishEncoding]; 52 54 53 55 IPC::encode(encoder, reinterpret_cast<CFDataRef>(data.get())); 56 #else 57 auto archiver = secureArchiver(); 58 [archiver encodeObject:detectedDataActionContext.get() forKey:@"actionContext"]; 59 60 IPC::encode(encoder, reinterpret_cast<CFDataRef>(archiver.get().encodedData)); 61 #endif 54 62 55 63 encoder << detectedDataBoundingBox; -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
r225264 r225309 214 214 auto copy = adoptNS([(NSObject *)object copy]); 215 215 216 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 216 217 auto data = adoptNS([[NSMutableData alloc] init]); 217 auto keyedArchiver = secureArchiverFromMutableData(data.get()); 218 auto keyedArchiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 219 [keyedArchiver setRequiresSecureCoding:YES]; 220 #else 221 auto keyedArchiver = secureArchiver(); 222 #endif 218 223 219 224 @try { … … 229 234 [_processPool->ensureBundleParameters() removeObjectForKey:parameter]; 230 235 236 #if (!PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) 237 auto data = keyedArchiver.get().encodedData; 238 #endif 239 231 240 _processPool->sendToAllProcesses(Messages::WebProcess::SetInjectedBundleParameter(parameter, IPC::DataReference(static_cast<const uint8_t*>([data bytes]), [data length]))); 232 241 } … … 236 245 auto copy = adoptNS([[NSDictionary alloc] initWithDictionary:dictionary copyItems:YES]); 237 246 247 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 238 248 auto data = adoptNS([[NSMutableData alloc] init]); 239 auto keyedArchiver = secureArchiverFromMutableData(data.get()); 249 auto keyedArchiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 250 [keyedArchiver setRequiresSecureCoding:YES]; 251 #else 252 auto keyedArchiver = secureArchiver(); 253 #endif 240 254 241 255 @try { … … 247 261 248 262 [_processPool->ensureBundleParameters() setValuesForKeysWithDictionary:copy.get()]; 263 264 #if (!PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) 265 auto data = keyedArchiver.get().encodedData; 266 #endif 249 267 250 268 _processPool->sendToAllProcesses(Messages::WebProcess::SetInjectedBundleParameters(IPC::DataReference(static_cast<const uint8_t*>([data bytes]), [data length]))); -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
r225264 r225309 216 216 217 217 if (m_bundleParameters) { 218 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 218 219 auto data = adoptNS([[NSMutableData alloc] init]); 219 auto keyedArchiver = secureArchiverFromMutableData(data.get()); 220 auto keyedArchiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 221 222 [keyedArchiver setRequiresSecureCoding:YES]; 223 #else 224 auto keyedArchiver = secureArchiver(); 225 #endif 220 226 221 227 @try { … … 225 231 LOG_ERROR("Failed to encode bundle parameters: %@", exception); 226 232 } 233 234 #if (!PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) 235 auto data = retainPtr(keyedArchiver.get().encodedData); 236 #endif 227 237 228 238 parameters.bundleParameterData = API::Data::createWithoutCopying((const unsigned char*)[data bytes], [data length], [] (unsigned char*, const void* data) { -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
r225264 r225309 485 485 return; 486 486 487 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 487 488 auto data = adoptNS([[NSMutableData alloc] init]); 488 auto archiver = secureArchiverFromMutableData(data.get()); 489 auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]); 490 [archiver setRequiresSecureCoding:YES]; 491 #else 492 auto archiver = secureArchiver(); 493 #endif 489 494 @try { 490 495 [archiver encodeObject:userObject forKey:@"userObject"]; … … 494 499 } 495 500 [archiver finishEncoding]; 501 502 #if (!PLATFORM(MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) 503 auto data = retainPtr(archiver.get().encodedData); 504 #endif 496 505 497 506 userData = API::Data::createWithoutCopying(WTFMove(data));
Note: See TracChangeset
for help on using the changeset viewer.