[Cocoa] Add some WKA extension points
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Aug 2019 22:55:30 +0000 (22:55 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Aug 2019 22:55:30 +0000 (22:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200506
<rdar://problem/51682474>

Reviewed by Tim Horton.

Source/WebCore:

* Modules/applepay/ApplePayPayment.h:
* Modules/applepay/ApplePayPaymentMethod.h:
* Modules/applepay/ApplePayRequestBase.cpp:
(WebCore::finishConverting):
(WebCore::convertAndValidate):
* Modules/applepay/ApplePayRequestBase.h:
* Modules/applepay/ApplePaySessionPaymentRequest.h:
* Modules/applepay/PaymentCoordinatorClient.cpp:
(WebCore::PaymentCoordinatorClient::supportsVersion):
* Modules/applepay/cocoa/PaymentCocoa.mm:
(WebCore::convert):
* Modules/applepay/cocoa/PaymentMethodCocoa.mm:
(WebCore::finishConverting):
(WebCore::convert):

Source/WebKit:

* Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::finishCreating):
(WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest):
* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::finishDecoding):
(IPC::finishEncoding):
(IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::encode):
(IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::decode):
* Shared/WebCoreArgumentCoders.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248692 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/ApplePayPayment.h
Source/WebCore/Modules/applepay/ApplePayPaymentMethod.h
Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp
Source/WebCore/Modules/applepay/ApplePayRequestBase.h
Source/WebCore/Modules/applepay/ApplePaySessionPaymentRequest.h
Source/WebCore/Modules/applepay/PaymentCoordinatorClient.cpp
Source/WebCore/Modules/applepay/cocoa/PaymentCocoa.mm
Source/WebCore/Modules/applepay/cocoa/PaymentMethodCocoa.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm
Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
Source/WebKit/Shared/WebCoreArgumentCoders.h

index 0875f1f..86c8936 100644 (file)
@@ -1,3 +1,26 @@
+2019-08-14  Andy Estes  <aestes@apple.com>
+
+        [Cocoa] Add some WKA extension points
+        https://bugs.webkit.org/show_bug.cgi?id=200506
+        <rdar://problem/51682474>
+
+        Reviewed by Tim Horton.
+
+        * Modules/applepay/ApplePayPayment.h:
+        * Modules/applepay/ApplePayPaymentMethod.h:
+        * Modules/applepay/ApplePayRequestBase.cpp:
+        (WebCore::finishConverting):
+        (WebCore::convertAndValidate):
+        * Modules/applepay/ApplePayRequestBase.h:
+        * Modules/applepay/ApplePaySessionPaymentRequest.h:
+        * Modules/applepay/PaymentCoordinatorClient.cpp:
+        (WebCore::PaymentCoordinatorClient::supportsVersion):
+        * Modules/applepay/cocoa/PaymentCocoa.mm:
+        (WebCore::convert):
+        * Modules/applepay/cocoa/PaymentMethodCocoa.mm:
+        (WebCore::finishConverting):
+        (WebCore::convert):
+
 2019-08-14  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: support `console.screenshot` with dataURL strings
