[Apple Pay] Use PKPaymentAuthorizationController to present the Apple Pay UI remotely...
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Mar 2019 22:42:09 +0000 (22:42 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Mar 2019 22:42:09 +0000 (22:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195530
<rdar://problem/48747164>

Reviewed by Alex Christensen.

Source/WebCore:

* Modules/applepay/PaymentCoordinatorClient.h: Defined isWebPaymentCoordinator.
* page/Settings.yaml: Defined the applePayRemoteUIEnabled setting and reordered the other
Apple Pay settings.

Source/WebCore/PAL:

* pal/cocoa/PassKitSoftLink.h: Soft-linked PKPaymentAuthorizationController on iOS.
* pal/cocoa/PassKitSoftLink.mm: Ditto.
* pal/spi/cocoa/PassKitSPI.h: Declared PKPaymentAuthorizationControllerPrivateDelegate and
related SPI.

Source/WebKit:

* Configurations/Network-iOS.entitlements: Added the 'com.apple.payment.all-access'
entitlement and reordered the others.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::didReceiveMessage): Forwarded
WebPaymentCoordinatorProxy messages to the payment coordinator.
(WebKit::NetworkConnectionToWebProcess::didReceiveSyncMessage): Ditto.
(WebKit::NetworkConnectionToWebProcess::didClose): Set m_paymentCoordinator to nullptr.
* NetworkProcess/NetworkConnectionToWebProcess.h: Inherited from
WebPaymentCoordinatorProxy::Client and added a unique_ptr<WebPaymentCoordinatorProxy> member.

* NetworkProcess/cocoa/NetworkSessionCocoa.h: Declared getters for source application bundle
and secondary identifiers, and CTDataConnectionServiceType on iOS.
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::NetworkSessionCocoa::sourceApplicationBundleIdentifier const): Defined getter.
(WebKit::NetworkSessionCocoa::sourceApplicationSecondaryIdentifier const): Ditto.
(WebKit::NetworkSessionCocoa::ctDataConnectionServiceType const): Ditto.
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa): Initialized
m_sourceApplicationBundleIdentifier and m_sourceApplicationSecondaryIdentifier with
corresponding NetworkSessionCreationParameters.

* NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm: Added.
(WebKit::NetworkConnectionToWebProcess::paymentCoordinator): Added. Returns
m_paymentCoordinator after lazily initializing it.
(WebKit::NetworkConnectionToWebProcess::paymentCoordinatorConnection): Added. Returns the
connection to the web process.
(WebKit::NetworkConnectionToWebProcess::paymentCoordinatorPresentingViewController): Added.
Returns nil.
(WebKit::NetworkConnectionToWebProcess::paymentCoordinatorCTDataConnectionServiceType):
Added. Returns the value from the network session identified by sessionID.
(WebKit::NetworkConnectionToWebProcess::paymentCoordinatorSourceApplicationBundleIdentifier):
Ditto.
(WebKit::NetworkConnectionToWebProcess::paymentCoordinatorSourceApplicationSecondaryIdentifier):
Ditto.
(WebKit::NetworkConnectionToWebProcess::paymentCoordinatorAuthorizationPresenter): Added.
Returns a new PaymentAuthorizationController.
(WebKit::NetworkConnectionToWebProcess::paymentCoordinatorAddMessageReceiver): Added empty
definition. NetworkConnectionToWebProcess explicitly forwards WebPaymentCoordinatorProxy
messages to its payment coordinator, so there's no need to register with a MessageReceiverMap.
(WebKit::NetworkConnectionToWebProcess::paymentCoordinatorRemoveMessageReceiver): Ditto.

* Platform/ios/PaymentAuthorizationController.h: Added. Declares a
PaymentAuthorizationPresenter subclass based on PKPaymentAuthorizationController.
* Platform/ios/PaymentAuthorizationController.mm: Added.
(-[WKPaymentAuthorizationControllerDelegate initWithRequest:presenter:]):
Initialized WKPaymentAuthorizationDelegate with request and presenter.
(-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationControllerDidFinish:]):
Forwarded call to WKPaymentAuthorizationDelegate.
(-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didAuthorizePayment:handler:]):
Ditto.
(-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectShippingMethod:handler:]):
Ditto.
(-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectShippingContact:handler:]):
Ditto.
(-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectPaymentMethod:handler:]):
Ditto.
(-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:willFinishWithError:]):
Ditto.
(-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didRequestMerchantSession:]):
Ditto.
(WebKit::PaymentAuthorizationController::PaymentAuthorizationController):
Initialized m_controller with a new PKPaymentAuthorizationController and m_delegate with a
new WKPaymentAuthorizationControllerDelegate.
(WebKit::PaymentAuthorizationController::platformDelegate): Returned m_delegate.
(WebKit::PaymentAuthorizationController::dismiss): Dismissed the controller, set its
delegates to nil, set m_controller to nil, invalidated the delegate, and set m_delegate to
nil.
(WebKit::PaymentAuthorizationController::present): Called -presentWithCompletion: on the
controller, forwarding the passed-in completion handler.
* Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb: Allowed PassKit to look up
the "com.apple.passd.in-app-payment" and "com.apple.passd.library" service endpoints.

* Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
(WebKit::WebPaymentCoordinatorProxy::WebPaymentCoordinatorProxy): Changed to call
paymentCoordinatorAddMessageReceiver.
(WebKit::WebPaymentCoordinatorProxy::~WebPaymentCoordinatorProxy): Changed to call
paymentCoordinatorRemoveMessageReceiver.
(WebKit::WebPaymentCoordinatorProxy::messageSenderDestinationID const): Deleted.
(WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard): Passed sessionID to
platformCanMakePaymentsWithActiveCard.
(WebKit::WebPaymentCoordinatorProxy::showPaymentUI): Stored destinationID and passed
sessionID to platformShowPaymentUI.
(WebKit::WebPaymentCoordinatorProxy::cancelPaymentSession): Changed to account for new
behavior of didCancelPaymentSession.
(WebKit::WebPaymentCoordinatorProxy::didCancelPaymentSession): Changed to call hidePaymentUI.
(WebKit::WebPaymentCoordinatorProxy::presenterDidFinish): Changed to only call hidePaymentUI
when didReachFinalState is true, since didCancelPaymentSession is called otherwise.
(WebKit::WebPaymentCoordinatorProxy::didReachFinalState): Cleared m_destinationID.
* Shared/ApplePay/WebPaymentCoordinatorProxy.h: Added m_destionationID member.
* Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in: Changed
CanMakePaymentsWithActiveCard and ShowPaymentUI messages to take destinationID and sessionID
arguments.

* Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard): Passed
sessionID to paymentCoordinatorSourceApplicationSecondaryIdentifier.
(WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest): Passed sessionID to various
m_client call sites.

* Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
(WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Passed sessionID to
platformPaymentRequest.
(WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Null-checked m_authorizationPresenter
before calling dismiss.

* Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
(WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Passed sessionID to
platformPaymentRequest.
(WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Null-checked m_authorizationPresenter
before calling dismiss.

* Shared/WebPreferences.yaml: Added ApplePayRemoteUIEnabled as an internal preference.

* SourcesCocoa.txt: Added NetworkConnectionToWebProcessIOS.mm and
PaymentAuthorizationController.mm.

* UIProcess/AuxiliaryProcessProxy.h:
(WebKit::AuxiliaryProcessProxy::messageReceiverMap): Deleted.

* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::paymentCoordinatorConnection): Moved from WebPageProxy.cpp.
(WebKit::WebPageProxy::paymentCoordinatorSourceApplicationBundleIdentifier): Ditto.
(WebKit::WebPageProxy::paymentCoordinatorSourceApplicationSecondaryIdentifier): Ditto.
(WebKit::WebPageProxy::paymentCoordinatorAddMessageReceiver): Ditto.
(WebKit::WebPageProxy::paymentCoordinatorRemoveMessageReceiver): Ditto.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::paymentCoordinatorConnection): Moved to WebPageProxyCocoa.mm.
(WebKit::WebPageProxy::paymentCoordinatorMessageReceiver): Ditto.
(WebKit::WebPageProxy::paymentCoordinatorSourceApplicationBundleIdentifier): Ditto.
(WebKit::WebPageProxy::paymentCoordinatorSourceApplicationSecondaryIdentifier): Ditto.
(WebKit::WebPageProxy::paymentCoordinatorDestinationID): Ditto.
* UIProcess/WebPageProxy.h:

* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::paymentCoordinatorCTDataConnectionServiceType): Asserted that
sessionID equals the website data store's sessionID.

* WebKit.xcodeproj/project.pbxproj:

* WebProcess/ApplePay/WebPaymentCoordinator.cpp:
(WebKit::WebPaymentCoordinator::networkProcessConnectionClosed): Added. Cancels the current
session if Apple Pay Remote UI is enabled and the network process connection closes.
(WebKit::WebPaymentCoordinator::availablePaymentNetworks): Changed to account for
WebPaymentCoordinator being an IPC::MessageSender.
(WebKit::WebPaymentCoordinator::canMakePayments): Ditto.
(WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCard): Ditto.
(WebKit::WebPaymentCoordinator::openPaymentSetup): Ditto.
(WebKit::WebPaymentCoordinator::showPaymentUI): Ditto.
(WebKit::WebPaymentCoordinator::completeMerchantValidation): Ditto.
(WebKit::WebPaymentCoordinator::completeShippingMethodSelection): Ditto.
(WebKit::WebPaymentCoordinator::completeShippingContactSelection): Ditto.
(WebKit::WebPaymentCoordinator::completePaymentMethodSelection): Ditto.
(WebKit::WebPaymentCoordinator::completePaymentSession): Ditto.
(WebKit::WebPaymentCoordinator::abortPaymentSession): Ditto.
(WebKit::WebPaymentCoordinator::cancelPaymentSession): Ditto.
(WebKit::WebPaymentCoordinator::messageSenderConnection const): Added. Returns a connection
to the network process if Apple Pay Remote UI is enabled. Otherwise, returned the web
process's parent connection.
(WebKit::WebPaymentCoordinator::messageSenderDestinationID const): Added. Returns the web
page's ID.
(WebKit::WebPaymentCoordinator::remoteUIEnabled const): Added. Calls Settings::applePayRemoteUIEnabled.
* WebProcess/ApplePay/WebPaymentCoordinator.h: Inherited from IPC::MessageSender.

* WebProcess/Network/NetworkProcessConnection.cpp:
(WebKit::NetworkProcessConnection::didReceiveMessage): Forwarded WebPaymentCoordinator
messages to the payment coordinator of the web page matching the decoder's destination ID.
(WebKit::NetworkProcessConnection::didReceiveSyncMessage): Ditto for sync messages.

* WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::paymentCoordinator): Added a payment coordinator getter.
* WebProcess/WebPage/WebPage.h: Ditto.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::networkProcessConnectionClosed): Called
WebPaymentCoordinator::networkProcessConnectionClosed when the network process connection
closes.

Source/WTF:

* wtf/FeatureDefines.h: Defined ENABLE_APPLE_PAY_REMOTE_UI.

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

39 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/FeatureDefines.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.h
Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.mm
Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h
Source/WebCore/page/Settings.yaml
Source/WebKit/ChangeLog
Source/WebKit/Configurations/Network-iOS.entitlements
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
Source/WebKit/NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm [new file with mode: 0644]
Source/WebKit/Platform/ios/PaymentAuthorizationController.h [new file with mode: 0644]
Source/WebKit/Platform/ios/PaymentAuthorizationController.mm [new file with mode: 0644]
Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb
Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.cpp
Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.h
Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in
Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm
Source/WebKit/Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm
Source/WebKit/Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/AuxiliaryProcessProxy.h
Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp
Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h
Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebProcess.cpp

