Diff
Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (204589 => 204590)
--- branches/safari-602-branch/Source/WebCore/ChangeLog 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog 2016-08-18 05:37:34 UTC (rev 204590)
@@ -1,3 +1,29 @@
+2016-08-17 Babak Shafiei <[email protected]>
+
+ Merge r204587. rdar://problem/27807479
+
+ 2016-08-17 Anders Carlsson <[email protected]>
+
+ Add support for additional networks
+ https://bugs.webkit.org/show_bug.cgi?id=160951
+ rdar://problem/27807479
+
+ Reviewed by Sam Weinig.
+
+ * Modules/applepay/ApplePaySession.cpp:
+ (WebCore::createSupportedNetworks):
+ (WebCore::createPaymentRequest):
+ (WebCore::ApplePaySession::create):
+ * Modules/applepay/PaymentRequest.cpp:
+ (WebCore::isAdditionalValidSupportedNetwork):
+ (WebCore::PaymentRequest::isValidSupportedNetwork):
+ * Modules/applepay/PaymentRequest.h:
+ (WebCore::PaymentRequest::supportedNetworks):
+ (WebCore::PaymentRequest::setSupportedNetworks):
+ * Modules/applepay/PaymentRequestValidator.cpp:
+ (WebCore::PaymentRequestValidator::validateSupportedNetworks):
+ * Modules/applepay/PaymentRequestValidator.h:
+
2016-08-09 Babak Shafiei <[email protected]>
Merge r204274. rdar://problem/27688892
Modified: branches/safari-602-branch/Source/WebCore/Modules/applepay/ApplePaySession.cpp (204589 => 204590)
--- branches/safari-602-branch/Source/WebCore/Modules/applepay/ApplePaySession.cpp 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebCore/Modules/applepay/ApplePaySession.cpp 2016-08-18 05:37:34 UTC (rev 204590)
@@ -313,9 +313,9 @@
return result;
}
-static Optional<PaymentRequest::SupportedNetworks> createSupportedNetworks(DOMWindow& window, const ArrayValue& supportedNetworksArray)
+static Optional<Vector<String>> createSupportedNetworks(unsigned version, DOMWindow& window, const ArrayValue& supportedNetworksArray)
{
- PaymentRequest::SupportedNetworks result;
+ Vector<String> result;
size_t supportedNetworksCount;
if (!supportedNetworksArray.length(supportedNetworksCount))
@@ -326,25 +326,13 @@
if (!supportedNetworksArray.get(i, supportedNetwork))
return Nullopt;
- if (supportedNetwork == "amex")
- result.amex = true;
- else if (supportedNetwork == "chinaUnionPay")
- result.chinaUnionPay = true;
- else if (supportedNetwork == "discover")
- result.discover = true;
- else if (supportedNetwork == "interac")
- result.interac = true;
- else if (supportedNetwork == "masterCard")
- result.masterCard = true;
- else if (supportedNetwork == "privateLabel")
- result.privateLabel = true;
- else if (supportedNetwork == "visa")
- result.visa = true;
- else {
+ if (!PaymentRequest::isValidSupportedNetwork(version, supportedNetwork)) {
auto message = makeString("\"" + supportedNetwork, "\" is not a valid payment network.");
window.printErrorMessage(message);
return Nullopt;
}
+
+ result.append(WTFMove(supportedNetwork));
}
return result;
@@ -482,7 +470,7 @@
return false;
}
-static Optional<PaymentRequest> createPaymentRequest(DOMWindow& window, const Dictionary& dictionary)
+static Optional<PaymentRequest> createPaymentRequest(unsigned version, DOMWindow& window, const Dictionary& dictionary)
{
PaymentRequest paymentRequest;
@@ -516,7 +504,7 @@
}
if (auto supportedNetworksArray = dictionary.get<ArrayValue>("supportedNetworks")) {
- auto supportedNetworks = createSupportedNetworks(window, *supportedNetworksArray);
+ auto supportedNetworks = createSupportedNetworks(version, window, *supportedNetworksArray);
if (!supportedNetworks)
return Nullopt;
@@ -672,7 +660,7 @@
return nullptr;
}
- auto paymentRequest = createPaymentRequest(window, dictionary);
+ auto paymentRequest = createPaymentRequest(version, window, dictionary);
if (!paymentRequest) {
ec = TYPE_MISMATCH_ERR;
return nullptr;
Modified: branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequest.cpp (204589 => 204590)
--- branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequest.cpp 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequest.cpp 2016-08-18 05:37:34 UTC (rev 204590)
@@ -28,6 +28,8 @@
#if ENABLE(APPLE_PAY)
+#include "SoftLinking.h"
+
namespace WebCore {
PaymentRequest::PaymentRequest()
@@ -38,6 +40,35 @@
{
}
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/PaymentRequestAdditions.cpp>)
+#include <WebKitAdditions/PaymentRequestAdditions.cpp>
+#else
+static inline bool isAdditionalValidSupportedNetwork(unsigned, const String&)
+{
+ return false;
}
+#endif
+bool PaymentRequest::isValidSupportedNetwork(unsigned version, const String& supportedNetwork)
+{
+ if (supportedNetwork == "amex")
+ return true;
+ if (supportedNetwork == "chinaUnionPay")
+ return true;
+ if (supportedNetwork == "discover")
+ return true;
+ if (supportedNetwork == "interac")
+ return true;
+ if (supportedNetwork == "masterCard")
+ return true;
+ if (supportedNetwork == "privateLabel")
+ return true;
+ if (supportedNetwork == "visa")
+ return true;
+
+ return isAdditionalValidSupportedNetwork(version, supportedNetwork);
+}
+
+}
+
#endif
Modified: branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequest.h (204589 => 204590)
--- branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequest.h 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequest.h 2016-08-18 05:37:34 UTC (rev 204590)
@@ -64,18 +64,10 @@
const PaymentContact& shippingContact() const { return m_shippingContact; }
void setShippingContact(const PaymentContact& shippingContact) { m_shippingContact = shippingContact; }
- struct SupportedNetworks {
- bool amex { false };
- bool chinaUnionPay { false };
- bool discover { false };
- bool interac { false };
- bool masterCard { false };
- bool privateLabel { false };
- bool visa { false };
- };
+ static bool isValidSupportedNetwork(unsigned version, const String&);
- const SupportedNetworks& supportedNetworks() const { return m_supportedNetworks; }
- void setSupportedNetworks(const SupportedNetworks& supportedNetworks) { m_supportedNetworks = supportedNetworks; }
+ const Vector<String>& supportedNetworks() const { return m_supportedNetworks; }
+ void setSupportedNetworks(const Vector<String>& supportedNetworks) { m_supportedNetworks = supportedNetworks; }
struct MerchantCapabilities {
bool supports3DS { false };
@@ -143,7 +135,7 @@
ContactFields m_requiredShippingContactFields;
PaymentContact m_shippingContact;
- SupportedNetworks m_supportedNetworks;
+ Vector<String> m_supportedNetworks;
MerchantCapabilities m_merchantCapabilities;
ShippingType m_shippingType { ShippingType::Shipping };
Modified: branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp (204589 => 204590)
--- branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp 2016-08-18 05:37:34 UTC (rev 204590)
@@ -147,9 +147,9 @@
return true;
}
-bool PaymentRequestValidator::validateSupportedNetworks(const PaymentRequest::SupportedNetworks& supportedNetworks) const
+bool PaymentRequestValidator::validateSupportedNetworks(const Vector<String>& supportedNetworks) const
{
- if (!supportedNetworks.amex && !supportedNetworks.chinaUnionPay && !supportedNetworks.discover && !supportedNetworks.interac && !supportedNetworks.masterCard && !supportedNetworks.privateLabel &&!supportedNetworks.visa) {
+ if (supportedNetworks.isEmpty()) {
m_window.printErrorMessage("Missing supported networks");
return false;
}
Modified: branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequestValidator.h (204589 => 204590)
--- branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequestValidator.h 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebCore/Modules/applepay/PaymentRequestValidator.h 2016-08-18 05:37:34 UTC (rev 204590)
@@ -45,7 +45,7 @@
bool validateCountryCode(const String&) const;
bool validateCurrencyCode(const String&) const;
bool validateMerchantCapabilities(const PaymentRequest::MerchantCapabilities&) const;
- bool validateSupportedNetworks(const PaymentRequest::SupportedNetworks&) const;
+ bool validateSupportedNetworks(const Vector<String>&) const;
bool validateShippingMethods(const Vector<PaymentRequest::ShippingMethod>&) const;
bool validateShippingMethod(const PaymentRequest::ShippingMethod&) const;
Modified: branches/safari-602-branch/Source/WebKit2/ChangeLog (204589 => 204590)
--- branches/safari-602-branch/Source/WebKit2/ChangeLog 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebKit2/ChangeLog 2016-08-18 05:37:34 UTC (rev 204590)
@@ -1,3 +1,27 @@
+2016-08-17 Babak Shafiei <[email protected]>
+
+ Merge r204587. rdar://problem/27807479
+
+ 2016-08-17 Anders Carlsson <[email protected]>
+
+ Add support for additional networks
+ https://bugs.webkit.org/show_bug.cgi?id=160951
+ rdar://problem/27807479
+
+ Reviewed by Sam Weinig.
+
+ * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+ (IPC::ArgumentCoder<PaymentRequest>::decode):
+ (IPC::ArgumentCoder<PaymentRequest::SupportedNetworks>::encode): Deleted.
+ (IPC::ArgumentCoder<PaymentRequest::SupportedNetworks>::decode): Deleted.
+ * Shared/WebCoreArgumentCoders.h:
+ * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+ (WebKit::toAdditionalSupportedNetwork):
+ (WebKit::toSupportedNetwork):
+ (WebKit::toSupportedNetworks):
+ * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
+ (WebKit::WebPaymentCoordinator::supportsVersion):
+
2016-08-12 Babak Shafiei <[email protected]>
Merge r204414. rdar://problem/27624095
Modified: branches/safari-602-branch/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (204589 => 204590)
--- branches/safari-602-branch/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm 2016-08-18 05:37:34 UTC (rev 204590)
@@ -238,7 +238,7 @@
return false;
request.setMerchantCapabilities(merchantCapabilities);
- PaymentRequest::SupportedNetworks supportedNetworks;
+ Vector<String> supportedNetworks;
if (!decoder.decode(supportedNetworks))
return false;
request.setSupportedNetworks(supportedNetworks);
@@ -334,37 +334,6 @@
return true;
}
-void ArgumentCoder<PaymentRequest::SupportedNetworks>::encode(ArgumentEncoder& encoder, const PaymentRequest::SupportedNetworks& supportedNetworks)
-{
- encoder << supportedNetworks.amex;
- encoder << supportedNetworks.chinaUnionPay;
- encoder << supportedNetworks.discover;
- encoder << supportedNetworks.interac;
- encoder << supportedNetworks.masterCard;
- encoder << supportedNetworks.privateLabel;
- encoder << supportedNetworks.visa;
-}
-
-bool ArgumentCoder<PaymentRequest::SupportedNetworks>::decode(ArgumentDecoder& decoder, PaymentRequest::SupportedNetworks& supportedNetworks)
-{
- if (!decoder.decode(supportedNetworks.amex))
- return false;
- if (!decoder.decode(supportedNetworks.chinaUnionPay))
- return false;
- if (!decoder.decode(supportedNetworks.discover))
- return false;
- if (!decoder.decode(supportedNetworks.interac))
- return false;
- if (!decoder.decode(supportedNetworks.masterCard))
- return false;
- if (!decoder.decode(supportedNetworks.privateLabel))
- return false;
- if (!decoder.decode(supportedNetworks.visa))
- return false;
-
- return true;
-}
-
void ArgumentCoder<PaymentRequest::ShippingMethod>::encode(ArgumentEncoder& encoder, const PaymentRequest::ShippingMethod& shippingMethod)
{
encoder << shippingMethod.label;
Modified: branches/safari-602-branch/Source/WebKit2/Shared/WebCoreArgumentCoders.h (204589 => 204590)
--- branches/safari-602-branch/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2016-08-18 05:37:34 UTC (rev 204590)
@@ -521,11 +521,6 @@
static bool decode(ArgumentDecoder&, WebCore::PaymentRequest::ShippingMethod&);
};
-template<> struct ArgumentCoder<WebCore::PaymentRequest::SupportedNetworks> {
- static void encode(ArgumentEncoder&, const WebCore::PaymentRequest::SupportedNetworks&);
- static bool decode(ArgumentDecoder&, WebCore::PaymentRequest::SupportedNetworks&);
-};
-
template<> struct ArgumentCoder<WebCore::PaymentRequest::TotalAndLineItems> {
static void encode(ArgumentEncoder&, const WebCore::PaymentRequest::TotalAndLineItems&);
static bool decode(ArgumentDecoder&, WebCore::PaymentRequest::TotalAndLineItems&);
Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (204589 => 204590)
--- branches/safari-602-branch/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm 2016-08-18 05:37:34 UTC (rev 204590)
@@ -282,24 +282,43 @@
return result;
}
-static RetainPtr<NSArray> toSupportedNetworks(const WebCore::PaymentRequest::SupportedNetworks& supportedNetworks)
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WebPaymentCoordinatorProxyCocoaAdditions.mm>)
+#import <WebKitAdditions/WebPaymentCoordinatorProxyCocoaAdditions.mm>
+#else
+static inline NSString *toAdditionalSupportedNetwork(const String&)
{
+ return nullptr;
+}
+#endif
+
+static NSString *toSupportedNetwork(const String& supportedNetwork)
+{
+ if (supportedNetwork == "amex")
+ return getPKPaymentNetworkAmex();
+ if (supportedNetwork == "chinaUnionPay")
+ return getPKPaymentNetworkChinaUnionPay();
+ if (supportedNetwork == "discover")
+ return getPKPaymentNetworkDiscover();
+ if (supportedNetwork == "interac")
+ return getPKPaymentNetworkInterac();
+ if (supportedNetwork == "masterCard")
+ return getPKPaymentNetworkMasterCard();
+ if (supportedNetwork == "privateLabel")
+ return getPKPaymentNetworkPrivateLabel();
+ if (supportedNetwork == "visa")
+ return getPKPaymentNetworkVisa();
+
+ return toAdditionalSupportedNetwork(supportedNetwork);
+}
+
+static RetainPtr<NSArray> toSupportedNetworks(const Vector<String>& supportedNetworks)
+{
auto result = adoptNS([[NSMutableArray alloc] init]);
- if (supportedNetworks.amex)
- [result addObject:getPKPaymentNetworkAmex()];
- if (supportedNetworks.chinaUnionPay)
- [result addObject:getPKPaymentNetworkChinaUnionPay()];
- if (supportedNetworks.discover)
- [result addObject:getPKPaymentNetworkDiscover()];
- if (supportedNetworks.interac)
- [result addObject:getPKPaymentNetworkInterac()];
- if (supportedNetworks.masterCard)
- [result addObject:getPKPaymentNetworkMasterCard()];
- if (supportedNetworks.privateLabel)
- [result addObject:getPKPaymentNetworkPrivateLabel()];
- if (supportedNetworks.visa)
- [result addObject:getPKPaymentNetworkVisa()];
+ for (auto& supportedNetwork : supportedNetworks) {
+ if (auto network = toSupportedNetwork(supportedNetwork))
+ [result addObject:network];
+ }
return result;
}
Modified: branches/safari-602-branch/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.cpp (204589 => 204590)
--- branches/safari-602-branch/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.cpp 2016-08-18 03:07:31 UTC (rev 204589)
+++ branches/safari-602-branch/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.cpp 2016-08-18 05:37:34 UTC (rev 204590)
@@ -54,7 +54,7 @@
{
ASSERT(version > 0);
- if (version == 1)
+ if (version <= 2)
return true;
return false;