Title: [243412] trunk/Source
Revision
243412
Author
[email protected]
Date
2019-03-23 09:39:01 -0700 (Sat, 23 Mar 2019)

Log Message

[Apple Pay] Stop calling PKPaymentAuthorizationViewController class methods on iOS
https://bugs.webkit.org/show_bug.cgi?id=196163
<rdar://problem/48787564>

Reviewed by Anders Carlsson.

Source/WebCore/PAL:

* pal/spi/cocoa/PassKitSPI.h:

Source/WebKit:

Now that we've transitioned to PKPaymentAuthorizationController on iOS, we should stop
calling PKPaymentAuthorizationViewController class methods on iOS in favor of their
PKPaymentAuthorizationController alternatives.

While we're here, we should also transition to calling
+paymentServicesMerchantURLForAPIType:completion: on both
PKPaymentAuthorizationViewController and PKPaymentAuthorizationController.

* Platform/cocoa/PaymentAuthorizationViewController.mm:
(-[WKPaymentAuthorizationViewControllerDelegate _paymentServicesMerchantURLForAPIType:completion:]):
* Platform/cocoa/WKPaymentAuthorizationDelegate.h:
* Platform/cocoa/WKPaymentAuthorizationDelegate.mm:
(-[WKPaymentAuthorizationDelegate _initWithRequest:presenter:]):
(-[WKPaymentAuthorizationDelegate _paymentServicesMerchantURLForAPIType:completion:]):
* Platform/ios/PaymentAuthorizationController.mm:
(-[WKPaymentAuthorizationControllerDelegate _paymentServicesMerchantURLForAPIType:completion:]):
* Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments): Deleted.
* Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
(WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):
* Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
(WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/ChangeLog (243411 => 243412)


--- trunk/Source/WebCore/PAL/ChangeLog	2019-03-23 11:25:58 UTC (rev 243411)
+++ trunk/Source/WebCore/PAL/ChangeLog	2019-03-23 16:39:01 UTC (rev 243412)
@@ -1,3 +1,13 @@
+2019-03-23  Andy Estes  <[email protected]>
+
+        [Apple Pay] Stop calling PKPaymentAuthorizationViewController class methods on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=196163
+        <rdar://problem/48787564>
+
+        Reviewed by Anders Carlsson.
+
+        * pal/spi/cocoa/PassKitSPI.h:
+
 2019-03-22  Keith Rollin  <[email protected]>
 
         Enable ThinLTO support in Production builds

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h (243411 => 243412)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h	2019-03-23 11:25:58 UTC (rev 243411)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h	2019-03-23 16:39:01 UTC (rev 243412)
@@ -49,6 +49,16 @@
 
 #else
 
+#import <Foundation/Foundation.h>
+
+#if HAVE(PASSKIT_API_TYPE)
+typedef NS_ENUM(NSUInteger, PKPaymentRequestAPIType) {
+    PKPaymentRequestAPITypeInApp = 0,
+    PKPaymentRequestAPITypeWebJS,
+    PKPaymentRequestAPITypeWebPaymentRequest,
+};
+#endif
+
 #if PLATFORM(IOS_FAMILY)
 
 #import <PassKit/PassKit.h>
@@ -58,6 +68,7 @@
 NS_ASSUME_NONNULL_BEGIN
 
 @interface PKPaymentAuthorizationController ()
++ (void)paymentServicesMerchantURLForAPIType:(PKPaymentRequestAPIType)APIType completion:(void(^)(NSURL *merchantURL, NSError *error))completion;
 @property (nonatomic, assign, nullable) id<PKPaymentAuthorizationControllerPrivateDelegate> privateDelegate;
 @end
 
@@ -272,6 +283,9 @@
 
 @interface PKPaymentAuthorizationViewController ()
 + (void)paymentServicesMerchantURL:(void(^)(NSURL *merchantURL, NSError *error))completion;
+#if HAVE(PASSKIT_API_TYPE)
++ (void)paymentServicesMerchantURLForAPIType:(PKPaymentRequestAPIType)APIType completion:(void(^)(NSURL *merchantURL, NSError *error))completion;
+#endif
 @property (nonatomic, assign, nullable) id<PKPaymentAuthorizationViewControllerPrivateDelegate> privateDelegate;
 @end
 
@@ -282,13 +296,7 @@
 - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didRequestMerchantSession:(void(^)(PKPaymentMerchantSession *, NSError *))sessionBlock;
 @end
 
-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101304) || PLATFORM(IOS_FAMILY)
-typedef NS_ENUM(NSUInteger, PKPaymentRequestAPIType) {
-    PKPaymentRequestAPITypeInApp = 0,
-    PKPaymentRequestAPITypeWebJS,
-    PKPaymentRequestAPITypeWebPaymentRequest,
-};
-
+#if HAVE(PASSKIT_API_TYPE)
 @interface PKPaymentRequest ()
 @property (nonatomic, assign) PKPaymentRequestAPIType APIType;
 @end