index 1685b79..63f7a85 100644 (file)
@@ -1,3 +1,13 @@
+2019-03-11  Andy Estes  <aestes@apple.com>
+
+        [Apple Pay] Use PKPaymentAuthorizationController to present the Apple Pay UI remotely from the Networking service on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=195530
+        <rdar://problem/48747164>
+
+        Reviewed by Alex Christensen.
+
+        * wtf/FeatureDefines.h: Defined ENABLE_APPLE_PAY_REMOTE_UI.
+
 2019-03-11  Yusuke Suzuki  <ysuzuki@apple.com>
 
         [JSC] Make StaticStringImpl & StaticSymbolImpl actually static
index 719be60..3b4da1e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2019 Apple Inc. All rights reserved.
  * Copyright (C) 2007-2009 Torch Mobile, Inc.
  * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
  * Copyright (C) 2013 Samsung Electronics. All rights reserved.
 #endif
 #endif
 
+#if !defined(ENABLE_APPLE_PAY_REMOTE_UI)
+#if !PLATFORM(APPLETV) && !PLATFORM(IOSMAC) && !PLATFORM(WATCHOS)
+#define ENABLE_APPLE_PAY_REMOTE_UI 1
+#endif
+#endif
+
 #if !defined(ENABLE_ASYNC_SCROLLING)
 #define ENABLE_ASYNC_SCROLLING 1
 #endif
index 619cd6a..f7610e3 100644 (file)
@@ -1,3 +1,15 @@
+2019-03-11  Andy Estes  <aestes@apple.com>
+
+        [Apple Pay] Use PKPaymentAuthorizationController to present the Apple Pay UI remotely from the Networking service on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=195530
+        <rdar://problem/48747164>
+
+        Reviewed by Alex Christensen.
+
+        * Modules/applepay/PaymentCoordinatorClient.h: Defined isWebPaymentCoordinator.
+        * page/Settings.yaml: Defined the applePayRemoteUIEnabled setting and reordered the other
+        Apple Pay settings.
+
 2019-03-11  Alex Christensen  <achristensen@webkit.org>
 
         Soft linking to Reveal framework should be optional
index d9aa3eb..0dab573 100644 (file)
@@ -63,6 +63,7 @@ public:
     virtual void paymentCoordinatorDestroyed() = 0;
 
     virtual bool isMockPaymentCoordinator() const { return false; }
+    virtual bool isWebPaymentCoordinator() const { return false; }
 
 protected:
     virtual ~PaymentCoordinatorClient() = default;
index 5189603..4c5de60 100644 (file)
@@ -1,3 +1,16 @@
+2019-03-11  Andy Estes  <aestes@apple.com>
+
+        [Apple Pay] Use PKPaymentAuthorizationController to present the Apple Pay UI remotely from the Networking service on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=195530
+        <rdar://problem/48747164>
+
+        Reviewed by Alex Christensen.
+
+        * pal/cocoa/PassKitSoftLink.h: Soft-linked PKPaymentAuthorizationController on iOS.
+        * pal/cocoa/PassKitSoftLink.mm: Ditto.
+        * pal/spi/cocoa/PassKitSPI.h: Declared PKPaymentAuthorizationControllerPrivateDelegate and
+        related SPI.
+
 2019-03-11  Alex Christensen  <achristensen@webkit.org>
 
         Soft linking to Reveal framework should be optional
index b1f2c97..19152a4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -42,6 +42,10 @@ SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentRequest)
 SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentSummaryItem)
 SOFT_LINK_CLASS_FOR_HEADER(PAL, PKShippingMethod)
 
+#if PLATFORM(IOS_FAMILY)
+SOFT_LINK_CLASS_FOR_HEADER(PAL, PKPaymentAuthorizationController)
+#endif
+
 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, PassKit, PKCanMakePaymentsWithMerchantIdentifierAndDomain, void, (NSString *identifier, NSString *domain, PKCanMakePaymentsCompletion completion), (identifier, domain, completion))
 SOFT_LINK_FUNCTION_FOR_HEADER(PAL, PassKit, PKDrawApplePayButton, void, (CGContextRef context, CGRect drawRect, CGFloat scale, PKPaymentButtonType type, PKPaymentButtonStyle style, NSString *languageCode), (context, drawRect, scale, type, style, languageCode))
 
index 872973e..40beaf8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -46,6 +46,10 @@ SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, PassKit, PKPaymentRequest, PAL_EXPOR
 SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, PassKit, PKPaymentSummaryItem, PAL_EXPORT)
 SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, PassKit, PKShippingMethod, PAL_EXPORT)
 
+#if PLATFORM(IOS_FAMILY)
+SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, PassKit, PKPaymentAuthorizationController, PAL_EXPORT)
+#endif
+
 SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, PassKit, PKCanMakePaymentsWithMerchantIdentifierAndDomain, void, (NSString *identifier, NSString *domain, PKCanMakePaymentsCompletion completion), (identifier, domain, completion), PAL_EXPORT)
 SOFT_LINK_FUNCTION_FOR_SOURCE(PAL, PassKit, PKDrawApplePayButton, void, (CGContextRef context, CGRect drawRect, CGFloat scale, PKPaymentButtonType type, PKPaymentButtonStyle style, NSString *languageCode), (context, drawRect, scale, type, style, languageCode))
 
index 18958e9..6a5b4fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -43,12 +43,34 @@ WTF_EXTERN_C_END
 #import <PassKit/PKPaymentAuthorizationViewController_Private.h>
 #import <PassKit/PKPaymentRequest_Private.h>
 
+#if PLATFORM(IOS_FAMILY)
+#import <PassKit/PKPaymentAuthorizationController_Private.h>
+#endif
+
 #else
 
 #if PLATFORM(IOS_FAMILY)
 
 #import <PassKit/PassKit.h>
 
+@protocol PKPaymentAuthorizationControllerPrivateDelegate;
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface PKPaymentAuthorizationController ()
+@property (nonatomic, assign, nullable) id<PKPaymentAuthorizationControllerPrivateDelegate> privateDelegate;
+@end
+
+@class PKPaymentMerchantSession;
+
+@protocol PKPaymentAuthorizationControllerPrivateDelegate <NSObject>
+@optional
+- (void)paymentAuthorizationController:(PKPaymentAuthorizationController *)controller willFinishWithError:(NSError *)error;
+- (void)paymentAuthorizationController:(PKPaymentAuthorizationController *)controller didRequestMerchantSession:(void(^)(PKPaymentMerchantSession *, NSError *))sessionBlock;
+@end
+
+NS_ASSUME_NONNULL_END
+
 #elif PLATFORM(MAC)
 
 #import <AppKit/AppKit.h>
index bf83eeb..540781c 100644 (file)
@@ -652,15 +652,18 @@ fontLoadTimingOverride:
 shouldIgnoreFontLoadCompletions:
   initial: false
 
-paymentRequestEnabled:
-  initial: false
-  conditional: PAYMENT_REQUEST
-applePayEnabled:
-  initial: false
-  conditional: APPLE_PAY
 applePayCapabilityDisclosureAllowed:
+  conditional: APPLE_PAY
   initial: true
+applePayEnabled:
   conditional: APPLE_PAY
+  initial: false
+applePayRemoteUIEnabled:
+  conditional: APPLE_PAY_REMOTE_UI
+  initial: true
+paymentRequestEnabled:
+  conditional: PAYMENT_REQUEST
+  initial: false
 
 javaEnabled:
   initial: false
