Title: [206238] trunk/Source
Revision
206238
Author
ander...@apple.com
Date
2016-09-21 15:51:52 -0700 (Wed, 21 Sep 2016)

Log Message

Source/WebCore:
support openPaymentSetup API on ApplePaySession object
https://bugs.webkit.org/show_bug.cgi?id=162357
rdar://problem/26776939

Reviewed by Tim Horton.

* Modules/applepay/ApplePaySession.cpp:
(WebCore::ApplePaySession::openPaymentSetup):
Perform security checks and then call into the PaymentCoordiantor. In its completion handler, we resolve the promise.

* Modules/applepay/ApplePaySession.h:
Add new members.

* Modules/applepay/ApplePaySession.idl:
Add openPaymentSetup declaration.

* Modules/applepay/PaymentCoordinator.cpp:
(WebCore::PaymentCoordinator::openPaymentSetup):
Call through to the clients.

* Modules/applepay/PaymentCoordinator.h:
* Modules/applepay/PaymentCoordinatorClient.h:
Add new members.

* loader/EmptyClients.cpp:
Add new stub.

* platform/spi/cocoa/PassKitSPI.h:
Add SPI declaration.

Source/WebKit/mac:
Support openPaymentSetup API on ApplePaySession object
https://bugs.webkit.org/show_bug.cgi?id=162357
rdar://problem/26776939

Reviewed by Tim Horton.

Add openPaymentSetup stub.

* WebCoreSupport/WebPaymentCoordinatorClient.h:
* WebCoreSupport/WebPaymentCoordinatorClient.mm:
(WebPaymentCoordinatorClient::openPaymentSetup):

Source/WebKit2:
support openPaymentSetup API on ApplePaySession object
https://bugs.webkit.org/show_bug.cgi?id=162357
rdar://problem/26776939

Reviewed by Tim Horton.

* UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp:
(WebKit::WebPaymentCoordinatorProxy::openPaymentSetup):
Call through to platformOpenPaymentSetup, and in the completion handler, send back a OpenPaymentSetupReply message.

* UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
Add new members.

* UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in:
Add OpenPaymentSetup message.

* UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::WebPaymentCoordinatorProxy::platformOpenPaymentSetup):
Allocate a PKPassLibrary and call openPaymentSetupForMerchantIdentifier:domain:completion: on it.

* WebProcess/ApplePay/WebPaymentCoordinator.cpp:
(WebKit::generateOpenPaymentSetupReplyID):
New helper function to generate a reply ID.

(WebKit::WebPaymentCoordinator::openPaymentSetup):
Add the completion handler to m_pendingOpenPaymentSetupCallbacks and send a OpenPaymentSetup message to the UI process.

(WebKit::WebPaymentCoordinator::openPaymentSetupReply):
Grab the callback given its ID and invoke it.

* WebProcess/ApplePay/WebPaymentCoordinator.h:
Add new members.

* WebProcess/ApplePay/WebPaymentCoordinator.messages.in:
Add OpenPaymentSetupReply message.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206237 => 206238)


--- trunk/Source/WebCore/ChangeLog	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebCore/ChangeLog	2016-09-21 22:51:52 UTC (rev 206238)
@@ -1,3 +1,35 @@
+2016-09-21  Anders Carlsson  <ander...@apple.com>
+
+        support openPaymentSetup API on ApplePaySession object
+        https://bugs.webkit.org/show_bug.cgi?id=162357
+        rdar://problem/26776939
+
+        Reviewed by Tim Horton.
+
+        * Modules/applepay/ApplePaySession.cpp:
+        (WebCore::ApplePaySession::openPaymentSetup):
+        Perform security checks and then call into the PaymentCoordiantor. In its completion handler, we resolve the promise.
+
+        * Modules/applepay/ApplePaySession.h:
+        Add new members.
+
+        * Modules/applepay/ApplePaySession.idl:
+        Add openPaymentSetup declaration.
+
+        * Modules/applepay/PaymentCoordinator.cpp:
+        (WebCore::PaymentCoordinator::openPaymentSetup):
+        Call through to the clients.
+
+        * Modules/applepay/PaymentCoordinator.h:
+        * Modules/applepay/PaymentCoordinatorClient.h:
+        Add new members.
+
+        * loader/EmptyClients.cpp:
+        Add new stub.
+
+        * platform/spi/cocoa/PassKitSPI.h:
+        Add SPI declaration.
+
 2016-09-21  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r206222 and r206227.

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp (206237 => 206238)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2016-09-21 22:51:52 UTC (rev 206238)
@@ -763,6 +763,32 @@
     });
 }
 
