⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243412 in webkit


Ignore:
Timestamp:
Mar 23, 2019, 9:39:01 AM (7 years ago)
Author:
aestes@apple.com
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):

Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/PAL/ChangeLog

    r243396 r243412  
     12019-03-23  Andy Estes  <aestes@apple.com>
     2
     3        [Apple Pay] Stop calling PKPaymentAuthorizationViewController class methods on iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=196163
     5        <rdar://problem/48787564>
     6
     7        Reviewed by Anders Carlsson.
     8
     9        * pal/spi/cocoa/PassKitSPI.h:
     10
    1112019-03-22  Keith Rollin  <krollin@apple.com>
    212
  • trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h

    r242748 r243412  
    5050#else
    5151
     52#import <Foundation/Foundation.h>
     53
     54#if HAVE(PASSKIT_API_TYPE)
     55typedef NS_ENUM(NSUInteger, PKPaymentRequestAPIType) {
     56    PKPaymentRequestAPITypeInApp = 0,
     57    PKPaymentRequestAPITypeWebJS,
     58    PKPaymentRequestAPITypeWebPaymentRequest,
     59};
     60#endif
     61
    5262#if PLATFORM(IOS_FAMILY)
    5363
     
    5969
    6070@interface PKPaymentAuthorizationController ()
     71+ (void)paymentServicesMerchantURLForAPIType:(PKPaymentRequestAPIType)APIType completion:(void(^)(NSURL *merchantURL, NSError *error))completion;
    6172@property (nonatomic, assign, nullable) id<PKPaymentAuthorizationControllerPrivateDelegate> privateDelegate;
    6273@end
     
    273284@interface PKPaymentAuthorizationViewController ()
    274285+ (void)paymentServicesMerchantURL:(void(^)(NSURL *merchantURL, NSError *error))completion;
     286#if HAVE(PASSKIT_API_TYPE)
     287+ (void)paymentServicesMerchantURLForAPIType:(PKPaymentRequestAPIType)APIType completion:(void(^)(NSURL *merchantURL, NSError *error))completion;
     288#endif
    275289@property (nonatomic, assign, nullable) id<PKPaymentAuthorizationViewControllerPrivateDelegate> privateDelegate;
    276290@end
     
    283297@end
    284298
    285 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101304) || PLATFORM(IOS_FAMILY)
    286 typedef NS_ENUM(NSUInteger, PKPaymentRequestAPIType) {
    287     PKPaymentRequestAPITypeInApp = 0,
    288     PKPaymentRequestAPITypeWebJS,
    289     PKPaymentRequestAPITypeWebPaymentRequest,
    290 };
    291 
     299#if HAVE(PASSKIT_API_TYPE)
    292300@interface PKPaymentRequest ()
    293301@property (nonatomic, assign) PKPaymentRequestAPIType APIType;
  • trunk/Source/WebKit/ChangeLog

    r243410 r243412  
     12019-03-23  Andy Estes  <aestes@apple.com>
     2
     3        [Apple Pay] Stop calling PKPaymentAuthorizationViewController class methods on iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=196163
     5        <rdar://problem/48787564>
     6
     7        Reviewed by Anders Carlsson.
     8
     9        Now that we've transitioned to PKPaymentAuthorizationController on iOS, we should stop
     10        calling PKPaymentAuthorizationViewController class methods on iOS in favor of their
     11        PKPaymentAuthorizationController alternatives.
     12
     13        While we're here, we should also transition to calling
     14        +paymentServicesMerchantURLForAPIType:completion: on both
     15        PKPaymentAuthorizationViewController and PKPaymentAuthorizationController.
     16
     17        * Platform/cocoa/PaymentAuthorizationViewController.mm:
     18        (-[WKPaymentAuthorizationViewControllerDelegate _paymentServicesMerchantURLForAPIType:completion:]):
     19        * Platform/cocoa/WKPaymentAuthorizationDelegate.h:
     20        * Platform/cocoa/WKPaymentAuthorizationDelegate.mm:
     21        (-[WKPaymentAuthorizationDelegate _initWithRequest:presenter:]):
     22        (-[WKPaymentAuthorizationDelegate _paymentServicesMerchantURLForAPIType:completion:]):
     23        * Platform/ios/PaymentAuthorizationController.mm:
     24        (-[WKPaymentAuthorizationControllerDelegate _paymentServicesMerchantURLForAPIType:completion:]):
     25        * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
     26        (WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments): Deleted.
     27        * Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
     28        (WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):
     29        * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
     30        (WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):
     31
    1322019-03-23  Carlos Garcia Campos  <cgarcia@igalia.com>
    233
  • trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationViewController.mm

    r242616 r243412  
    4646
    4747    return self;
     48}
     49
     50- (void)_getPaymentServicesMerchantURL:(void(^)(NSURL *, NSError *))completion
     51{
     52#if HAVE(PASSKIT_API_TYPE)
     53    [PAL::getPKPaymentAuthorizationViewControllerClass() paymentServicesMerchantURLForAPIType:[_request APIType] completion:completion];
     54#else
     55    [PAL::getPKPaymentAuthorizationViewControllerClass() paymentServicesMerchantURL:completion];
     56#endif
    4857}
    4958
  • trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.h

    r242616 r243412  
    2828#import <pal/spi/cocoa/PassKitSPI.h>
    2929#import <wtf/BlockPtr.h>
     30#import <wtf/RetainPtr.h>
    3031
    3132OBJC_CLASS NSArray;
     
    5354}
    5455
    55 @interface WKPaymentAuthorizationDelegate : NSObject
     56@interface WKPaymentAuthorizationDelegate : NSObject {
     57    RetainPtr<PKPaymentRequest> _request;
     58}
    5659
    5760- (instancetype)init NS_UNAVAILABLE;
     
    8184- (void)_didSelectShippingContact:(PKContact *)contact completion:(WebKit::DidSelectShippingContactCompletion::BlockType)completion;
    8285- (void)_didSelectShippingMethod:(PKShippingMethod *)shippingMethod completion:(WebKit::DidSelectShippingMethodCompletion::BlockType)completion;
     86- (void)_getPaymentServicesMerchantURL:(void(^)(NSURL *, NSError *))completion;
    8387- (void)_willFinishWithError:(NSError *)error;
    8488
  • trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm

    r242616 r243412  
    121121        return nil;
    122122
     123    _presenter = makeWeakPtr(presenter);
     124    _request = request;
     125    _shippingMethods = request.shippingMethods;
    123126    _summaryItems = request.paymentSummaryItems;
    124     _shippingMethods = request.shippingMethods;
    125     _presenter = makeWeakPtr(presenter);
    126127    return self;
    127128}
     
    150151    _didRequestMerchantSessionCompletion = completion;
    151152
    152     [PAL::getPKPaymentAuthorizationViewControllerClass() paymentServicesMerchantURL:^(NSURL *merchantURL, NSError *error) {
     153    [self _getPaymentServicesMerchantURL:^(NSURL *merchantURL, NSError *error) {
    153154        if (error)
    154155            LOG_ERROR("PKCanMakePaymentsWithMerchantIdentifierAndDomain error %@", error);
     
    217218}
    218219
     220- (void) NO_RETURN_DUE_TO_ASSERT _getPaymentServicesMerchantURL:(void(^)(NSURL *, NSError *))completion
     221{
     222    ASSERT_NOT_REACHED();
     223    completion(nil, nil);
     224}
     225
    219226- (void)_willFinishWithError:(NSError *)error
    220227{
  • trunk/Source/WebKit/Platform/ios/PaymentAuthorizationController.mm

    r242748 r243412  
    4646
    4747    return self;
     48}
     49
     50- (void)_getPaymentServicesMerchantURL:(void(^)(NSURL *, NSError *))completion
     51{
     52    // FIXME: This -respondsToSelector: check can be removed once rdar://problem/48771320 is in an iOS SDK.
     53    if ([PAL::getPKPaymentAuthorizationControllerClass() respondsToSelector:@selector(paymentServicesMerchantURLForAPIType:completion:)])
     54        [PAL::getPKPaymentAuthorizationControllerClass() paymentServicesMerchantURLForAPIType:[_request APIType] completion:completion];
     55    else
     56        [PAL::getPKPaymentAuthorizationViewControllerClass() paymentServicesMerchantURLForAPIType:[_request APIType] completion:completion];
    4857}
    4958
  • trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm

    r242904 r243412  
    5353namespace WebKit {
    5454
    55 bool WebPaymentCoordinatorProxy::platformCanMakePayments()
    56 {
    57 #if PLATFORM(MAC)
    58     if (!PAL::isPassKitFrameworkAvailable())
    59         return false;
    60 #endif
    61 
    62     return [PAL::getPKPaymentAuthorizationViewControllerClass() canMakePayments];
    63 }
    64 
    6555void WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, PAL::SessionID sessionID, WTF::Function<void(bool)>&& completionHandler)
    6656{
  • trunk/Source/WebKit/Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm

    r242748 r243412  
    3939namespace WebKit {
    4040
     41bool WebPaymentCoordinatorProxy::platformCanMakePayments()
     42{
     43    return [PAL::getPKPaymentAuthorizationControllerClass() canMakePayments];
     44}
     45
    4146void WebPaymentCoordinatorProxy::platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLStrings, PAL::SessionID sessionID, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
    4247{
  • trunk/Source/WebKit/Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm

    r242795 r243412  
    3535
    3636namespace WebKit {
     37
     38bool WebPaymentCoordinatorProxy::platformCanMakePayments()
     39{
     40    if (!PAL::isPassKitFrameworkAvailable())
     41        return false;
     42
     43    return [PAL::getPKPaymentAuthorizationViewControllerClass() canMakePayments];
     44}
    3745
    3846void WebPaymentCoordinatorProxy::platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLStrings, PAL::SessionID sessionID, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
Note: See TracChangeset for help on using the changeset viewer.