index cce9f36..bf50379 100644 (file)
@@ -1,3 +1,189 @@
+2019-03-11  Andy Estes  <aestes@apple.com>
+
+        [Apple Pay] Use PKPaymentAuthorizationController to present the Apple Pay UI remotely from the Networking service on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=195530
+        <rdar://problem/48747164>
+
+        Reviewed by Alex Christensen.
+
+        * Configurations/Network-iOS.entitlements: Added the 'com.apple.payment.all-access'
+        entitlement and reordered the others.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::didReceiveMessage): Forwarded
+        WebPaymentCoordinatorProxy messages to the payment coordinator.
+        (WebKit::NetworkConnectionToWebProcess::didReceiveSyncMessage): Ditto.
+        (WebKit::NetworkConnectionToWebProcess::didClose): Set m_paymentCoordinator to nullptr.
+        * NetworkProcess/NetworkConnectionToWebProcess.h: Inherited from
+        WebPaymentCoordinatorProxy::Client and added a unique_ptr<WebPaymentCoordinatorProxy> member.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.h: Declared getters for source application bundle
+        and secondary identifiers, and CTDataConnectionServiceType on iOS.
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (WebKit::NetworkSessionCocoa::sourceApplicationBundleIdentifier const): Defined getter.
+        (WebKit::NetworkSessionCocoa::sourceApplicationSecondaryIdentifier const): Ditto.
+        (WebKit::NetworkSessionCocoa::ctDataConnectionServiceType const): Ditto.
+        (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): Initialized
+        m_sourceApplicationBundleIdentifier and m_sourceApplicationSecondaryIdentifier with
+        corresponding NetworkSessionCreationParameters.
+
+        * NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm: Added.
+        (WebKit::NetworkConnectionToWebProcess::paymentCoordinator): Added. Returns
+        m_paymentCoordinator after lazily initializing it.
+        (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorConnection): Added. Returns the
+        connection to the web process.
+        (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorPresentingViewController): Added.
+        Returns nil.
+        (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorCTDataConnectionServiceType):
+        Added. Returns the value from the network session identified by sessionID.
+        (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorSourceApplicationBundleIdentifier):
+        Ditto.
+        (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorSourceApplicationSecondaryIdentifier):
+        Ditto.
+        (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorAuthorizationPresenter): Added.
+        Returns a new PaymentAuthorizationController.
+        (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorAddMessageReceiver): Added empty
+        definition. NetworkConnectionToWebProcess explicitly forwards WebPaymentCoordinatorProxy
+        messages to its payment coordinator, so there's no need to register with a MessageReceiverMap.
+        (WebKit::NetworkConnectionToWebProcess::paymentCoordinatorRemoveMessageReceiver): Ditto.
+
+        * Platform/ios/PaymentAuthorizationController.h: Added. Declares a
+        PaymentAuthorizationPresenter subclass based on PKPaymentAuthorizationController.
+        * Platform/ios/PaymentAuthorizationController.mm: Added.
+        (-[WKPaymentAuthorizationControllerDelegate initWithRequest:presenter:]):
+        Initialized WKPaymentAuthorizationDelegate with request and presenter.
+        (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationControllerDidFinish:]):
+        Forwarded call to WKPaymentAuthorizationDelegate.
+        (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didAuthorizePayment:handler:]):
+        Ditto.
+        (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectShippingMethod:handler:]):
+        Ditto.
+        (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectShippingContact:handler:]):
+        Ditto.
+        (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didSelectPaymentMethod:handler:]):
+        Ditto.
+        (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:willFinishWithError:]):
+        Ditto.
+        (-[WKPaymentAuthorizationControllerDelegate paymentAuthorizationController:didRequestMerchantSession:]):
+        Ditto.
+        (WebKit::PaymentAuthorizationController::PaymentAuthorizationController):
+        Initialized m_controller with a new PKPaymentAuthorizationController and m_delegate with a
+        new WKPaymentAuthorizationControllerDelegate.
+        (WebKit::PaymentAuthorizationController::platformDelegate): Returned m_delegate.
+        (WebKit::PaymentAuthorizationController::dismiss): Dismissed the controller, set its
+        delegates to nil, set m_controller to nil, invalidated the delegate, and set m_delegate to
+        nil.
+        (WebKit::PaymentAuthorizationController::present): Called -presentWithCompletion: on the
+        controller, forwarding the passed-in completion handler.
+        * Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb: Allowed PassKit to look up
+        the "com.apple.passd.in-app-payment" and "com.apple.passd.library" service endpoints.
+
+        * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
+        (WebKit::WebPaymentCoordinatorProxy::WebPaymentCoordinatorProxy): Changed to call
+        paymentCoordinatorAddMessageReceiver.
+        (WebKit::WebPaymentCoordinatorProxy::~WebPaymentCoordinatorProxy): Changed to call
+        paymentCoordinatorRemoveMessageReceiver.
+        (WebKit::WebPaymentCoordinatorProxy::messageSenderDestinationID const): Deleted.
+        (WebKit::WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard): Passed sessionID to
+        platformCanMakePaymentsWithActiveCard.
+        (WebKit::WebPaymentCoordinatorProxy::showPaymentUI): Stored destinationID and passed
+        sessionID to platformShowPaymentUI.
+        (WebKit::WebPaymentCoordinatorProxy::cancelPaymentSession): Changed to account for new
+        behavior of didCancelPaymentSession.
+        (WebKit::WebPaymentCoordinatorProxy::didCancelPaymentSession): Changed to call hidePaymentUI.
+        (WebKit::WebPaymentCoordinatorProxy::presenterDidFinish): Changed to only call hidePaymentUI
+        when didReachFinalState is true, since didCancelPaymentSession is called otherwise.
+        (WebKit::WebPaymentCoordinatorProxy::didReachFinalState): Cleared m_destinationID.
+        * Shared/ApplePay/WebPaymentCoordinatorProxy.h: Added m_destionationID member.
+        * Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in: Changed
+        CanMakePaymentsWithActiveCard and ShowPaymentUI messages to take destinationID and sessionID
+        arguments.
+
+        * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard): Passed
+        sessionID to paymentCoordinatorSourceApplicationSecondaryIdentifier.
+        (WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest): Passed sessionID to various
+        m_client call sites.
+
+        * Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Passed sessionID to
+        platformPaymentRequest.
+        (WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Null-checked m_authorizationPresenter
+        before calling dismiss.
+
+        * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Passed sessionID to
+        platformPaymentRequest.
+        (WebKit::WebPaymentCoordinatorProxy::hidePaymentUI): Null-checked m_authorizationPresenter
+        before calling dismiss.
+
+        * Shared/WebPreferences.yaml: Added ApplePayRemoteUIEnabled as an internal preference.
+
+        * SourcesCocoa.txt: Added NetworkConnectionToWebProcessIOS.mm and
+        PaymentAuthorizationController.mm.
+
+        * UIProcess/AuxiliaryProcessProxy.h:
+        (WebKit::AuxiliaryProcessProxy::messageReceiverMap): Deleted.
+
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        (WebKit::WebPageProxy::paymentCoordinatorConnection): Moved from WebPageProxy.cpp.
+        (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationBundleIdentifier): Ditto.
+        (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationSecondaryIdentifier): Ditto.
+        (WebKit::WebPageProxy::paymentCoordinatorAddMessageReceiver): Ditto.
+        (WebKit::WebPageProxy::paymentCoordinatorRemoveMessageReceiver): Ditto.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::paymentCoordinatorConnection): Moved to WebPageProxyCocoa.mm.
+        (WebKit::WebPageProxy::paymentCoordinatorMessageReceiver): Ditto.
+        (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationBundleIdentifier): Ditto.
+        (WebKit::WebPageProxy::paymentCoordinatorSourceApplicationSecondaryIdentifier): Ditto.
+        (WebKit::WebPageProxy::paymentCoordinatorDestinationID): Ditto.
+        * UIProcess/WebPageProxy.h:
+
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::paymentCoordinatorCTDataConnectionServiceType): Asserted that
+        sessionID equals the website data store's sessionID.
+
+        * WebKit.xcodeproj/project.pbxproj:
+
+        * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
+        (WebKit::WebPaymentCoordinator::networkProcessConnectionClosed): Added. Cancels the current
+        session if Apple Pay Remote UI is enabled and the network process connection closes.
+        (WebKit::WebPaymentCoordinator::availablePaymentNetworks): Changed to account for
+        WebPaymentCoordinator being an IPC::MessageSender.
+        (WebKit::WebPaymentCoordinator::canMakePayments): Ditto.
+        (WebKit::WebPaymentCoordinator::canMakePaymentsWithActiveCard): Ditto.
+        (WebKit::WebPaymentCoordinator::openPaymentSetup): Ditto.
+        (WebKit::WebPaymentCoordinator::showPaymentUI): Ditto.
+        (WebKit::WebPaymentCoordinator::completeMerchantValidation): Ditto.
+        (WebKit::WebPaymentCoordinator::completeShippingMethodSelection): Ditto.
+        (WebKit::WebPaymentCoordinator::completeShippingContactSelection): Ditto.
+        (WebKit::WebPaymentCoordinator::completePaymentMethodSelection): Ditto.
+        (WebKit::WebPaymentCoordinator::completePaymentSession): Ditto.
+        (WebKit::WebPaymentCoordinator::abortPaymentSession): Ditto.
+        (WebKit::WebPaymentCoordinator::cancelPaymentSession): Ditto.
+        (WebKit::WebPaymentCoordinator::messageSenderConnection const): Added. Returns a connection
+        to the network process if Apple Pay Remote UI is enabled. Otherwise, returned the web
+        process's parent connection.
+        (WebKit::WebPaymentCoordinator::messageSenderDestinationID const): Added. Returns the web
+        page's ID.
+        (WebKit::WebPaymentCoordinator::remoteUIEnabled const): Added. Calls Settings::applePayRemoteUIEnabled.
+        * WebProcess/ApplePay/WebPaymentCoordinator.h: Inherited from IPC::MessageSender.
+
+        * WebProcess/Network/NetworkProcessConnection.cpp:
+        (WebKit::NetworkProcessConnection::didReceiveMessage): Forwarded WebPaymentCoordinator
+        messages to the payment coordinator of the web page matching the decoder's destination ID.
+        (WebKit::NetworkProcessConnection::didReceiveSyncMessage): Ditto for sync messages.
+
+        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+        (WebKit::WebPage::paymentCoordinator): Added a payment coordinator getter.
+        * WebProcess/WebPage/WebPage.h: Ditto.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::networkProcessConnectionClosed): Called
+        WebPaymentCoordinator::networkProcessConnectionClosed when the network process connection
+        closes.
+
 2019-03-11  Per Arne Vollan  <pvollan@apple.com>
 
         [iOS] Block access to backboardd service
index 9b73758..2ee6966 100644 (file)
@@ -2,17 +2,19 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+       <key>com.apple.multitasking.systemappassertions</key>
+       <true/>
+       <key>com.apple.payment.all-access</key>
+       <true/>
        <key>com.apple.private.accounts.bundleidspoofing</key>
        <true/>
+       <key>com.apple.private.memorystatus</key>
+       <true/>
        <key>com.apple.private.network.socket-delegate</key>
        <true/>
        <key>seatbelt-profiles</key>
        <array>
                <string>com.apple.WebKit.Networking</string>
        </array>
-       <key>com.apple.multitasking.systemappassertions</key>
-       <true/>
-       <key>com.apple.private.memorystatus</key>
-       <true/>
 </dict>
 </plist>
index dd2035a..bd1093e 100644 (file)
 #include <WebCore/SameSiteInfo.h>
 #include <WebCore/SecurityPolicy.h>
 
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+#include "WebPaymentCoordinatorProxyMessages.h"
+#endif
+
 namespace WebKit {
 using namespace WebCore;
 
@@ -197,6 +201,11 @@ void NetworkConnectionToWebProcess::didReceiveMessage(IPC::Connection& connectio
     }
 #endif
 
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    if (decoder.messageReceiverName() == Messages::WebPaymentCoordinatorProxy::messageReceiverName())
+        return paymentCoordinator().didReceiveMessage(connection, decoder);
+#endif
+
     ASSERT_NOT_REACHED();
 }
 
@@ -231,6 +240,11 @@ void NetworkConnectionToWebProcess::didReceiveSyncMessage(IPC::Connection& conne
     }
 #endif
 
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    if (decoder.messageReceiverName() == Messages::WebPaymentCoordinatorProxy::messageReceiverName())
+        return paymentCoordinator().didReceiveSyncMessage(connection, decoder, reply);
+#endif
+
     ASSERT_NOT_REACHED();
 }
 
@@ -278,6 +292,10 @@ void NetworkConnectionToWebProcess::didClose(IPC::Connection& connection)
 #if ENABLE(SERVICE_WORKER)
     unregisterSWConnections();
 #endif
+
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    m_paymentCoordinator = nullptr;
+#endif
 }
 
 void NetworkConnectionToWebProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference)
index 7535018..398430e 100644 (file)
@@ -32,6 +32,7 @@
 #include "NetworkConnectionToWebProcessMessages.h"
 #include "NetworkMDNSRegister.h"
 #include "NetworkRTCProvider.h"
+#include "WebPaymentCoordinatorProxy.h"
 #include <WebCore/NetworkLoadInformation.h>
 #include <WebCore/RegistrableDomain.h>
 #include <wtf/RefCounted.h>
@@ -63,7 +64,12 @@ namespace NetworkCache {
 struct DataKey;
 }
 
-class NetworkConnectionToWebProcess : public RefCounted<NetworkConnectionToWebProcess>, IPC::Connection::Client {
+class NetworkConnectionToWebProcess
+    : public RefCounted<NetworkConnectionToWebProcess>
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    , public WebPaymentCoordinatorProxy::Client
+#endif
+    , IPC::Connection::Client {
 public:
     using RegistrableDomain = WebCore::RegistrableDomain;
 
@@ -244,6 +250,20 @@ private:
     size_t findRootNetworkActivity(uint64_t pageID);
     size_t findNetworkActivityTracker(ResourceLoadIdentifier resourceID);
 
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    WebPaymentCoordinatorProxy& paymentCoordinator();
+
+    // WebPaymentCoordinatorProxy::Client
+    IPC::Connection* paymentCoordinatorConnection(const WebPaymentCoordinatorProxy&) final;
+    UIViewController *paymentCoordinatorPresentingViewController(const WebPaymentCoordinatorProxy&) final;
+    const String& paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&, PAL::SessionID) final;
+    const String& paymentCoordinatorSourceApplicationBundleIdentifier(const WebPaymentCoordinatorProxy&, PAL::SessionID) final;
+    const String& paymentCoordinatorSourceApplicationSecondaryIdentifier(const WebPaymentCoordinatorProxy&, PAL::SessionID) final;
+    std::unique_ptr<PaymentAuthorizationPresenter> paymentCoordinatorAuthorizationPresenter(WebPaymentCoordinatorProxy&, PKPaymentRequest *) final;
+    void paymentCoordinatorAddMessageReceiver(WebPaymentCoordinatorProxy&, const IPC::StringReference&, IPC::MessageReceiver&) final;
+    void paymentCoordinatorRemoveMessageReceiver(WebPaymentCoordinatorProxy&, const IPC::StringReference&) final;
+#endif
+
     Ref<IPC::Connection> m_connection;
     Ref<NetworkProcess> m_networkProcess;
 
@@ -269,10 +289,14 @@ private:
 #if ENABLE(INDEXED_DATABASE)
     HashMap<uint64_t, RefPtr<WebIDBConnectionToClient>> m_webIDBConnections;
 #endif
-    
+
 #if ENABLE(SERVICE_WORKER)
     HashMap<WebCore::SWServerConnectionIdentifier, WeakPtr<WebSWServerConnection>> m_swConnections;
 #endif
+
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    std::unique_ptr<WebPaymentCoordinatorProxy> m_paymentCoordinator;
+#endif
 };
 
 } // namespace WebKit
index 18621a4..4b508cb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -47,9 +47,12 @@ public:
     static Ref<NetworkSession> create(NetworkProcess&, NetworkSessionCreationParameters&&);
     ~NetworkSessionCocoa();
 
