Title: [243443] trunk/Source/WebKit
Revision
243443
Author
[email protected]
Date
2019-03-25 11:26:10 -0700 (Mon, 25 Mar 2019)

Log Message

[Apple Pay] Remove the AvailablePaymentNetworks synchronous message
https://bugs.webkit.org/show_bug.cgi?id=196180

Reviewed by Youenn Fablet.

Unlike many PassKit interactions, it's ok to call +[PKPaymentRequest availableNetworks]
without an entitlement. Therefore, we can call it from the web process directly rather than
synchronously messaging the entitled UI or networking process.

* Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
* Shared/ApplePay/WebPaymentCoordinatorProxy.h:
* Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in:
* Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
* SourcesCocoa.txt:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/ApplePay/WebPaymentCoordinator.cpp:
(WebKit::WebPaymentCoordinator::availablePaymentNetworks):
* WebProcess/ApplePay/WebPaymentCoordinator.h:
* WebProcess/ApplePay/cocoa/WebPaymentCoordinatorCocoa.mm: Added.
(WebKit::WebPaymentCoordinator::platformAvailablePaymentNetworks const):
* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm:
(-[WKAccessibilityWebPageObjectBase accessibilityRootObjectWrapper]):
(-[WKAccessibilityWebPageObjectBase setWebPage:]):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (243442 => 243443)


--- trunk/Source/WebKit/ChangeLog	2019-03-25 18:13:09 UTC (rev 243442)
+++ trunk/Source/WebKit/ChangeLog	2019-03-25 18:26:10 UTC (rev 243443)
@@ -1,3 +1,29 @@
+2019-03-25  Andy Estes  <[email protected]>
+
+        [Apple Pay] Remove the AvailablePaymentNetworks synchronous message
+        https://bugs.webkit.org/show_bug.cgi?id=196180
+
+        Reviewed by Youenn Fablet.
+
+        Unlike many PassKit interactions, it's ok to call +[PKPaymentRequest availableNetworks]
+        without an entitlement. Therefore, we can call it from the web process directly rather than
+        synchronously messaging the entitled UI or networking process.
+
+        * Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
+        * Shared/ApplePay/WebPaymentCoordinatorProxy.h:
+        * Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in:
+        * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        * SourcesCocoa.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
+        (WebKit::WebPaymentCoordinator::availablePaymentNetworks):
+        * WebProcess/ApplePay/WebPaymentCoordinator.h:
+        * WebProcess/ApplePay/cocoa/WebPaymentCoordinatorCocoa.mm: Added.
+        (WebKit::WebPaymentCoordinator::platformAvailablePaymentNetworks const):
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm:
+        (-[WKAccessibilityWebPageObjectBase accessibilityRootObjectWrapper]):
+        (-[WKAccessibilityWebPageObjectBase setWebPage:]):
+
 2019-03-25  Chris Dumez  <[email protected]>
 
         Unreviewed, tiny fix after r243388 to address API test failures on iOS

Modified: trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.cpp (243442 => 243443)


--- trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.cpp	2019-03-25 18:13:09 UTC (rev 243442)
+++ trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.cpp	2019-03-25 18:26:10 UTC (rev 243443)
@@ -68,11 +68,6 @@
     return *m_destinationID;
 }
 
-void WebPaymentCoordinatorProxy::availablePaymentNetworks(CompletionHandler<void(Vector<String>&&)>&& completionHandler)
-{
-    completionHandler(platformAvailablePaymentNetworks());
-}
-
 void WebPaymentCoordinatorProxy::canMakePayments(CompletionHandler<void(bool)>&& reply)
 {
     reply(platformCanMakePayments());

Modified: trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.h (243442 => 243443)


--- trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.h	2019-03-25 18:13:09 UTC (rev 243442)
+++ trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.h	2019-03-25 18:26:10 UTC (rev 243443)
@@ -111,7 +111,6 @@
     void presenterWillValidateMerchant(PaymentAuthorizationPresenter&, const URL&) final;
 
     // Message handlers
-    void availablePaymentNetworks(CompletionHandler<void(Vector<String>&&)>&&);
     void canMakePayments(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)>&&);
@@ -133,7 +132,6 @@
     void didReachFinalState();
     void hidePaymentUI();
 
-    Vector<String> platformAvailablePaymentNetworks();
     bool platformCanMakePayments();
     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);

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


--- trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in	2019-03-25 18:13:09 UTC (rev 243442)
+++ trunk/Source/WebKit/Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in	2019-03-25 18:26:10 UTC (rev 243443)
@@ -26,7 +26,6 @@
 
 messages -> WebPaymentCoordinatorProxy {
 
-    AvailablePaymentNetworks() -> (Vector<String> availablePaymentNetworks) Synchronous
     CanMakePayments() -> (bool result) Synchronous
     CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName, PAL::SessionID sessionID) -> (bool canMakePayments) Async
     OpenPaymentSetup(String merchantIdentifier, String domainName) -> (bool result) Async

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


--- trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2019-03-25 18:13:09 UTC (rev 243442)
+++ trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2019-03-25 18:26:10 UTC (rev 243443)
@@ -349,21 +349,6 @@
     m_authorizationPresenter->completePaymentMethodSelection(update);
 }
 
-Vector<String> WebPaymentCoordinatorProxy::platformAvailablePaymentNetworks()
-{
-#if PLATFORM(MAC)
-    if (!PAL::isPassKitFrameworkAvailable())
-        return { };
-#endif
-
-    NSArray<PKPaymentNetwork> *availableNetworks = [PAL::getPKPaymentRequestClass() availableNetworks];
-    Vector<String> result;
-    result.reserveInitialCapacity(availableNetworks.count);
-    for (PKPaymentNetwork network in availableNetworks)
-        result.uncheckedAppend(network);
-    return result;
-}
-
 } // namespace WebKit
 
 #endif // ENABLE(APPLE_PAY)

Modified: trunk/Source/WebKit/SourcesCocoa.txt (243442 => 243443)


--- trunk/Source/WebKit/SourcesCocoa.txt	2019-03-25 18:13:09 UTC (rev 243442)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2019-03-25 18:26:10 UTC (rev 243443)
@@ -494,6 +494,8 @@
 
 WebProcess/ApplePay/WebPaymentCoordinator.cpp
 
