Changeset 242681 in webkit
- Timestamp:
- Mar 9, 2019 9:29:42 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242679 r242681 1 2019-03-09 Andy Estes <aestes@apple.com> 2 3 [Apple Pay] CanMakePaymentsWithActiveCard and OpenPaymentSetup should be async messages 4 https://bugs.webkit.org/show_bug.cgi?id=195526 5 <rdar://problem/48745636> 6 7 Reviewed by Chris Dumez. 8 9 * Modules/applepay/PaymentCoordinatorClient.h: 10 * loader/EmptyClients.cpp: 11 * testing/MockPaymentCoordinator.cpp: 12 (WebCore::MockPaymentCoordinator::canMakePaymentsWithActiveCard): 13 (WebCore::MockPaymentCoordinator::openPaymentSetup): 14 * testing/MockPaymentCoordinator.h: 15 1 16 2019-03-09 Zalan Bujtas <zalan@apple.com> 2 17 -
trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp
r239427 r242681 32 32 #include "PaymentCoordinatorClient.h" 33 33 #include "PaymentSession.h" 34 #include <wtf/CompletionHandler.h> 34 35 #include <wtf/URL.h> 35 36 -
trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h
r241105 r242681 50 50 virtual Optional<String> validatedPaymentNetwork(const String&) = 0; 51 51 virtual bool canMakePayments() = 0; 52 virtual void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) = 0;53 virtual void openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) = 0;52 virtual void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&) = 0; 53 virtual void openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&) = 0; 54 54 55 55 virtual bool showPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLs, const ApplePaySessionPaymentRequest&) = 0; -
trunk/Source/WebCore/loader/EmptyClients.cpp
r242317 r242681 317 317 Optional<String> validatedPaymentNetwork(const String&) final { return WTF::nullopt; } 318 318 bool canMakePayments() final { return false; } 319 void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&& completionHandler) final { callOnMainThread([completionHandler = WTFMove(completionHandler)]{ completionHandler(false); }); }320 void openPaymentSetup(const String&, const String&, WTF::Function<void(bool)>&& completionHandler) final { callOnMainThread([completionHandler = WTFMove(completionHandler)]{ completionHandler(false); }); }319 void canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&& completionHandler) final { callOnMainThread([completionHandler = WTFMove(completionHandler)]() mutable { completionHandler(false); }); } 320 void openPaymentSetup(const String&, const String&, CompletionHandler<void(bool)>&& completionHandler) final { callOnMainThread([completionHandler = WTFMove(completionHandler)]() mutable { completionHandler(false); }); } 321 321 bool showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&) final { return false; } 322 322 void completeMerchantValidation(const PaymentMerchantSession&) final { } -
trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp
r241105 r242681 35 35 #include "Page.h" 36 36 #include "PaymentCoordinator.h" 37 #include <wtf/CompletionHandler.h> 37 38 #include <wtf/RunLoop.h> 38 39 #include <wtf/URL.h> … … 67 68 } 68 69 69 void MockPaymentCoordinator::canMakePaymentsWithActiveCard(const String&, const String&, Function<void(bool)>&& completionHandler)70 { 71 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), canMakePaymentsWithActiveCard = m_canMakePaymentsWithActiveCard] {70 void MockPaymentCoordinator::canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&& completionHandler) 71 { 72 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), canMakePaymentsWithActiveCard = m_canMakePaymentsWithActiveCard]() mutable { 72 73 completionHandler(canMakePaymentsWithActiveCard); 73 74 }); 74 75 } 75 76 76 void MockPaymentCoordinator::openPaymentSetup(const String&, const String&, Function<void(bool)>&& completionHandler)77 { 78 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {77 void MockPaymentCoordinator::openPaymentSetup(const String&, const String&, CompletionHandler<void(bool)>&& completionHandler) 78 { 79 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)]() mutable { 79 80 completionHandler(true); 80 81 }); -
trunk/Source/WebCore/testing/MockPaymentCoordinator.h
r241105 r242681 67 67 Optional<String> validatedPaymentNetwork(const String&) final; 68 68 bool canMakePayments() final; 69 void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&&);70 void openPaymentSetup(const String&, const String&, WTF::Function<void(bool)>&&);69 void canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&&); 70 void openPaymentSetup(const String&, const String&, CompletionHandler<void(bool)>&&); 71 71 bool showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&) final; 72 72 void completeMerchantValidation(const PaymentMerchantSession&) final; -
trunk/Source/WebKit/ChangeLog
r242680 r242681 1 2019-03-09 Andy Estes <aestes@apple.com> 2 3 [Apple Pay] CanMakePaymentsWithActiveCard and OpenPaymentSetup should be async messages 4 https://bugs.webkit.org/show_bug.cgi?id=195526 5 <rdar://problem/48745636> 6 7 Reviewed by Chris Dumez. 8 9 * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp: 10 (WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard): 11 (WebKit::WebPaymentCoordinatorProxy::openPaymentSetup): 12 * Shared/ApplePay/WebPaymentCoordinatorProxy.h: 13 * Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in: 14 * WebProcess/ApplePay/WebPaymentCoordinator.cpp: 15 (WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCard): 16 (WebKit::WebPaymentCoordinator::openPaymentSetup): 17 (WebKit::generateCanMakePaymentsWithActiveCardReplyID): Deleted. 18 (WebKit::generateOpenPaymentSetupReplyID): Deleted. 19 (WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCardReply): Deleted. 20 (WebKit::WebPaymentCoordinator::openPaymentSetupReply): Deleted. 21 * WebProcess/ApplePay/WebPaymentCoordinator.h: 22 * WebProcess/ApplePay/WebPaymentCoordinator.messages.in: 23 1 24 2019-03-09 Andy Estes <aestes@apple.com> 2 25 -
trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.cpp
r242616 r242681 79 79 } 80 80 81 void WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, uint64_t requestID) 82 { 83 platformCanMakePaymentsWithActiveCard(merchantIdentifier, domainName, [weakThis = makeWeakPtr(*this), requestID](bool canMakePayments) { 84 if (auto paymentCoordinatorProxy = weakThis.get()) 85 paymentCoordinatorProxy->send(Messages::WebPaymentCoordinator::CanMakePaymentsWithActiveCardReply(requestID, canMakePayments)); 86 }); 87 } 88 89 void WebPaymentCoordinatorProxy::openPaymentSetup(const String& merchantIdentifier, const String& domainName, uint64_t requestID) 90 { 91 platformOpenPaymentSetup(merchantIdentifier, domainName, [weakThis = makeWeakPtr(*this), requestID](bool result) { 92 if (auto paymentCoordinatorProxy = weakThis.get()) 93 paymentCoordinatorProxy->send(Messages::WebPaymentCoordinator::OpenPaymentSetupReply(requestID, result)); 94 }); 81 void WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler) 82 { 83 platformCanMakePaymentsWithActiveCard(merchantIdentifier, domainName, WTFMove(completionHandler)); 84 } 85 86 void WebPaymentCoordinatorProxy::openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler) 87 { 88 platformOpenPaymentSetup(merchantIdentifier, domainName, WTFMove(completionHandler)); 95 89 } 96 90 -
trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.h
r242616 r242681 113 113 void availablePaymentNetworks(CompletionHandler<void(Vector<String>&&)>&&); 114 114 void canMakePayments(CompletionHandler<void(bool)>&&); 115 void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, uint64_t requestID);116 void openPaymentSetup(const String& merchantIdentifier, const String& domainName, uint64_t requestID);115 void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&); 116 void openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&); 117 117 void showPaymentUI(const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest&, CompletionHandler<void(bool)>&&); 118 118 void completeMerchantValidation(const WebCore::PaymentMerchantSession&); -
trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in
r242356 r242681 29 29 AvailablePaymentNetworks() -> (Vector<String> availablePaymentNetworks) Delayed 30 30 CanMakePayments() -> (bool result) Delayed 31 CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName , uint64_t requestID)32 OpenPaymentSetup(String merchantIdentifier, String domainName , uint64_t requestID)31 CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName) -> (bool canMakePayments) Async 32 OpenPaymentSetup(String merchantIdentifier, String domainName) -> (bool result) Async 33 33 34 34 ShowPaymentUI(String originatingURLString, Vector<String> linkIconURLStrings, WebCore::ApplePaySessionPaymentRequest paymentRequest) -> (bool result) Delayed -
trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp
r241105 r242681 87 87 } 88 88 89 static uint64_t generateCanMakePaymentsWithActiveCardReplyID()89 void WebPaymentCoordinator::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler) 90 90 { 91 static uint64_t canMakePaymentsWithActiveCardReplyID; 92 93 return ++canMakePaymentsWithActiveCardReplyID; 91 m_webPage.sendWithAsyncReply(Messages::WebPaymentCoordinatorProxy::CanMakePaymentsWithActiveCard(merchantIdentifier, domainName), WTFMove(completionHandler)); 94 92 } 95 93 96 void WebPaymentCoordinator:: canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void(bool)>&& completionHandler)94 void WebPaymentCoordinator::openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler) 97 95 { 98 auto replyID = generateCanMakePaymentsWithActiveCardReplyID(); 99 100 m_pendingCanMakePaymentsWithActiveCardCallbacks.add(replyID, WTFMove(completionHandler)); 101 m_webPage.send(Messages::WebPaymentCoordinatorProxy::CanMakePaymentsWithActiveCard(merchantIdentifier, domainName, replyID)); 102 } 103 104 static uint64_t generateOpenPaymentSetupReplyID() 105 { 106 static uint64_t openPaymentSetupReplyID; 107 108 return ++openPaymentSetupReplyID; 109 } 110 111 void WebPaymentCoordinator::openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) 112 { 113 auto replyID = generateOpenPaymentSetupReplyID(); 114 115 m_pendingOpenPaymentSetupCallbacks.add(replyID, WTFMove(completionHandler)); 116 m_webPage.send(Messages::WebPaymentCoordinatorProxy::OpenPaymentSetup(merchantIdentifier, domainName, replyID)); 96 m_webPage.sendWithAsyncReply(Messages::WebPaymentCoordinatorProxy::OpenPaymentSetup(merchantIdentifier, domainName), WTFMove(completionHandler)); 117 97 } 118 98 … … 200 180 } 201 181 202 void WebPaymentCoordinator::canMakePaymentsWithActiveCardReply(uint64_t requestID, bool canMakePayments)203 {204 auto callback = m_pendingCanMakePaymentsWithActiveCardCallbacks.take(requestID);205 callback(canMakePayments);206 }207 208 void WebPaymentCoordinator::openPaymentSetupReply(uint64_t requestID, bool result)209 {210 auto callback = m_pendingOpenPaymentSetupCallbacks.take(requestID);211 callback(result);212 }213 214 182 WebCore::PaymentCoordinator& WebPaymentCoordinator::paymentCoordinator() 215 183 { -
trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h
r241105 r242681 58 58 Optional<String> validatedPaymentNetwork(const String&) override; 59 59 bool canMakePayments() override; 60 void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) override;61 void openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) override;60 void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&) override; 61 void openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&) override; 62 62 bool showPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest&) override; 63 63 void completeMerchantValidation(const WebCore::PaymentMerchantSession&) override; … … 82 82 void didSelectPaymentMethod(const WebCore::PaymentMethod&); 83 83 void didCancelPaymentSession(); 84 void canMakePaymentsWithActiveCardReply(uint64_t requestID, bool canMakePayments);85 void openPaymentSetupReply(uint64_t requestID, bool result);86 84 87 85 WebCore::PaymentCoordinator& paymentCoordinator(); … … 91 89 92 90 WebPage& m_webPage; 93 94 HashMap<uint64_t, WTF::Function<void (bool)>> m_pendingCanMakePaymentsWithActiveCardCallbacks;95 HashMap<uint64_t, WTF::Function<void (bool)>> m_pendingOpenPaymentSetupCallbacks;96 91 97 92 Optional<AvailablePaymentNetworksSet> m_availablePaymentNetworks; -
trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.messages.in
r220821 r242681 33 33 DidSelectPaymentMethod(WebCore::PaymentMethod paymentMethod) 34 34 DidCancelPaymentSession() 35 CanMakePaymentsWithActiveCardReply(uint64_t requestID, bool canMakePayments)36 OpenPaymentSetupReply(uint64_t requestID, bool result)37 35 } 38 36 -
trunk/Source/WebKitLegacy/mac/ChangeLog
r242624 r242681 1 2019-03-09 Andy Estes <aestes@apple.com> 2 3 [Apple Pay] CanMakePaymentsWithActiveCard and OpenPaymentSetup should be async messages 4 https://bugs.webkit.org/show_bug.cgi?id=195526 5 <rdar://problem/48745636> 6 7 Reviewed by Chris Dumez. 8 9 * WebCoreSupport/WebPaymentCoordinatorClient.h: 10 * WebCoreSupport/WebPaymentCoordinatorClient.mm: 11 (WebPaymentCoordinatorClient::canMakePaymentsWithActiveCard): 12 (WebPaymentCoordinatorClient::openPaymentSetup): 13 1 14 2019-03-07 Said Abou-Hallawa <sabouhallawa@apple.com> 2 15 -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.h
r241105 r242681 39 39 Optional<String> validatedPaymentNetwork(const String&) override; 40 40 bool canMakePayments() override; 41 void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void (bool)>&& completionHandler) override;42 void openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) override;41 void canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&&) override; 42 void openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&) override; 43 43 bool showPaymentUI(const URL&, const Vector<URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest&) override; 44 44 void completeMerchantValidation(const WebCore::PaymentMerchantSession&) override; -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm
r241105 r242681 28 28 #if ENABLE(APPLE_PAY) 29 29 30 #import <wtf/CompletionHandler.h> 30 31 #import <wtf/MainThread.h> 31 32 #import <wtf/URL.h> … … 49 50 } 50 51 51 void WebPaymentCoordinatorClient::canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&& completionHandler)52 void WebPaymentCoordinatorClient::canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&& completionHandler) 52 53 { 53 callOnMainThread([completionHandler = WTFMove(completionHandler)] {54 callOnMainThread([completionHandler = WTFMove(completionHandler)]() mutable { 54 55 completionHandler(false); 55 56 }); 56 57 } 57 58 58 void WebPaymentCoordinatorClient::openPaymentSetup(const String&, const String&, WTF::Function<void(bool)>&& completionHandler)59 void WebPaymentCoordinatorClient::openPaymentSetup(const String&, const String&, CompletionHandler<void(bool)>&& completionHandler) 59 60 { 60 callOnMainThread([completionHandler = WTFMove(completionHandler)] {61 callOnMainThread([completionHandler = WTFMove(completionHandler)]() mutable { 61 62 completionHandler(false); 62 63 });
Note: See TracChangeset
for help on using the changeset viewer.