+    const String& sourceApplicationBundleIdentifier() const;
+    const String& sourceApplicationSecondaryIdentifier() const;
     // Must be called before any NetworkSession has been created.
     // FIXME: Move this to NetworkSessionCreationParameters.
 #if PLATFORM(IOS_FAMILY)
+    const String& ctDataConnectionServiceType() const;
     static void setCTDataConnectionServiceType(const String&);
 #endif
 
@@ -82,6 +85,8 @@ private:
     RetainPtr<WKNetworkSessionDelegate> m_statelessSessionDelegate;
 
     String m_boundInterfaceIdentifier;
+    String m_sourceApplicationBundleIdentifier;
+    String m_sourceApplicationSecondaryIdentifier;
     RetainPtr<CFDictionaryRef> m_proxyConfiguration;
     bool m_shouldLogCookieInformation { false };
     Seconds m_loadThrottleLatency;
index 6fbd9e7..c0176e2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -803,15 +803,28 @@ static NSURLSessionConfiguration *configurationForSessionID(const PAL::SessionID
     return [NSURLSessionConfiguration defaultSessionConfiguration];
 }
 
+const String& NetworkSessionCocoa::sourceApplicationBundleIdentifier() const
+{
+    return m_sourceApplicationBundleIdentifier;
+}
+
+const String& NetworkSessionCocoa::sourceApplicationSecondaryIdentifier() const
+{
+    return m_sourceApplicationSecondaryIdentifier;
+}
+
 #if PLATFORM(IOS_FAMILY)
 static String& globalCTDataConnectionServiceType()
 {
     static NeverDestroyed<String> ctDataConnectionServiceType;
     return ctDataConnectionServiceType.get();
 }
-#endif
 
-#if PLATFORM(IOS_FAMILY)
+const String& NetworkSessionCocoa::ctDataConnectionServiceType() const
+{
+    return globalCTDataConnectionServiceType();
+}
+
 void NetworkSessionCocoa::setCTDataConnectionServiceType(const String& type)
 {
     ASSERT(!sessionsCreated);
@@ -850,6 +863,8 @@ static NSDictionary *proxyDictionary(const URL& httpProxy, const URL& httpsProxy
 NetworkSessionCocoa::NetworkSessionCocoa(NetworkProcess& networkProcess, NetworkSessionCreationParameters&& parameters)
     : NetworkSession(networkProcess, parameters.sessionID)
     , m_boundInterfaceIdentifier(parameters.boundInterfaceIdentifier)
+    , m_sourceApplicationBundleIdentifier(parameters.sourceApplicationBundleIdentifier)
+    , m_sourceApplicationSecondaryIdentifier(parameters.sourceApplicationSecondaryIdentifier)
     , m_proxyConfiguration(parameters.proxyConfiguration)
     , m_shouldLogCookieInformation(parameters.shouldLogCookieInformation)
     , m_loadThrottleLatency(parameters.loadThrottleLatency)
@@ -882,13 +897,13 @@ NetworkSessionCocoa::NetworkSessionCocoa(NetworkProcess& networkProcess, Network
     if (auto data = networkProcess.sourceApplicationAuditData())
         configuration._sourceApplicationAuditTokenData = (__bridge NSData *)data.get();
 
-    if (!parameters.sourceApplicationBundleIdentifier.isEmpty()) {
-        configuration._sourceApplicationBundleIdentifier = parameters.sourceApplicationBundleIdentifier;
+    if (!m_sourceApplicationBundleIdentifier.isEmpty()) {
+        configuration._sourceApplicationBundleIdentifier = m_sourceApplicationBundleIdentifier;
         configuration._sourceApplicationAuditTokenData = nil;
     }
 
-    if (!parameters.sourceApplicationSecondaryIdentifier.isEmpty())
-        configuration._sourceApplicationSecondaryIdentifier = parameters.sourceApplicationSecondaryIdentifier;
+    if (!m_sourceApplicationSecondaryIdentifier.isEmpty())
+        configuration._sourceApplicationSecondaryIdentifier = m_sourceApplicationSecondaryIdentifier;
 
     configuration.connectionProxyDictionary = proxyDictionary(parameters.httpProxy, parameters.httpsProxy);
 
diff --git a/Source/WebKit/NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm b/Source/WebKit/NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm
new file mode 100644 (file)
index 0000000..da60cc5
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "NetworkConnectionToWebProcess.h"
+
+#if PLATFORM(IOS_FAMILY)
+
+#import "NetworkSessionCocoa.h"
+#import "PaymentAuthorizationController.h"
+
+namespace WebKit {
+    
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+
+WebPaymentCoordinatorProxy& NetworkConnectionToWebProcess::paymentCoordinator()
+{
+    if (!m_paymentCoordinator)
+        m_paymentCoordinator = std::make_unique<WebPaymentCoordinatorProxy>(*this);
+    return *m_paymentCoordinator;
+}
+
+IPC::Connection* NetworkConnectionToWebProcess::paymentCoordinatorConnection(const WebPaymentCoordinatorProxy&)
+{
+    return &connection();
+}
+
+UIViewController *NetworkConnectionToWebProcess::paymentCoordinatorPresentingViewController(const WebPaymentCoordinatorProxy&)
+{
+    return nil;
+}
+
+const String& NetworkConnectionToWebProcess::paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&, PAL::SessionID sessionID)
+{
+    if (auto session = static_cast<NetworkSessionCocoa*>(m_networkProcess->networkSession(sessionID)))
+        return session->ctDataConnectionServiceType();
+    return emptyString();
+}
+
+const String& NetworkConnectionToWebProcess::paymentCoordinatorSourceApplicationBundleIdentifier(const WebPaymentCoordinatorProxy&, PAL::SessionID sessionID)
+{
+    if (auto session = static_cast<NetworkSessionCocoa*>(m_networkProcess->networkSession(sessionID)))
+        return session->sourceApplicationBundleIdentifier();
+    return emptyString();
+}
+
+const String& NetworkConnectionToWebProcess::paymentCoordinatorSourceApplicationSecondaryIdentifier(const WebPaymentCoordinatorProxy&, PAL::SessionID sessionID)
+{
+    if (auto session = static_cast<NetworkSessionCocoa*>(m_networkProcess->networkSession(sessionID)))
+        return session->sourceApplicationSecondaryIdentifier();
+    return emptyString();
+}
+
+std::unique_ptr<PaymentAuthorizationPresenter> NetworkConnectionToWebProcess::paymentCoordinatorAuthorizationPresenter(WebPaymentCoordinatorProxy& coordinator, PKPaymentRequest *request)
+{
+    return std::make_unique<PaymentAuthorizationController>(coordinator, request);
+}
+
+void NetworkConnectionToWebProcess::paymentCoordinatorAddMessageReceiver(WebPaymentCoordinatorProxy&, const IPC::StringReference&, IPC::MessageReceiver&)
+{
+}
+
+void NetworkConnectionToWebProcess::paymentCoordinatorRemoveMessageReceiver(WebPaymentCoordinatorProxy&, const IPC::StringReference&)
+{
+}
+
+#endif // ENABLE(APPLE_PAY_REMOTE_UI)
+
+} // namespace WebKit
+
+#endif // PLATFORM(IOS_FAMILY)
diff --git a/Source/WebKit/Platform/ios/PaymentAuthorizationController.h b/Source/WebKit/Platform/ios/PaymentAuthorizationController.h
new file mode 100644 (file)
index 0000000..6667a80
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(PASSKIT) && PLATFORM(IOS_FAMILY)
+
+#include "PaymentAuthorizationPresenter.h"
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS PKPaymentAuthorizationController;
+OBJC_CLASS PKPaymentRequest;
+OBJC_CLASS WKPaymentAuthorizationControllerDelegate;
+OBJC_CLASS WKPaymentAuthorizationDelegate;
+
+namespace WebKit {
+
+class PaymentAuthorizationController final : public PaymentAuthorizationPresenter {
+public:
+    PaymentAuthorizationController(PaymentAuthorizationPresenter::Client&, PKPaymentRequest *);
+
+private:
+    // PaymentAuthorizationPresenter
+    WKPaymentAuthorizationDelegate *platformDelegate() final;
+    void dismiss() final;
+    void present(UIViewController *, CompletionHandler<void(bool)>&&) final;
+
+    RetainPtr<PKPaymentAuthorizationController> m_controller;
+    RetainPtr<WKPaymentAuthorizationControllerDelegate> m_delegate;
+};
+
+} // namespace WebKit
+
+#endif // USE(PASSKIT) && PLATFORM(IOS_FAMILY)
diff --git a/Source/WebKit/Platform/ios/PaymentAuthorizationController.mm b/Source/WebKit/Platform/ios/PaymentAuthorizationController.mm
new file mode 100644 (file)
index 0000000..dcb0a02
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PaymentAuthorizationController.h"
+
+#if USE(PASSKIT) && PLATFORM(IOS_FAMILY)
+
+#import "WKPaymentAuthorizationDelegate.h"
+#import <pal/cocoa/PassKitSoftLink.h>
+
+@interface WKPaymentAuthorizationControllerDelegate : WKPaymentAuthorizationDelegate <PKPaymentAuthorizationControllerDelegate, PKPaymentAuthorizationControllerPrivateDelegate>
+
+- (instancetype)initWithRequest:(PKPaymentRequest *)request presenter:(WebKit::PaymentAuthorizationPresenter&)presenter;
+
+@end
+
+@implementation WKPaymentAuthorizationControllerDelegate
+
+- (instancetype)initWithRequest:(PKPaymentRequest *)request presenter:(WebKit::PaymentAuthorizationPresenter&)presenter
+{
+    if (!(self = [super _initWithRequest:request presenter:presenter]))
+        return nil;
+
+    return self;
+}
+
+#pragma mark PKPaymentAuthorizationControllerDelegate
+
+- (void)paymentAuthorizationControllerDidFinish:(PKPaymentAuthorizationController *)controller
+{
+    [self _didFinish];
+}
+
+- (void)paymentAuthorizationController:(PKPaymentAuthorizationController *)controller didAuthorizePayment:(PKPayment *)payment handler:(void(^)(PKPaymentAuthorizationResult *result))completion
+{
+    [self _didAuthorizePayment:payment completion:completion];
+}
+
+- (void)paymentAuthorizationController:(PKPaymentAuthorizationController *)controller didSelectShippingMethod:(PKShippingMethod *)shippingMethod handler:(void(^)(PKPaymentRequestShippingMethodUpdate *requestUpdate))completion
+{
+    [self _didSelectShippingMethod:shippingMethod completion:completion];
+}
+
+- (void)paymentAuthorizationController:(PKPaymentAuthorizationController *)controller didSelectShippingContact:(PKContact *)contact handler:(void(^)(PKPaymentRequestShippingContactUpdate *requestUpdate))completion
+{
+    [self _didSelectShippingContact:contact completion:completion];
+}
+
+- (void)paymentAuthorizationController:(PKPaymentAuthorizationController *)controller didSelectPaymentMethod:(PKPaymentMethod *)paymentMethod handler:(void(^)(PKPaymentRequestPaymentMethodUpdate *requestUpdate))completion
+{
+    [self _didSelectPaymentMethod:paymentMethod completion:completion];
+}
+
+#pragma mark PKPaymentAuthorizationControllerPrivateDelegate
+
+- (void)paymentAuthorizationController:(PKPaymentAuthorizationController *)controller willFinishWithError:(NSError *)error
+{
+    [self _willFinishWithError:error];
+}
+
+- (void)paymentAuthorizationController:(PKPaymentAuthorizationController *)controller didRequestMerchantSession:(void(^)(PKPaymentMerchantSession *, NSError *))sessionBlock
+{
+    [self _didRequestMerchantSession:sessionBlock];
+}
+
+@end
+
+namespace WebKit {
+
+PaymentAuthorizationController::PaymentAuthorizationController(PaymentAuthorizationPresenter::Client& client, PKPaymentRequest *request)
+    : PaymentAuthorizationPresenter(client)
+    , m_controller(adoptNS([PAL::allocPKPaymentAuthorizationControllerInstance() initWithPaymentRequest:request]))
+    , m_delegate(adoptNS([[WKPaymentAuthorizationControllerDelegate alloc] initWithRequest:request presenter:*this]))
+{
+    [m_controller setDelegate:m_delegate.get()];
+    [m_controller setPrivateDelegate:m_delegate.get()];
+}
+
+WKPaymentAuthorizationDelegate *PaymentAuthorizationController::platformDelegate()
+{
+    return m_delegate.get();
+}
+
+void PaymentAuthorizationController::dismiss()
+{
+    [m_controller dismissWithCompletion:nil];
+    [m_controller setDelegate:nil];
+    [m_controller setPrivateDelegate:nil];
+    m_controller = nil;
+    [m_delegate invalidate];
+    m_delegate = nil;
+}
+
+void PaymentAuthorizationController::present(UIViewController *, CompletionHandler<void(bool)>&& completionHandler)
+{
+    if (!m_controller)
+        return completionHandler(false);
+
+    [m_controller presentWithCompletion:makeBlockPtr([completionHandler = WTFMove(completionHandler)](BOOL success) mutable {
+        completionHandler(success);
+    }).get()];
+}
+
+} // namespace WebKit
+
+#endif // USE(PASSKIT) && PLATFORM(IOS_FAMILY)
index b9094db..a6c6596 100644 (file)
@@ -1,4 +1,4 @@
-; Copyright (C) 2014-2015 Apple Inc. All rights reserved.
+; Copyright (C) 2014-2019 Apple Inc. All rights reserved.
 ;
 ; Redistribution and use in source and binary forms, with or without
 ; modification, are permitted provided that the following conditions
     (global-name "com.apple.ocspd")
     (global-name "com.apple.securityd"))
 
+;; PassKit framework
+(allow mach-lookup
+    (global-name "com.apple.passd.in-app-payment")
+    (global-name "com.apple.passd.library"))
+
 (deny file-write-create
        (vnode-type SYMLINK))
 
index 6bb56e2..aea63e9 100644 (file)
@@ -46,7 +46,7 @@ static WeakPtr<WebPaymentCoordinatorProxy>& activePaymentCoordinatorProxy()
 WebPaymentCoordinatorProxy::WebPaymentCoordinatorProxy(WebPaymentCoordinatorProxy::Client& client)
     : m_client { client }
 {
-    m_client.paymentCoordinatorMessageReceiver(*this).addMessageReceiver(Messages::WebPaymentCoordinatorProxy::messageReceiverName(), m_client.paymentCoordinatorDestinationID(*this), *this);
+    m_client.paymentCoordinatorAddMessageReceiver(*this, Messages::WebPaymentCoordinatorProxy::messageReceiverName(), *this);
     finishConstruction(*this);
 }
 
@@ -55,7 +55,7 @@ WebPaymentCoordinatorProxy::~WebPaymentCoordinatorProxy()
     if (m_state != State::Idle)
         hidePaymentUI();
 
-    m_client.paymentCoordinatorMessageReceiver(*this).removeMessageReceiver(Messages::WebPaymentCoordinatorProxy::messageReceiverName(), m_client.paymentCoordinatorDestinationID(*this));
+    m_client.paymentCoordinatorRemoveMessageReceiver(*this, Messages::WebPaymentCoordinatorProxy::messageReceiverName());
 }
 
 IPC::Connection* WebPaymentCoordinatorProxy::messageSenderConnection() const
@@ -65,7 +65,7 @@ IPC::Connection* WebPaymentCoordinatorProxy::messageSenderConnection() const
 
 uint64_t WebPaymentCoordinatorProxy::messageSenderDestinationID() const
 {
-    return m_client.paymentCoordinatorDestinationID(*this);
+    return *m_destinationID;
 }
 
 void WebPaymentCoordinatorProxy::availablePaymentNetworks(CompletionHandler<void(Vector<String>&&)>&& completionHandler)
@@ -78,9 +78,9 @@ void WebPaymentCoordinatorProxy::canMakePayments(CompletionHandler<void(bool)>&&
     reply(platformCanMakePayments());
 }
 
-void WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler)
+void WebPaymentCoordinatorProxy::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, PAL::SessionID sessionID, CompletionHandler<void(bool)>&& completionHandler)
 {
-    platformCanMakePaymentsWithActiveCard(merchantIdentifier, domainName, WTFMove(completionHandler));
+    platformCanMakePaymentsWithActiveCard(merchantIdentifier, domainName, sessionID, WTFMove(completionHandler));
 }
 
 void WebPaymentCoordinatorProxy::openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler)