+WebProcess/ApplePay/cocoa/WebPaymentCoordinatorCocoa.mm
+
 WebProcess/cocoa/PlaybackSessionManager.mm
 WebProcess/cocoa/UserMediaCaptureManager.cpp
 WebProcess/cocoa/VideoFullscreenManager.mm

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (243442 => 243443)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-03-25 18:13:09 UTC (rev 243442)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-03-25 18:26:10 UTC (rev 243443)
@@ -3903,6 +3903,7 @@
 		A1A4FE5918DCE9FA00B5EA8A /* _WKDownloadInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDownloadInternal.h; sourceTree = "<group>"; };
 		A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDownloadDelegate.h; sourceTree = "<group>"; };
 		A1B89B92221E023300EB4CEA /* SDKVariant.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = SDKVariant.xcconfig; sourceTree = "<group>"; };
+		A1B9CA382246E54A003D6DCA /* WebPaymentCoordinatorCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPaymentCoordinatorCocoa.mm; sourceTree = "<group>"; };
 		A1C512C6190656E500448914 /* WebPreviewLoaderClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebPreviewLoaderClient.cpp; path = ios/WebPreviewLoaderClient.cpp; sourceTree = "<group>"; };
 		A1C512C7190656E500448914 /* WebPreviewLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebPreviewLoaderClient.h; path = ios/WebPreviewLoaderClient.h; sourceTree = "<group>"; };
 		A1DF631018E0B7C8003A3E2A /* DownloadClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DownloadClient.mm; sourceTree = "<group>"; };
@@ -5296,6 +5297,7 @@
 		1AB1F7701D1B2F5D007C9BD1 /* ApplePay */ = {
 			isa = PBXGroup;
 			children = (
+				A1B9CA372246E525003D6DCA /* cocoa */,
 				1AB1F7711D1B2F7E007C9BD1 /* WebPaymentCoordinator.cpp */,
 				1AB1F7721D1B2F7E007C9BD1 /* WebPaymentCoordinator.h */,
 				1AB1F7731D1B2F7E007C9BD1 /* WebPaymentCoordinator.messages.in */,
@@ -7190,6 +7192,14 @@
 			path = ios;
 			sourceTree = "<group>";
 		};
+		A1B9CA372246E525003D6DCA /* cocoa */ = {
+			isa = PBXGroup;
+			children = (
+				A1B9CA382246E54A003D6DCA /* WebPaymentCoordinatorCocoa.mm */,
+			);
+			path = cocoa;
+			sourceTree = "<group>";
+		};
 		A1E6886E1F6E2B82007006A6 /* mac */ = {
 			isa = PBXGroup;
 			children = (

Modified: trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp (243442 => 243443)


--- trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp	2019-03-25 18:13:09 UTC (rev 243442)
+++ trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp	2019-03-25 18:26:10 UTC (rev 243443)
@@ -59,28 +59,13 @@
 #endif
 }
 
-const WebPaymentCoordinator::AvailablePaymentNetworksSet& WebPaymentCoordinator::availablePaymentNetworks()
+Optional<String> WebPaymentCoordinator::validatedPaymentNetwork(const String& paymentNetwork)
 {
-    if (m_availablePaymentNetworks)
-        return *m_availablePaymentNetworks;
+    if (!m_availablePaymentNetworks)
+        m_availablePaymentNetworks = platformAvailablePaymentNetworks();
 
-    m_availablePaymentNetworks = WebPaymentCoordinator::AvailablePaymentNetworksSet();
-
-    Vector<String> availablePaymentNetworks;
-    using AvailablePaymentNetworksMessage = Messages::WebPaymentCoordinatorProxy::AvailablePaymentNetworks;
-    if (sendSync(AvailablePaymentNetworksMessage(), AvailablePaymentNetworksMessage::Reply(availablePaymentNetworks))) {
-        for (auto& network : availablePaymentNetworks)
-            m_availablePaymentNetworks->add(network);
-    }
-
-    return *m_availablePaymentNetworks;
-}
-
-Optional<String> WebPaymentCoordinator::validatedPaymentNetwork(const String& paymentNetwork)
-{
-    auto& paymentNetworks = availablePaymentNetworks();
-    auto result = paymentNetworks.find(paymentNetwork);
-    if (result == paymentNetworks.end())
+    auto result = m_availablePaymentNetworks->find(paymentNetwork);
+    if (result == m_availablePaymentNetworks->end())
         return WTF::nullopt;
     return *result;
 }

Modified: trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h (243442 => 243443)


--- trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h	2019-03-25 18:13:09 UTC (rev 243442)
+++ trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h	2019-03-25 18:26:10 UTC (rev 243443)
@@ -102,7 +102,7 @@
 #endif
 
     using AvailablePaymentNetworksSet = HashSet<String, ASCIICaseInsensitiveHash>;
-    const AvailablePaymentNetworksSet& availablePaymentNetworks();
+    static AvailablePaymentNetworksSet platformAvailablePaymentNetworks();
 
     WebPage& m_webPage;
 

Added: trunk/Source/WebKit/WebProcess/ApplePay/cocoa/WebPaymentCoordinatorCocoa.mm (0 => 243443)


--- trunk/Source/WebKit/WebProcess/ApplePay/cocoa/WebPaymentCoordinatorCocoa.mm	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/ApplePay/cocoa/WebPaymentCoordinatorCocoa.mm	2019-03-25 18:26:10 UTC (rev 243443)
@@ -0,0 +1,50 @@
+/*
+ * 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
+ * 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 "WebPaymentCoordinator.h"
+
+#if ENABLE(APPLE_PAY) && PLATFORM(COCOA)
+
+#import <pal/cocoa/PassKitSoftLink.h>
+
+namespace WebKit {
+
+WebPaymentCoordinator::AvailablePaymentNetworksSet WebPaymentCoordinator::platformAvailablePaymentNetworks()
+{
+#if PLATFORM(MAC)
+    if (!PAL::isPassKitFrameworkAvailable())
+        return { };
+#endif
+
+    WebPaymentCoordinator::AvailablePaymentNetworksSet availableNetworks;
+    for (PKPaymentNetwork network in [PAL::getPKPaymentRequestClass() availableNetworks])
+        availableNetworks.add(network);
+    return availableNetworks;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(APPLE_PAY) && PLATFORM(COCOA)

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm (243442 => 243443)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm	2019-03-25 18:13:09 UTC (rev 243442)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm	2019-03-25 18:26:10 UTC (rev 243443)
@@ -44,8 +44,6 @@
 #import <WebCore/Scrollbar.h>
 #import <wtf/ObjCRuntimeExtras.h>
 
-using namespace WebKit;
-
 @implementation WKAccessibilityWebPageObjectBase
 
 - (WebCore::AXObjectCache*)axObjectCache
@@ -132,7 +130,7 @@
         return [self isolatedTreeRootObject];
 #endif
 
-    if (AXObjectCache* cache = [self axObjectCache]) {
+    if (auto cache = [self axObjectCache]) {
         if (WebCore::AccessibilityObject* root = cache->rootObject())
             return root->wrapper();
     }
@@ -140,7 +138,7 @@
     return nil;
 }
 
-- (void)setWebPage:(WebPage*)page
+- (void)setWebPage:(WebKit::WebPage*)page
 {
     m_page = page;
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to