Changeset 242681 in webkit


Ignore:
Timestamp:
Mar 9, 2019 9:29:42 PM (5 years ago)
Author:
aestes@apple.com
Message:

[Apple Pay] CanMakePaymentsWithActiveCard and OpenPaymentSetup should be async messages
https://bugs.webkit.org/show_bug.cgi?id=195526
<rdar://problem/48745636>

Reviewed by Chris Dumez.

Source/WebCore:

  • Modules/applepay/PaymentCoordinatorClient.h:
  • loader/EmptyClients.cpp:
  • testing/MockPaymentCoordinator.cpp:

(WebCore::MockPaymentCoordinator::canMakePaymentsWithActiveCard):
(WebCore::MockPaymentCoordinator::openPaymentSetup):

  • testing/MockPaymentCoordinator.h:

Source/WebKit:

  • Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:

(WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard):
(WebKit::WebPaymentCoordinatorProxy::openPaymentSetup):

  • Shared/ApplePay/WebPaymentCoordinatorProxy.h:
  • Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in:
  • WebProcess/ApplePay/WebPaymentCoordinator.cpp:

(WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCard):
(WebKit::WebPaymentCoordinator::openPaymentSetup):
(WebKit::generateCanMakePaymentsWithActiveCardReplyID): Deleted.
(WebKit::generateOpenPaymentSetupReplyID): Deleted.
(WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCardReply): Deleted.
(WebKit::WebPaymentCoordinator::openPaymentSetupReply): Deleted.

  • WebProcess/ApplePay/WebPaymentCoordinator.h:
  • WebProcess/ApplePay/WebPaymentCoordinator.messages.in:

Source/WebKitLegacy/mac:

  • WebCoreSupport/WebPaymentCoordinatorClient.h:
  • WebCoreSupport/WebPaymentCoordinatorClient.mm:

