Title: [202581] trunk/Source
Revision
202581
Author
[email protected]
Date
2016-06-28 12:31:10 -0700 (Tue, 28 Jun 2016)

Log Message

PaymentMerchantSession should wrap a PKPaymentMerchantSession
https://bugs.webkit.org/show_bug.cgi?id=159218
rdar://problem/26872118

Reviewed by Tim Horton.

Source/WebCore:

* Modules/applepay/ApplePaySession.cpp:
(WebCore::ApplePaySession::completeMerchantValidation):
Use PaymentMerchantSession::fromJS.

(WebCore::createMerchantSession): Deleted.

* Modules/applepay/PaymentCoordinator.h:
PaymentMerchantSession is now a class.

* Modules/applepay/PaymentCoordinatorClient.h:
PaymentMerchantSession is now a class.

* Modules/applepay/PaymentMerchantSession.h:
(WebCore::PaymentMerchantSession::PaymentMerchantSession):
(WebCore::PaymentMerchantSession::~PaymentMerchantSession):
(WebCore::PaymentMerchantSession::pkPaymentMerchantSession):
Store a PKPaymentMerchantSession in a RetainPtr inside the PaymentMerchantSession object.

* Modules/applepay/cocoa/PaymentMerchantSessionCocoa.mm:
(WebCore::PaymentMerchantSession::fromJS):
Convert the JS object to a PKPaymentMerchantSession and return a PaymentMerchantSession that wraps it.

* WebCore.xcodeproj/project.pbxproj:
Add new files.

* bindings/js/Dictionary.h:
(WebCore::Dictionary::initializerObject):
Add new getter.

Source/WebKit2:

* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::encode):
(IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::decode):
Use NSCoder.

* UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
PaymentMerchantSession is now a class.

* UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in:
PaymentMerchantSession is now a class.

* UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::WebPaymentCoordinatorProxy::platformCompleteMerchantValidation):
Just get the underlying PKPaymentMerchantSession from the PaymentMerchantSession object.
(WebKit::toPKPaymentMerchantSession): Deleted.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (202580 => 202581)


--- trunk/Source/WebCore/ChangeLog	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebCore/ChangeLog	2016-06-28 19:31:10 UTC (rev 202581)
@@ -1,3 +1,40 @@
+2016-06-28  Anders Carlsson  <[email protected]>
+
+        PaymentMerchantSession should wrap a PKPaymentMerchantSession
+        https://bugs.webkit.org/show_bug.cgi?id=159218
+        rdar://problem/26872118
+
+        Reviewed by Tim Horton.
+
+        * Modules/applepay/ApplePaySession.cpp:
+        (WebCore::ApplePaySession::completeMerchantValidation):
+        Use PaymentMerchantSession::fromJS.
+
+        (WebCore::createMerchantSession): Deleted.
+
+        * Modules/applepay/PaymentCoordinator.h:
+        PaymentMerchantSession is now a class.
+
+        * Modules/applepay/PaymentCoordinatorClient.h:
+        PaymentMerchantSession is now a class.
+
+        * Modules/applepay/PaymentMerchantSession.h:
+        (WebCore::PaymentMerchantSession::PaymentMerchantSession):
+        (WebCore::PaymentMerchantSession::~PaymentMerchantSession):
+        (WebCore::PaymentMerchantSession::pkPaymentMerchantSession):
+        Store a PKPaymentMerchantSession in a RetainPtr inside the PaymentMerchantSession object.
+
+        * Modules/applepay/cocoa/PaymentMerchantSessionCocoa.mm:
+        (WebCore::PaymentMerchantSession::fromJS):
+        Convert the JS object to a PKPaymentMerchantSession and return a PaymentMerchantSession that wraps it.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Add new files.
+
+        * bindings/js/Dictionary.h:
+        (WebCore::Dictionary::initializerObject):
+        Add new getter.
+
 2016-06-28  Brian Burg  <[email protected]>
 
         RunLoop::Timer should use constructor templates instead of class templates

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp (202580 => 202581)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2016-06-28 19:31:10 UTC (rev 202581)
@@ -808,47 +808,6 @@
     didReachFinalState();
 }
 