+void ApplePaySession::openPaymentSetup(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredWrapper>&& passedPromise, ExceptionCode& ec)
+{
+    auto& document = downcast<Document>(scriptExecutionContext);
+    DOMWindow& window = *document.domWindow();
+
+    String errorMessage;
+    if (!canCallApplePaySessionAPIs(document, errorMessage)) {
+        window.printErrorMessage(errorMessage);
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
+    if (!ScriptController::processingUserGesture()) {
+        window.printErrorMessage("Must call ApplePaySession.openPaymemntSetup from a user gesture handler.");
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
+    RefPtr<DeferredWrapper> promise(WTFMove(passedPromise));
+    auto& paymentCoordinator = document.frame()->mainFrame().paymentCoordinator();
+
+    paymentCoordinator.openPaymentSetup(merchantIdentifier, document.domain(), [promise](bool result) mutable {
+        promise->resolve(result);
+    });
+}
+
 void ApplePaySession::begin(ExceptionCode& ec)
 {
     auto& document = *downcast<Document>(scriptExecutionContext());

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.h (206237 => 206238)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.h	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.h	2016-09-21 22:51:52 UTC (rev 206238)
@@ -64,6 +64,7 @@
     static bool supportsVersion(ScriptExecutionContext&, unsigned version, ExceptionCode&);
     static bool canMakePayments(ScriptExecutionContext&, ExceptionCode&);
     static void canMakePaymentsWithActiveCard(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredWrapper>&&, ExceptionCode&);
+    static void openPaymentSetup(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredWrapper>&&, ExceptionCode&);
 
     void begin(ExceptionCode&);
     void abort(ExceptionCode&);

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.idl (206237 => 206238)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.idl	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.idl	2016-09-21 22:51:52 UTC (rev 206238)
@@ -43,6 +43,7 @@
     [CallWith=ScriptExecutionContext, RaisesException] static boolean supportsVersion(unsigned long version);
     [CallWith=ScriptExecutionContext, RaisesException] static boolean canMakePayments();
     [CallWith=ScriptExecutionContext, RaisesException] static Promise canMakePaymentsWithActiveCard(DOMString merchantIdentifier);
+    [CallWith=ScriptExecutionContext, RaisesException] static Promise openPaymentSetup(DOMString merchantIdentifier);
 
     [RaisesException] void begin();
     [RaisesException] void abort();

Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp (206237 => 206238)


--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp	2016-09-21 22:51:52 UTC (rev 206238)
@@ -60,6 +60,11 @@
     m_client.canMakePaymentsWithActiveCard(merchantIdentifier, domainName, WTFMove(completionHandler));
 }
 
+void PaymentCoordinator::openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler)
+{
+    m_client.openPaymentSetup(merchantIdentifier, domainName, WTFMove(completionHandler));
+}
+
 bool PaymentCoordinator::beginPaymentSession(ApplePaySession& paymentSession, const URL& originatingURL, const Vector<URL>& linkIconURLs, const PaymentRequest& paymentRequest)
 {
     ASSERT(!m_activeSession);

Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h (206237 => 206238)


--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h	2016-09-21 22:51:52 UTC (rev 206238)
@@ -49,6 +49,7 @@
     bool supportsVersion(unsigned version);
     bool canMakePayments();
     void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler);
+    void openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler);
 
     bool hasActiveSession() const { return m_activeSession; }
 

Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h (206237 => 206238)


--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h	2016-09-21 22:51:52 UTC (rev 206238)
@@ -42,6 +42,7 @@
     virtual bool supportsVersion(unsigned version) = 0;
     virtual bool canMakePayments() = 0;
     virtual void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) = 0;
+    virtual void openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) = 0;
 
     virtual bool showPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLs, const PaymentRequest&) = 0;
     virtual void completeMerchantValidation(const PaymentMerchantSession&) = 0;

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (206237 => 206238)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2016-09-21 22:51:52 UTC (rev 206238)
@@ -58,6 +58,8 @@
     bool supportsVersion(unsigned) override { return false; }
     bool canMakePayments() override { return false; }
     void canMakePaymentsWithActiveCard(const String&, const String&, std::function<void (bool)> completionHandler) override { callOnMainThread([completionHandler] { completionHandler(false); }); }
