Diff
Modified: trunk/Source/WebCore/ChangeLog (226097 => 226098)
--- trunk/Source/WebCore/ChangeLog 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/ChangeLog 2017-12-19 05:39:26 UTC (rev 226098)
@@ -1,3 +1,49 @@
+2017-12-18 Andy Estes <[email protected]>
+
+ [Apple Pay] Only include phonetic name properties in ApplePayPaymentContact when version >= 3
+ https://bugs.webkit.org/show_bug.cgi?id=180925
+ <rdar://problem/35907596>
+
+ Reviewed by Tim Horton.
+
+ No tests possible. The fix involves converting PKContacts, which we can't create in our test harness.
+
+ * Modules/applepay/ApplePayPaymentAuthorizedEvent.cpp:
+ (WebCore::ApplePayPaymentAuthorizedEvent::ApplePayPaymentAuthorizedEvent):
+ * Modules/applepay/ApplePayPaymentAuthorizedEvent.h:
+ * Modules/applepay/ApplePaySession.cpp:
+ (WebCore::ApplePaySession::create):
+ (WebCore::ApplePaySession::ApplePaySession):
+ (WebCore::ApplePaySession::version const):
+ (WebCore::ApplePaySession::didAuthorizePayment):
+ (WebCore::ApplePaySession::didSelectShippingContact):
+ * Modules/applepay/ApplePaySession.h:
+ * Modules/applepay/ApplePayShippingContactSelectedEvent.cpp:
+ (WebCore::ApplePayShippingContactSelectedEvent::ApplePayShippingContactSelectedEvent):
+ * Modules/applepay/ApplePayShippingContactSelectedEvent.h:
+ * Modules/applepay/Payment.h:
+ * Modules/applepay/PaymentContact.h:
+ * Modules/applepay/PaymentCoordinator.cpp:
+ (WebCore::PaymentCoordinator::supportsVersion const):
+ (WebCore::PaymentCoordinator::supportsVersion): Deleted.
+ * Modules/applepay/PaymentCoordinator.h:
+ * Modules/applepay/PaymentSession.h:
+ * Modules/applepay/cocoa/PaymentCocoa.mm:
+ (WebCore::convert):
+ (WebCore::Payment::toApplePayPayment const):
+ * Modules/applepay/cocoa/PaymentContactCocoa.mm:
+ (WebCore::convert):
+ (WebCore::PaymentContact::toApplePayPaymentContact const):
+ * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+ (WebCore::ApplePayPaymentHandler::document const):
+ (WebCore::ApplePayPaymentHandler::paymentCoordinator const):
+ (WebCore::ApplePayPaymentHandler::version const):
+ (WebCore::ApplePayPaymentHandler::didAuthorizePayment):
+ (WebCore::ApplePayPaymentHandler::didSelectShippingContact):
+ (WebCore::ApplePayPaymentHandler::document): Deleted.
+ (WebCore::ApplePayPaymentHandler::paymentCoordinator): Deleted.
+ * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
+
2017-12-18 Wenson Hsieh <[email protected]>
[Attachment Support] The 'webkitattachmentbloburl' attribute should not persist after markup serialization
Modified: trunk/Source/WebCore/Modules/applepay/ApplePayPaymentAuthorizedEvent.cpp (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/ApplePayPaymentAuthorizedEvent.cpp 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayPaymentAuthorizedEvent.cpp 2017-12-19 05:39:26 UTC (rev 226098)
@@ -32,9 +32,9 @@
namespace WebCore {
-ApplePayPaymentAuthorizedEvent::ApplePayPaymentAuthorizedEvent(const AtomicString& type, const Payment& payment)
+ApplePayPaymentAuthorizedEvent::ApplePayPaymentAuthorizedEvent(const AtomicString& type, unsigned version, const Payment& payment)
: Event(type, false, false)
- , m_payment(payment.toApplePayPayment())
+ , m_payment(payment.toApplePayPayment(version))
{
}
Modified: trunk/Source/WebCore/Modules/applepay/ApplePayPaymentAuthorizedEvent.h (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/ApplePayPaymentAuthorizedEvent.h 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayPaymentAuthorizedEvent.h 2017-12-19 05:39:26 UTC (rev 226098)
@@ -36,9 +36,9 @@
class ApplePayPaymentAuthorizedEvent final : public Event {
public:
- static Ref<ApplePayPaymentAuthorizedEvent> create(const AtomicString& type, const Payment& payment)
+ static Ref<ApplePayPaymentAuthorizedEvent> create(const AtomicString& type, unsigned version, const Payment& payment)
{
- return adoptRef(*new ApplePayPaymentAuthorizedEvent(type, payment));
+ return adoptRef(*new ApplePayPaymentAuthorizedEvent(type, version, payment));
}
virtual ~ApplePayPaymentAuthorizedEvent();
@@ -46,7 +46,7 @@
const ApplePayPayment& payment() const { return m_payment; }
private:
- ApplePayPaymentAuthorizedEvent(const AtomicString& type, const Payment&);
+ ApplePayPaymentAuthorizedEvent(const AtomicString& type, unsigned version, const Payment&);
// Event.
EventInterface eventInterface() const override;
Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp 2017-12-19 05:39:26 UTC (rev 226098)
@@ -417,13 +417,15 @@
if (convertedPaymentRequest.hasException())
return convertedPaymentRequest.releaseException();
- return adoptRef(*new ApplePaySession(document, convertedPaymentRequest.releaseReturnValue()));
+ return adoptRef(*new ApplePaySession(document, version, convertedPaymentRequest.releaseReturnValue()));
}
-ApplePaySession::ApplePaySession(Document& document, ApplePaySessionPaymentRequest&& paymentRequest)
- : ActiveDOMObject(&document)
- , m_paymentRequest(WTFMove(paymentRequest))
+ApplePaySession::ApplePaySession(Document& document, unsigned version, ApplePaySessionPaymentRequest&& paymentRequest)
+ : ActiveDOMObject { &document }
+ , m_paymentRequest { WTFMove(paymentRequest) }
+ , m_version { version }
{
+ ASSERT(document.frame()->mainFrame().paymentCoordinator().supportsVersion(version));
suspendIfNeeded();
}
@@ -735,6 +737,11 @@
return completePayment(WTFMove(result));
}
+unsigned ApplePaySession::version() const
+{
+ return m_version;
+}
+
void ApplePaySession::validateMerchant(const URL& validationURL)
{
if (m_state == State::Aborted) {
@@ -763,7 +770,7 @@
m_state = State::Authorized;
- auto event = ApplePayPaymentAuthorizedEvent::create(eventNames().paymentauthorizedEvent, payment);
+ auto event = ApplePayPaymentAuthorizedEvent::create(eventNames().paymentauthorizedEvent, version(), payment);
dispatchEvent(event.get());
}
@@ -791,7 +798,7 @@
}
m_state = State::ShippingContactSelected;
- auto event = ApplePayShippingContactSelectedEvent::create(eventNames().shippingcontactselectedEvent, shippingContact);
+ auto event = ApplePayShippingContactSelectedEvent::create(eventNames().shippingcontactselectedEvent, version(), shippingContact);
dispatchEvent(event.get());
}
Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.h (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.h 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.h 2017-12-19 05:39:26 UTC (rev 226098)
@@ -97,7 +97,7 @@
using PaymentSession::deref;
private:
- ApplePaySession(Document&, ApplePaySessionPaymentRequest&&);
+ ApplePaySession(Document&, unsigned version, ApplePaySessionPaymentRequest&&);
// ActiveDOMObject.
const char* activeDOMObjectName() const override;
@@ -111,6 +111,7 @@
void derefEventTarget() override { deref(); }
// PaymentSession
+ unsigned version() const override;
void validateMerchant(const URL&) override;
void didAuthorizePayment(const Payment&) override;
void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) override;
@@ -154,6 +155,7 @@
} m_merchantValidationState { MerchantValidationState::Idle };
const ApplePaySessionPaymentRequest m_paymentRequest;
+ unsigned m_version;
};
}
Modified: trunk/Source/WebCore/Modules/applepay/ApplePayShippingContactSelectedEvent.cpp (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/ApplePayShippingContactSelectedEvent.cpp 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayShippingContactSelectedEvent.cpp 2017-12-19 05:39:26 UTC (rev 226098)
@@ -32,9 +32,9 @@
namespace WebCore {
-ApplePayShippingContactSelectedEvent::ApplePayShippingContactSelectedEvent(const AtomicString& type, const PaymentContact& shippingContact)
+ApplePayShippingContactSelectedEvent::ApplePayShippingContactSelectedEvent(const AtomicString& type, unsigned version, const PaymentContact& shippingContact)
: Event(type, false, false)
- , m_shippingContact(shippingContact.toApplePayPaymentContact())
+ , m_shippingContact(shippingContact.toApplePayPaymentContact(version))
{
}
Modified: trunk/Source/WebCore/Modules/applepay/ApplePayShippingContactSelectedEvent.h (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/ApplePayShippingContactSelectedEvent.h 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayShippingContactSelectedEvent.h 2017-12-19 05:39:26 UTC (rev 226098)
@@ -36,9 +36,9 @@
class ApplePayShippingContactSelectedEvent final : public Event {
public:
- static Ref<ApplePayShippingContactSelectedEvent> create(const AtomicString& type, const PaymentContact& shippingContact)
+ static Ref<ApplePayShippingContactSelectedEvent> create(const AtomicString& type, unsigned version, const PaymentContact& shippingContact)
{
- return adoptRef(*new ApplePayShippingContactSelectedEvent(type, shippingContact));
+ return adoptRef(*new ApplePayShippingContactSelectedEvent(type, version, shippingContact));
}
virtual ~ApplePayShippingContactSelectedEvent();
@@ -46,7 +46,7 @@
const ApplePayPaymentContact& shippingContact() const { return m_shippingContact; }
private:
- ApplePayShippingContactSelectedEvent(const AtomicString& type, const PaymentContact&);
+ ApplePayShippingContactSelectedEvent(const AtomicString& type, unsigned version, const PaymentContact&);
// Event.
EventInterface eventInterface() const override;
Modified: trunk/Source/WebCore/Modules/applepay/Payment.h (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/Payment.h 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/Payment.h 2017-12-19 05:39:26 UTC (rev 226098)
@@ -46,7 +46,7 @@
virtual ~Payment() = default;
- virtual ApplePayPayment toApplePayPayment() const;
+ virtual ApplePayPayment toApplePayPayment(unsigned version) const;
PKPayment *pkPayment() const { return m_pkPayment.get(); }
Modified: trunk/Source/WebCore/Modules/applepay/PaymentContact.h (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/PaymentContact.h 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/PaymentContact.h 2017-12-19 05:39:26 UTC (rev 226098)
@@ -46,7 +46,7 @@
virtual ~PaymentContact() = default;
static PaymentContact fromApplePayPaymentContact(unsigned version, const ApplePayPaymentContact&);
- virtual ApplePayPaymentContact toApplePayPaymentContact() const;
+ virtual ApplePayPaymentContact toApplePayPaymentContact(unsigned version) const;
PKContact *pkContact() const { return m_pkContact.get(); }
Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp 2017-12-19 05:39:26 UTC (rev 226098)
@@ -45,7 +45,7 @@
m_client.paymentCoordinatorDestroyed();
}
-bool PaymentCoordinator::supportsVersion(unsigned version)
+bool PaymentCoordinator::supportsVersion(unsigned version) const
{
return m_client.supportsVersion(version);
}
Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h 2017-12-19 05:39:26 UTC (rev 226098)
@@ -50,7 +50,7 @@
WEBCORE_EXPORT explicit PaymentCoordinator(PaymentCoordinatorClient&);
WEBCORE_EXPORT ~PaymentCoordinator();
- bool supportsVersion(unsigned version);
+ bool supportsVersion(unsigned version) const;
bool canMakePayments();
void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler);
void openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler);
Modified: trunk/Source/WebCore/Modules/applepay/PaymentSession.h (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/PaymentSession.h 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/PaymentSession.h 2017-12-19 05:39:26 UTC (rev 226098)
@@ -43,6 +43,7 @@
public:
static ExceptionOr<void> canCreateSession(Document&);
+ virtual unsigned version() const = 0;
virtual void validateMerchant(const URL&) = 0;
virtual void didAuthorizePayment(const Payment&) = 0;
virtual void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) = 0;
Modified: trunk/Source/WebCore/Modules/applepay/cocoa/PaymentCocoa.mm (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/cocoa/PaymentCocoa.mm 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/cocoa/PaymentCocoa.mm 2017-12-19 05:39:26 UTC (rev 226098)
@@ -51,7 +51,7 @@
return result;
}
-static ApplePayPayment convert(PKPayment *payment)
+static ApplePayPayment convert(unsigned version, PKPayment *payment)
{
ASSERT(payment);
@@ -60,16 +60,16 @@
result.token = convert(payment.token);
if (payment.billingContact)
- result.billingContact = PaymentContact(payment.billingContact).toApplePayPaymentContact();
+ result.billingContact = PaymentContact(payment.billingContact).toApplePayPaymentContact(version);
if (payment.shippingContact)
- result.shippingContact = PaymentContact(payment.shippingContact).toApplePayPaymentContact();
+ result.shippingContact = PaymentContact(payment.shippingContact).toApplePayPaymentContact(version);
return result;
}
-ApplePayPayment Payment::toApplePayPayment() const
+ApplePayPayment Payment::toApplePayPayment(unsigned version) const
{
- return convert(m_pkPayment.get());
+ return convert(version, m_pkPayment.get());
}
}
Modified: trunk/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm 2017-12-19 05:39:26 UTC (rev 226098)
@@ -177,7 +177,7 @@
return result;
}
-static ApplePayPaymentContact convert(PKContact *contact)
+static ApplePayPaymentContact convert(unsigned version, PKContact *contact)
{
ASSERT(contact);
@@ -191,10 +191,12 @@
result.familyName = name.familyName;
result.localizedName = [NSPersonNameComponentsFormatter localizedStringFromPersonNameComponents:name style:NSPersonNameComponentsFormatterStyleDefault options:0];
- NSPersonNameComponents *phoneticName = name.phoneticRepresentation;
- result.phoneticGivenName = phoneticName.givenName;
- result.phoneticFamilyName = phoneticName.familyName;
- result.localizedPhoneticName = [NSPersonNameComponentsFormatter localizedStringFromPersonNameComponents:name style:NSPersonNameComponentsFormatterStyleDefault options:NSPersonNameComponentsFormatterPhonetic];
+ if (version >= 3) {
+ NSPersonNameComponents *phoneticName = name.phoneticRepresentation;
+ result.phoneticGivenName = phoneticName.givenName;
+ result.phoneticFamilyName = phoneticName.familyName;
+ result.localizedPhoneticName = [NSPersonNameComponentsFormatter localizedStringFromPersonNameComponents:name style:NSPersonNameComponentsFormatterStyleDefault options:NSPersonNameComponentsFormatterPhonetic];
+ }
CNPostalAddress *postalAddress = contact.postalAddress;
if (postalAddress.street.length) {
@@ -218,9 +220,9 @@
return PaymentContact(convert(version, contact).get());
}
-ApplePayPaymentContact PaymentContact::toApplePayPaymentContact() const
+ApplePayPaymentContact PaymentContact::toApplePayPaymentContact(unsigned version) const
{
- return convert(m_pkContact.get());
+ return convert(version, m_pkContact.get());
}
}
Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2017-12-19 05:39:26 UTC (rev 226098)
@@ -79,12 +79,12 @@
ASSERT(handlesIdentifier(m_identifier));
}
-Document& ApplePayPaymentHandler::document()
+Document& ApplePayPaymentHandler::document() const
{
return downcast<Document>(*scriptExecutionContext());
}
-PaymentCoordinator& ApplePayPaymentHandler::paymentCoordinator()
+PaymentCoordinator& ApplePayPaymentHandler::paymentCoordinator() const
{
return WebCore::paymentCoordinator(document());
}
@@ -385,6 +385,16 @@
paymentCoordinator().completePaymentSession(WTFMove(authorizationResult));
}
+unsigned ApplePayPaymentHandler::version() const
+{
+ if (!m_applePayRequest)
+ return 0;
+
+ auto version = m_applePayRequest->version;
+ ASSERT(paymentCoordinator().supportsVersion(version));
+ return version;
+}
+
void ApplePayPaymentHandler::validateMerchant(const URL& validationURL)
{
if (validationURL.isValid())
@@ -398,7 +408,7 @@
void ApplePayPaymentHandler::didAuthorizePayment(const Payment& payment)
{
- auto applePayPayment = payment.toApplePayPayment();
+ auto applePayPayment = payment.toApplePayPayment(version());
auto& execState = *document().execState();
auto lock = JSC::JSLockHolder { &execState };
auto details = JSC::Strong<JSC::JSObject> { execState.vm(), asObject(toJS<IDLDictionary<ApplePayPayment>>(execState, *JSC::jsCast<JSDOMGlobalObject*>(execState.lexicalGlobalObject()), applePayPayment)) };
@@ -413,7 +423,7 @@
void ApplePayPaymentHandler::didSelectShippingContact(const PaymentContact& shippingContact)
{
- m_paymentRequest->shippingAddressChanged(convert(shippingContact.toApplePayPaymentContact()));
+ m_paymentRequest->shippingAddressChanged(convert(shippingContact.toApplePayPaymentContact(version())));
}
void ApplePayPaymentHandler::didSelectPaymentMethod(const PaymentMethod& paymentMethod)
Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h (226097 => 226098)
--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h 2017-12-19 05:39:26 UTC (rev 226098)
@@ -49,8 +49,8 @@
friend class PaymentHandler;
explicit ApplePayPaymentHandler(Document&, const PaymentRequest::MethodIdentifier&, PaymentRequest&);
- Document& document();
- PaymentCoordinator& paymentCoordinator();
+ Document& document() const;
+ PaymentCoordinator& paymentCoordinator() const;
ExceptionOr<ApplePaySessionPaymentRequest::TotalAndLineItems> computeTotalAndLineItems();
@@ -67,6 +67,7 @@
void complete(std::optional<PaymentComplete>&&) final;
// PaymentSession
+ unsigned version() const final;
void validateMerchant(const URL&) final;
void didAuthorizePayment(const Payment&) final;
void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) final;
Modified: trunk/Source/WebCore/testing/MockPayment.h (226097 => 226098)
--- trunk/Source/WebCore/testing/MockPayment.h 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/testing/MockPayment.h 2017-12-19 05:39:26 UTC (rev 226098)
@@ -39,7 +39,7 @@
{
}
- ApplePayPayment toApplePayPayment() const final { return m_applePayPayment; }
+ ApplePayPayment toApplePayPayment(unsigned) const final { return m_applePayPayment; }
private:
ApplePayPayment m_applePayPayment;
Modified: trunk/Source/WebCore/testing/MockPaymentContact.h (226097 => 226098)
--- trunk/Source/WebCore/testing/MockPaymentContact.h 2017-12-19 05:38:47 UTC (rev 226097)
+++ trunk/Source/WebCore/testing/MockPaymentContact.h 2017-12-19 05:39:26 UTC (rev 226098)
@@ -39,7 +39,7 @@
{
}
- ApplePayPaymentContact toApplePayPaymentContact() const final { return m_applePayPaymentContact; }
+ ApplePayPaymentContact toApplePayPaymentContact(unsigned) const final { return m_applePayPaymentContact; }
private:
ApplePayPaymentContact m_applePayPaymentContact;