-static Optional<PaymentMerchantSession> createMerchantSession(DOMWindow& window, const Dictionary& merchantSessionDictionary)
-{
-    auto merchantIdentifier = merchantSessionDictionary.get<String>("merchantIdentifier");
-    if (!merchantIdentifier) {
-        window.printErrorMessage("Missing merchant identifier.");
-        return Nullopt;
-    }
-
-    auto sessionIdentifier = merchantSessionDictionary.get<String>("merchantSessionIdentifier");
-    if (!sessionIdentifier) {
-        window.printErrorMessage("Missing merchant session identifier.");
-        return Nullopt;
-    }
-
-    auto nonce = merchantSessionDictionary.get<String>("nonce");
-    if (!nonce) {
-        window.printErrorMessage("Missing nonce.");
-        return Nullopt;
-    }
-
-    auto domainName = merchantSessionDictionary.get<String>("domainName");
-    if (!domainName) {
-        window.printErrorMessage("Missing domain name.");
-        return Nullopt;
-    }
-
-    auto epochTimestamp = merchantSessionDictionary.get<uint64_t>("epochTimestamp");
-    if (!epochTimestamp) {
-        window.printErrorMessage("Missing epoch time stamp.");
-        return Nullopt;
-    }
-
-    auto signature = merchantSessionDictionary.get<String>("signature");
-    if (!signature) {
-        window.printErrorMessage("Missing signature.");
-        return Nullopt;
-    }
-
-    return PaymentMerchantSession { *merchantIdentifier, *sessionIdentifier, *nonce, *domainName, *epochTimestamp, *signature };
-}
-
 void ApplePaySession::completeMerchantValidation(const Dictionary& merchantSessionDictionary, ExceptionCode& ec)
 {
     if (!canCompleteMerchantValidation()) {
@@ -859,8 +818,10 @@
     auto& document = *downcast<Document>(scriptExecutionContext());
     auto& window = *document.domWindow();
 
-    auto merchantSession = createMerchantSession(window, merchantSessionDictionary);
+    String errorMessage;
+    auto merchantSession = PaymentMerchantSession::fromJS(*merchantSessionDictionary.execState(), merchantSessionDictionary.initializerObject(), errorMessage);
     if (!merchantSession) {
+        window.printErrorMessage(errorMessage);
         ec = INVALID_ACCESS_ERR;
         return;
     }

Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h (202580 => 202581)


--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h	2016-06-28 19:31:10 UTC (rev 202581)
@@ -36,10 +36,10 @@
 class Payment;
 class PaymentCoordinatorClient;
 class PaymentContact;
+class PaymentMerchantSession;
 class PaymentMethod;
 class URL;
 enum class PaymentAuthorizationStatus;
-struct PaymentMerchantSession;
 
 class PaymentCoordinator {
 public:

Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h (202580 => 202581)


--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h	2016-06-28 19:31:10 UTC (rev 202581)
@@ -33,9 +33,9 @@
 
 namespace WebCore {
 
+class PaymentMerchantSession;
 class URL;
 enum class PaymentAuthorizationStatus;
-struct PaymentMerchantSession;
 
 class PaymentCoordinatorClient {
 public:

Modified: trunk/Source/WebCore/Modules/applepay/PaymentMerchantSession.h (202580 => 202581)


--- trunk/Source/WebCore/Modules/applepay/PaymentMerchantSession.h	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebCore/Modules/applepay/PaymentMerchantSession.h	2016-06-28 19:31:10 UTC (rev 202581)
@@ -27,18 +27,39 @@
 
 #if ENABLE(APPLE_PAY)
 
-#include <wtf/text/WTFString.h>
+#include <wtf/Forward.h>
+#include <wtf/RetainPtr.h>
 
+namespace JSC {
+class ExecState;
+class JSValue;
+}
+
+OBJC_CLASS PKPaymentMerchantSession;
+
 namespace WebCore {
 
-// FIXME: This should be a wrapper class around a PKPaymentMerchantSession.
-struct PaymentMerchantSession {
-    String merchantIdentifier;
-    String sessionIdentifier;
-    String nonce;
-    String domainName;
-    uint64_t epochTimestamp;
-    String signature;
+class PaymentMerchantSession {
+public:
+    PaymentMerchantSession()
+    {
+    }
+
+    explicit PaymentMerchantSession(PKPaymentMerchantSession *pkPaymentMerchantSession)
+        : m_pkPaymentMerchantSession(pkPaymentMerchantSession)
+    {
+    }
+
+    ~PaymentMerchantSession()
+    {
+    }
+
+    static Optional<PaymentMerchantSession> fromJS(JSC::ExecState&, JSC::JSValue, String& errorMessage);
+
+    PKPaymentMerchantSession *pkPaymentMerchantSession() const { return m_pkPaymentMerchantSession.get(); }
+
+private:
+    RetainPtr<PKPaymentMerchantSession> m_pkPaymentMerchantSession;
 };
 
 }

Copied: trunk/Source/WebCore/Modules/applepay/cocoa/PaymentMerchantSessionCocoa.mm (from rev 202580, trunk/Source/WebCore/Modules/applepay/PaymentMerchantSession.h) (0 => 202581)


--- trunk/Source/WebCore/Modules/applepay/cocoa/PaymentMerchantSessionCocoa.mm	                        (rev 0)
+++ trunk/Source/WebCore/Modules/applepay/cocoa/PaymentMerchantSessionCocoa.mm	2016-06-28 19:31:10 UTC (rev 202581)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2016 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 "PaymentMerchantSession.h"
+
+#if ENABLE(APPLE_PAY)
+
+#import "SoftLinking.h"
+#import <PassKitCore/PKPaymentMerchantSession.h>
+#import <runtime/JSONObject.h>
+
+#if PLATFORM(MAC)
+SOFT_LINK_PRIVATE_FRAMEWORK(PassKit)
+#else
+SOFT_LINK_FRAMEWORK(PassKit)
+#endif
+
+SOFT_LINK_CLASS(PassKit, PKPaymentMerchantSession)
+
+namespace WebCore {
+
+Optional<PaymentMerchantSession> PaymentMerchantSession::fromJS(JSC::ExecState& state, JSC::JSValue value, String&)
+{
+    // FIXME: Don't round-trip using NSString.
+    auto jsonString = JSONStringify(&state, value, 0);
+    if (!jsonString)
+        return Nullopt;
+
+    auto dictionary = dynamic_objc_cast<NSDictionary>([NSJSONSerialization JSONObjectWithData:[(NSString *)jsonString dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil]);
+    if (!dictionary || ![dictionary isKindOfClass:[NSDictionary class]])
+        return Nullopt;
+
+    auto pkPaymentMerchantSession = adoptNS([allocPKPaymentMerchantSessionInstance() initWithDictionary:dictionary]);
+
+    return PaymentMerchantSession(pkPaymentMerchantSession.get());
+}
+
+}
+
+#endif

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (202580 => 202581)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-06-28 19:31:10 UTC (rev 202581)
@@ -895,6 +895,7 @@
 		1AD2316E0CD269E700C1F194 /* JSSQLTransactionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD2316D0CD269E700C1F194 /* JSSQLTransactionCustom.cpp */; };
 		1AD8F81B11CAB9E900E93E54 /* PlatformStrategies.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD8F81911CAB9E900E93E54 /* PlatformStrategies.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1AD8F81C11CAB9E900E93E54 /* PlatformStrategies.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD8F81A11CAB9E900E93E54 /* PlatformStrategies.cpp */; };
+		1ADA4A1C1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ADA4A1B1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm */; };
 		1AE00D59182DAC8D00087DD7 /* KeyedCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE00D57182DAC8D00087DD7 /* KeyedCoding.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1AE2AA1E0A1CDAB400B42B25 /* JSHTMLAreaElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE2AA0A0A1CDAB300B42B25 /* JSHTMLAreaElement.cpp */; };
 		1AE2AA1F0A1CDAB400B42B25 /* JSHTMLAreaElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE2AA0B0A1CDAB300B42B25 /* JSHTMLAreaElement.h */; };
@@ -8420,6 +8421,7 @@
 		1AD2316D0CD269E700C1F194 /* JSSQLTransactionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSQLTransactionCustom.cpp; sourceTree = "<group>"; };
 		1AD8F81911CAB9E900E93E54 /* PlatformStrategies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformStrategies.h; sourceTree = "<group>"; };
 		1AD8F81A11CAB9E900E93E54 /* PlatformStrategies.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformStrategies.cpp; sourceTree = "<group>"; };
+		1ADA4A1B1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PaymentMerchantSessionCocoa.mm; sourceTree = "<group>"; };
 		1AE00D57182DAC8D00087DD7 /* KeyedCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedCoding.h; sourceTree = "<group>"; };
 		1AE2A9F00A1CDA5700B42B25 /* HTMLAreaElement.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = HTMLAreaElement.idl; sourceTree = "<group>"; };
 		1AE2A9F10A1CDA5700B42B25 /* HTMLBaseFontElement.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = HTMLBaseFontElement.idl; sourceTree = "<group>"; };
@@ -16298,10 +16300,10 @@
 			children = (
 				1A8A64691D19FF8700D0E00F /* PaymentCocoa.mm */,
 				1A8A646A1D19FF8700D0E00F /* PaymentContactCocoa.mm */,
+				1ADA4A1B1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm */,
 				1A8A646B1D19FF8700D0E00F /* PaymentMethodCocoa.mm */,
 			);
-			name = cocoa;
-			path = applepay/cocoa;
+			path = cocoa;
 			sourceTree = "<group>";
 		};
 		1A88A90117553CD7000C74F9 /* forms */ = {
@@ -31733,6 +31735,7 @@
 				BCEC01BD0C274DAC009F4EC9 /* Screen.cpp in Sources */,
 				A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */,
 				A5F8CD131D18F33100AC0E53 /* PageHeapAgent.cpp in Sources */,
+				1ADA4A1C1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm in Sources */,
 				41F1D2200EF35C2A00DA8753 /* ScriptCachedFrameData.cpp in Sources */,
 				93B70D6F09EB0C7C009D8468 /* ScriptController.cpp in Sources */,
 				A83E1C740E49042C00140B9C /* ScriptControllerMac.mm in Sources */,

Modified: trunk/Source/WebCore/bindings/js/Dictionary.h (202580 => 202581)


--- trunk/Source/WebCore/bindings/js/Dictionary.h	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebCore/bindings/js/Dictionary.h	2016-06-28 19:31:10 UTC (rev 202581)
@@ -61,6 +61,7 @@
     bool getWithUndefinedOrNullCheck(const char* propertyName, String& value) const;
 
     JSC::ExecState* execState() const { return m_dictionary.execState(); }
+    JSC::JSObject* initializerObject() const { return m_dictionary.initializerObject(); }
 
 private:
     template<typename T> JSC::JSObject* asJSObject(T*) const;

Modified: trunk/Source/WebKit2/ChangeLog (202580 => 202581)


--- trunk/Source/WebKit2/ChangeLog	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebKit2/ChangeLog	2016-06-28 19:31:10 UTC (rev 202581)
@@ -1,3 +1,27 @@
+2016-06-28  Anders Carlsson  <[email protected]>
+
+        PaymentMerchantSession should wrap a PKPaymentMerchantSession
+        https://bugs.webkit.org/show_bug.cgi?id=159218
+        rdar://problem/26872118
+
+        Reviewed by Tim Horton.
+
+        * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+        (IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::encode):
+        (IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::decode):
+        Use NSCoder.
+
+        * UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
+        PaymentMerchantSession is now a class.
+
+        * UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in:
+        PaymentMerchantSession is now a class.
+
+        * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (WebKit::WebPaymentCoordinatorProxy::platformCompleteMerchantValidation):
+        Just get the underlying PKPaymentMerchantSession from the PaymentMerchantSession object.
+        (WebKit::toPKPaymentMerchantSession): Deleted.
+
 2016-06-28  Brian Burg  <[email protected]>
 
         RunLoop::Timer should use constructor templates instead of class templates

Modified: trunk/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (202580 => 202581)


--- trunk/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm	2016-06-28 19:31:10 UTC (rev 202581)
@@ -41,6 +41,7 @@
 SOFT_LINK_CLASS(PassKit, PKContact);
 SOFT_LINK_CLASS(PassKit, PKPayment);
 SOFT_LINK_CLASS(PassKit, PKPaymentMethod);
+SOFT_LINK_CLASS(PassKit, PKPaymentMerchantSession);
 
 using namespace WebCore;
 
@@ -116,29 +117,36 @@
 
 void ArgumentCoder<WebCore::PaymentMerchantSession>::encode(ArgumentEncoder& encoder, const WebCore::PaymentMerchantSession& paymentMerchantSession)
 {
-    encoder << paymentMerchantSession.merchantIdentifier;
-    encoder << paymentMerchantSession.sessionIdentifier;
-    encoder << paymentMerchantSession.nonce;
-    encoder << paymentMerchantSession.domainName;
-    encoder << paymentMerchantSession.epochTimestamp;
-    encoder << paymentMerchantSession.signature;
+    auto data = "" alloc] init]);
+    auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
+
+    [archiver setRequiresSecureCoding:YES];
+
+    [archiver encodeObject:paymentMerchantSession.pkPaymentMerchantSession() forKey:NSKeyedArchiveRootObjectKey];
+    [archiver finishEncoding];
+
+    encoder << DataReference(static_cast<const uint8_t*>([data bytes]), [data length]);
 }
 
 bool ArgumentCoder<WebCore::PaymentMerchantSession>::decode(ArgumentDecoder& decoder, WebCore::PaymentMerchantSession& paymentMerchantSession)
 {
-    if (!decoder.decode(paymentMerchantSession.merchantIdentifier))
+    IPC::DataReference dataReference;
+    if (!decoder.decode(dataReference))
         return false;
-    if (!decoder.decode(paymentMerchantSession.sessionIdentifier))
+
+    auto data = "" alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(dataReference.data())) length:dataReference.size() freeWhenDone:NO]);
+    auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:data.get()]);
+    [unarchiver setRequiresSecureCoding:YES];
+    @try {
+        PKPaymentMerchantSession *pkPaymentMerchantSession = [unarchiver decodeObjectOfClass:getPKPaymentMerchantSessionClass() forKey:NSKeyedArchiveRootObjectKey];
+        paymentMerchantSession = PaymentMerchantSession(pkPaymentMerchantSession);
+    } @catch (NSException *exception) {
+        LOG_ERROR("Failed to decode PKPaymentMerchantSession: %@", exception);
         return false;
-    if (!decoder.decode(paymentMerchantSession.nonce))
-        return false;
-    if (!decoder.decode(paymentMerchantSession.domainName))
-        return false;
-    if (!decoder.decode(paymentMerchantSession.epochTimestamp))
-        return false;
-    if (!decoder.decode(paymentMerchantSession.signature))
-        return false;
+    }
 