index 5c58457..3b84025 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "ApplePayPaymentContact.h"
 #include "ApplePayPaymentMethod.h"
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/ApplePayPaymentAdditions.h>
+#endif
+
 namespace WebCore {
 
 struct ApplePayPayment {
@@ -42,6 +46,11 @@ struct ApplePayPayment {
     Token token;
     Optional<ApplePayPaymentContact> billingContact;
     Optional<ApplePayPaymentContact> shippingContact;
+
+#if defined(APPLEPAYPAYMENT_ADDITIONS)
+APPLEPAYPAYMENT_ADDITIONS
+#undef APPLEPAYPAYMENT_ADDITIONS
+#endif
 };
 
 }
index 16f5c7e..c45bec0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "ApplePayPaymentPass.h"
 #include <wtf/Optional.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/ApplePayPaymentMethodAdditions.h>
+#endif
+
 namespace WebCore {
 
 enum class ApplePayPaymentMethodType;
 
 struct ApplePayPaymentMethod {    
     using Type = ApplePayPaymentMethodType;
-    
+
     String displayName;
     String network;
     Optional<Type> type;
     Optional<ApplePayPaymentPass> paymentPass;
+
+#if defined(APPLEPAYPAYMENTMETHOD_ADDITIONS)
+APPLEPAYPAYMENTMETHOD_ADDITIONS
+#undef APPLEPAYPAYMENTMETHOD_ADDITIONS
+#endif
 };
 
 }
index 0ce91f9..5d81279 100644 (file)
 #include "PaymentCoordinator.h"
 #include <wtf/text/StringConcatenateNumbers.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/ApplePayRequestBaseAdditions.cpp>
+#else
+namespace WebCore {
+static void finishConverting(ApplePaySessionPaymentRequest&, ApplePayRequestBase&) { }
+}
+#endif
+
 namespace WebCore {
 
 static ExceptionOr<Vector<String>> convertAndValidate(Document& document, unsigned version, const Vector<String>& supportedNetworks, const PaymentCoordinator& paymentCoordinator)
@@ -78,7 +86,7 @@ ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(Document& document
 
     if (request.billingContact)
         result.setBillingContact(PaymentContact::fromApplePayPaymentContact(version, *request.billingContact));
-    
+
     if (request.requiredShippingContactFields) {
         auto requiredShippingContactFields = convertAndValidate(version, *request.requiredShippingContactFields);
         if (requiredShippingContactFields.hasException())
@@ -94,6 +102,8 @@ ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(Document& document
     if (version >= 3)
         result.setSupportedCountries(WTFMove(request.supportedCountries));
 
+    finishConverting(result, request);
+
     return WTFMove(result);
 }
 
index b80c937..9320ec8 100644 (file)
 #include "ApplePayMerchantCapability.h"
 #include "ApplePayPaymentContact.h"
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/ApplePayRequestBaseAdditions.h>
+#endif
+
 namespace WebCore {
 
 class Document;
@@ -49,6 +53,11 @@ struct ApplePayRequestBase {
 
     String applicationData;
     Vector<String> supportedCountries;
+
+#if defined(APPLEPAYREQUESTBASE_ADDITIONS)
+APPLEPAYREQUESTBASE_ADDITIONS
+#undef APPLEPAYREQUESTBASE_ADDITIONS
+#endif
 };
 
 ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(Document&, unsigned version, ApplePayRequestBase&, const PaymentCoordinator&);
index 40e30b3..f575a54 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/ApplePaySessionPaymentRequestAdditions.h>
+#endif
+
 namespace WebCore {
 
 enum class PaymentAuthorizationStatus;
@@ -137,6 +141,11 @@ public:
     Requester requester() const { return m_requester; }
     void setRequester(Requester requester) { m_requester = requester; }
 
+#if defined(APPLEPAYSESSIONPAYMENTREQUEST_PUBLIC_ADDITIONS)
+APPLEPAYSESSIONPAYMENTREQUEST_PUBLIC_ADDITIONS
+#undef APPLEPAYSESSIONPAYMENTREQUEST_PUBLIC_ADDITIONS
+#endif
+
 private:
     unsigned m_version { 0 };
 
@@ -162,6 +171,11 @@ private:
     Vector<String> m_supportedCountries;
 
     Requester m_requester { Requester::ApplePayJS };
+
+#if defined(APPLEPAYSESSIONPAYMENTREQUEST_PRIVATE_ADDITIONS)
+APPLEPAYSESSIONPAYMENTREQUEST_PRIVATE_ADDITIONS
+#undef APPLEPAYSESSIONPAYMENTREQUEST_PRIVATE_ADDITIONS
+#endif
 };
 
 struct PaymentError {
index bb2943a..d5d0658 100644 (file)
@@ -40,8 +40,10 @@ bool PaymentCoordinatorClient::supportsVersion(unsigned version)
     static const unsigned currentVersion = 3;
 #elif !ENABLE(APPLE_PAY_SESSION_V7)
     static const unsigned currentVersion = 6;
-#else
+#elif !ENABLE(APPLE_PAY_SESSION_V8)
     static const unsigned currentVersion = 7;
+#else
+    static const unsigned currentVersion = 8;
 #endif
 
     return version <= currentVersion;
index 60a97e1..9516768 100644 (file)
 #import "PaymentMethod.h"
 #import <pal/spi/cocoa/PassKitSPI.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/PaymentCocoaAdditions.mm>
+#else
+namespace WebCore {
+static void finishConverting(PKPayment *, ApplePayPayment&) { }
+}
+#endif
+
 namespace WebCore {
 
 static ApplePayPayment::Token convert(PKPaymentToken *paymentToken)
@@ -64,6 +72,8 @@ static ApplePayPayment convert(unsigned version, PKPayment *payment)
     if (payment.shippingContact)
         result.shippingContact = PaymentContact(payment.shippingContact).toApplePayPaymentContact(version);
 
+    finishConverting(payment, result);
+
     return result;
 }
     
index bd6c9ae..d115f2e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #import "ApplePayPaymentMethodType.h"
 #import <pal/spi/cocoa/PassKitSPI.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/PaymentMethodCocoaAdditions.mm>
+#else
+namespace WebCore {
+static void finishConverting(PKPaymentMethod *, ApplePayPaymentMethod&) { }
+}
+#endif
+
 namespace WebCore {
 
 static ApplePayPaymentPass::ActivationState convert(PKPaymentPassActivationState paymentPassActivationState)
@@ -98,6 +106,8 @@ static ApplePayPaymentMethod convert(PKPaymentMethod *paymentMethod)
     result.type = convert(paymentMethod.type);
     result.paymentPass = convert(paymentMethod.paymentPass);
 
+    finishConverting(paymentMethod, result);
+
     return result;
 }
 
index 19fed51..a5af8ae 100644 (file)
@@ -1,3 +1,21 @@
+2019-08-14  Andy Estes  <aestes@apple.com>
+
+        [Cocoa] Add some WKA extension points
+        https://bugs.webkit.org/show_bug.cgi?id=200506
+        <rdar://problem/51682474>
+
+        Reviewed by Tim Horton.
+
+        * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (WebKit::finishCreating):
+        (WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest):
+        * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+        (IPC::finishDecoding):
+        (IPC::finishEncoding):
+        (IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::encode):
+        (IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::decode):
+        * Shared/WebCoreArgumentCoders.h:
+
 2019-08-14  Luming Yin  <luming_yin@apple.com>
 
         v3: CrashTracer: Regression : MobileSafari at UIKitCore: -[UITargetedPreview initWithView:parameters:]
index a5a8b78..2d5d49e 100644 (file)
 #import <wtf/RunLoop.h>
 #import <wtf/URL.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WebPaymentCoordinatorProxyCocoaAdditions.mm>
+#else
+namespace WebKit {
+static void finishCreating(PKPaymentRequest *, const WebCore::ApplePaySessionPaymentRequest&) { }
+}
+#endif
+
 // FIXME: We don't support any platforms without -setThumbnailURLs:, so this can be removed.
 @interface PKPaymentRequest ()
 @property (nonatomic, strong) NSURL *thumbnailURL;
@@ -328,6 +336,8 @@ RetainPtr<PKPaymentRequest> WebPaymentCoordinatorProxy::platformPaymentRequest(c
         [result setCTDataConnectionServiceType:serviceType];
 #endif
 
+    finishCreating(result.get(), paymentRequest);
+
     return result;
 }
 
index a4f1433..b19b486 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #import <UIKit/UIFont.h>
 #endif
 
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WebCoreArgumentCodersCocoaAdditions.mm>
+#else
+namespace IPC {
+static bool finishDecoding(Decoder&, WebCore::ApplePaySessionPaymentRequest&) { return true; }
+static void finishEncoding(Encoder&, const WebCore::ApplePaySessionPaymentRequest&) { }
+}
+#endif
+
 namespace IPC {
 using namespace WebCore;
 
@@ -181,6 +190,7 @@ void ArgumentCoder<ApplePaySessionPaymentRequest>::encode(Encoder& encoder, cons
     encoder << request.applicationData();
     encoder << request.supportedCountries();
     encoder.encodeEnum(request.requester());
+    finishEncoding(encoder, request);
 }
 
 bool ArgumentCoder<ApplePaySessionPaymentRequest>::decode(Decoder& decoder, ApplePaySessionPaymentRequest& request)
@@ -263,6 +273,9 @@ bool ArgumentCoder<ApplePaySessionPaymentRequest>::decode(Decoder& decoder, Appl
         return false;
     request.setRequester(requester);
 
+    if (!finishDecoding(decoder, request))
+        return false;
+
     return true;
 }
 
index eaa9f30..3163417 100644 (file)
 #include <WebCore/CurlProxySettings.h>
 #endif
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/WebCoreArgumentCodersAdditions.h>
+#endif
+
 #if PLATFORM(COCOA)
 namespace WTF {
 class MachSendRight;