@@ -88,18 +88,18 @@ void WebPaymentCoordinatorProxy::openPaymentSetup(const String& merchantIdentifi
     platformOpenPaymentSetup(merchantIdentifier, domainName, WTFMove(completionHandler));
 }
 
-void WebPaymentCoordinatorProxy::showPaymentUI(const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& paymentRequest, CompletionHandler<void(bool)>&& completionHandler)
+void WebPaymentCoordinatorProxy::showPaymentUI(uint64_t destinationID, PAL::SessionID sessionID, const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& paymentRequest, CompletionHandler<void(bool)>&& completionHandler)
 {
-    // FIXME: Make this a message check.
-    ASSERT(canBegin());
-
-    if (auto& coordinator = activePaymentCoordinatorProxy()) {
-        coordinator->hidePaymentUI();
+    if (auto& coordinator = activePaymentCoordinatorProxy())
         coordinator->didCancelPaymentSession();
-    }
-
     activePaymentCoordinatorProxy() = makeWeakPtr(this);
 
+    // FIXME: Make this a message check.
+    ASSERT(canBegin());
+    ASSERT(!m_destinationID);
+    ASSERT(!m_authorizationPresenter);
+
+    m_destinationID = destinationID;
     m_state = State::Activating;
 
     URL originatingURL(URL(), originatingURLString);
@@ -108,7 +108,7 @@ void WebPaymentCoordinatorProxy::showPaymentUI(const String& originatingURLStrin
     for (const auto& linkIconURLString : linkIconURLStrings)
         linkIconURLs.append(URL(URL(), linkIconURLString));
 
-    platformShowPaymentUI(originatingURL, linkIconURLs, paymentRequest, [weakThis = makeWeakPtr(*this)](bool result) {
+    platformShowPaymentUI(originatingURL, linkIconURLs, sessionID, paymentRequest, [weakThis = makeWeakPtr(*this)](bool result) {
         if (!weakThis)
             return;
 
@@ -124,7 +124,6 @@ void WebPaymentCoordinatorProxy::showPaymentUI(const String& originatingURLStrin
     completionHandler(true);
 }
 
-    
 void WebPaymentCoordinatorProxy::completeMerchantValidation(const WebCore::PaymentMerchantSession& paymentMerchantSession)
 {
     // It's possible that the payment has been canceled already.
@@ -211,16 +210,14 @@ void WebPaymentCoordinatorProxy::cancelPaymentSession()
     if (!canCancel())
         return;
 
-    hidePaymentUI();
     didCancelPaymentSession();
 }
 
 void WebPaymentCoordinatorProxy::didCancelPaymentSession()
 {
     ASSERT(canCancel());
-
     send(Messages::WebPaymentCoordinator::DidCancelPaymentSession());
-
+    hidePaymentUI();
     didReachFinalState();
 }
 
@@ -242,7 +239,8 @@ void WebPaymentCoordinatorProxy::presenterDidFinish(PaymentAuthorizationPresente
 {
     if (!didReachFinalState)
         didCancelPaymentSession();
-    hidePaymentUI();
+    else
+        hidePaymentUI();
 }
 
 void WebPaymentCoordinatorProxy::presenterDidSelectShippingMethod(PaymentAuthorizationPresenter&, const WebCore::ApplePaySessionPaymentRequest::ShippingMethod& shippingMethod)
@@ -335,6 +333,7 @@ bool WebPaymentCoordinatorProxy::canAbort() const
 
 void WebPaymentCoordinatorProxy::didReachFinalState()
 {
+    m_destinationID = WTF::nullopt;
     m_state = State::Idle;
     m_merchantValidationState = MerchantValidationState::Idle;
 
index 21f9698..84d3ec7 100644 (file)
 
 namespace IPC {
 class Connection;
-class MessageReceiverMap;
+}
+
+namespace PAL {
+class SessionID;
 }
 
 namespace WebCore {
@@ -72,13 +75,13 @@ public:
         virtual ~Client() = default;
 
         virtual IPC::Connection* paymentCoordinatorConnection(const WebPaymentCoordinatorProxy&) = 0;
-        virtual IPC::MessageReceiverMap& paymentCoordinatorMessageReceiver(const WebPaymentCoordinatorProxy&) = 0;
-        virtual const String& paymentCoordinatorSourceApplicationBundleIdentifier(const WebPaymentCoordinatorProxy&) = 0;
-        virtual const String& paymentCoordinatorSourceApplicationSecondaryIdentifier(const WebPaymentCoordinatorProxy&) = 0;
-        virtual uint64_t paymentCoordinatorDestinationID(const WebPaymentCoordinatorProxy&) = 0;
+        virtual const String& paymentCoordinatorSourceApplicationBundleIdentifier(const WebPaymentCoordinatorProxy&, PAL::SessionID) = 0;
+        virtual const String& paymentCoordinatorSourceApplicationSecondaryIdentifier(const WebPaymentCoordinatorProxy&, PAL::SessionID) = 0;
+        virtual void paymentCoordinatorAddMessageReceiver(WebPaymentCoordinatorProxy&, const IPC::StringReference&, IPC::MessageReceiver&) = 0;
+        virtual void paymentCoordinatorRemoveMessageReceiver(WebPaymentCoordinatorProxy&, const IPC::StringReference&) = 0;
 #if PLATFORM(IOS_FAMILY)
         virtual UIViewController *paymentCoordinatorPresentingViewController(const WebPaymentCoordinatorProxy&) = 0;
-        virtual const String& paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&) = 0;
+        virtual const String& paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&, PAL::SessionID) = 0;
         virtual std::unique_ptr<PaymentAuthorizationPresenter> paymentCoordinatorAuthorizationPresenter(WebPaymentCoordinatorProxy&, PKPaymentRequest *) = 0;
 #endif
 #if PLATFORM(MAC)
@@ -86,12 +89,10 @@ public:
 #endif
     };
 
+    friend class NetworkConnectionToWebProcess;
     explicit WebPaymentCoordinatorProxy(Client&);
     ~WebPaymentCoordinatorProxy();
 
-    void didCancelPaymentSession();
-    void hidePaymentUI();
-
 private:
     // IPC::MessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
@@ -112,9 +113,9 @@ private:
     // Message handlers
     void availablePaymentNetworks(CompletionHandler<void(Vector<String>&&)>&&);
     void canMakePayments(CompletionHandler<void(bool)>&&);
-    void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&);
+    void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, PAL::SessionID, CompletionHandler<void(bool)>&&);
     void openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&);
-    void showPaymentUI(const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest&, CompletionHandler<void(bool)>&&);
+    void showPaymentUI(uint64_t destinationID, PAL::SessionID, const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest&, CompletionHandler<void(bool)>&&);
     void completeMerchantValidation(const WebCore::PaymentMerchantSession&);
     void completeShippingMethodSelection(const Optional<WebCore::ShippingMethodUpdate>&);
     void completeShippingContactSelection(const Optional<WebCore::ShippingContactUpdate>&);
@@ -128,23 +129,26 @@ private:
     bool canCompletePayment() const;
     bool canAbort() const;
 
+    void didCancelPaymentSession();
     void didReachFinalState();
+    void hidePaymentUI();
 
     Vector<String> platformAvailablePaymentNetworks();
     bool platformCanMakePayments();
-    void platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void(bool)>&& completionHandler);
+    void platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, PAL::SessionID, WTF::Function<void(bool)>&& completionHandler);
     void platformOpenPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void(bool)>&& completionHandler);