+    void openPaymentSetup(const String&, const String&, std::function<void (bool)> completionHandler) override { callOnMainThread([completionHandler] { completionHandler(false); }); }
+
     bool showPaymentUI(const URL&, const Vector<URL>&, const PaymentRequest&) override { return false; }
     void completeMerchantValidation(const PaymentMerchantSession&) override { }
 

Modified: trunk/Source/WebCore/platform/spi/cocoa/PassKitSPI.h (206237 => 206238)


--- trunk/Source/WebCore/platform/spi/cocoa/PassKitSPI.h	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebCore/platform/spi/cocoa/PassKitSPI.h	2016-09-21 22:51:52 UTC (rev 206238)
@@ -232,3 +232,11 @@
 
 extern "C"
 void PKDrawApplePayButton(_Nonnull CGContextRef, CGRect drawRect, CGFloat scale, PKPaymentButtonType, PKPaymentButtonStyle, NSString * _Nullable languageCode);
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface PKPassLibrary ()
+- (void)openPaymentSetupForMerchantIdentifier:(NSString *)identifier domain:(NSString *)domain completion:(void(^)(BOOL success))completion;
+@end
+
+NS_ASSUME_NONNULL_END

Modified: trunk/Source/WebKit/mac/ChangeLog (206237 => 206238)


--- trunk/Source/WebKit/mac/ChangeLog	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-09-21 22:51:52 UTC (rev 206238)
@@ -1,3 +1,17 @@
+2016-09-21  Anders Carlsson  <ander...@apple.com>
+
+        Support openPaymentSetup API on ApplePaySession object
+        https://bugs.webkit.org/show_bug.cgi?id=162357
+        rdar://problem/26776939
+
+        Reviewed by Tim Horton.
+
+        Add openPaymentSetup stub.
+
+        * WebCoreSupport/WebPaymentCoordinatorClient.h:
+        * WebCoreSupport/WebPaymentCoordinatorClient.mm:
+        (WebPaymentCoordinatorClient::openPaymentSetup):
+
 2016-09-19  Daniel Bates  <daba...@apple.com>
 
         Remove ENABLE(TEXT_AUTOSIZING) automatic text size adjustment code

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPaymentCoordinatorClient.h (206237 => 206238)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebPaymentCoordinatorClient.h	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPaymentCoordinatorClient.h	2016-09-21 22:51:52 UTC (rev 206238)
@@ -39,6 +39,7 @@
     bool supportsVersion(unsigned) override;
     bool canMakePayments() override;
     void canMakePaymentsWithActiveCard(const String&, const String&, std::function<void (bool)> completionHandler) override;
+    void openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) override;
     bool showPaymentUI(const WebCore::URL&, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest&) override;
     void completeMerchantValidation(const WebCore::PaymentMerchantSession&) override;
     void completeShippingMethodSelection(WebCore::PaymentAuthorizationStatus, Optional<WebCore::PaymentRequest::TotalAndLineItems> newTotalAndItems) override;

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm (206237 => 206238)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm	2016-09-21 22:51:52 UTC (rev 206238)
@@ -55,6 +55,13 @@
     });
 }
 
+void WebPaymentCoordinatorClient::openPaymentSetup(const String&, const String&, std::function<void (bool)> completionHandler)
+{
+    callOnMainThread([completionHandler] {
+        completionHandler(false);
+    });
+}
+
 bool WebPaymentCoordinatorClient::showPaymentUI(const WebCore::URL&, const Vector<WebCore::URL>&, const WebCore::PaymentRequest&)
 {
     return false;

Modified: trunk/Source/WebKit2/ChangeLog (206237 => 206238)


--- trunk/Source/WebKit2/ChangeLog	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit2/ChangeLog	2016-09-21 22:51:52 UTC (rev 206238)
@@ -1,3 +1,41 @@
+2016-09-21  Anders Carlsson  <ander...@apple.com>
+
+        support openPaymentSetup API on ApplePaySession object
+        https://bugs.webkit.org/show_bug.cgi?id=162357
+        rdar://problem/26776939
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp:
+        (WebKit::WebPaymentCoordinatorProxy::openPaymentSetup):
+        Call through to platformOpenPaymentSetup, and in the completion handler, send back a OpenPaymentSetupReply message.
+
+        * UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
+        Add new members.
+
+        * UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in:
+        Add OpenPaymentSetup message.
+
+        * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformOpenPaymentSetup):
+        Allocate a PKPassLibrary and call openPaymentSetupForMerchantIdentifier:domain:completion: on it.
+
+        * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
+        (WebKit::generateOpenPaymentSetupReplyID):
+        New helper function to generate a reply ID.
+
+        (WebKit::WebPaymentCoordinator::openPaymentSetup):
+        Add the completion handler to m_pendingOpenPaymentSetupCallbacks and send a OpenPaymentSetup message to the UI process.
+
+        (WebKit::WebPaymentCoordinator::openPaymentSetupReply):
+        Grab the callback given its ID and invoke it.
+
+        * WebProcess/ApplePay/WebPaymentCoordinator.h:
+        Add new members.
+
+        * WebProcess/ApplePay/WebPaymentCoordinator.messages.in:
+        Add OpenPaymentSetupReply message.
+
 2016-09-21  Gustavo Noronha Silva  <gustavo.noro...@collabora.co.uk>
 
         Unreviewed, build fix.

