ApplePayShippingContactUpdate.idl shouldn't have status field
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Mar 2017 22:26:25 +0000 (22:26 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Mar 2017 22:26:25 +0000 (22:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170202
rdar://problem/31307106

Reviewed by Beth Dakin.

* Modules/applepay/ApplePaySession.cpp:
(WebCore::convertAndValidate):
If status isn't set, infer it based on whether there are errors present or not.

* Modules/applepay/ApplePayShippingContactUpdate.h:
Make status optional here; it's still used by the old code path.

* Modules/applepay/ApplePayShippingContactUpdate.idl:
Remove status here.

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/ApplePaySession.cpp
Source/WebCore/Modules/applepay/ApplePayShippingContactUpdate.h
Source/WebCore/Modules/applepay/ApplePayShippingContactUpdate.idl

index 7403d8b..d3b842b 100644 (file)
@@ -1,3 +1,21 @@
+2017-03-28  Anders Carlsson  <andersca@apple.com>
+
+        ApplePayShippingContactUpdate.idl shouldn't have status field
+        https://bugs.webkit.org/show_bug.cgi?id=170202
+        rdar://problem/31307106
+
+        Reviewed by Beth Dakin.
+
+        * Modules/applepay/ApplePaySession.cpp:
+        (WebCore::convertAndValidate):
+        If status isn't set, infer it based on whether there are errors present or not.
+
+        * Modules/applepay/ApplePayShippingContactUpdate.h:
+        Make status optional here; it's still used by the old code path.
+
+        * Modules/applepay/ApplePayShippingContactUpdate.idl:
+        Remove status here.
+
 2017-03-28  Brian Burg  <bburg@apple.com>
 
         Web Inspector: Add "Disable Caches" option that only applies to the inspected page while Web Inspector is open
index 1289383..105a29e 100644 (file)
@@ -472,11 +472,21 @@ static ExceptionOr<ShippingContactUpdate> convertAndValidate(ApplePayShippingCon
 {
     ShippingContactUpdate convertedUpdate;
 
-    auto authorizationStatus = toPaymentAuthorizationStatus(update.status);
-    if (!authorizationStatus)
-        return Exception { INVALID_ACCESS_ERR };
-    convertedUpdate.status = *authorizationStatus;
-    convertedUpdate.errors = convert(update.errors);
+    if (!update.status) {
+        convertedUpdate.errors = convert(update.errors);
+        if (convertedUpdate.errors.isEmpty())
+            convertedUpdate.status = PaymentAuthorizationStatus::Success;
+        else
+            convertedUpdate.status = PaymentAuthorizationStatus::Failure;
+    } else {
+        ASSERT(update.errors.isEmpty());
+
+        auto authorizationStatus = toPaymentAuthorizationStatus(*update.status);
+        if (!authorizationStatus)
+            return Exception { INVALID_ACCESS_ERR };
+
+        convertedUpdate.status = *authorizationStatus;
+    }
 
     auto convertedNewShippingMethods = convertAndValidate(WTFMove(update.newShippingMethods));
     if (convertedNewShippingMethods.hasException())
index 5fd42b9..0aacb6c 100644 (file)
@@ -34,7 +34,7 @@
 namespace WebCore {
 
 struct ApplePayShippingContactUpdate {
-    unsigned short status;
+    std::optional<unsigned short> status;
     Vector<RefPtr<ApplePayError>> errors;
 
     Vector<ApplePayShippingMethod> newShippingMethods;
index 55c6062..931570d 100644 (file)
@@ -26,7 +26,6 @@
 [
     Conditional=APPLE_PAY_DELEGATE,
 ] dictionary ApplePayShippingContactUpdate {
-    required unsigned short status;
     sequence<ApplePayError> errors;
 
     sequence<ApplePayShippingMethod> newShippingMethods;