[Cocoa] Add a WKA extension point
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Sep 2019 17:46:04 +0000 (17:46 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Sep 2019 17:46:04 +0000 (17:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201801
<rdar://problem/55372507>

Reviewed by Alexey Proskuryakov.

* Modules/applepay/ApplePayRequestBase.cpp:
(WebCore::requiresSupportedNetworks):
(WebCore::convertAndValidate):

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp

index 3629ec7..7c1c870 100644 (file)
@@ -1,3 +1,15 @@
+2019-09-17  Andy Estes  <aestes@apple.com>
+
+        [Cocoa] Add a WKA extension point
+        https://bugs.webkit.org/show_bug.cgi?id=201801
+        <rdar://problem/55372507>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Modules/applepay/ApplePayRequestBase.cpp:
+        (WebCore::requiresSupportedNetworks):
+        (WebCore::convertAndValidate):
+
 2019-09-17  Antti Koivisto  <antti@apple.com>
 
         TextIterator should convert tabs to spaces
index 5d81279..1d6bf2d 100644 (file)
@@ -36,6 +36,7 @@
 #else
 namespace WebCore {
 static void finishConverting(ApplePaySessionPaymentRequest&, ApplePayRequestBase&) { }
+static bool requiresSupportedNetworks(unsigned, const ApplePayRequestBase&) { return true; }
 }
 #endif
 
@@ -43,9 +44,6 @@ namespace WebCore {
 
 static ExceptionOr<Vector<String>> convertAndValidate(Document& document, unsigned version, const Vector<String>& supportedNetworks, const PaymentCoordinator& paymentCoordinator)
 {
-    if (supportedNetworks.isEmpty())
-        return Exception { TypeError, "At least one supported network must be provided." };
-
     Vector<String> result;
     result.reserveInitialCapacity(supportedNetworks.size());
     for (auto& supportedNetwork : supportedNetworks) {
@@ -72,6 +70,9 @@ ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(Document& document
         return merchantCapabilities.releaseException();
     result.setMerchantCapabilities(merchantCapabilities.releaseReturnValue());
 
+    if (requiresSupportedNetworks(version, request) && request.supportedNetworks.isEmpty())
+        return Exception { TypeError, "At least one supported network must be provided." };
+
     auto supportedNetworks = convertAndValidate(document, version, request.supportedNetworks, paymentCoordinator);
     if (supportedNetworks.hasException())
         return supportedNetworks.releaseException();