[Mac] Ensure Apple Pay is unavailable when PassKit.framework is missing
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Mar 2019 15:07:13 +0000 (15:07 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Mar 2019 15:07:13 +0000 (15:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195583
<rdar://problem/48420224>

Reviewed by Daniel Bates.

PassKit.framework is optionally soft-linked on Mac because it is missing from the Recovery
Partition. We need to check if the framework is available before calling into it.

* Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):
(WebKit::WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard):
(WebKit::WebPaymentCoordinatorProxy::platformOpenPaymentSetup):
(WebKit::WebPaymentCoordinatorProxy::platformAvailablePaymentNetworks):
* Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
(WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242795 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm
Source/WebKit/Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm

index 377a395..6a66e0b 100644 (file)
@@ -1,3 +1,22 @@
+2019-03-11  Andy Estes  <aestes@apple.com>
+
+        [Mac] Ensure Apple Pay is unavailable when PassKit.framework is missing
+        https://bugs.webkit.org/show_bug.cgi?id=195583
+        <rdar://problem/48420224>
+
+        Reviewed by Daniel Bates.
+
+        PassKit.framework is optionally soft-linked on Mac because it is missing from the Recovery
+        Partition. We need to check if the framework is available before calling into it.
+
+        * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):
+        (WebKit::WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard):
+        (WebKit::WebPaymentCoordinatorProxy::platformOpenPaymentSetup):
+        (WebKit::WebPaymentCoordinatorProxy::platformAvailablePaymentNetworks):
+        * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI):
+
 2019-03-12  Antti Koivisto  <antti@apple.com>
 
         Compositing layer that renders two positioned elements should not hit test
index 73ed51a..6f58662 100644 (file)
@@ -54,11 +54,21 @@ namespace WebKit {
 
 bool WebPaymentCoordinatorProxy::platformCanMakePayments()
 {
+#if PLATFORM(MAC)
+    if (!PAL::isPassKitFrameworkAvailable())
+        return false;
+#endif
+
     return [PAL::getPKPaymentAuthorizationViewControllerClass() canMakePayments];
 }
 
 void WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, PAL::SessionID sessionID, WTF::Function<void(bool)>&& completionHandler)
 {
+#if PLATFORM(MAC)
+    if (!PAL::isPassKitFrameworkAvailable())
+        return completionHandler(false);
+#endif
+
 #if HAVE(PASSKIT_GRANULAR_ERRORS)
     PKCanMakePaymentsWithMerchantIdentifierDomainAndSourceApplication(merchantIdentifier, domainName, m_client.paymentCoordinatorSourceApplicationSecondaryIdentifier(*this, sessionID), makeBlockPtr([completionHandler = WTFMove(completionHandler)](BOOL canMakePayments, NSError *error) mutable {
         if (error)
@@ -82,6 +92,11 @@ void WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard(const Str
 
 void WebPaymentCoordinatorProxy::platformOpenPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void(bool)>&& completionHandler)
 {
+#if PLATFORM(MAC)
+    if (!PAL::isPassKitFrameworkAvailable())
+        return completionHandler(false);
+#endif
+
     auto passLibrary = adoptNS([PAL::allocPKPassLibraryInstance() init]);
     [passLibrary openPaymentSetupForMerchantIdentifier:merchantIdentifier domain:domainName completion:makeBlockPtr([completionHandler = WTFMove(completionHandler)](BOOL result) mutable {
         RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), result] {
@@ -344,6 +359,11 @@ void WebPaymentCoordinatorProxy::platformCompletePaymentMethodSelection(const Op
 
 Vector<String> WebPaymentCoordinatorProxy::platformAvailablePaymentNetworks()
 {
+#if PLATFORM(MAC)
+    if (!PAL::isPassKitFrameworkAvailable())
+        return { };
+#endif
+
     NSArray<PKPaymentNetwork> *availableNetworks = [PAL::getPKPaymentRequestClass() availableNetworks];
     Vector<String> result;
     result.reserveInitialCapacity(availableNetworks.count);
index 80fc12c..af80bf5 100644 (file)
@@ -37,6 +37,9 @@ namespace WebKit {
 
 void WebPaymentCoordinatorProxy::platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLStrings, PAL::SessionID sessionID, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
 {
+    if (!PAL::isPassKitFrameworkAvailable())
+        return completionHandler(false);
+
     auto paymentRequest = platformPaymentRequest(originatingURL, linkIconURLStrings, sessionID, request);
 
     auto showPaymentUIRequestSeed = m_showPaymentUIRequestSeed;