Changeset 206238 in webkit
- Timestamp:
- Sep 21, 2016 3:51:52 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206236 r206238 1 2016-09-21 Anders Carlsson <andersca@apple.com> 2 3 support openPaymentSetup API on ApplePaySession object 4 https://bugs.webkit.org/show_bug.cgi?id=162357 5 rdar://problem/26776939 6 7 Reviewed by Tim Horton. 8 9 * Modules/applepay/ApplePaySession.cpp: 10 (WebCore::ApplePaySession::openPaymentSetup): 11 Perform security checks and then call into the PaymentCoordiantor. In its completion handler, we resolve the promise. 12 13 * Modules/applepay/ApplePaySession.h: 14 Add new members. 15 16 * Modules/applepay/ApplePaySession.idl: 17 Add openPaymentSetup declaration. 18 19 * Modules/applepay/PaymentCoordinator.cpp: 20 (WebCore::PaymentCoordinator::openPaymentSetup): 21 Call through to the clients. 22 23 * Modules/applepay/PaymentCoordinator.h: 24 * Modules/applepay/PaymentCoordinatorClient.h: 25 Add new members. 26 27 * loader/EmptyClients.cpp: 28 Add new stub. 29 30 * platform/spi/cocoa/PassKitSPI.h: 31 Add SPI declaration. 32 1 33 2016-09-21 Commit Queue <commit-queue@webkit.org> 2 34 -
trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp
r205257 r206238 764 764 } 765 765 766 void ApplePaySession::openPaymentSetup(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredWrapper>&& passedPromise, ExceptionCode& ec) 767 { 768 auto& document = downcast<Document>(scriptExecutionContext); 769 DOMWindow& window = *document.domWindow(); 770 771 String errorMessage; 772 if (!canCallApplePaySessionAPIs(document, errorMessage)) { 773 window.printErrorMessage(errorMessage); 774 ec = INVALID_ACCESS_ERR; 775 return; 776 } 777 778 if (!ScriptController::processingUserGesture()) { 779 window.printErrorMessage("Must call ApplePaySession.openPaymemntSetup from a user gesture handler."); 780 ec = INVALID_ACCESS_ERR; 781 return; 782 } 783 784 RefPtr<DeferredWrapper> promise(WTFMove(passedPromise)); 785 auto& paymentCoordinator = document.frame()->mainFrame().paymentCoordinator(); 786 787 paymentCoordinator.openPaymentSetup(merchantIdentifier, document.domain(), [promise](bool result) mutable { 788 promise->resolve(result); 789 }); 790 } 791 766 792 void ApplePaySession::begin(ExceptionCode& ec) 767 793 { -
trunk/Source/WebCore/Modules/applepay/ApplePaySession.h
r205257 r206238 65 65 static bool canMakePayments(ScriptExecutionContext&, ExceptionCode&); 66 66 static void canMakePaymentsWithActiveCard(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredWrapper>&&, ExceptionCode&); 67 static void openPaymentSetup(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredWrapper>&&, ExceptionCode&); 67 68 68 69 void begin(ExceptionCode&); -
trunk/Source/WebCore/Modules/applepay/ApplePaySession.idl
r202309 r206238 44 44 [CallWith=ScriptExecutionContext, RaisesException] static boolean canMakePayments(); 45 45 [CallWith=ScriptExecutionContext, RaisesException] static Promise canMakePaymentsWithActiveCard(DOMString merchantIdentifier); 46 [CallWith=ScriptExecutionContext, RaisesException] static Promise openPaymentSetup(DOMString merchantIdentifier); 46 47 47 48 [RaisesException] void begin(); -
trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp
r203746 r206238 59 59 { 60 60 m_client.canMakePaymentsWithActiveCard(merchantIdentifier, domainName, WTFMove(completionHandler)); 61 } 62 63 void PaymentCoordinator::openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) 64 { 65 m_client.openPaymentSetup(merchantIdentifier, domainName, WTFMove(completionHandler)); 61 66 } 62 67 -
trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h
r203084 r206238 50 50 bool canMakePayments(); 51 51 void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler); 52 void openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler); 52 53 53 54 bool hasActiveSession() const { return m_activeSession; } -
trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h
r203084 r206238 43 43 virtual bool canMakePayments() = 0; 44 44 virtual void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) = 0; 45 virtual void openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) = 0; 45 46 46 47 virtual bool showPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLs, const PaymentRequest&) = 0; -
trunk/Source/WebCore/loader/EmptyClients.cpp
r205462 r206238 59 59 bool canMakePayments() override { return false; } 60 60 void canMakePaymentsWithActiveCard(const String&, const String&, std::function<void (bool)> completionHandler) override { callOnMainThread([completionHandler] { completionHandler(false); }); } 61 void openPaymentSetup(const String&, const String&, std::function<void (bool)> completionHandler) override { callOnMainThread([completionHandler] { completionHandler(false); }); } 62 61 63 bool showPaymentUI(const URL&, const Vector<URL>&, const PaymentRequest&) override { return false; } 62 64 void completeMerchantValidation(const PaymentMerchantSession&) override { } -
trunk/Source/WebCore/platform/spi/cocoa/PassKitSPI.h
r205992 r206238 233 233 extern "C" 234 234 void PKDrawApplePayButton(_Nonnull CGContextRef, CGRect drawRect, CGFloat scale, PKPaymentButtonType, PKPaymentButtonStyle, NSString * _Nullable languageCode); 235 236 NS_ASSUME_NONNULL_BEGIN 237 238 @interface PKPassLibrary () 239 - (void)openPaymentSetupForMerchantIdentifier:(NSString *)identifier domain:(NSString *)domain completion:(void(^)(BOOL success))completion; 240 @end 241 242 NS_ASSUME_NONNULL_END -
trunk/Source/WebKit/mac/ChangeLog
r206119 r206238 1 2016-09-21 Anders Carlsson <andersca@apple.com> 2 3 Support openPaymentSetup API on ApplePaySession object 4 https://bugs.webkit.org/show_bug.cgi?id=162357 5 rdar://problem/26776939 6 7 Reviewed by Tim Horton. 8 9 Add openPaymentSetup stub. 10 11 * WebCoreSupport/WebPaymentCoordinatorClient.h: 12 * WebCoreSupport/WebPaymentCoordinatorClient.mm: 13 (WebPaymentCoordinatorClient::openPaymentSetup): 14 1 15 2016-09-19 Daniel Bates <dabates@apple.com> 2 16 -
trunk/Source/WebKit/mac/WebCoreSupport/WebPaymentCoordinatorClient.h
r203084 r206238 40 40 bool canMakePayments() override; 41 41 void canMakePaymentsWithActiveCard(const String&, const String&, std::function<void (bool)> completionHandler) override; 42 void openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) override; 42 43 bool showPaymentUI(const WebCore::URL&, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest&) override; 43 44 void completeMerchantValidation(const WebCore::PaymentMerchantSession&) override; -
trunk/Source/WebKit/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm
r203084 r206238 56 56 } 57 57 58 void WebPaymentCoordinatorClient::openPaymentSetup(const String&, const String&, std::function<void (bool)> completionHandler) 59 { 60 callOnMainThread([completionHandler] { 61 completionHandler(false); 62 }); 63 } 64 58 65 bool WebPaymentCoordinatorClient::showPaymentUI(const WebCore::URL&, const Vector<WebCore::URL>&, const WebCore::PaymentRequest&) 59 66 { -
trunk/Source/WebKit2/ChangeLog
r206216 r206238 1 2016-09-21 Anders Carlsson <andersca@apple.com> 2 3 support openPaymentSetup API on ApplePaySession object 4 https://bugs.webkit.org/show_bug.cgi?id=162357 5 rdar://problem/26776939 6 7 Reviewed by Tim Horton. 8 9 * UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp: 10 (WebKit::WebPaymentCoordinatorProxy::openPaymentSetup): 11 Call through to platformOpenPaymentSetup, and in the completion handler, send back a OpenPaymentSetupReply message. 12 13 * UIProcess/ApplePay/WebPaymentCoordinatorProxy.h: 14 Add new members. 15 16 * UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in: 17 Add OpenPaymentSetup message. 18 19 * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm: 20 (WebKit::WebPaymentCoordinatorProxy::platformOpenPaymentSetup): 21 Allocate a PKPassLibrary and call openPaymentSetupForMerchantIdentifier:domain:completion: on it. 22 23 * WebProcess/ApplePay/WebPaymentCoordinator.cpp: 24 (WebKit::generateOpenPaymentSetupReplyID): 25 New helper function to generate a reply ID. 26 27 (WebKit::WebPaymentCoordinator::openPaymentSetup): 28 Add the completion handler to m_pendingOpenPaymentSetupCallbacks and send a OpenPaymentSetup message to the UI process. 29 30 (WebKit::WebPaymentCoordinator::openPaymentSetupReply): 31 Grab the callback given its ID and invoke it. 32 33 * WebProcess/ApplePay/WebPaymentCoordinator.h: 34 Add new members. 35 36 * WebProcess/ApplePay/WebPaymentCoordinator.messages.in: 37 Add OpenPaymentSetupReply message. 38 1 39 2016-09-21 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> 2 40 -
trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp
r206176 r206238 76 76 } 77 77 78 void WebPaymentCoordinatorProxy::openPaymentSetup(const String& merchantIdentifier, const String& domainName, uint64_t requestID) 79 { 80 auto weakThis = m_weakPtrFactory.createWeakPtr(); 81 platformOpenPaymentSetup(merchantIdentifier, domainName, [weakThis, requestID](bool result) { 82 auto paymentCoordinatorProxy = weakThis.get(); 83 if (!paymentCoordinatorProxy) 84 return; 85 86 paymentCoordinatorProxy->m_webPageProxy.send(Messages::WebPaymentCoordinator::OpenPaymentSetupReply(requestID, result)); 87 }); 88 } 89 78 90 void WebPaymentCoordinatorProxy::showPaymentUI(const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::PaymentRequest& paymentRequest, bool& result) 79 91 { -
trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h
r204668 r206238 78 78 void canMakePayments(bool& reply); 79 79 void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, uint64_t requestID); 80 void openPaymentSetup(const String& merchantIdentifier, const String& domainName, uint64_t requestID); 80 81 void showPaymentUI(const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::PaymentRequest&, bool& result); 81 82 void completeMerchantValidation(const WebCore::PaymentMerchantSession&); … … 95 96 bool platformCanMakePayments(); 96 97 void platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler); 98 void platformOpenPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler); 97 99 void platformShowPaymentUI(const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest&, std::function<void (bool)> completionHandler); 98 100 void platformCompleteMerchantValidation(const WebCore::PaymentMerchantSession&); -
trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in
r203084 r206238 29 29 CanMakePayments() -> (bool result) 30 30 CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName, uint64_t requestID) 31 OpenPaymentSetup(String merchantIdentifier, String domainName, uint64_t requestID) 31 32 32 33 ShowPaymentUI(String originatingURLString, Vector<String> linkIconURLStrings, WebCore::PaymentRequest paymentRequest) -> (bool result) -
trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm
r204587 r206238 43 43 #endif 44 44 45 SOFT_LINK_CLASS(PassKit, PKPassLibrary); 45 46 SOFT_LINK_CLASS(PassKit, PKPaymentAuthorizationViewController); 46 47 SOFT_LINK_CLASS(PassKit, PKPaymentMerchantSession); … … 221 222 }); 222 223 }); 224 } 225 226 void WebPaymentCoordinatorProxy::platformOpenPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) 227 { 228 auto passLibrary = adoptNS([allocPKPassLibraryInstance() init]); 229 if (![passLibrary respondsToSelector:@selector(openPaymentSetupForMerchantIdentifier:domain:completion:)]) { 230 RunLoop::main().dispatch([completionHandler] { 231 completionHandler(false); 232 }); 233 return; 234 } 235 236 [passLibrary openPaymentSetupForMerchantIdentifier:merchantIdentifier domain:domainName completion:[completionHandler](BOOL result) { 237 RunLoop::main().dispatch([completionHandler, result] { 238 completionHandler(result); 239 }); 240 }]; 223 241 } 224 242 -
trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.cpp
r204587 r206238 85 85 } 86 86 87 static uint64_t generateOpenPaymentSetupReplyID() 88 { 89 static uint64_t openPaymentSetupReplyID; 90 91 return ++openPaymentSetupReplyID; 92 } 93 94 void WebPaymentCoordinator::openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) 95 { 96 auto replyID = generateOpenPaymentSetupReplyID(); 97 98 m_pendingOpenPaymentSetupCallbacks.add(replyID, WTFMove(completionHandler)); 99 m_webPage.send(Messages::WebPaymentCoordinatorProxy::OpenPaymentSetup(merchantIdentifier, domainName, replyID)); 100 } 101 87 102 bool WebPaymentCoordinator::showPaymentUI(const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest& paymentRequest) 88 103 { … … 169 184 } 170 185 186 void WebPaymentCoordinator::openPaymentSetupReply(uint64_t requestID, bool result) 187 { 188 auto callback = m_pendingOpenPaymentSetupCallbacks.take(requestID); 189 callback(result); 190 } 191 171 192 WebCore::PaymentCoordinator& WebPaymentCoordinator::paymentCoordinator() 172 193 { -
trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.h
r204668 r206238 57 57 bool canMakePayments() override; 58 58 void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) override; 59 void openPaymentSetup(const String& merchantIdentifier, const String& domainName, std::function<void (bool)> completionHandler) override; 59 60 bool showPaymentUI(const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest&) override; 60 61 void completeMerchantValidation(const WebCore::PaymentMerchantSession&) override; … … 78 79 void didCancelPayment(); 79 80 void canMakePaymentsWithActiveCardReply(uint64_t requestID, bool canMakePayments); 81 void openPaymentSetupReply(uint64_t requestID, bool result); 80 82 81 83 WebCore::PaymentCoordinator& paymentCoordinator(); … … 84 86 85 87 HashMap<uint64_t, std::function<void (bool)>> m_pendingCanMakePaymentsWithActiveCardCallbacks; 88 HashMap<uint64_t, std::function<void (bool)>> m_pendingOpenPaymentSetupCallbacks; 86 89 }; 87 90 -
trunk/Source/WebKit2/WebProcess/ApplePay/WebPaymentCoordinator.messages.in
r202432 r206238 34 34 DidCancelPayment() 35 35 CanMakePaymentsWithActiveCardReply(uint64_t requestID, bool canMakePayments) 36 OpenPaymentSetupReply(uint64_t requestID, bool result) 36 37 } 37 38
Note: See TracChangeset
for help on using the changeset viewer.