-    void platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest&, CompletionHandler<void(bool)>&&);
+    void platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLs, PAL::SessionID, const WebCore::ApplePaySessionPaymentRequest&, CompletionHandler<void(bool)>&&);
     void platformCompleteMerchantValidation(const WebCore::PaymentMerchantSession&);
     void platformCompleteShippingMethodSelection(const Optional<WebCore::ShippingMethodUpdate>&);
     void platformCompleteShippingContactSelection(const Optional<WebCore::ShippingContactUpdate>&);
     void platformCompletePaymentMethodSelection(const Optional<WebCore::PaymentMethodUpdate>&);
     void platformCompletePaymentSession(const Optional<WebCore::PaymentAuthorizationResult>&);
 #if PLATFORM(COCOA)
-    RetainPtr<PKPaymentRequest> platformPaymentRequest(const URL& originatingURL, const Vector<URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest&);
+    RetainPtr<PKPaymentRequest> platformPaymentRequest(const URL& originatingURL, const Vector<URL>& linkIconURLs, PAL::SessionID, const WebCore::ApplePaySessionPaymentRequest&);
 #endif
 
     Client& m_client;
+    Optional<uint64_t> m_destinationID;
 
     enum class State {
         // Idle - Nothing's happening.
index d108d27..6c7e0fd 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2018 Apple Inc. All rights reserved.
+# Copyright (C) 2015-2019 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -28,10 +28,10 @@ messages -> WebPaymentCoordinatorProxy {
 
     AvailablePaymentNetworks() -> (Vector<String> availablePaymentNetworks) Delayed
     CanMakePayments() -> (bool result) Delayed
-    CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName) -> (bool canMakePayments) Async
+    CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName, PAL::SessionID sessionID) -> (bool canMakePayments) Async
     OpenPaymentSetup(String merchantIdentifier, String domainName) -> (bool result) Async
 
-    ShowPaymentUI(String originatingURLString, Vector<String> linkIconURLStrings, WebCore::ApplePaySessionPaymentRequest paymentRequest) -> (bool result) Delayed
+    ShowPaymentUI(uint64_t destinationID, PAL::SessionID sessionID, String originatingURLString, Vector<String> linkIconURLStrings, WebCore::ApplePaySessionPaymentRequest paymentRequest) -> (bool result) Delayed
     CompleteMerchantValidation(WebCore::PaymentMerchantSession paymentMerchantSession)
     CompleteShippingMethodSelection(Optional<WebCore::ShippingMethodUpdate> update)
     CompleteShippingContactSelection(Optional<WebCore::ShippingContactUpdate> update)
index 8500950..73ed51a 100644 (file)
@@ -57,10 +57,10 @@ bool WebPaymentCoordinatorProxy::platformCanMakePayments()
     return [PAL::getPKPaymentAuthorizationViewControllerClass() canMakePayments];
 }
 
-void WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void(bool)>&& completionHandler)
+void WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, PAL::SessionID sessionID, WTF::Function<void(bool)>&& completionHandler)
 {
 #if HAVE(PASSKIT_GRANULAR_ERRORS)
-    PKCanMakePaymentsWithMerchantIdentifierDomainAndSourceApplication(merchantIdentifier, domainName, m_client.paymentCoordinatorSourceApplicationSecondaryIdentifier(*this), makeBlockPtr([completionHandler = WTFMove(completionHandler)](BOOL canMakePayments, NSError *error) mutable {
+    PKCanMakePaymentsWithMerchantIdentifierDomainAndSourceApplication(merchantIdentifier, domainName, m_client.paymentCoordinatorSourceApplicationSecondaryIdentifier(*this, sessionID), makeBlockPtr([completionHandler = WTFMove(completionHandler)](BOOL canMakePayments, NSError *error) mutable {
         if (error)
             LOG_ERROR("PKCanMakePaymentsWithMerchantIdentifierAndDomain error %@", error);
 
@@ -236,7 +236,7 @@ static PKPaymentRequestAPIType toAPIType(WebCore::ApplePaySessionPaymentRequest:
 }
 #endif
 
-RetainPtr<PKPaymentRequest> WebPaymentCoordinatorProxy::platformPaymentRequest(const URL& originatingURL, const Vector<URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest& paymentRequest)
+RetainPtr<PKPaymentRequest> WebPaymentCoordinatorProxy::platformPaymentRequest(const URL& originatingURL, const Vector<URL>& linkIconURLs, PAL::SessionID sessionID, const WebCore::ApplePaySessionPaymentRequest& paymentRequest)
 {
     auto result = adoptNS([PAL::allocPKPaymentRequestInstance() init]);
 
@@ -300,16 +300,16 @@ RetainPtr<PKPaymentRequest> WebPaymentCoordinatorProxy::platformPaymentRequest(c
 #endif
 
     // FIXME: Instead of using respondsToSelector, this should use a proper #if version check.
-    auto& bundleIdentifier = m_client.paymentCoordinatorSourceApplicationBundleIdentifier(*this);
+    auto& bundleIdentifier = m_client.paymentCoordinatorSourceApplicationBundleIdentifier(*this, sessionID);
     if (!bundleIdentifier.isEmpty() && [result respondsToSelector:@selector(setSourceApplicationBundleIdentifier:)])
         [result setSourceApplicationBundleIdentifier:bundleIdentifier];
 
-    auto& secondaryIdentifier = m_client.paymentCoordinatorSourceApplicationSecondaryIdentifier(*this);
+    auto& secondaryIdentifier = m_client.paymentCoordinatorSourceApplicationSecondaryIdentifier(*this, sessionID);
     if (!secondaryIdentifier.isEmpty() && [result respondsToSelector:@selector(setSourceApplicationSecondaryIdentifier:)])
         [result setSourceApplicationSecondaryIdentifier:secondaryIdentifier];
 
 #if PLATFORM(IOS_FAMILY)
-    auto& serviceType = m_client.paymentCoordinatorCTDataConnectionServiceType(*this);
+    auto& serviceType = m_client.paymentCoordinatorCTDataConnectionServiceType(*this, sessionID);
     if (!serviceType.isEmpty() && [result respondsToSelector:@selector(setCTDataConnectionServiceType:)])
         [result setCTDataConnectionServiceType:serviceType];
 #endif
index 70d5444..51a368e 100644 (file)
@@ -38,9 +38,9 @@
 
 namespace WebKit {
 
-void WebPaymentCoordinatorProxy::platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
+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, request);
+    auto paymentRequest = platformPaymentRequest(originatingURL, linkIconURLStrings, sessionID, request);
 
     ASSERT(!m_authorizationPresenter);
     m_authorizationPresenter = m_client.paymentCoordinatorAuthorizationPresenter(*this, paymentRequest.get());
@@ -52,7 +52,8 @@ void WebPaymentCoordinatorProxy::platformShowPaymentUI(const URL& originatingURL
 
 void WebPaymentCoordinatorProxy::hidePaymentUI()
 {
-    m_authorizationPresenter->dismiss();
+    if (m_authorizationPresenter)
+        m_authorizationPresenter->dismiss();
     m_authorizationPresenter = nullptr;
 }
 
index 6ccf9c3..80fc12c 100644 (file)
@@ -35,9 +35,9 @@
 
 namespace WebKit {
 
-void WebPaymentCoordinatorProxy::platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
+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, request);
+    auto paymentRequest = platformPaymentRequest(originatingURL, linkIconURLStrings, sessionID, request);
 
     auto showPaymentUIRequestSeed = m_showPaymentUIRequestSeed;
     auto weakThis = makeWeakPtr(*this);
@@ -97,7 +97,9 @@ void WebPaymentCoordinatorProxy::hidePaymentUI()
     m_sheetWindowWillCloseObserver = nullptr;
 
     [[m_sheetWindow sheetParent] endSheet:m_sheetWindow.get()];
-    m_authorizationPresenter->dismiss();
+
+    if (m_authorizationPresenter)
+        m_authorizationPresenter->dismiss();
     m_authorizationPresenter = nullptr;
 
     m_sheetWindow = nullptr;
index 8cfc15b..33afc79 100644 (file)
@@ -1580,6 +1580,14 @@ ReferrerPolicyAttributeEnabled:
   category: experimental
   webcoreBinding: RuntimeEnabledFeatures
 
+ApplePayRemoteUIEnabled:
+  category: internal
+  condition: ENABLE(APPLE_PAY_REMOTE_UI)
+  defaultValue: true
+  humanReadableDescription: "Enable Apple Pay Remote UI"
+  humanReadableName: "Apple Pay Remote UI"
+  type: bool
+
 # Deprecated
 
 ICECandidateFilteringEnabled:
index ca8ef8f..bc4a6cd 100644 (file)
@@ -43,6 +43,7 @@ NetworkProcess/Downloads/cocoa/DownloadCocoa.mm
 NetworkProcess/EntryPoint/Cocoa/Daemon/DaemonEntryPoint.mm
 NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkServiceEntryPoint.mm
 
+NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm
 NetworkProcess/ios/NetworkProcessIOS.mm
 
 NetworkProcess/mac/NetworkProcessMac.mm
@@ -75,6 +76,7 @@ Platform/cocoa/WebKitAdditions.mm @no-unify
 Platform/foundation/LoggingFoundation.mm
 
 Platform/ios/AccessibilityIOS.mm
+Platform/ios/PaymentAuthorizationController.mm
 
 Platform/IPC/mac/ConnectionMac.mm
 Platform/IPC/mac/MachMessage.cpp
index d9df7f2..9893d39 100644 (file)
@@ -86,8 +86,6 @@ public:
 
     void setProcessSuppressionEnabled(bool);
 
-    IPC::MessageReceiverMap& messageReceiverMap() { return m_messageReceiverMap; }
-
 protected:
     // ProcessLauncher::Client
     void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
index 2010f65..1ec9a2e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -35,6 +35,7 @@
 #import "SafeBrowsingWarning.h"
 #import "WebPageMessages.h"
 #import "WebProcessProxy.h"
+#import "WebsiteDataStore.h"
 #import <WebCore/DragItem.h>
 #import <WebCore/NotImplemented.h>
 #import <WebCore/SearchPopupMenuCocoa.h>
@@ -206,5 +207,36 @@ void WebPageProxy::performDictionaryLookupOfCurrentSelection()
     
     process().send(Messages::WebPage::PerformDictionaryLookupOfCurrentSelection(), m_pageID);
 }
+    
+#if ENABLE(APPLE_PAY)
+
+IPC::Connection* WebPageProxy::paymentCoordinatorConnection(const WebPaymentCoordinatorProxy&)
+{
+    return messageSenderConnection();
+}
+
+const String& WebPageProxy::paymentCoordinatorSourceApplicationBundleIdentifier(const WebPaymentCoordinatorProxy&, PAL::SessionID sessionID)
+{
+    ASSERT_UNUSED(sessionID, sessionID == websiteDataStore().sessionID());
+    return websiteDataStore().sourceApplicationBundleIdentifier();
+}
+
+const String& WebPageProxy::paymentCoordinatorSourceApplicationSecondaryIdentifier(const WebPaymentCoordinatorProxy&, PAL::SessionID sessionID)
+{
+    ASSERT_UNUSED(sessionID, sessionID == websiteDataStore().sessionID());
+    return websiteDataStore().sourceApplicationSecondaryIdentifier();
+}
+
+void WebPageProxy::paymentCoordinatorAddMessageReceiver(WebPaymentCoordinatorProxy&, const IPC::StringReference& messageReceiverName, IPC::MessageReceiver& messageReceiver)
+{
+    process().addMessageReceiver(messageReceiverName, m_pageID, messageReceiver);
+}
+
+void WebPageProxy::paymentCoordinatorRemoveMessageReceiver(WebPaymentCoordinatorProxy&, const IPC::StringReference& messageReceiverName)
+{
+    process().removeMessageReceiver(messageReceiverName, m_pageID);
+}
+
+#endif
 
 } // namespace WebKit
index 92ea590..48f0f39 100644 (file)
@@ -8767,35 +8767,6 @@ void WebPageProxy::clearAdClickAttribution(CompletionHandler<void()>&& completio
     m_process->processPool().clearAdClickAttribution(m_websiteDataStore->sessionID(), WTFMove(completionHandler));
 }
 
-#if ENABLE(APPLE_PAY)
-
-IPC::Connection* WebPageProxy::paymentCoordinatorConnection(const WebPaymentCoordinatorProxy&)
-{
-    return messageSenderConnection();
-}
-
-IPC::MessageReceiverMap& WebPageProxy::paymentCoordinatorMessageReceiver(const WebPaymentCoordinatorProxy&)
-{
-    return process().messageReceiverMap();
-}
-
-const String& WebPageProxy::paymentCoordinatorSourceApplicationBundleIdentifier(const WebPaymentCoordinatorProxy&)
-{
-    return websiteDataStore().sourceApplicationBundleIdentifier();
-}
-
-const String& WebPageProxy::paymentCoordinatorSourceApplicationSecondaryIdentifier(const WebPaymentCoordinatorProxy&)
-{
-    return websiteDataStore().sourceApplicationSecondaryIdentifier();
-}
-
-uint64_t WebPageProxy::paymentCoordinatorDestinationID(const WebPaymentCoordinatorProxy&)
-{
-    return messageSenderDestinationID();
-}
-
-#endif
-
 void WebPageProxy::addObserver(WebViewDidMoveToWindowObserver& observer)
 {
     auto result = m_webViewDidMoveToWindowObservers.add(&observer, makeWeakPtr(observer));
index c43b6b3..5519eb0 100644 (file)
@@ -1986,14 +1986,14 @@ private:
     // WebPaymentCoordinatorProxy::Client
 #if ENABLE(APPLE_PAY)
     IPC::Connection* paymentCoordinatorConnection(const WebPaymentCoordinatorProxy&) final;
-    IPC::MessageReceiverMap& paymentCoordinatorMessageReceiver(const WebPaymentCoordinatorProxy&) final;
-    const String& paymentCoordinatorSourceApplicationBundleIdentifier(const WebPaymentCoordinatorProxy&) final;
-    const String& paymentCoordinatorSourceApplicationSecondaryIdentifier(const WebPaymentCoordinatorProxy&) final;
-    uint64_t paymentCoordinatorDestinationID(const WebPaymentCoordinatorProxy&) final;
+    const String& paymentCoordinatorSourceApplicationBundleIdentifier(const WebPaymentCoordinatorProxy&, PAL::SessionID) final;
+    const String& paymentCoordinatorSourceApplicationSecondaryIdentifier(const WebPaymentCoordinatorProxy&, PAL::SessionID) final;
+    void paymentCoordinatorAddMessageReceiver(WebPaymentCoordinatorProxy&, const IPC::StringReference&, IPC::MessageReceiver&) final;
+    void paymentCoordinatorRemoveMessageReceiver(WebPaymentCoordinatorProxy&, const IPC::StringReference&) final;
 #endif
 #if ENABLE(APPLE_PAY) && PLATFORM(IOS_FAMILY)
     UIViewController *paymentCoordinatorPresentingViewController(const WebPaymentCoordinatorProxy&) final;
-    const String& paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&) final;
+    const String& paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&, PAL::SessionID) final;
     std::unique_ptr<PaymentAuthorizationPresenter> paymentCoordinatorAuthorizationPresenter(WebPaymentCoordinatorProxy&, PKPaymentRequest *) final;
 #endif
 #if ENABLE(APPLE_PAY) && PLATFORM(MAC)
index 501c727..98553ad 100644 (file)
@@ -1190,8 +1190,9 @@ UIViewController *WebPageProxy::paymentCoordinatorPresentingViewController(const
     return uiClient().presentingViewController();
 }
 
-const String& WebPageProxy::paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&)
+const String& WebPageProxy::paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&, PAL::SessionID sessionID)
 {
+    ASSERT_UNUSED(sessionID, sessionID == websiteDataStore().sessionID());
     return process().processPool().configuration().ctDataConnectionServiceType();
 }
 
index bde9cab..d308ef4 100644 (file)
                A1798B43222D98DF000764BD /* PaymentAuthorizationViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = A1798B3F222D98B6000764BD /* PaymentAuthorizationViewController.h */; };
                A1798B49222E531D000764BD /* WKPaymentAuthorizationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A1798B47222E530A000764BD /* WKPaymentAuthorizationDelegate.h */; };
                A1798B4C222F1BD4000764BD /* WebPaymentCoordinatorProxyCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = A1798B4B222F1BD4000764BD /* WebPaymentCoordinatorProxyCocoa.h */; };
+               A1798B512230A10E000764BD /* PaymentAuthorizationController.h in Headers */ = {isa = PBXBuildFile; fileRef = A1798B4F2230A0FE000764BD /* PaymentAuthorizationController.h */; };
                A181A79821ACC74B0059A316 /* WebKitAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = A181A79721ACAC610059A316 /* WebKitAdditions.mm */; };
                A182D5B51BE6BD250087A7CC /* AccessibilityIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A182D5B31BE6BD250087A7CC /* AccessibilityIOS.h */; };
                A19DD3C01D07D16800AC823B /* _WKWebViewPrintFormatterInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A19DD3BF1D07D16800AC823B /* _WKWebViewPrintFormatterInternal.h */; };
                A1798B48222E530A000764BD /* WKPaymentAuthorizationDelegate.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPaymentAuthorizationDelegate.mm; sourceTree = "<group>"; };
                A1798B4A222F133A000764BD /* PaymentAuthorizationPresenter.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PaymentAuthorizationPresenter.mm; sourceTree = "<group>"; };
                A1798B4B222F1BD4000764BD /* WebPaymentCoordinatorProxyCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebPaymentCoordinatorProxyCocoa.h; sourceTree = "<group>"; };
+               A1798B4F2230A0FE000764BD /* PaymentAuthorizationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaymentAuthorizationController.h; sourceTree = "<group>"; };
+               A1798B502230A0FE000764BD /* PaymentAuthorizationController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PaymentAuthorizationController.mm; sourceTree = "<group>"; };
+               A1798B5722332203000764BD /* NetworkConnectionToWebProcessIOS.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkConnectionToWebProcessIOS.mm; sourceTree = "<group>"; };
                A181A79721ACAC610059A316 /* WebKitAdditions.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitAdditions.mm; sourceTree = "<group>"; };
                A182D5B21BE6BD250087A7CC /* AccessibilityIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityIOS.mm; sourceTree = "<group>"; };
                A182D5B31BE6BD250087A7CC /* AccessibilityIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityIOS.h; sourceTree = "<group>"; };
                2DA944BB188511DD00ED86DB /* ios */ = {
                        isa = PBXGroup;
                        children = (
+                               A1798B5722332203000764BD /* NetworkConnectionToWebProcessIOS.mm */,
                                2DA944BC188511E700ED86DB /* NetworkProcessIOS.mm */,
                        );
                        path = ios;
                        children = (
                                A182D5B31BE6BD250087A7CC /* AccessibilityIOS.h */,
                                A182D5B21BE6BD250087A7CC /* AccessibilityIOS.mm */,
+                               A1798B4F2230A0FE000764BD /* PaymentAuthorizationController.h */,
+                               A1798B502230A0FE000764BD /* PaymentAuthorizationController.mm */,
                        );
                        path = ios;
                        sourceTree = "<group>";
                                1AC7537C183A9FDB0072CB15 /* PageLoadState.h in Headers */,
                                1A8B66B01BC43C860082DF77 /* PageLoadStateObserver.h in Headers */,
                                C574A58112E66681002DFE98 /* PasteboardTypes.h in Headers */,
+                               A1798B512230A10E000764BD /* PaymentAuthorizationController.h in Headers */,
                                A1798B3E222D97A2000764BD /* PaymentAuthorizationPresenter.h in Headers */,
                                A1798B43222D98DF000764BD /* PaymentAuthorizationViewController.h in Headers */,
                                C1E123BA20A11573002646F4 /* PDFContextMenu.h in Headers */,
                                                CreatedOnToolsVersion = 10.1;
                                                ProvisioningStyle = Automatic;
                                        };
