Title: [226182] trunk/Source
Revision
226182
Author
aes...@apple.com
Date
2017-12-20 09:11:29 -0800 (Wed, 20 Dec 2017)

Log Message

[Apple Pay] Tell PassKit whether Apple Pay JS or Payment Request was used to start an Apple Pay session
https://bugs.webkit.org/show_bug.cgi?id=181001
<rdar://problem/35479106>

Reviewed by Tim Horton.

Source/WebCore:

* Modules/applepay/ApplePaySession.cpp:
(WebCore::convertAndValidate):
* Modules/applepay/ApplePaySessionPaymentRequest.h:
(WebCore::ApplePaySessionPaymentRequest::requester const):
(WebCore::ApplePaySessionPaymentRequest::setRequester):
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::show):

Source/WebCore/PAL:

* pal/spi/cocoa/PassKitSPI.h:

Source/WebKit:

* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::encode):
(IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::decode):
* UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::toAPIType):
(WebKit::toPKPaymentRequest):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (226181 => 226182)


--- trunk/Source/WebCore/ChangeLog	2017-12-20 16:52:59 UTC (rev 226181)
+++ trunk/Source/WebCore/ChangeLog	2017-12-20 17:11:29 UTC (rev 226182)
@@ -1,3 +1,19 @@
+2017-12-20  Andy Estes  <aes...@apple.com>
+
+        [Apple Pay] Tell PassKit whether Apple Pay JS or Payment Request was used to start an Apple Pay session
+        https://bugs.webkit.org/show_bug.cgi?id=181001
+        <rdar://problem/35479106>
+
+        Reviewed by Tim Horton.
+
+        * Modules/applepay/ApplePaySession.cpp:
+        (WebCore::convertAndValidate):
+        * Modules/applepay/ApplePaySessionPaymentRequest.h:
+        (WebCore::ApplePaySessionPaymentRequest::requester const):
+        (WebCore::ApplePaySessionPaymentRequest::setRequester):
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+        (WebCore::ApplePayPaymentHandler::show):
+
 2017-12-20  Zalan Bujtas  <za...@apple.com>
 
         [RenderTreeBuilder] Move finding-the-parent/creating-wrapper logic from RenderTable::addChild to RenderTreeBuilder

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp (226181 => 226182)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2017-12-20 16:52:59 UTC (rev 226181)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2017-12-20 17:11:29 UTC (rev 226182)
@@ -214,6 +214,7 @@
         return convertedRequest.releaseException();
 
     auto result = convertedRequest.releaseReturnValue();
+    result.setRequester(ApplePaySessionPaymentRequest::Requester::ApplePayJS);
     result.setCurrencyCode(paymentRequest.currencyCode);
 
     auto total = convertAndValidateTotal(WTFMove(paymentRequest.total));

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySessionPaymentRequest.h (226181 => 226182)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySessionPaymentRequest.h	2017-12-20 16:52:59 UTC (rev 226181)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySessionPaymentRequest.h	2017-12-20 17:11:29 UTC (rev 226182)
@@ -127,6 +127,14 @@
     const Vector<String>& supportedCountries() const { return m_supportedCountries; }
     void setSupportedCountries(Vector<String>&& supportedCountries) { m_supportedCountries = WTFMove(supportedCountries); }
 
+    enum class Requester {
+        ApplePayJS,
+        PaymentRequest,
+    };
+
+    Requester requester() const { return m_requester; }
+    void setRequester(Requester requester) { m_requester = requester; }
+
 private:
     String m_countryCode;
     String m_currencyCode;
@@ -148,6 +156,8 @@
 
     String m_applicationData;
     Vector<String> m_supportedCountries;
