Changeset 220718 in webkit
- Timestamp:
- Aug 14, 2017 3:03:56 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r220717 r220718 1 2017-08-14 Andy Estes <aestes@apple.com> 2 3 [Apple Pay] Add support for phonetic contact names 4 https://bugs.webkit.org/show_bug.cgi?id=175537 5 <rdar://problem/32002644> 6 7 Reviewed by Tim Horton. 8 9 * http/tests/ssl/applepay/ApplePayError-expected.txt: 10 * http/tests/ssl/applepay/ApplePayError.html: 11 * http/tests/ssl/applepay/ApplePaySession-expected.txt: 12 * http/tests/ssl/applepay/ApplePaySession.html: 13 * http/tests/ssl/applepay/ApplePaySessionV3-expected.txt: 14 * http/tests/ssl/applepay/ApplePaySessionV3.html: 15 1 16 2017-08-14 Said Abou-Hallawa <sabouhallawa@apple.com> 2 17 -
trunk/LayoutTests/http/tests/ssl/applepay/ApplePayError-expected.txt
r217086 r220718 28 28 29 29 SETUP: 30 PASS new ApplePayError('unknown', []) threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "p ostalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode".30 PASS new ApplePayError('unknown', []) threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "phoneticName", "postalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode". 31 31 32 32 SETUP: 33 PASS new ApplePayError('unknown', '') threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "p ostalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode".33 PASS new ApplePayError('unknown', '') threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "phoneticName", "postalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode". 34 34 35 35 SETUP: … … 41 41 SETUP: 42 42 PASS new ApplePayError('unknown', 'name') did not throw exception. 43 44 SETUP: 45 PASS new ApplePayError('unknown', 'phoneticName') did not throw exception. 43 46 44 47 SETUP: -
trunk/LayoutTests/http/tests/ssl/applepay/ApplePayError.html
r217086 r220718 41 41 logAndShouldNotThrow("", "new ApplePayError('unknown', 'emailAddress')") 42 42 logAndShouldNotThrow("", "new ApplePayError('unknown', 'name')") 43 logAndShouldNotThrow("", "new ApplePayError('unknown', 'phoneticName')") 43 44 logAndShouldNotThrow("", "new ApplePayError('unknown', 'postalAddress')") 44 45 logAndShouldNotThrow("", "new ApplePayError('unknown', 'addressLines')") -
trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt
r219896 r220718 232 232 PASS new ApplePaySession(2, request) threw exception TypeError: Type error. 233 233 234 SETUP: request = validRequest(); request.requiredBillingContactFields = ['phoneticName']; 235 PASS new ApplePaySession(2, request) threw exception TypeError: "phoneticName" is not a valid contact field.. 236 234 237 SETUP: request = validRequest(); request.requiredBillingContactFields = ['email', 'name', 'phone', 'postalAddress']; 235 238 PASS new ApplePaySession(2, request) did not throw exception. … … 289 292 SETUP: request = validRequest(); request.requiredShippingContactFields = ['invalid']; 290 293 PASS new ApplePaySession(2, request) threw exception TypeError: Type error. 294 295 SETUP: request = validRequest(); request.requiredShippingContactFields = ['phoneticName']; 296 PASS new ApplePaySession(2, request) threw exception TypeError: "phoneticName" is not a valid contact field.. 291 297 292 298 SETUP: request = validRequest(); request.requiredShippingContactFields = ['email', 'name', 'phone', 'postalAddress']; -
trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html
r219896 r220718 136 136 logAndShouldThrow("request = validRequest(); request.requiredBillingContactFields = [{}];", "new ApplePaySession(2, request)") 137 137 logAndShouldThrow("request = validRequest(); request.requiredBillingContactFields = ['invalid'];", "new ApplePaySession(2, request)") 138 logAndShouldThrow("request = validRequest(); request.requiredBillingContactFields = ['phoneticName'];", "new ApplePaySession(2, request)") 138 139 logAndShouldNotThrow("request = validRequest(); request.requiredBillingContactFields = ['email', 'name', 'phone', 'postalAddress'];", "new ApplePaySession(2, request)") 139 140 // FIXME: Should duplicate contactFields be allowed? … … 161 162 logAndShouldThrow("request = validRequest(); request.requiredShippingContactFields = [{}];", "new ApplePaySession(2, request)") 162 163 logAndShouldThrow("request = validRequest(); request.requiredShippingContactFields = ['invalid'];", "new ApplePaySession(2, request)") 164 logAndShouldThrow("request = validRequest(); request.requiredShippingContactFields = ['phoneticName'];", "new ApplePaySession(2, request)") 163 165 logAndShouldNotThrow("request = validRequest(); request.requiredShippingContactFields = ['email', 'name', 'phone', 'postalAddress'];", "new ApplePaySession(2, request)") 164 166 // FIXME: Should duplicate contactFields be allowed? -
trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3-expected.txt
r217723 r220718 44 44 PASS new ApplePaySession(3, request) did not throw exception. 45 45 46 SETUP: request = validRequest(); request.requiredBillingContactFields = ['phoneticName']; 47 PASS new ApplePaySession(3, request) did not throw exception. 48 49 SETUP: request = validRequest(); request.requiredShippingContactFields = ['phoneticName']; 50 PASS new ApplePaySession(3, request) did not throw exception. 51 46 52 47 53 PASS successfullyParsed is true -
trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3.html
r219896 r220718 57 57 logAndShouldNotThrow("request = validRequest(); request.supportedCountries = ['US'];", "new ApplePaySession(3, request)"); 58 58 logAndShouldNotThrow("request = validRequest(); request.supportedCountries = ['US', 'US'];", "new ApplePaySession(3, request)"); 59 logAndShouldNotThrow("request = validRequest(); request.requiredBillingContactFields = ['phoneticName'];", "new ApplePaySession(3, request)") 60 logAndShouldNotThrow("request = validRequest(); request.requiredShippingContactFields = ['phoneticName'];", "new ApplePaySession(3, request)") 59 61 debug(""); 60 62 -
trunk/Source/WebCore/ChangeLog
r220717 r220718 1 2017-08-14 Andy Estes <aestes@apple.com> 2 3 [Apple Pay] Add support for phonetic contact names 4 https://bugs.webkit.org/show_bug.cgi?id=175537 5 <rdar://problem/32002644> 6 7 Reviewed by Tim Horton. 8 9 * Modules/applepay/ApplePayError.idl: Defined "phoneticName" in ApplePayErrorContactField. 10 * Modules/applepay/ApplePayPaymentContact.h: Defined phoneticGivenName and phoneticFamilyName 11 in ApplePayPaymentContact. 12 * Modules/applepay/ApplePayPaymentContact.idl: Ditto. 13 * Modules/applepay/ApplePayPaymentRequest.h: Defined PhoneticName in 14 ApplePayPaymentRequest::ContactField. 15 * Modules/applepay/ApplePayPaymentRequest.idl: Defined "phoneticName" in ApplePayContactField. 16 * Modules/applepay/ApplePaySession.cpp: 17 (WebCore::convertAndValidate): Added a version parameter. Added code to convert 18 ContactField::PhoneticName, throwing an exception if version is less than 3. 19 * Modules/applepay/PaymentContact.h: Added a version parameter to fromApplePayPaymentContact(). 20 * Modules/applepay/PaymentRequest.h: Defined phoneticName in PaymentRequest::ContactFields 21 and defined PhoneticName in PaymentError::ContactField. 22 * Modules/applepay/cocoa/PaymentContactCocoa.mm: 23 (WebCore::convert): Added a version parameter. Set a phoneticRepresentation on the 24 PKContact's name if there are non-empty phonetic names and version is 3 or greater. 25 (WebCore::PaymentContact::fromApplePayPaymentContact): Passed version to convert(). 26 1 27 2017-08-14 Said Abou-Hallawa <sabouhallawa@apple.com> 2 28 -
trunk/Source/WebCore/Modules/applepay/ApplePayError.idl
r217626 r220718 39 39 "emailAddress", 40 40 "name", 41 "phoneticName", 41 42 "postalAddress", 42 43 "addressLines", -
trunk/Source/WebCore/Modules/applepay/ApplePayPaymentContact.h
r209927 r220718 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 39 39 String givenName; 40 40 String familyName; 41 String phoneticGivenName; 42 String phoneticFamilyName; 41 43 std::optional<Vector<String>> addressLines; 42 44 String locality; -
trunk/Source/WebCore/Modules/applepay/ApplePayPaymentContact.idl
r209927 r220718 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 DOMString givenName; 33 33 DOMString familyName; 34 [Conditional=APPLE_PAY_SESSION_V3] DOMString phoneticGivenName; 35 [Conditional=APPLE_PAY_SESSION_V3] DOMString phoneticFamilyName; 34 36 sequence<DOMString> addressLines; 35 37 DOMString locality; -
trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h
r217723 r220718 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 struct ApplePayPaymentRequest { 38 38 enum class MerchantCapability { Supports3DS, SupportsEMV, SupportsCredit, SupportsDebit }; 39 enum class ContactField { Email, Name, Phone , PostalAddress };39 enum class ContactField { Email, Name, PhoneticName, Phone, PostalAddress }; 40 40 41 41 using ShippingType = PaymentRequest::ShippingType; -
trunk/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.idl
r217723 r220718 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 38 38 "email", 39 39 "name", 40 "phoneticName", 40 41 "phone", 41 42 "postalAddress" -
trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp
r219856 r220718 1 1 /* 2 * Copyright (C) 2015 , 2016Apple Inc. All rights reserved.2 * Copyright (C) 2015-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 258 258 } 259 259 260 static ExceptionOr<PaymentRequest::ContactFields> convertAndValidate( Vector<ApplePayPaymentRequest::ContactField>&& contactFields)260 static ExceptionOr<PaymentRequest::ContactFields> convertAndValidate(unsigned version, Vector<ApplePayPaymentRequest::ContactField>&& contactFields) 261 261 { 262 262 PaymentRequest::ContactFields result; … … 269 269 case ApplePayPaymentRequest::ContactField::Name: 270 270 result.name = true; 271 break; 272 case ApplePayPaymentRequest::ContactField::PhoneticName: 273 if (version < 3) 274 return Exception { TypeError, "\"phoneticName\" is not a valid contact field." }; 275 result.phoneticName = true; 271 276 break; 272 277 case ApplePayPaymentRequest::ContactField::Phone: … … 340 345 341 346 if (paymentRequest.requiredBillingContactFields) { 342 auto requiredBillingContactFields = convertAndValidate( WTFMove(*paymentRequest.requiredBillingContactFields));347 auto requiredBillingContactFields = convertAndValidate(version, WTFMove(*paymentRequest.requiredBillingContactFields)); 343 348 if (requiredBillingContactFields.hasException()) 344 349 return requiredBillingContactFields.releaseException(); … … 347 352 348 353 if (paymentRequest.billingContact) 349 result.setBillingContact(PaymentContact::fromApplePayPaymentContact( paymentRequest.billingContact.value()));354 result.setBillingContact(PaymentContact::fromApplePayPaymentContact(version, paymentRequest.billingContact.value())); 350 355 351 356 if (paymentRequest.requiredShippingContactFields) { 352 auto requiredShippingContactFields = convertAndValidate( WTFMove(*paymentRequest.requiredShippingContactFields));357 auto requiredShippingContactFields = convertAndValidate(version, WTFMove(*paymentRequest.requiredShippingContactFields)); 353 358 if (requiredShippingContactFields.hasException()) 354 359 return requiredShippingContactFields.releaseException(); … … 357 362 358 363 if (paymentRequest.shippingContact) 359 result.setShippingContact(PaymentContact::fromApplePayPaymentContact( paymentRequest.shippingContact.value()));364 result.setShippingContact(PaymentContact::fromApplePayPaymentContact(version, paymentRequest.shippingContact.value())); 360 365 361 366 result.setShippingType(paymentRequest.shippingType); -
trunk/Source/WebCore/Modules/applepay/PaymentContact.h
r209927 r220718 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 45 45 } 46 46 47 static PaymentContact fromApplePayPaymentContact( const ApplePayPaymentContact&);47 static PaymentContact fromApplePayPaymentContact(unsigned version, const ApplePayPaymentContact&); 48 48 ApplePayPaymentContact toApplePayPaymentContact() const; 49 49 -
trunk/Source/WebCore/Modules/applepay/PaymentRequest.h
r217723 r220718 1 1 /* 2 * Copyright (C) 2015 , 2016Apple Inc. All rights reserved.2 * Copyright (C) 2015-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 54 54 bool email { false }; 55 55 bool name { false }; 56 bool phoneticName { false }; 56 57 }; 57 58 … … 167 168 EmailAddress, 168 169 Name, 170 PhoneticName, 169 171 PostalAddress, 170 172 AddressLines, -
trunk/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm
r220506 r220718 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 49 49 namespace WebCore { 50 50 51 static RetainPtr<PKContact> convert( const ApplePayPaymentContact& contact)51 static RetainPtr<PKContact> convert(unsigned version, const ApplePayPaymentContact& contact) 52 52 { 53 53 auto result = adoptNS([allocPKContactInstance() init]); 54 54 55 if (!contact.familyName.isEmpty() || !contact.givenName.isEmpty()) { 55 NSString *familyName = nil; 56 NSString *phoneticFamilyName = nil; 57 if (!contact.familyName.isEmpty()) { 58 familyName = contact.familyName; 59 if (version >= 3 && !contact.phoneticFamilyName.isEmpty()) 60 phoneticFamilyName = contact.phoneticFamilyName; 61 } 62 63 NSString *givenName = nil; 64 NSString *phoneticGivenName = nil; 65 if (!contact.givenName.isEmpty()) { 66 givenName = contact.givenName; 67 if (version >= 3 && !contact.phoneticGivenName.isEmpty()) 68 phoneticGivenName = contact.phoneticGivenName; 69 } 70 71 if (familyName || givenName) { 56 72 auto name = adoptNS([[NSPersonNameComponents alloc] init]); 57 [name setFamilyName:contact.familyName]; 58 [name setGivenName:contact.givenName]; 73 [name setFamilyName:familyName]; 74 [name setGivenName:givenName]; 75 if (phoneticFamilyName || phoneticGivenName) { 76 auto phoneticName = adoptNS([[NSPersonNameComponents alloc] init]); 77 [phoneticName setFamilyName:phoneticFamilyName]; 78 [phoneticName setGivenName:phoneticGivenName]; 79 [name setPhoneticRepresentation:phoneticName.get()]; 80 } 59 81 [result setName:name.get()]; 60 82 } … … 75 97 builder.append('\n'); 76 98 } 77 99 78 100 // FIXME: StringBuilder should hava a toNSString() function to avoid the extra String allocation. 79 101 [address setStreet:builder.toString()]; … … 102 124 ApplePayPaymentContact result; 103 125 104 if (contact.phoneNumber) 105 result.phoneNumber = contact.phoneNumber.stringValue; 106 if (contact.emailAddress) 107 result.emailAddress = contact.emailAddress; 108 if (contact.name.givenName) 109 result.givenName = contact.name.givenName; 110 if (contact.name.familyName) 111 result.familyName = contact.name.familyName; 112 if (contact.postalAddress.street.length) { 126 result.phoneNumber = contact.phoneNumber.stringValue; 127 result.emailAddress = contact.emailAddress; 128 129 NSPersonNameComponents *name = contact.name; 130 result.givenName = name.givenName; 131 result.familyName = name.familyName; 132 133 NSPersonNameComponents *phoneticName = name.phoneticRepresentation; 134 result.phoneticGivenName = phoneticName.givenName; 135 result.phoneticFamilyName = phoneticName.familyName; 136 137 CNPostalAddress *postalAddress = contact.postalAddress; 138 if (postalAddress.street.length) { 113 139 Vector<String> addressLines; 114 String( contact.postalAddress.street).split("\n", addressLines);140 String(postalAddress.street).split("\n", addressLines); 115 141 result.addressLines = WTFMove(addressLines); 116 142 } 117 if (contact.postalAddress.city) 118 result.locality = contact.postalAddress.city; 119 if (contact.postalAddress.postalCode) 120 result.postalCode = contact.postalAddress.postalCode; 121 if (contact.postalAddress.state) 122 result.administrativeArea = contact.postalAddress.state; 123 if (contact.postalAddress.country) 124 result.country = contact.postalAddress.country; 125 if (contact.postalAddress.ISOCountryCode) 126 result.countryCode = contact.postalAddress.ISOCountryCode; 143 result.locality = postalAddress.city; 144 result.postalCode = postalAddress.postalCode; 145 result.administrativeArea = postalAddress.state; 146 result.country = postalAddress.country; 147 result.countryCode = postalAddress.ISOCountryCode; 127 148 128 149 return result; 129 150 } 130 151 131 PaymentContact PaymentContact::fromApplePayPaymentContact( const ApplePayPaymentContact& contact)152 PaymentContact PaymentContact::fromApplePayPaymentContact(unsigned version, const ApplePayPaymentContact& contact) 132 153 { 133 return PaymentContact(convert( contact).get());154 return PaymentContact(convert(version, contact).get()); 134 155 } 135 156 -
trunk/Source/WebKit/ChangeLog
r220709 r220718 1 2017-08-14 Andy Estes <aestes@apple.com> 2 3 [Apple Pay] Add support for phonetic contact names 4 https://bugs.webkit.org/show_bug.cgi?id=175537 5 <rdar://problem/32002644> 6 7 Reviewed by Tim Horton. 8 9 * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm: Soft-linked PKContactFieldPhoneticName. 10 (WebKit::toPKContactFields): Added code to append PKContactFieldPhoneticName to result if 11 contactFields.phoneticName is true. 12 (WebKit::toNSError): Specified PKContactFieldPhoneticName as the contact field for 13 PaymentError::ContactField::PhoneticName. 14 1 15 2017-08-14 Tim Horton <timothy_horton@apple.com> 2 16 -
trunk/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm
r220506 r220718 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 78 78 SOFT_LINK_CONSTANT(PassKit, PKContactFieldPhoneNumber, NSString *); 79 79 SOFT_LINK_CONSTANT(PassKit, PKContactFieldName, NSString *); 80 SOFT_LINK_CONSTANT(PassKit, PKContactFieldPhoneticName, NSString *); 80 81 SOFT_LINK_CONSTANT(PassKit, PKPaymentErrorContactFieldUserInfoKey, NSString *); 81 82 SOFT_LINK_CONSTANT(PassKit, PKPaymentErrorPostalAddressUserInfoKey, NSString *); … … 363 364 if (contactFields.name) 364 365 result.append(getPKContactFieldName()); 366 if (contactFields.phoneticName) 367 result.append(getPKContactFieldPhoneticName()); 365 368 366 369 return adoptNS([[NSSet alloc] initWithObjects:result.data() count:result.size()]); … … 639 642 break; 640 643 644 case WebCore::PaymentError::ContactField::PhoneticName: 645 pkContactField = getPKContactFieldPhoneticName(); 646 break; 647 641 648 case WebCore::PaymentError::ContactField::PostalAddress: 642 649 pkContactField = getPKContactFieldPostalAddress();
Note: See TracChangeset
for help on using the changeset viewer.