Modified: trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp (206237 => 206238)


--- trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp	2016-09-21 22:51:52 UTC (rev 206238)
@@ -75,6 +75,18 @@
     });
 }
 
+void WebPaymentCoordinatorProxy::openPaymentSetup(const String& merchantIdentifier, const String& domainName, uint64_t requestID)
+{
+    auto weakThis = m_weakPtrFactory.createWeakPtr();
+    platformOpenPaymentSetup(merchantIdentifier, domainName, [weakThis, requestID](bool result) {
+        auto paymentCoordinatorProxy = weakThis.get();
+        if (!paymentCoordinatorProxy)
+            return;
+
+        paymentCoordinatorProxy->m_webPageProxy.send(Messages::WebPaymentCoordinator::OpenPaymentSetupReply(requestID, result));
+    });
+}
+
 void WebPaymentCoordinatorProxy::showPaymentUI(const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::PaymentRequest& paymentRequest, bool& result)
 {
     // FIXME: Make this a message check.

Modified: trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h (206237 => 206238)


--- trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h	2016-09-21 22:51:52 UTC (rev 206238)
@@ -77,6 +77,7 @@
     // Message handlers.
     void canMakePayments(bool& reply);
     void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, uint64_t requestID);
+    void openPaymentSetup(const String& merchantIdentifier, const String& domainName, uint64_t requestID);
     void showPaymentUI(const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::PaymentRequest&, bool& result);
     void completeMerchantValidation(const WebCore::PaymentMerchantSession&);
     void completeShippingMethodSelection(uint32_t opaqueStatus, const Optional<WebCore::PaymentRequest::TotalAndLineItems>&);
@@ -94,6 +95,7 @@
 
     bool platformCanMakePayments();
     void platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler);
+    void platformOpenPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler);
     void platformShowPaymentUI(const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest&, std::function<void (bool)> completionHandler);
     void platformCompleteMerchantValidation(const WebCore::PaymentMerchantSession&);
     void platformCompleteShippingMethodSelection(WebCore::PaymentAuthorizationStatus, const Optional<WebCore::PaymentRequest::TotalAndLineItems>&);

Modified: trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in (206237 => 206238)


--- trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in	2016-09-21 22:51:52 UTC (rev 206238)
@@ -28,6 +28,7 @@
 
     CanMakePayments() -> (bool result)
     CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName, uint64_t requestID)
+    OpenPaymentSetup(String merchantIdentifier, String domainName, uint64_t requestID)
 
     ShowPaymentUI(String originatingURLString, Vector<String> linkIconURLStrings, WebCore::PaymentRequest paymentRequest) -> (bool result)
     CompleteMerchantValidation(WebCore::PaymentMerchantSession paymentMerchantSession);

Modified: trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (206237 => 206238)


--- trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2016-09-21 22:51:52 UTC (rev 206238)
@@ -42,6 +42,7 @@
 SOFT_LINK_FRAMEWORK(PassKit)
 #endif
 
+SOFT_LINK_CLASS(PassKit, PKPassLibrary);
 SOFT_LINK_CLASS(PassKit, PKPaymentAuthorizationViewController);
 SOFT_LINK_CLASS(PassKit, PKPaymentMerchantSession);
 SOFT_LINK_CLASS(PassKit, PKPaymentRequest);