+    [unarchiver finishDecoding];
+
     return true;
 }
 

Modified: trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h (202580 => 202581)


--- trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h	2016-06-28 19:31:10 UTC (rev 202581)
@@ -41,9 +41,9 @@
 enum class PaymentAuthorizationStatus;
 class Payment;
 class PaymentContact;
+class PaymentMerchantSession;
 class PaymentMethod;
 class URL;
-struct PaymentMerchantSession;
 }
 
 OBJC_CLASS NSWindow;

Modified: trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in (202580 => 202581)


--- trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in	2016-06-28 19:31:10 UTC (rev 202581)
@@ -30,7 +30,7 @@
     CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName, uint64_t requestID)
 
     ShowPaymentUI(String originatingURLString, Vector<String> linkIconURLStrings, WebCore::PaymentRequest paymentRequest)
-    CompleteMerchantValidation(struct WebCore::PaymentMerchantSession paymentMerchantSession);
+    CompleteMerchantValidation(WebCore::PaymentMerchantSession paymentMerchantSession);
     CompleteShippingMethodSelection(uint32_t opaqueStatus, Optional<WebCore::PaymentRequest::TotalAndLineItems> newTotalAndItems)
     CompleteShippingContactSelection(uint32_t opaqueStatus, Vector<WebCore::PaymentRequest::ShippingMethod> newShippingMethods, Optional<WebCore::PaymentRequest::TotalAndLineItems> newTotalAndItems)
     CompletePaymentMethodSelection(Optional<WebCore::PaymentRequest::TotalAndLineItems> newTotalAndItems)