+
+    Requester m_requester { Requester::ApplePayJS };
 };
 
 struct PaymentError {

Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (226181 => 226182)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2017-12-20 16:52:59 UTC (rev 226181)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2017-12-20 17:11:29 UTC (rev 226182)
@@ -179,6 +179,7 @@
         return validatedRequest.releaseException();
 
     ApplePaySessionPaymentRequest request = validatedRequest.releaseReturnValue();
+    request.setRequester(ApplePaySessionPaymentRequest::Requester::PaymentRequest);
 
     String expectedCurrency = m_paymentRequest->paymentDetails().total.amount.currency;
     request.setCurrencyCode(expectedCurrency);

Modified: trunk/Source/WebCore/PAL/ChangeLog (226181 => 226182)


--- trunk/Source/WebCore/PAL/ChangeLog	2017-12-20 16:52:59 UTC (rev 226181)
+++ trunk/Source/WebCore/PAL/ChangeLog	2017-12-20 17:11:29 UTC (rev 226182)
@@ -1,3 +1,13 @@
+2017-12-20  Andy Estes  <aes...@apple.com>
+
+        [Apple Pay] Tell PassKit whether Apple Pay JS or Payment Request was used to start an Apple Pay session
+        https://bugs.webkit.org/show_bug.cgi?id=181001
+        <rdar://problem/35479106>
+
+        Reviewed by Tim Horton.
+
+        * pal/spi/cocoa/PassKitSPI.h:
+
 2017-12-19  Andy Estes  <aes...@apple.com>
 
         [Apple Pay] Stop maintaining a list of payment networks

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


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h	2017-12-20 16:52:59 UTC (rev 226181)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h	2017-12-20 17:11:29 UTC (rev 226182)
@@ -29,6 +29,7 @@
 
 #import <PassKit/PassKit.h>
 #import <PassKit/PKPaymentAuthorizationViewController_Private.h>
+#import <PassKit/PKPaymentRequest_Private.h>
 
 #else
 
@@ -246,6 +247,18 @@
 - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didRequestMerchantSession:(void(^)(PKPaymentMerchantSession *, NSError *))sessionBlock;
 @end
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101304) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110300)
+typedef NS_ENUM(NSUInteger, PKPaymentRequestAPIType) {
+    PKPaymentRequestAPITypeInApp = 0,
+    PKPaymentRequestAPITypeWebJS,
+    PKPaymentRequestAPITypeWebPaymentRequest,
+};
+
+@interface PKPaymentRequest ()
+@property (nonatomic, assign) PKPaymentRequestAPIType APIType;
+@end
+#endif
+
 NS_ASSUME_NONNULL_END
 
 #endif

Modified: trunk/Source/WebKit/ChangeLog (226181 => 226182)


--- trunk/Source/WebKit/ChangeLog	2017-12-20 16:52:59 UTC (rev 226181)
+++ trunk/Source/WebKit/ChangeLog	2017-12-20 17:11:29 UTC (rev 226182)
@@ -1,3 +1,18 @@
+2017-12-20  Andy Estes  <aes...@apple.com>
+
+        [Apple Pay] Tell PassKit whether Apple Pay JS or Payment Request was used to start an Apple Pay session
+        https://bugs.webkit.org/show_bug.cgi?id=181001
+        <rdar://problem/35479106>
+
+        Reviewed by Tim Horton.
+
+        * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+        (IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::encode):
+        (IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::decode):
+        * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (WebKit::toAPIType):
+        (WebKit::toPKPaymentRequest):
+
 2017-12-20  Ms2ger  <ms2...@igalia.com>
 
         REGRESSION(r226160) Build broken when MEDIA_STREAM is disabled with MediaStreamRequest namespace confusion

Modified: trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (226181 => 226182)


--- trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm	2017-12-20 16:52:59 UTC (rev 226181)
+++ trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm	2017-12-20 17:11:29 UTC (rev 226182)
@@ -291,6 +291,7 @@
     encoder << request.total();
     encoder << request.applicationData();
     encoder << request.supportedCountries();
+    encoder.encodeEnum(request.requester());
 }
 
 bool ArgumentCoder<ApplePaySessionPaymentRequest>::decode(Decoder& decoder, ApplePaySessionPaymentRequest& request)
@@ -366,6 +367,11 @@
         return false;
     request.setSupportedCountries(WTFMove(supportedCountries));
 
+    ApplePaySessionPaymentRequest::Requester requester;
+    if (!decoder.decodeEnum(requester))
+        return false;
+    request.setRequester(requester);
+
     return true;
 }
 

Modified: trunk/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (226181 => 226182)


--- trunk/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2017-12-20 16:52:59 UTC (rev 226181)
+++ trunk/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2017-12-20 17:11:29 UTC (rev 226182)
@@ -479,6 +479,19 @@
 }
 #endif
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101304) \
+    || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110300)
+static PKPaymentRequestAPIType toAPIType(WebCore::ApplePaySessionPaymentRequest::Requester requester)
+{
+    switch (requester) {
+    case WebCore::ApplePaySessionPaymentRequest::Requester::ApplePayJS:
+        return PKPaymentRequestAPITypeWebJS;
+    case WebCore::ApplePaySessionPaymentRequest::Requester::PaymentRequest:
+        return PKPaymentRequestAPITypeWebPaymentRequest;
+    }
+}
+#endif
+
 RetainPtr<PKPaymentRequest> toPKPaymentRequest(WebPageProxy& webPageProxy, const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLs, const WebCore::ApplePaySessionPaymentRequest& paymentRequest)
 {
     auto result = adoptNS([allocPKPaymentRequestInstance() init]);
@@ -494,6 +507,11 @@
     } else if (!linkIconURLs.isEmpty())
         [result setThumbnailURL:linkIconURLs[0]];
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101304) \
+    || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110300)
+    [result setAPIType:toAPIType(paymentRequest.requester())];
+#endif
+
     [result setCountryCode:paymentRequest.countryCode()];
     [result setCurrencyCode:paymentRequest.currencyCode()];
     [result setBillingContact:paymentRequest.billingContact().pkContact()];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to