+                                       A1798B59223464C4000764BD = {
+                                               CreatedOnToolsVersion = 10.2;
+                                       };
                                        E1AC2E2720F7B94C00B0897D = {
                                                CreatedOnToolsVersion = 9.3;
                                                ProvisioningStyle = Automatic;
index 501cd53..b4aece9 100644 (file)
@@ -51,6 +51,14 @@ WebPaymentCoordinator::~WebPaymentCoordinator()
     WebProcess::singleton().removeMessageReceiver(*this);
 }
 
+void WebPaymentCoordinator::networkProcessConnectionClosed()
+{
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    if (remoteUIEnabled())
+        didCancelPaymentSession();
+#endif
+}
+
 const WebPaymentCoordinator::AvailablePaymentNetworksSet& WebPaymentCoordinator::availablePaymentNetworks()
 {
     if (m_availablePaymentNetworks)
@@ -60,7 +68,7 @@ const WebPaymentCoordinator::AvailablePaymentNetworksSet& WebPaymentCoordinator:
 
     Vector<String> availablePaymentNetworks;
     using AvailablePaymentNetworksMessage = Messages::WebPaymentCoordinatorProxy::AvailablePaymentNetworks;
-    if (m_webPage.sendSync(AvailablePaymentNetworksMessage(), AvailablePaymentNetworksMessage::Reply(availablePaymentNetworks))) {
+    if (sendSync(AvailablePaymentNetworksMessage(), AvailablePaymentNetworksMessage::Reply(availablePaymentNetworks))) {
         for (auto& network : availablePaymentNetworks)
             m_availablePaymentNetworks->add(network);
     }
@@ -80,7 +88,7 @@ Optional<String> WebPaymentCoordinator::validatedPaymentNetwork(const String& pa
 bool WebPaymentCoordinator::canMakePayments()
 {
     bool canMakePayments;
-    if (!m_webPage.sendSync(Messages::WebPaymentCoordinatorProxy::CanMakePayments(), Messages::WebPaymentCoordinatorProxy::CanMakePayments::Reply(canMakePayments)))
+    if (!sendSync(Messages::WebPaymentCoordinatorProxy::CanMakePayments(), Messages::WebPaymentCoordinatorProxy::CanMakePayments::Reply(canMakePayments)))
         return false;
 
     return canMakePayments;
@@ -88,12 +96,12 @@ bool WebPaymentCoordinator::canMakePayments()
 
 void WebPaymentCoordinator::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler)
 {
-    m_webPage.sendWithAsyncReply(Messages::WebPaymentCoordinatorProxy::CanMakePaymentsWithActiveCard(merchantIdentifier, domainName), WTFMove(completionHandler));
+    sendWithAsyncReply(Messages::WebPaymentCoordinatorProxy::CanMakePaymentsWithActiveCard(merchantIdentifier, domainName, m_webPage.sessionID()), WTFMove(completionHandler));
 }
 
 void WebPaymentCoordinator::openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&& completionHandler)
 {
-    m_webPage.sendWithAsyncReply(Messages::WebPaymentCoordinatorProxy::OpenPaymentSetup(merchantIdentifier, domainName), WTFMove(completionHandler));
+    sendWithAsyncReply(Messages::WebPaymentCoordinatorProxy::OpenPaymentSetup(merchantIdentifier, domainName), WTFMove(completionHandler));
 }
 
 bool WebPaymentCoordinator::showPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest& paymentRequest)
@@ -103,7 +111,7 @@ bool WebPaymentCoordinator::showPaymentUI(const URL& originatingURL, const Vecto
         linkIconURLStrings.append(linkIconURL.string());
 
     bool result;
-    if (!m_webPage.sendSync(Messages::WebPaymentCoordinatorProxy::ShowPaymentUI(originatingURL.string(), linkIconURLStrings, paymentRequest), Messages::WebPaymentCoordinatorProxy::ShowPaymentUI::Reply(result)))
+    if (!sendSync(Messages::WebPaymentCoordinatorProxy::ShowPaymentUI(m_webPage.pageID(), m_webPage.sessionID(), originatingURL.string(), linkIconURLStrings, paymentRequest), Messages::WebPaymentCoordinatorProxy::ShowPaymentUI::Reply(result)))
         return false;
 
     return result;
@@ -111,37 +119,37 @@ bool WebPaymentCoordinator::showPaymentUI(const URL& originatingURL, const Vecto
 
 void WebPaymentCoordinator::completeMerchantValidation(const WebCore::PaymentMerchantSession& paymentMerchantSession)
 {
-    m_webPage.send(Messages::WebPaymentCoordinatorProxy::CompleteMerchantValidation(paymentMerchantSession));
+    send(Messages::WebPaymentCoordinatorProxy::CompleteMerchantValidation(paymentMerchantSession));
 }
 
 void WebPaymentCoordinator::completeShippingMethodSelection(Optional<WebCore::ShippingMethodUpdate>&& update)
 {
-    m_webPage.send(Messages::WebPaymentCoordinatorProxy::CompleteShippingMethodSelection(update));
+    send(Messages::WebPaymentCoordinatorProxy::CompleteShippingMethodSelection(update));
 }
 
 void WebPaymentCoordinator::completeShippingContactSelection(Optional<WebCore::ShippingContactUpdate>&& update)
 {
-    m_webPage.send(Messages::WebPaymentCoordinatorProxy::CompleteShippingContactSelection(update));
+    send(Messages::WebPaymentCoordinatorProxy::CompleteShippingContactSelection(update));
 }
 
 void WebPaymentCoordinator::completePaymentMethodSelection(Optional<WebCore::PaymentMethodUpdate>&& update)
 {
-    m_webPage.send(Messages::WebPaymentCoordinatorProxy::CompletePaymentMethodSelection(update));
+    send(Messages::WebPaymentCoordinatorProxy::CompletePaymentMethodSelection(update));
 }
 
 void WebPaymentCoordinator::completePaymentSession(Optional<WebCore::PaymentAuthorizationResult>&& result)
 {
-    m_webPage.send(Messages::WebPaymentCoordinatorProxy::CompletePaymentSession(result));
+    send(Messages::WebPaymentCoordinatorProxy::CompletePaymentSession(result));
 }
 
 void WebPaymentCoordinator::abortPaymentSession()
 {
-    m_webPage.send(Messages::WebPaymentCoordinatorProxy::AbortPaymentSession());
+    send(Messages::WebPaymentCoordinatorProxy::AbortPaymentSession());
 }
 
 void WebPaymentCoordinator::cancelPaymentSession()
 {
-    m_webPage.send(Messages::WebPaymentCoordinatorProxy::CancelPaymentSession());
+    send(Messages::WebPaymentCoordinatorProxy::CancelPaymentSession());
 }
 
 void WebPaymentCoordinator::paymentCoordinatorDestroyed()
@@ -149,6 +157,20 @@ void WebPaymentCoordinator::paymentCoordinatorDestroyed()
     delete this;
 }
 
+IPC::Connection* WebPaymentCoordinator::messageSenderConnection() const
+{
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    if (remoteUIEnabled())
+        return &WebProcess::singleton().ensureNetworkProcessConnection().connection();
+#endif
+    return WebProcess::singleton().parentProcessConnection();
+}
+
+uint64_t WebPaymentCoordinator::messageSenderDestinationID() const
+{
+    return m_webPage.pageID();
+}
+
 void WebPaymentCoordinator::validateMerchant(const String& validationURLString)
 {
     paymentCoordinator().validateMerchant(URL(URL(), validationURLString));
@@ -184,6 +206,15 @@ WebCore::PaymentCoordinator& WebPaymentCoordinator::paymentCoordinator()
     return m_webPage.corePage()->paymentCoordinator();
 }
 
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+bool WebPaymentCoordinator::remoteUIEnabled() const
+{
+    if (auto page = m_webPage.corePage())
+        return page->settings().applePayRemoteUIEnabled();
+    return false;
+}
+#endif
+
 }
 
 #endif
index 6e9a458..85b2b1a 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(APPLE_PAY)
 
 #include "MessageReceiver.h"
+#include "MessageSender.h"
 #include <WebCore/PaymentCoordinatorClient.h>
 #include <WebCore/PaymentHeaders.h>
 #include <wtf/Forward.h>
@@ -46,13 +47,17 @@ class PaymentContact;
 
 namespace WebKit {
 
+class NetworkProcessConnection;
 class WebPage;
 
-class WebPaymentCoordinator final : public WebCore::PaymentCoordinatorClient, private IPC::MessageReceiver {
+class WebPaymentCoordinator final : public WebCore::PaymentCoordinatorClient, private IPC::MessageReceiver, private IPC::MessageSender {
 public:
+    friend class NetworkProcessConnection;
     explicit WebPaymentCoordinator(WebPage&);
     ~WebPaymentCoordinator();
 
+    void networkProcessConnectionClosed();
+
 private:
     // WebCore::PaymentCoordinatorClient.
     Optional<String> validatedPaymentNetwork(const String&) override;
@@ -71,8 +76,14 @@ private:
 
     void paymentCoordinatorDestroyed() override;
 
+    bool isWebPaymentCoordinator() const override { return true; }
+
     // IPC::MessageReceiver.
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
+    
+    // IPC::MessageSender.
+    IPC::Connection* messageSenderConnection() const final;
+    uint64_t messageSenderDestinationID() const final;
 
     // Message handlers.
     void validateMerchant(const String& validationURLString);
@@ -83,7 +94,11 @@ private:
     void didCancelPaymentSession();
 
     WebCore::PaymentCoordinator& paymentCoordinator();
-    
+
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    bool remoteUIEnabled() const;
+#endif
+
     using AvailablePaymentNetworksSet = HashSet<String, ASCIICaseInsensitiveHash>;
     const AvailablePaymentNetworksSet& availablePaymentNetworks();
 
@@ -96,5 +111,10 @@ private:
 #endif
 };
 
-}
+} // namespace WebKit
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebKit::WebPaymentCoordinator)
+static bool isType(const WebCore::PaymentCoordinatorClient& paymentCoordinatorClient) { return paymentCoordinatorClient.isWebPaymentCoordinator(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif
index c4744a2..5ea3cd2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,6 +39,7 @@
 #include "WebMDNSRegisterMessages.h"
 #include "WebPage.h"
 #include "WebPageMessages.h"
+#include "WebPaymentCoordinator.h"
 #include "WebProcess.h"
 #include "WebRTCMonitor.h"
 #include "WebRTCMonitorMessages.h"
 #include <WebCore/SharedBuffer.h>
 #include <pal/SessionID.h>
 
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+#include "WebPaymentCoordinatorMessages.h"
+#endif
+
 namespace WebKit {
 using namespace WebCore;
 
@@ -141,6 +146,14 @@ void NetworkProcessConnection::didReceiveMessage(IPC::Connection& connection, IP
     }
 #endif
 
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    if (decoder.messageReceiverName() == Messages::WebPaymentCoordinator::messageReceiverName()) {
+        if (auto webPage = WebProcess::singleton().webPage(decoder.destinationID()))
+            webPage->paymentCoordinator()->didReceiveMessage(connection, decoder);
+        return;
+    }
+#endif
+
     didReceiveNetworkProcessConnectionMessage(connection, decoder);
 }
 
@@ -155,6 +168,14 @@ void NetworkProcessConnection::didReceiveSyncMessage(IPC::Connection& connection
     }
 #endif
 
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    if (decoder.messageReceiverName() == Messages::WebPaymentCoordinator::messageReceiverName()) {
+        if (auto webPage = WebProcess::singleton().webPage(decoder.destinationID()))
+            webPage->paymentCoordinator()->didReceiveSyncMessage(connection, decoder, replyEncoder);
+        return;
+    }
+#endif
+
     ASSERT_NOT_REACHED();
 }
 
index 163c5ca..d630670 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,6 +30,7 @@
 #import "LoadParameters.h"
 #import "PluginView.h"
 #import "WebPageProxyMessages.h"
+#import "WebPaymentCoordinator.h"
 #import <WebCore/DictionaryLookup.h>
 #import <WebCore/Editor.h>
 #import <WebCore/EventHandler.h>
@@ -37,6 +38,7 @@
 #import <WebCore/HTMLConverter.h>
 #import <WebCore/HitTestResult.h>
 #import <WebCore/NodeRenderStyle.h>
+#import <WebCore/PaymentCoordinator.h>
 #import <WebCore/PlatformMediaSessionManager.h>
 #import <WebCore/RenderElement.h>
 #import <WebCore/RenderObject.h>
@@ -189,6 +191,16 @@ void WebPage::accessibilityTransferRemoteToken(RetainPtr<NSData> remoteToken)
     send(Messages::WebPageProxy::RegisterWebProcessAccessibilityToken(dataToken));
 }
 
+#if ENABLE(APPLE_PAY)
+WebPaymentCoordinator* WebPage::paymentCoordinator()
+{
+    if (!m_page)
+        return nullptr;
+    auto& client = m_page->paymentCoordinator().client();
+    return is<WebPaymentCoordinator>(client) ? downcast<WebPaymentCoordinator>(&client) : nullptr;
+}
+#endif
+
 } // namespace WebKit
 
 #endif // PLATFORM(COCOA)
index 454f8f2..2f8eca7 100644 (file)
@@ -232,6 +232,7 @@ class WebOpenPanelResultListener;
 class WebPageGroupProxy;
 class WebPageInspectorTargetController;
 class WebPageOverlay;
+class WebPaymentCoordinator;
 class WebPopupMenu;
 class WebTouchEvent;
 class WebURLSchemeHandlerProxy;
@@ -1160,6 +1161,10 @@ public:
     void suspendAllMediaBuffering();
     void resumeAllMediaBuffering();
 
+#if ENABLE(APPLE_PAY)
+    WebPaymentCoordinator* paymentCoordinator();
+#endif
+
 private:
     WebPage(uint64_t pageID, WebPageCreationParameters&&);
 
index d6520d1..c1e44f1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2009-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -57,6 +57,7 @@
 #include "WebMessagePortChannelProvider.h"
 #include "WebPage.h"
 #include "WebPageGroupProxy.h"
+#include "WebPaymentCoordinator.h"
 #include "WebPlatformStrategies.h"
 #include "WebPluginInfoProvider.h"
 #include "WebProcessCreationParameters.h"
@@ -1286,8 +1287,13 @@ void WebProcess::networkProcessConnectionClosed(NetworkProcessConnection* connec
     m_webLoaderStrategy.networkProcessCrashed();
     WebSocketStream::networkProcessCrashed();
 
-    for (auto& page : m_pageMap.values())
+    for (auto& page : m_pageMap.values()) {
         page->stopAllURLSchemeTasks();
+#if ENABLE(APPLE_PAY)
+        if (auto paymentCoordinator = page->paymentCoordinator())
+            paymentCoordinator->networkProcessConnectionClosed();
+#endif
+    }
 }
 
 WebLoaderStrategy& WebProcess::webLoaderStrategy()