Modified: trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (202580 => 202581)


--- trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2016-06-28 19:10:31 UTC (rev 202580)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2016-06-28 19:31:10 UTC (rev 202581)
@@ -330,20 +330,6 @@
     return result;
 }
 
-static RetainPtr<PKPaymentMerchantSession> toPKPaymentMerchantSession(const WebCore::PaymentMerchantSession& paymentMerchantSession)
-{
-    NSDictionary *dictionary = @{
-        @"merchantSessionIdentifier" : paymentMerchantSession.sessionIdentifier,
-        @"merchantIdentifier" : paymentMerchantSession.merchantIdentifier,
-        @"nOnce" : paymentMerchantSession.nonce,
-        @"epochTimestamp" : @(static_cast<NSUInteger>(paymentMerchantSession.epochTimestamp)),
-        @"FQDN" : paymentMerchantSession.domainName,
-        @"signature" : paymentMerchantSession.signature,
-    };
-
-    return adoptNS([allocPKPaymentMerchantSessionInstance() initWithDictionary:dictionary]);
-}
-
 RetainPtr<PKPaymentRequest> toPKPaymentRequest(const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest& paymentRequest)
 {
     auto result = adoptNS([allocPKPaymentRequestInstance() init]);
@@ -434,7 +420,7 @@
     ASSERT(m_paymentAuthorizationViewController);
     ASSERT(m_paymentAuthorizationViewControllerDelegate);
 
-    m_paymentAuthorizationViewControllerDelegate->_sessionBlock(toPKPaymentMerchantSession(paymentMerchantSession).get(), nullptr);
+    m_paymentAuthorizationViewControllerDelegate->_sessionBlock(paymentMerchantSession.pkPaymentMerchantSession(), nullptr);
     m_paymentAuthorizationViewControllerDelegate->_sessionBlock = nullptr;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to