(WebPaymentCoordinatorClient::canMakePaymentsWithActiveCard):
(WebPaymentCoordinatorClient::openPaymentSetup):

Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242679 r242681  
     12019-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
    1162019-03-09  Zalan Bujtas  <zalan@apple.com>
    217
  • trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp

    r239427 r242681  
    3232#include "PaymentCoordinatorClient.h"
    3333#include "PaymentSession.h"
     34#include <wtf/CompletionHandler.h>
    3435#include <wtf/URL.h>
    3536
  • trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h

    r241105 r242681  
    5050    virtual Optional<String> validatedPaymentNetwork(const String&) = 0;
    5151    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;
    5454
    5555    virtual bool showPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLs, const ApplePaySessionPaymentRequest&) = 0;
  • trunk/Source/WebCore/loader/EmptyClients.cpp

    r242317 r242681  
    317317    Optional<String> validatedPaymentNetwork(const String&) final { return WTF::nullopt; }
    318318    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); }); }
    321321    bool showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&) final { return false; }
    322322    void completeMerchantValidation(const PaymentMerchantSession&) final { }
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp

    r241105 r242681  
    3535#include "Page.h"
    3636#include "PaymentCoordinator.h"
     37#include <wtf/CompletionHandler.h>
    3738#include <wtf/RunLoop.h>
    3839#include <wtf/URL.h>
     
    6768}
    6869
    69 void MockPaymentCoordinator::canMakePaymentsWithActiveCard(const String&, const String&, Function<void(bool)>&& completionHandler)
    70 {
    71     RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), canMakePaymentsWithActiveCard = m_canMakePaymentsWithActiveCard] {
     70void MockPaymentCoordinator::canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&& completionHandler)
     71{
     72    RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), canMakePaymentsWithActiveCard = m_canMakePaymentsWithActiveCard]() mutable {
    7273        completionHandler(canMakePaymentsWithActiveCard);
    7374    });
    7475}
    7576
    76 void MockPaymentCoordinator::openPaymentSetup(const String&, const String&, Function<void(bool)>&& completionHandler)
    77 {
    78     RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {
     77void MockPaymentCoordinator::openPaymentSetup(const String&, const String&, CompletionHandler<void(bool)>&& completionHandler)
     78{
     79    RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)]() mutable {
    7980        completionHandler(true);
    8081    });
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.h

    r241105 r242681  
    6767    Optional<String> validatedPaymentNetwork(const String&) final;
    6868    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)>&&);
    7171    bool showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&) final;
    7272    void completeMerchantValidation(const PaymentMerchantSession&) final;
  • trunk/Source/WebKit/ChangeLog

    r242680 r242681  
     12019-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
    1242019-03-09  Andy Estes  <aestes@apple.com>
    225
  • trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.cpp

    r242616 r242681  
    7979}
    8080
    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     });
     81void WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler)
     82{
     83    platformCanMakePaymentsWithActiveCard(merchantIdentifier, domainName, WTFMove(completionHandler));
     84}
     85
     86void WebPaymentCoordinatorProxy::openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler)
     87{
     88    platformOpenPaymentSetup(merchantIdentifier, domainName, WTFMove(completionHandler));
    9589}
    9690
  • trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.h

    r242616 r242681  
    113113    void availablePaymentNetworks(CompletionHandler<void(Vector<String>&&)>&&);
    114114    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)>&&);
    117117    void showPaymentUI(const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest&, CompletionHandler<void(bool)>&&);
    118118    void completeMerchantValidation(const WebCore::PaymentMerchantSession&);
  • trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in

    r242356 r242681  
    2929    AvailablePaymentNetworks() -> (Vector<String> availablePaymentNetworks) Delayed
    3030    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
    3333
    3434    ShowPaymentUI(String originatingURLString, Vector<String> linkIconURLStrings, WebCore::ApplePaySessionPaymentRequest paymentRequest) -> (bool result) Delayed
  • trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp

    r241105 r242681  
    8787}
    8888
    89 static uint64_t generateCanMakePaymentsWithActiveCardReplyID()
     89void WebPaymentCoordinator::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler)
    9090{
    91     static uint64_t canMakePaymentsWithActiveCardReplyID;
    92 
    93     return ++canMakePaymentsWithActiveCardReplyID;
     91    m_webPage.sendWithAsyncReply(Messages::WebPaymentCoordinatorProxy::CanMakePaymentsWithActiveCard(merchantIdentifier, domainName), WTFMove(completionHandler));
    9492}
    9593
    96 void WebPaymentCoordinator::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler)
     94void WebPaymentCoordinator::openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler)
    9795{
    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));
    11797}
    11898
     
    200180}
    201181
    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 
    214182WebCore::PaymentCoordinator& WebPaymentCoordinator::paymentCoordinator()
    215183{
  • trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h

    r241105 r242681  
    5858    Optional<String> validatedPaymentNetwork(const String&) override;
    5959    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;
    6262    bool showPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest&) override;
    6363    void completeMerchantValidation(const WebCore::PaymentMerchantSession&) override;
     
    8282    void didSelectPaymentMethod(const WebCore::PaymentMethod&);
    8383    void didCancelPaymentSession();
    84     void canMakePaymentsWithActiveCardReply(uint64_t requestID, bool canMakePayments);
    85     void openPaymentSetupReply(uint64_t requestID, bool result);
    8684
    8785    WebCore::PaymentCoordinator& paymentCoordinator();
     
    9189
    9290    WebPage& m_webPage;
    93 
    94     HashMap<uint64_t, WTF::Function<void (bool)>> m_pendingCanMakePaymentsWithActiveCardCallbacks;
    95     HashMap<uint64_t, WTF::Function<void (bool)>> m_pendingOpenPaymentSetupCallbacks;
    9691
    9792    Optional<AvailablePaymentNetworksSet> m_availablePaymentNetworks;
  • trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.messages.in

    r220821 r242681  
    3333    DidSelectPaymentMethod(WebCore::PaymentMethod paymentMethod)
    3434    DidCancelPaymentSession()
    35     CanMakePaymentsWithActiveCardReply(uint64_t requestID, bool canMakePayments)
    36     OpenPaymentSetupReply(uint64_t requestID, bool result)
    3735}
    3836
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r242624 r242681  
     12019-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
    1142019-03-07  Said Abou-Hallawa  <sabouhallawa@apple.com>
    215
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.h

    r241105 r242681  
    3939    Optional<String> validatedPaymentNetwork(const String&) override;
    4040    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;
    4343    bool showPaymentUI(const URL&, const Vector<URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest&) override;
    4444    void completeMerchantValidation(const WebCore::PaymentMerchantSession&) override;
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm

    r241105 r242681  
    2828#if ENABLE(APPLE_PAY)
    2929
     30#import <wtf/CompletionHandler.h>
    3031#import <wtf/MainThread.h>
    3132#import <wtf/URL.h>
     
    4950}
    5051
    51 void WebPaymentCoordinatorClient::canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void (bool)>&& completionHandler)
     52void WebPaymentCoordinatorClient::canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&& completionHandler)
    5253{
    53     callOnMainThread([completionHandler = WTFMove(completionHandler)] {
     54    callOnMainThread([completionHandler = WTFMove(completionHandler)]() mutable {
    5455        completionHandler(false);
    5556    });
    5657}
    5758
    58 void WebPaymentCoordinatorClient::openPaymentSetup(const String&, const String&, WTF::Function<void (bool)>&& completionHandler)
     59void WebPaymentCoordinatorClient::openPaymentSetup(const String&, const String&, CompletionHandler<void(bool)>&& completionHandler)
    5960{
    60     callOnMainThread([completionHandler = WTFMove(completionHandler)] {
     61    callOnMainThread([completionHandler = WTFMove(completionHandler)]() mutable {
    6162        completionHandler(false);
    6263    });
Note: See TracChangeset for help on using the changeset viewer.