@@ -222,6 +223,23 @@
     });
 }
 
+void WebPaymentCoordinatorProxy::platformOpenPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler)
+{
+    auto passLibrary = adoptNS([allocPKPassLibraryInstance() init]);
+    if (![passLibrary respondsToSelector:@selector(openPaymentSetupForMerchantIdentifier:domain:completion:)]) {
+        RunLoop::main().dispatch([completionHandler] {
+            completionHandler(false);
+        });
+        return;
+    }
+
+    [passLibrary openPaymentSetupForMerchantIdentifier:merchantIdentifier domain:domainName completion:[completionHandler](BOOL result) {
+        RunLoop::main().dispatch([completionHandler, result] {
+            completionHandler(result);
+        });
+    }];
+}
+
 static PKAddressField toPKAddressField(const WebCore::PaymentRequest::ContactFields& contactFields)
 {
     PKAddressField result = 0;

Modified: trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.cpp (206237 => 206238)


--- trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.cpp	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.cpp	2016-09-21 22:51:52 UTC (rev 206238)
@@ -84,6 +84,21 @@
     m_webPage.send(Messages::WebPaymentCoordinatorProxy::CanMakePaymentsWithActiveCard(merchantIdentifier, domainName, replyID));
 }
 
+static uint64_t generateOpenPaymentSetupReplyID()
+{
+    static uint64_t openPaymentSetupReplyID;
+
+    return ++openPaymentSetupReplyID;
+}
+
+void WebPaymentCoordinator::openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler)
+{
+    auto replyID = generateOpenPaymentSetupReplyID();
+
+    m_pendingOpenPaymentSetupCallbacks.add(replyID, WTFMove(completionHandler));
+    m_webPage.send(Messages::WebPaymentCoordinatorProxy::OpenPaymentSetup(merchantIdentifier, domainName, replyID));
+}
+
 bool WebPaymentCoordinator::showPaymentUI(const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest& paymentRequest)
 {
     Vector<String> linkIconURLStrings;
@@ -168,6 +183,12 @@
     callback(canMakePayments);
 }
 
+void WebPaymentCoordinator::openPaymentSetupReply(uint64_t requestID, bool result)
+{
+    auto callback = m_pendingOpenPaymentSetupCallbacks.take(requestID);
+    callback(result);
+}
+
 WebCore::PaymentCoordinator& WebPaymentCoordinator::paymentCoordinator()
 {
     return m_webPage.mainFrame()->paymentCoordinator();

Modified: trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.h (206237 => 206238)


--- trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.h	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.h	2016-09-21 22:51:52 UTC (rev 206238)
@@ -56,6 +56,7 @@
     bool supportsVersion(unsigned version) override;
     bool canMakePayments() override;
     void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) override;
+    void openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) override;
     bool showPaymentUI(const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest&) override;
     void completeMerchantValidation(const WebCore::PaymentMerchantSession&) override;
     void completeShippingMethodSelection(WebCore::PaymentAuthorizationStatus, Optional<WebCore::PaymentRequest::TotalAndLineItems> newTotalAndItems) override;
@@ -77,6 +78,7 @@
     void didSelectPaymentMethod(const WebCore::PaymentMethod&);
     void didCancelPayment();
     void canMakePaymentsWithActiveCardReply(uint64_t requestID, bool canMakePayments);
+    void openPaymentSetupReply(uint64_t requestID, bool result);
 
     WebCore::PaymentCoordinator& paymentCoordinator();
 
@@ -83,6 +85,7 @@
     WebPage& m_webPage;
 
     HashMap<uint64_t, std::function<void (bool)>> m_pendingCanMakePaymentsWithActiveCardCallbacks;
+    HashMap<uint64_t, std::function<void (bool)>> m_pendingOpenPaymentSetupCallbacks;
 };
 
 }

Modified: trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.messages.in (206237 => 206238)


--- trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.messages.in	2016-09-21 21:40:22 UTC (rev 206237)
+++ trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.messages.in	2016-09-21 22:51:52 UTC (rev 206238)
@@ -33,6 +33,7 @@
     DidSelectPaymentMethod(WebCore::PaymentMethod paymentMethod)
     DidCancelPayment()
     CanMakePaymentsWithActiveCardReply(uint64_t requestID, bool canMakePayments)
+    OpenPaymentSetupReply(uint64_t requestID, bool result)
 }
 
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to