Modified: trunk/Source/WebKit/ChangeLog (243411 => 243412)


--- trunk/Source/WebKit/ChangeLog	2019-03-23 11:25:58 UTC (rev 243411)
+++ trunk/Source/WebKit/ChangeLog	2019-03-23 16:39:01 UTC (rev 243412)
@@ -1,3 +1,34 @@
+2019-03-23  Andy Estes  <[email protected]>
+
+        [Apple Pay] Stop calling PKPaymentAuthorizationViewController class methods on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=196163
+        <rdar://problem/48787564>
+
+        Reviewed by Anders Carlsson.
+
+        Now that we've transitioned to PKPaymentAuthorizationController on iOS, we should stop
+        calling PKPaymentAuthorizationViewController class methods on iOS in favor of their
+        PKPaymentAuthorizationController alternatives.
+
+        While we're here, we should also transition to calling
+        +paymentServicesMerchantURLForAPIType:completion: on both
+        PKPaymentAuthorizationViewController and PKPaymentAuthorizationController.
+
+        * Platform/cocoa/PaymentAuthorizationViewController.mm:
+        (-[WKPaymentAuthorizationViewControllerDelegate _paymentServicesMerchantURLForAPIType:completion:]):
+        * Platform/cocoa/WKPaymentAuthorizationDelegate.h:
+        * Platform/cocoa/WKPaymentAuthorizationDelegate.mm:
+        (-[WKPaymentAuthorizationDelegate _initWithRequest:presenter:]):
+        (-[WKPaymentAuthorizationDelegate _paymentServicesMerchantURLForAPIType:completion:]):
+        * Platform/ios/PaymentAuthorizationController.mm:
+        (-[WKPaymentAuthorizationControllerDelegate _paymentServicesMerchantURLForAPIType:completion:]):
+        * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments): Deleted.
+        * Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):
+        * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):
+
 2019-03-23  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix GTK build after r243409.

Modified: trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationViewController.mm (243411 => 243412)


--- trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationViewController.mm	2019-03-23 11:25:58 UTC (rev 243411)
+++ trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationViewController.mm	2019-03-23 16:39:01 UTC (rev 243412)
@@ -47,6 +47,15 @@
     return self;
 }
 
+- (void)_getPaymentServicesMerchantURL:(void(^)(NSURL *, NSError *))completion
+{
+#if HAVE(PASSKIT_API_TYPE)
+    [PAL::getPKPaymentAuthorizationViewControllerClass() paymentServicesMerchantURLForAPIType:[_request APIType] completion:completion];
+#else
+    [PAL::getPKPaymentAuthorizationViewControllerClass() paymentServicesMerchantURL:completion];
+#endif
+}
+
 #pragma mark PKPaymentAuthorizationViewControllerDelegate
 
 - (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller

Modified: trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.h (243411 => 243412)


--- trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.h	2019-03-23 11:25:58 UTC (rev 243411)
+++ trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.h	2019-03-23 16:39:01 UTC (rev 243412)
@@ -27,6 +27,7 @@
 
 #import <pal/spi/cocoa/PassKitSPI.h>
 #import <wtf/BlockPtr.h>
+#import <wtf/RetainPtr.h>
 
 OBJC_CLASS NSArray;
 OBJC_CLASS NSError;
@@ -52,7 +53,9 @@
 
 }
 
-@interface WKPaymentAuthorizationDelegate : NSObject
+@interface WKPaymentAuthorizationDelegate : NSObject {
+    RetainPtr<PKPaymentRequest> _request;
+}
 
 - (instancetype)init NS_UNAVAILABLE;
 
@@ -80,6 +83,7 @@
 - (void)_didSelectPaymentMethod:(PKPaymentMethod *)paymentMethod completion:(WebKit::DidSelectPaymentMethodCompletion::BlockType)completion;
 - (void)_didSelectShippingContact:(PKContact *)contact completion:(WebKit::DidSelectShippingContactCompletion::BlockType)completion;
 - (void)_didSelectShippingMethod:(PKShippingMethod *)shippingMethod completion:(WebKit::DidSelectShippingMethodCompletion::BlockType)completion;
+- (void)_getPaymentServicesMerchantURL:(void(^)(NSURL *, NSError *))completion;
 - (void)_willFinishWithError:(NSError *)error;
 
 @end

Modified: trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm (243411 => 243412)


--- trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm	2019-03-23 11:25:58 UTC (rev 243411)
+++ trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm	2019-03-23 16:39:01 UTC (rev 243412)
@@ -120,9 +120,10 @@
     if (!(self = [super init]))
         return nil;
 
+    _presenter = makeWeakPtr(presenter);
+    _request = request;
+    _shippingMethods = request.shippingMethods;
     _summaryItems = request.paymentSummaryItems;
-    _shippingMethods = request.shippingMethods;
-    _presenter = makeWeakPtr(presenter);
     return self;
 }
 
@@ -149,7 +150,7 @@
     ASSERT(!_didRequestMerchantSessionCompletion);
     _didRequestMerchantSessionCompletion = completion;
 
-    [PAL::getPKPaymentAuthorizationViewControllerClass() paymentServicesMerchantURL:^(NSURL *merchantURL, NSError *error) {
+    [self _getPaymentServicesMerchantURL:^(NSURL *merchantURL, NSError *error) {
         if (error)
             LOG_ERROR("PKCanMakePaymentsWithMerchantIdentifierAndDomain error %@", error);
 
@@ -216,6 +217,12 @@
     presenter->client().presenterDidSelectShippingMethod(*presenter, toShippingMethod(shippingMethod));
 }
 
+- (void) NO_RETURN_DUE_TO_ASSERT _getPaymentServicesMerchantURL:(void(^)(NSURL *, NSError *))completion
+{
+    ASSERT_NOT_REACHED();
+    completion(nil, nil);
+}
+
 - (void)_willFinishWithError:(NSError *)error
 {
 }

Modified: trunk/Source/WebKit/Platform/ios/PaymentAuthorizationController.mm (243411 => 243412)


--- trunk/Source/WebKit/Platform/ios/PaymentAuthorizationController.mm	2019-03-23 11:25:58 UTC (rev 243411)
+++ trunk/Source/WebKit/Platform/ios/PaymentAuthorizationController.mm	2019-03-23 16:39:01 UTC (rev 243412)
@@ -47,6 +47,15 @@
     return self;
 }
 
+- (void)_getPaymentServicesMerchantURL:(void(^)(NSURL *, NSError *))completion
+{
+    // FIXME: This -respondsToSelector: check can be removed once rdar://problem/48771320 is in an iOS SDK.
+    if ([PAL::getPKPaymentAuthorizationControllerClass() respondsToSelector:@selector(paymentServicesMerchantURLForAPIType:completion:)])
+        [PAL::getPKPaymentAuthorizationControllerClass() paymentServicesMerchantURLForAPIType:[_request APIType] completion:completion];
+    else
+        [PAL::getPKPaymentAuthorizationViewControllerClass() paymentServicesMerchantURLForAPIType:[_request APIType] completion:completion];
+}
+
 #pragma mark PKPaymentAuthorizationControllerDelegate
 
 - (void)paymentAuthorizationControllerDidFinish:(PKPaymentAuthorizationController *)controller

Modified: trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (243411 => 243412)


--- trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2019-03-23 11:25:58 UTC (rev 243411)
+++ trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2019-03-23 16:39:01 UTC (rev 243412)
@@ -52,16 +52,6 @@
 
 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)

Modified: trunk/Source/WebKit/Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm (243411 => 243412)


--- trunk/Source/WebKit/Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm	2019-03-23 11:25:58 UTC (rev 243411)
+++ trunk/Source/WebKit/Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm	2019-03-23 16:39:01 UTC (rev 243412)
@@ -38,6 +38,11 @@
 
 namespace WebKit {
 
+bool WebPaymentCoordinatorProxy::platformCanMakePayments()
+{
+    return [PAL::getPKPaymentAuthorizationControllerClass() canMakePayments];
+}
+
 void WebPaymentCoordinatorProxy::platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLStrings, PAL::SessionID sessionID, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
 {
     auto paymentRequest = platformPaymentRequest(originatingURL, linkIconURLStrings, sessionID, request);

Modified: trunk/Source/WebKit/Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm (243411 => 243412)


--- trunk/Source/WebKit/Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm	2019-03-23 11:25:58 UTC (rev 243411)
+++ trunk/Source/WebKit/Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm	2019-03-23 16:39:01 UTC (rev 243412)
@@ -35,6 +35,14 @@
 
 namespace WebKit {
 
+bool WebPaymentCoordinatorProxy::platformCanMakePayments()
+{
+    if (!PAL::isPassKitFrameworkAvailable())
+        return false;
+
+    return [PAL::getPKPaymentAuthorizationViewControllerClass() canMakePayments];
+}
+
 void WebPaymentCoordinatorProxy::platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLStrings, PAL::SessionID sessionID, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
 {
     if (!PAL::isPassKitFrameworkAvailable())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to