[Apple Pay] Stop maintaining a list of payment networks
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Dec 2017 17:49:29 +0000 (17:49 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Dec 2017 17:49:29 +0000 (17:49 +0000)
commit419fe1e8a530c7c1cc2f62b43675c435620d7dc9
tree558b5fb9a749b4457891e30b041e3473cd3495e8
parent867f6c6379ff995701d62edcd0567368f0f7bb3f
[Apple Pay] Stop maintaining a list of payment networks
https://bugs.webkit.org/show_bug.cgi?id=180965
<rdar://problem/34696560>

Reviewed by Tim Horton.

Source/WebCore:

Instead of maintaining the list of valid payment networks in WebCore, allow the client to
provide the list when constructing a PaymentCoordinator. Then, use PaymentCoordinator's list
to validate ApplePaySessionPaymentRequests.

Validation will now be done case-insensitively since Cocoa clients will provide a list of
network names that differ in capitalization from the names formerly accepted by WebCore.

Added new test cases to http/tests/ssl/applepay/ApplePaySession.html.

* Modules/applepay/ApplePayRequestBase.cpp:
(WebCore::convertAndValidate): Changed to return a Vector of validated strings.
(WebCore::validate): Renamed to convertAndValidate.
* Modules/applepay/ApplePayRequestBase.h:
* Modules/applepay/ApplePaySession.cpp:
(WebCore::convertAndValidate):
(WebCore::ApplePaySession::create):
* Modules/applepay/ApplePaySessionPaymentRequest.cpp:
(WebCore::ApplePaySessionPaymentRequest::isValidSupportedNetwork): Deleted.
* Modules/applepay/ApplePaySessionPaymentRequest.h:
* Modules/applepay/PaymentCoordinator.cpp:
(WebCore::toHashSet):
(WebCore::PaymentCoordinator::PaymentCoordinator): Converted availablePaymentNetworks to a
case-insensitive HashSet and stored in m_availablePaymentNetworks.
(WebCore::PaymentCoordinator::validatedPaymentNetwork const): Added special cases for "jcb"
and "carteBancaire" for API compatibility. For other networks, checked m_availablePaymentNetworks.
* Modules/applepay/PaymentCoordinator.h:
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::show):
* page/MainFrame.cpp:
(WebCore::MainFrame::MainFrame): Constructed m_paymentCoordinator with configuration.availablePaymentNetworks.
* page/PageConfiguration.h:
* testing/Internals.cpp:
(WebCore::Internals::Internals):
* testing/MockPaymentCoordinator.cpp:
* testing/MockPaymentCoordinator.h:

Source/WebCore/PAL:

* pal/spi/cocoa/PassKitSPI.h: Defined +[PKPaymentRequest availableNetworks].

Source/WebKit:

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h: Defined availablePaymentNetworks.
* UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
* UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::toSupportedNetworks):
(WebKit::WebPaymentCoordinatorProxy::availablePaymentNetworks): Called
+[PKPaymentRequest availableNetworks].
(WebKit::toSupportedNetwork): Deleted.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters): Set parameters.availablePaymentNetworks by
calling WebPaymentCoordinatorProxy::availablePaymentNetworks.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Set pageConfiguration.availablePaymentNetworks to
parameters.availablePaymentNetworks.

LayoutTests:

* http/tests/ssl/applepay/ApplePaySession-expected.txt:
* http/tests/ssl/applepay/ApplePaySession.html: Added a test case for network names with
varying capitalization.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226123 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt
LayoutTests/http/tests/ssl/applepay/ApplePaySession.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp
Source/WebCore/Modules/applepay/ApplePayRequestBase.h
Source/WebCore/Modules/applepay/ApplePaySession.cpp
Source/WebCore/Modules/applepay/ApplePaySessionPaymentRequest.cpp
Source/WebCore/Modules/applepay/ApplePaySessionPaymentRequest.h
Source/WebCore/Modules/applepay/PaymentCoordinator.cpp
Source/WebCore/Modules/applepay/PaymentCoordinator.h
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h
Source/WebCore/page/MainFrame.cpp
Source/WebCore/page/PageConfiguration.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/MockPaymentCoordinator.cpp
Source/WebCore/testing/MockPaymentCoordinator.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPageCreationParameters.cpp
Source/WebKit/Shared/WebPageCreationParameters.h
Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h
Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp