Title: [283320] trunk/Source
Revision
283320
Author
commit-qu...@webkit.org
Date
2021-09-30 10:48:19 -0700 (Thu, 30 Sep 2021)

Log Message

Adopt presentationSceneIdentifierForPaymentAuthorizationController delegate call from PassKit
https://bugs.webkit.org/show_bug.cgi?id=230874

Patch by Eddy Wong <eddy_w...@apple.com> on 2021-09-30
Reviewed by Devin Rousso.

Source/WebKit:

* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm:
(WebKit::NetworkConnectionToWebProcess::getWindowSceneIdentifierForPaymentPresentation): Implements getWindowSceneIdentifierForPaymentPresentation() by asking parent process (UIProcess) for scene ID via new XPC message.
* Platform/cocoa/PaymentAuthorizationPresenter.h:
(WebKit::PaymentAuthorizationPresenter::sceneIdentifier const): Holds temporarily the scene ID we'd like to use when presenting the payment sheet, to be read by WKPaymentAuthorizationControllerDelegate.
* Platform/cocoa/PaymentAuthorizationViewController.h: Declares presentInScene() which is just for conformance to PaymentAuthorizationPresenter
* Platform/cocoa/PaymentAuthorizationViewController.mm:
(WebKit::PaymentAuthorizationViewController::presentInScene): Provides a dummy implementation for presentInScene() for conformance.
* Platform/cocoa/WKPaymentAuthorizationDelegate.h: Surfaces _presenter for PaymentAuthorizationPresenter's use.
* Platform/cocoa/WKPaymentAuthorizationDelegate.mm: Ditto.
* Platform/ios/PaymentAuthorizationController.h:
* Platform/ios/PaymentAuthorizationController.mm:
(-[WKPaymentAuthorizationControllerDelegate presentationSceneIdentifierForPaymentAuthorizationController:]): Implements the new PassKit delegate call returning the scene ID for the UIProcess.
(WebKit::PaymentAuthorizationController::dismiss): House keeping.
(WebKit::PaymentAuthorizationController::presentInScene): Stores the scene ID from the caller for WKPaymentAuthorizationControllerDelegate to read from.
* Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
(WebKit::WebPaymentCoordinatorProxy::showPaymentUI): Relays webPageProxyID for use by UIProcess ultimately to look up the correct WebPageProxy.
* Shared/ApplePay/WebPaymentCoordinatorProxy.h: Ditto.
* Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in: Ditto.
* Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
(WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Presents payment sheet with scene ID if applicable.
* Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
(WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Signature change.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::getWindowSceneIdentifierForPaymentPresentation): Looks up the correct WebPageProxy and retrieve the scene ID for the caller (NetworkProcess).
* UIProcess/Network/NetworkProcessProxy.h: Ditto.
* UIProcess/Network/NetworkProcessProxy.messages.in: Ditto.
* UIProcess/PageClient.h: Adds ability to retrieve scene ID.
* UIProcess/WebPageProxy.h:
* UIProcess/ios/PageClientImplIOS.h: Ditto.
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::sceneID): Ditto.
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::getWindowSceneIdentifierForPaymentPresentation): Dummy implementation for conformance to WebPageProxy. WebProcess does not talk to UIProcess directly for this function.
* WebProcess/ApplePay/WebPaymentCoordinator.cpp:
(WebKit::WebPaymentCoordinator::showPaymentUI): Passes the WebPageProxyIdentifier along.

Source/WTF:

* wtf/PlatformEnableCocoa.h: Defines new flag ENABLE_APPLE_PAY_REMOTE_UI_USES_SCENE

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (283319 => 283320)


--- trunk/Source/WTF/ChangeLog	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WTF/ChangeLog	2021-09-30 17:48:19 UTC (rev 283320)
@@ -1,3 +1,12 @@
+2021-09-30  Eddy Wong  <eddy_w...@apple.com>
+
+        Adopt presentationSceneIdentifierForPaymentAuthorizationController delegate call from PassKit
+        https://bugs.webkit.org/show_bug.cgi?id=230874
+
+        Reviewed by Devin Rousso.
+
+        * wtf/PlatformEnableCocoa.h: Defines new flag ENABLE_APPLE_PAY_REMOTE_UI_USES_SCENE
+
 2021-09-30  Darin Adler  <da...@apple.com>
 
         Add StdLibExtras.h include to a file that uses bitwise_cast without including it

Modified: trunk/Source/WTF/wtf/PlatformEnableCocoa.h (283319 => 283320)


--- trunk/Source/WTF/wtf/PlatformEnableCocoa.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WTF/wtf/PlatformEnableCocoa.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -83,10 +83,18 @@
 #define ENABLE_APPLE_PAY_RECURRING_LINE_ITEM 1
 #endif
 
-#if !defined(ENABLE_APPLE_PAY_REMOTE_UI) && !PLATFORM(MAC) && !PLATFORM(MACCATALYST) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
+#if !PLATFORM(MAC) && !PLATFORM(MACCATALYST) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
+
+#if !defined(ENABLE_APPLE_PAY_REMOTE_UI)
 #define ENABLE_APPLE_PAY_REMOTE_UI 1
 #endif
 
+#if !defined(ENABLE_APPLE_PAY_REMOTE_UI_USES_SCENE) && HAVE(UIKIT_WEBKIT_INTERNALS)
+#define ENABLE_APPLE_PAY_REMOTE_UI_USES_SCENE 1
+#endif
+
+#endif // !PLATFORM(MAC) && !PLATFORM(MACCATALYST) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
+
 #if !defined(ENABLE_APPLE_PAY_SESSION_V11) && ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140500))
 #define ENABLE_APPLE_PAY_SESSION_V11 1
 #endif

Modified: trunk/Source/WebKit/ChangeLog (283319 => 283320)


--- trunk/Source/WebKit/ChangeLog	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/ChangeLog	2021-09-30 17:48:19 UTC (rev 283320)
@@ -1,3 +1,48 @@
+2021-09-30  Eddy Wong  <eddy_w...@apple.com>
+
+        Adopt presentationSceneIdentifierForPaymentAuthorizationController delegate call from PassKit
+        https://bugs.webkit.org/show_bug.cgi?id=230874
+
+        Reviewed by Devin Rousso.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm:         
+        (WebKit::NetworkConnectionToWebProcess::getWindowSceneIdentifierForPaymentPresentation): Implements getWindowSceneIdentifierForPaymentPresentation() by asking parent process (UIProcess) for scene ID via new XPC message.
+        * Platform/cocoa/PaymentAuthorizationPresenter.h:
+        (WebKit::PaymentAuthorizationPresenter::sceneIdentifier const): Holds temporarily the scene ID we'd like to use when presenting the payment sheet, to be read by WKPaymentAuthorizationControllerDelegate.
+        * Platform/cocoa/PaymentAuthorizationViewController.h: Declares presentInScene() which is just for conformance to PaymentAuthorizationPresenter
+        * Platform/cocoa/PaymentAuthorizationViewController.mm:
+        (WebKit::PaymentAuthorizationViewController::presentInScene): Provides a dummy implementation for presentInScene() for conformance.
+        * Platform/cocoa/WKPaymentAuthorizationDelegate.h: Surfaces _presenter for PaymentAuthorizationPresenter's use.
+        * Platform/cocoa/WKPaymentAuthorizationDelegate.mm: Ditto.
+        * Platform/ios/PaymentAuthorizationController.h:
+        * Platform/ios/PaymentAuthorizationController.mm:
+        (-[WKPaymentAuthorizationControllerDelegate presentationSceneIdentifierForPaymentAuthorizationController:]): Implements the new PassKit delegate call returning the scene ID for the UIProcess.
+        (WebKit::PaymentAuthorizationController::dismiss): House keeping.
+        (WebKit::PaymentAuthorizationController::presentInScene): Stores the scene ID from the caller for WKPaymentAuthorizationControllerDelegate to read from.
+        * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp: 
+        (WebKit::WebPaymentCoordinatorProxy::showPaymentUI): Relays webPageProxyID for use by UIProcess ultimately to look up the correct WebPageProxy.
+        * Shared/ApplePay/WebPaymentCoordinatorProxy.h: Ditto.
+        * Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in: Ditto.
+        * Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Presents payment sheet with scene ID if applicable.
+        * Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI): Signature change.
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::getWindowSceneIdentifierForPaymentPresentation): Looks up the correct WebPageProxy and retrieve the scene ID for the caller (NetworkProcess).
+        * UIProcess/Network/NetworkProcessProxy.h: Ditto.
+        * UIProcess/Network/NetworkProcessProxy.messages.in: Ditto.
+        * UIProcess/PageClient.h: Adds ability to retrieve scene ID.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/PageClientImplIOS.h: Ditto.
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::sceneID): Ditto.
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::getWindowSceneIdentifierForPaymentPresentation): Dummy implementation for conformance to WebPageProxy. WebProcess does not talk to UIProcess directly for this function.
+        * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
+        (WebKit::WebPaymentCoordinator::showPaymentUI): Passes the WebPageProxyIdentifier along.
+
+
 2021-09-30  Jer Noble  <jer.no...@apple.com>
 
         Unreviewed Catalyst build fix; forward-declare in RemoteMediaPlayerProxy.h and include the correct file in RemoteMediaPlayerProxy.cpp.

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (283319 => 283320)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -355,6 +355,9 @@
     // WebPaymentCoordinatorProxy::Client
     IPC::Connection* paymentCoordinatorConnection(const WebPaymentCoordinatorProxy&) final;
     UIViewController *paymentCoordinatorPresentingViewController(const WebPaymentCoordinatorProxy&) final;
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+    void getWindowSceneIdentifierForPaymentPresentation(WebPageProxyIdentifier, CompletionHandler<void(const String&)>&&) final;
+#endif
     const String& paymentCoordinatorBoundInterfaceIdentifier(const WebPaymentCoordinatorProxy&) final;
     const String& paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&) final;
     const String& paymentCoordinatorSourceApplicationBundleIdentifier(const WebPaymentCoordinatorProxy&) final;

Modified: trunk/Source/WebKit/NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm (283319 => 283320)


--- trunk/Source/WebKit/NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm	2021-09-30 17:48:19 UTC (rev 283320)
@@ -25,6 +25,7 @@
 
 #import "config.h"
 #import "NetworkConnectionToWebProcess.h"
+#import "NetworkProcessProxyMessages.h"
 
 #if PLATFORM(IOS_FAMILY)
 
@@ -52,6 +53,13 @@
     return nil;
 }
 
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+void NetworkConnectionToWebProcess::getWindowSceneIdentifierForPaymentPresentation(WebPageProxyIdentifier webPageProxyIdentifier, CompletionHandler<void(const String&)>&& completionHandler)
+{
+    networkProcess().parentProcessConnection()->sendWithAsyncReply(Messages::NetworkProcessProxy::GetWindowSceneIdentifierForPaymentPresentation(webPageProxyIdentifier), WTFMove(completionHandler));
+}
+#endif
+
 const String& NetworkConnectionToWebProcess::paymentCoordinatorBoundInterfaceIdentifier(const WebPaymentCoordinatorProxy&)
 {
     if (auto* session = static_cast<NetworkSessionCocoa*>(networkSession()))

Modified: trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationPresenter.h (283319 => 283320)


--- trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationPresenter.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationPresenter.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -85,7 +85,11 @@
     virtual void dismiss() = 0;
 #if PLATFORM(IOS_FAMILY)
     virtual void present(UIViewController *, CompletionHandler<void(bool)>&&) = 0;
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+    virtual void presentInScene(const String&, CompletionHandler<void(bool)>&&) = 0;
+    const String& sceneIdentifier() const { return m_sceneIdentifier; }
 #endif
+#endif
 
 protected:
     explicit PaymentAuthorizationPresenter(Client& client)
@@ -95,6 +99,10 @@
 
     virtual WKPaymentAuthorizationDelegate *platformDelegate() = 0;
 
+#if PLATFORM(IOS_FAMILY) && ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+    String m_sceneIdentifier;
+#endif
+
 private:
     Client& m_client;
 };

Modified: trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationViewController.h (283319 => 283320)


--- trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationViewController.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationViewController.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -49,7 +49,10 @@
     void dismiss() final;
 #if PLATFORM(IOS_FAMILY)
     void present(UIViewController *, CompletionHandler<void(bool)>&&) final;
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+    void presentInScene(const String&, CompletionHandler<void(bool)>&&) final;
 #endif
+#endif
 
     RetainPtr<PKPaymentAuthorizationViewController> m_viewController;
     RetainPtr<WKPaymentAuthorizationViewControllerDelegate> m_delegate;

Modified: trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationViewController.mm (283319 => 283320)


--- trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationViewController.mm	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationViewController.mm	2021-09-30 17:48:19 UTC (rev 283320)
@@ -153,8 +153,16 @@
     completionHandler(true);
 }
 
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+void PaymentAuthorizationViewController::presentInScene(const String&, CompletionHandler<void(bool)>&& completionHandler)
+{
+    ASSERT_NOT_REACHED();
+    completionHandler(false);
+}
 #endif
 
+#endif
+
 } // namespace WebKit
 
 #endif // USE(PASSKIT) && ENABLE(APPLE_PAY)

Modified: trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.h (283319 => 283320)


--- trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -51,6 +51,7 @@
 
 @interface WKPaymentAuthorizationDelegate : NSObject {
     RetainPtr<PKPaymentRequest> _request;
+    WeakPtr<WebKit::PaymentAuthorizationPresenter> _presenter;
 }
 
 - (instancetype)init NS_UNAVAILABLE;

Modified: trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm (283319 => 283320)


--- trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm	2021-09-30 17:48:19 UTC (rev 283320)
@@ -37,7 +37,6 @@
     RetainPtr<NSArray<PKPaymentSummaryItem *>> _summaryItems;
     RetainPtr<NSArray<PKShippingMethod *>> _shippingMethods;
     RetainPtr<NSError> _sessionError;
-    WeakPtr<WebKit::PaymentAuthorizationPresenter> _presenter;
     WebKit::DidAuthorizePaymentCompletion _didAuthorizePaymentCompletion;
     WebKit::DidRequestMerchantSessionCompletion _didRequestMerchantSessionCompletion;
     WebKit::DidSelectPaymentMethodCompletion _didSelectPaymentMethodCompletion;

Modified: trunk/Source/WebKit/Platform/ios/PaymentAuthorizationController.h (283319 => 283320)


--- trunk/Source/WebKit/Platform/ios/PaymentAuthorizationController.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Platform/ios/PaymentAuthorizationController.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -46,6 +46,9 @@
     WKPaymentAuthorizationDelegate *platformDelegate() final;
     void dismiss() final;
     void present(UIViewController *, CompletionHandler<void(bool)>&&) final;
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+    void presentInScene(const String&, CompletionHandler<void(bool)>&&) final;
+#endif
 
     RetainPtr<PKPaymentAuthorizationController> m_controller;
     RetainPtr<WKPaymentAuthorizationControllerDelegate> m_delegate;

Modified: trunk/Source/WebKit/Platform/ios/PaymentAuthorizationController.mm (283319 => 283320)


--- trunk/Source/WebKit/Platform/ios/PaymentAuthorizationController.mm	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Platform/ios/PaymentAuthorizationController.mm	2021-09-30 17:48:19 UTC (rev 283320)
@@ -105,6 +105,15 @@
     [self _didRequestMerchantSession:sessionBlock];
 }
 
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+- (NSString *)presentationSceneIdentifierForPaymentAuthorizationController:(PKPaymentAuthorizationController *)controller
+{
+    if (!_presenter)
+        return nil;
+    return nsStringNilIfEmpty(_presenter->sceneIdentifier());
+}
+#endif
+
 @end
 
 namespace WebKit {
@@ -131,6 +140,9 @@
     m_controller = nil;
     [m_delegate invalidate];
     m_delegate = nil;
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+    m_sceneIdentifier = nullString();
+#endif
 }
 
 void PaymentAuthorizationController::present(UIViewController *, CompletionHandler<void(bool)>&& completionHandler)
@@ -143,6 +155,14 @@
     }).get()];
 }
 
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+void PaymentAuthorizationController::presentInScene(const String& sceneIdentifier, CompletionHandler<void(bool)>&& completionHandler)
+{
+    m_sceneIdentifier = sceneIdentifier;
+    present(nil, WTFMove(completionHandler));
+}
+#endif
+
 } // namespace WebKit
 
 #endif // USE(PASSKIT) && PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (283319 => 283320)


--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -1291,6 +1291,10 @@
 @end
 #endif
 
+@interface UIScene ()
+@property (nonatomic, readonly) NSString *_sceneIdentifier;
+@end
+
 #endif // USE(APPLE_INTERNAL_SDK)
 
 #define UIWKDocumentRequestMarkedTextRects (1 << 5)

Modified: trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.cpp (283319 => 283320)


--- trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.cpp	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.cpp	2021-09-30 17:48:19 UTC (rev 283320)
@@ -78,7 +78,7 @@
     platformOpenPaymentSetup(merchantIdentifier, domainName, WTFMove(completionHandler));
 }
 
-void WebPaymentCoordinatorProxy::showPaymentUI(WebCore::PageIdentifier destinationID, const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& paymentRequest, CompletionHandler<void(bool)>&& completionHandler)
+void WebPaymentCoordinatorProxy::showPaymentUI(WebCore::PageIdentifier destinationID, WebPageProxyIdentifier webPageProxyID, const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& paymentRequest, CompletionHandler<void(bool)>&& completionHandler)
 {
     if (auto& coordinator = activePaymentCoordinatorProxy())
         coordinator->didReachFinalState();
@@ -97,7 +97,7 @@
     for (const auto& linkIconURLString : linkIconURLStrings)
         linkIconURLs.append(URL(URL(), linkIconURLString));
 
-    platformShowPaymentUI(originatingURL, linkIconURLs, paymentRequest, [this, weakThis = makeWeakPtr(*this)](bool result) {
+    platformShowPaymentUI(webPageProxyID, originatingURL, linkIconURLs, paymentRequest, [this, weakThis = makeWeakPtr(*this)](bool result) {
         if (!weakThis)
             return;
 

Modified: trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.h (283319 => 283320)


--- trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -30,6 +30,7 @@
 #include "MessageReceiver.h"
 #include "MessageSender.h"
 #include "PaymentAuthorizationPresenter.h"
+#include "WebPageProxyIdentifier.h"
 #include <WebCore/PageIdentifier.h>
 #include <WebCore/PaymentHeaders.h>
 #include <wtf/Forward.h>
@@ -91,6 +92,9 @@
         virtual void paymentCoordinatorRemoveMessageReceiver(WebPaymentCoordinatorProxy&, IPC::ReceiverName) = 0;
 #if PLATFORM(IOS_FAMILY)
         virtual UIViewController *paymentCoordinatorPresentingViewController(const WebPaymentCoordinatorProxy&) = 0;
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+        virtual void getWindowSceneIdentifierForPaymentPresentation(WebPageProxyIdentifier, CompletionHandler<void(const String&)>&&) = 0;
+#endif
         virtual const String& paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&) = 0;
         virtual std::unique_ptr<PaymentAuthorizationPresenter> paymentCoordinatorAuthorizationPresenter(WebPaymentCoordinatorProxy&, PKPaymentRequest *) = 0;
 #endif
@@ -127,7 +131,7 @@
     void canMakePayments(CompletionHandler<void(bool)>&&);
     void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&);
     void openPaymentSetup(const String& merchantIdentifier, const String& domainName, CompletionHandler<void(bool)>&&);
-    void showPaymentUI(WebCore::PageIdentifier destinationID, const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest&, CompletionHandler<void(bool)>&&);
+    void showPaymentUI(WebCore::PageIdentifier destinationID, WebPageProxyIdentifier, const String& originatingURLString, const Vector<String>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest&, CompletionHandler<void(bool)>&&);
     void completeMerchantValidation(const WebCore::PaymentMerchantSession&);
     void completeShippingMethodSelection(std::optional<WebCore::ApplePayShippingMethodUpdate>&&);
     void completeShippingContactSelection(std::optional<WebCore::ApplePayShippingContactUpdate>&&);
@@ -155,7 +159,7 @@
     void platformCanMakePayments(CompletionHandler<void(bool)>&&);
     void platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, 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(WebPageProxyIdentifier, const URL& originatingURL, const Vector<URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest&, CompletionHandler<void(bool)>&&);
     void platformCompleteMerchantValidation(const WebCore::PaymentMerchantSession&);
     void platformCompleteShippingMethodSelection(std::optional<WebCore::ApplePayShippingMethodUpdate>&&);
     void platformCompleteShippingContactSelection(std::optional<WebCore::ApplePayShippingContactUpdate>&&);

Modified: trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in (283319 => 283320)


--- trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in	2021-09-30 17:48:19 UTC (rev 283320)
@@ -30,7 +30,7 @@
     CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName) -> (bool canMakePayments) Async
     OpenPaymentSetup(String merchantIdentifier, String domainName) -> (bool result) Async
 
-    ShowPaymentUI(WebCore::PageIdentifier destinationID, String originatingURLString, Vector<String> linkIconURLStrings, WebCore::ApplePaySessionPaymentRequest paymentRequest) -> (bool result) Synchronous
+    ShowPaymentUI(WebCore::PageIdentifier destinationID, WebKit::WebPageProxyIdentifier webPageProxyIdentifier, String originatingURLString, Vector<String> linkIconURLStrings, WebCore::ApplePaySessionPaymentRequest paymentRequest) -> (bool result) Synchronous
     CompleteMerchantValidation(WebCore::PaymentMerchantSession paymentMerchantSession)
     CompleteShippingMethodSelection(std::optional<WebCore::ApplePayShippingMethodUpdate> update)
     CompleteShippingContactSelection(std::optional<WebCore::ApplePayShippingContactUpdate> update)

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


--- trunk/Source/WebKit/Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm	2021-09-30 17:48:19 UTC (rev 283320)
@@ -46,7 +46,7 @@
     });
 }
 
-void WebPaymentCoordinatorProxy::platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
+void WebPaymentCoordinatorProxy::platformShowPaymentUI(WebPageProxyIdentifier webPageProxyID, const URL& originatingURL, const Vector<URL>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
 {
     auto paymentRequest = platformPaymentRequest(originatingURL, linkIconURLStrings, request);
 
@@ -55,7 +55,24 @@
     if (!m_authorizationPresenter)
         return completionHandler(false);
 
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+    m_client.getWindowSceneIdentifierForPaymentPresentation(webPageProxyID, [weakThis = makeWeakPtr(*this), completionHandler = WTFMove(completionHandler)](const String& sceneID) mutable {
+        if (!weakThis) {
+            completionHandler(false);
+            return;
+        }
+
+        if (!weakThis->m_authorizationPresenter) {
+            completionHandler(false);
+            return;
+        }
+
+        weakThis->m_authorizationPresenter->presentInScene(sceneID, WTFMove(completionHandler));
+    });
+#else
+    UNUSED_PARAM(webPageProxyID);
     m_authorizationPresenter->present(m_client.paymentCoordinatorPresentingViewController(*this), WTFMove(completionHandler));
+#endif
 }
 
 void WebPaymentCoordinatorProxy::platformHidePaymentUI()

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


--- trunk/Source/WebKit/Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm	2021-09-30 17:48:19 UTC (rev 283320)
@@ -47,7 +47,7 @@
     });
 }
 
-void WebPaymentCoordinatorProxy::platformShowPaymentUI(const URL& originatingURL, const Vector<URL>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
+void WebPaymentCoordinatorProxy::platformShowPaymentUI(WebPageProxyIdentifier, const URL& originatingURL, const Vector<URL>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& request, CompletionHandler<void(bool)>&& completionHandler)
 {
     if (!PAL::isPassKitFrameworkAvailable())
         return completionHandler(false);

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (283319 => 283320)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2021-09-30 17:48:19 UTC (rev 283320)
@@ -44,6 +44,7 @@
 #include "NetworkProcessCreationParameters.h"
 #include "NetworkProcessMessages.h"
 #include "NetworkProcessProxyMessages.h"
+#include "PageClient.h"
 #include "SandboxExtension.h"
 #if HAVE(SEC_KEY_PROXY)
 #include "SecKeyProxyStore.h"
@@ -1172,6 +1173,18 @@
 }
 #endif
 
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+void NetworkProcessProxy::getWindowSceneIdentifierForPaymentPresentation(WebPageProxyIdentifier webPageProxyIdentifier, CompletionHandler<void(const String&)>&& completionHandler)
+{
+    auto* page = WebProcessProxy::webPage(webPageProxyIdentifier);
+    if (!page) {
+        completionHandler(nullString());
+        return;
+    }
+    completionHandler(page->pageClient().sceneID());
+}
+#endif
+
 void NetworkProcessProxy::setShouldDowngradeReferrerForTesting(bool enabled, CompletionHandler<void()>&& completionHandler)
 {
     if (!canSendMessage()) {

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (283319 => 283320)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -255,6 +255,9 @@
     void getAppBoundDomains(PAL::SessionID, CompletionHandler<void(HashSet<WebCore::RegistrableDomain>&&)>&&);
 #endif
 
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+    void getWindowSceneIdentifierForPaymentPresentation(WebPageProxyIdentifier, CompletionHandler<void(const String&)>&&);
+#endif
     // ProcessThrottlerClient
     void sendPrepareToSuspend(IsSuspensionImminent, CompletionHandler<void()>&&) final;
     void updateBundleIdentifier(const String&, CompletionHandler<void()>&&);

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (283319 => 283320)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2021-09-30 17:48:19 UTC (rev 283320)
@@ -78,4 +78,8 @@
 #if USE(SOUP)
     DidExceedMemoryLimit()
 #endif
+
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+    GetWindowSceneIdentifierForPaymentPresentation(WebKit::WebPageProxyIdentifier webPageProxyIdentifier) -> (String sceneID) Async
+#endif
 }

Modified: trunk/Source/WebKit/UIProcess/PageClient.h (283319 => 283320)


--- trunk/Source/WebKit/UIProcess/PageClient.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/UIProcess/PageClient.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -498,6 +498,7 @@
 #endif
 
     virtual WebCore::Color contentViewBackgroundColor() = 0;
+    virtual String sceneID() = 0;
 #endif
 
     // Auxiliary Client Creation

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (283319 => 283320)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -2497,6 +2497,9 @@
 #endif
 #if ENABLE(APPLE_PAY) && PLATFORM(IOS_FAMILY)
     UIViewController *paymentCoordinatorPresentingViewController(const WebPaymentCoordinatorProxy&) final;
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+    void getWindowSceneIdentifierForPaymentPresentation(WebPageProxyIdentifier, CompletionHandler<void(const String&)>&&) final;
+#endif
     const String& paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&) final;
     std::unique_ptr<PaymentAuthorizationPresenter> paymentCoordinatorAuthorizationPresenter(WebPaymentCoordinatorProxy&, PKPaymentRequest *) final;
 #endif

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (283319 => 283320)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2021-09-30 17:48:19 UTC (rev 283320)
@@ -300,6 +300,7 @@
 #endif
 
     WebCore::Color contentViewBackgroundColor() final;
+    String sceneID() final;
 
     WeakObjCPtr<WKContentView> m_contentView;
     RetainPtr<WKEditorUndoTarget> m_undoTarget;

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (283319 => 283320)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2021-09-30 17:48:19 UTC (rev 283320)
@@ -1023,6 +1023,11 @@
     [m_contentView _scrollToRect:targetRect withOrigin:origin minimumScrollDistance:0];
 }
 
+String PageClientImpl::sceneID()
+{
+    return [m_contentView window].windowScene._sceneIdentifier;
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (283319 => 283320)


--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm	2021-09-30 17:48:19 UTC (rev 283320)
@@ -1238,6 +1238,14 @@
     return uiClient().presentingViewController();
 }
 
+#if ENABLE(APPLE_PAY_REMOTE_UI_USES_SCENE)
+void WebPageProxy::getWindowSceneIdentifierForPaymentPresentation(WebPageProxyIdentifier, CompletionHandler<void(const String&)>&& completionHandler)
+{
+    ASSERT_NOT_REACHED();
+    completionHandler(nullString());
+}
+#endif
+
 const String& WebPageProxy::paymentCoordinatorCTDataConnectionServiceType(const WebPaymentCoordinatorProxy&)
 {
     return websiteDataStore().configuration().dataConnectionServiceType();

Modified: trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp (283319 => 283320)


--- trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp	2021-09-30 17:39:44 UTC (rev 283319)
+++ trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp	2021-09-30 17:48:19 UTC (rev 283320)
@@ -102,7 +102,7 @@
         linkIconURLStrings.append(linkIconURL.string());
 
     bool result;
-    if (!sendSync(Messages::WebPaymentCoordinatorProxy::ShowPaymentUI(m_webPage.identifier(), originatingURL.string(), linkIconURLStrings, paymentRequest), Messages::WebPaymentCoordinatorProxy::ShowPaymentUI::Reply(result)))
+    if (!sendSync(Messages::WebPaymentCoordinatorProxy::ShowPaymentUI(m_webPage.identifier(), m_webPage.webPageProxyIdentifier(), originatingURL.string(), linkIconURLStrings, paymentRequest), Messages::WebPaymentCoordinatorProxy::ShowPaymentUI::Reply(result)))
         return false;
 
     return result;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to