<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[202581] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/202581">202581</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2016-06-28 12:31:10 -0700 (Tue, 28 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>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&lt;WebCore::PaymentMerchantSession&gt;::encode):
(IPC::ArgumentCoder&lt;WebCore::PaymentMerchantSession&gt;::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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayApplePaySessioncpp">trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayPaymentCoordinatorh">trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayPaymentCoordinatorClienth">trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayPaymentMerchantSessionh">trunk/Source/WebCore/Modules/applepay/PaymentMerchantSession.h</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsDictionaryh">trunk/Source/WebCore/bindings/js/Dictionary.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedCocoaWebCoreArgumentCodersCocoamm">trunk/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessApplePayWebPaymentCoordinatorProxyh">trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessApplePayWebPaymentCoordinatorProxymessagesin">trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessApplePaycocoaWebPaymentCoordinatorProxyCocoamm">trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreModulesapplepaycocoaPaymentMerchantSessionCocoamm">trunk/Source/WebCore/Modules/applepay/cocoa/PaymentMerchantSessionCocoa.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2016-06-28  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        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.
+
</ins><span class="cx"> 2016-06-28  Brian Burg  &lt;bburg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         RunLoop::Timer should use constructor templates instead of class templates
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayApplePaySessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -808,47 +808,6 @@
</span><span class="cx">     didReachFinalState();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Optional&lt;PaymentMerchantSession&gt; createMerchantSession(DOMWindow&amp; window, const Dictionary&amp; merchantSessionDictionary)
-{
-    auto merchantIdentifier = merchantSessionDictionary.get&lt;String&gt;(&quot;merchantIdentifier&quot;);
-    if (!merchantIdentifier) {
-        window.printErrorMessage(&quot;Missing merchant identifier.&quot;);
-        return Nullopt;
-    }
-
-    auto sessionIdentifier = merchantSessionDictionary.get&lt;String&gt;(&quot;merchantSessionIdentifier&quot;);
-    if (!sessionIdentifier) {
-        window.printErrorMessage(&quot;Missing merchant session identifier.&quot;);
-        return Nullopt;
-    }
-
-    auto nonce = merchantSessionDictionary.get&lt;String&gt;(&quot;nonce&quot;);
-    if (!nonce) {
-        window.printErrorMessage(&quot;Missing nonce.&quot;);
-        return Nullopt;
-    }
-
-    auto domainName = merchantSessionDictionary.get&lt;String&gt;(&quot;domainName&quot;);
-    if (!domainName) {
-        window.printErrorMessage(&quot;Missing domain name.&quot;);
-        return Nullopt;
-    }
-
-    auto epochTimestamp = merchantSessionDictionary.get&lt;uint64_t&gt;(&quot;epochTimestamp&quot;);
-    if (!epochTimestamp) {
-        window.printErrorMessage(&quot;Missing epoch time stamp.&quot;);
-        return Nullopt;
-    }
-
-    auto signature = merchantSessionDictionary.get&lt;String&gt;(&quot;signature&quot;);
-    if (!signature) {
-        window.printErrorMessage(&quot;Missing signature.&quot;);
-        return Nullopt;
-    }
-
-    return PaymentMerchantSession { *merchantIdentifier, *sessionIdentifier, *nonce, *domainName, *epochTimestamp, *signature };
-}
-
</del><span class="cx"> void ApplePaySession::completeMerchantValidation(const Dictionary&amp; merchantSessionDictionary, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     if (!canCompleteMerchantValidation()) {
</span><span class="lines">@@ -859,8 +818,10 @@
</span><span class="cx">     auto&amp; document = *downcast&lt;Document&gt;(scriptExecutionContext());
</span><span class="cx">     auto&amp; window = *document.domWindow();
</span><span class="cx"> 
</span><del>-    auto merchantSession = createMerchantSession(window, merchantSessionDictionary);
</del><ins>+    String errorMessage;
+    auto merchantSession = PaymentMerchantSession::fromJS(*merchantSessionDictionary.execState(), merchantSessionDictionary.initializerObject(), errorMessage);
</ins><span class="cx">     if (!merchantSession) {
</span><ins>+        window.printErrorMessage(errorMessage);
</ins><span class="cx">         ec = INVALID_ACCESS_ERR;
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayPaymentCoordinatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -36,10 +36,10 @@
</span><span class="cx"> class Payment;
</span><span class="cx"> class PaymentCoordinatorClient;
</span><span class="cx"> class PaymentContact;
</span><ins>+class PaymentMerchantSession;
</ins><span class="cx"> class PaymentMethod;
</span><span class="cx"> class URL;
</span><span class="cx"> enum class PaymentAuthorizationStatus;
</span><del>-struct PaymentMerchantSession;
</del><span class="cx"> 
</span><span class="cx"> class PaymentCoordinator {
</span><span class="cx"> public:
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayPaymentCoordinatorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -33,9 +33,9 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class PaymentMerchantSession;
</ins><span class="cx"> class URL;
</span><span class="cx"> enum class PaymentAuthorizationStatus;
</span><del>-struct PaymentMerchantSession;
</del><span class="cx"> 
</span><span class="cx"> class PaymentCoordinatorClient {
</span><span class="cx"> public:
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayPaymentMerchantSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/PaymentMerchantSession.h (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -27,18 +27,39 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(APPLE_PAY)
</span><span class="cx"> 
</span><del>-#include &lt;wtf/text/WTFString.h&gt;
</del><ins>+#include &lt;wtf/Forward.h&gt;
+#include &lt;wtf/RetainPtr.h&gt;
</ins><span class="cx"> 
</span><ins>+namespace JSC {
+class ExecState;
+class JSValue;
+}
+
+OBJC_CLASS PKPaymentMerchantSession;
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-// 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;
</del><ins>+class PaymentMerchantSession {
+public:
+    PaymentMerchantSession()
+    {
+    }
+
+    explicit PaymentMerchantSession(PKPaymentMerchantSession *pkPaymentMerchantSession)
+        : m_pkPaymentMerchantSession(pkPaymentMerchantSession)
+    {
+    }
+
+    ~PaymentMerchantSession()
+    {
+    }
+
+    static Optional&lt;PaymentMerchantSession&gt; fromJS(JSC::ExecState&amp;, JSC::JSValue, String&amp; errorMessage);
+
+    PKPaymentMerchantSession *pkPaymentMerchantSession() const { return m_pkPaymentMerchantSession.get(); }
+
+private:
+    RetainPtr&lt;PKPaymentMerchantSession&gt; m_pkPaymentMerchantSession;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepaycocoaPaymentMerchantSessionCocoammfromrev202580trunkSourceWebCoreModulesapplepayPaymentMerchantSessionh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/applepay/cocoa/PaymentMerchantSessionCocoa.mm (from rev 202580, trunk/Source/WebCore/Modules/applepay/PaymentMerchantSession.h) (0 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+/*
+ * 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 &quot;config.h&quot;
+#import &quot;PaymentMerchantSession.h&quot;
+
+#if ENABLE(APPLE_PAY)
+
+#import &quot;SoftLinking.h&quot;
+#import &lt;PassKitCore/PKPaymentMerchantSession.h&gt;
+#import &lt;runtime/JSONObject.h&gt;
+
+#if PLATFORM(MAC)
+SOFT_LINK_PRIVATE_FRAMEWORK(PassKit)
+#else
+SOFT_LINK_FRAMEWORK(PassKit)
+#endif
+
+SOFT_LINK_CLASS(PassKit, PKPaymentMerchantSession)
+
+namespace WebCore {
+
+Optional&lt;PaymentMerchantSession&gt; PaymentMerchantSession::fromJS(JSC::ExecState&amp; state, JSC::JSValue value, String&amp;)
+{
+    // FIXME: Don't round-trip using NSString.
+    auto jsonString = JSONStringify(&amp;state, value, 0);
+    if (!jsonString)
+        return Nullopt;
+
+    auto dictionary = dynamic_objc_cast&lt;NSDictionary&gt;([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
</ins></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -895,6 +895,7 @@
</span><span class="cx">                 1AD2316E0CD269E700C1F194 /* JSSQLTransactionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD2316D0CD269E700C1F194 /* JSSQLTransactionCustom.cpp */; };
</span><span class="cx">                 1AD8F81B11CAB9E900E93E54 /* PlatformStrategies.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AD8F81911CAB9E900E93E54 /* PlatformStrategies.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1AD8F81C11CAB9E900E93E54 /* PlatformStrategies.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD8F81A11CAB9E900E93E54 /* PlatformStrategies.cpp */; };
</span><ins>+                1ADA4A1C1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ADA4A1B1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm */; };
</ins><span class="cx">                 1AE00D59182DAC8D00087DD7 /* KeyedCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE00D57182DAC8D00087DD7 /* KeyedCoding.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1AE2AA1E0A1CDAB400B42B25 /* JSHTMLAreaElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE2AA0A0A1CDAB300B42B25 /* JSHTMLAreaElement.cpp */; };
</span><span class="cx">                 1AE2AA1F0A1CDAB400B42B25 /* JSHTMLAreaElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE2AA0B0A1CDAB300B42B25 /* JSHTMLAreaElement.h */; };
</span><span class="lines">@@ -8420,6 +8421,7 @@
</span><span class="cx">                 1AD2316D0CD269E700C1F194 /* JSSQLTransactionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSQLTransactionCustom.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AD8F81911CAB9E900E93E54 /* PlatformStrategies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformStrategies.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AD8F81A11CAB9E900E93E54 /* PlatformStrategies.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformStrategies.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                1ADA4A1B1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PaymentMerchantSessionCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 1AE00D57182DAC8D00087DD7 /* KeyedCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedCoding.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AE2A9F00A1CDA5700B42B25 /* HTMLAreaElement.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = HTMLAreaElement.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AE2A9F10A1CDA5700B42B25 /* HTMLBaseFontElement.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = HTMLBaseFontElement.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -16298,10 +16300,10 @@
</span><span class="cx">                         children = (
</span><span class="cx">                                 1A8A64691D19FF8700D0E00F /* PaymentCocoa.mm */,
</span><span class="cx">                                 1A8A646A1D19FF8700D0E00F /* PaymentContactCocoa.mm */,
</span><ins>+                                1ADA4A1B1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm */,
</ins><span class="cx">                                 1A8A646B1D19FF8700D0E00F /* PaymentMethodCocoa.mm */,
</span><span class="cx">                         );
</span><del>-                        name = cocoa;
-                        path = applepay/cocoa;
</del><ins>+                        path = cocoa;
</ins><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="cx">                 };
</span><span class="cx">                 1A88A90117553CD7000C74F9 /* forms */ = {
</span><span class="lines">@@ -31733,6 +31735,7 @@
</span><span class="cx">                                 BCEC01BD0C274DAC009F4EC9 /* Screen.cpp in Sources */,
</span><span class="cx">                                 A84D82C211D3474800972990 /* ScriptableDocumentParser.cpp in Sources */,
</span><span class="cx">                                 A5F8CD131D18F33100AC0E53 /* PageHeapAgent.cpp in Sources */,
</span><ins>+                                1ADA4A1C1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm in Sources */,
</ins><span class="cx">                                 41F1D2200EF35C2A00DA8753 /* ScriptCachedFrameData.cpp in Sources */,
</span><span class="cx">                                 93B70D6F09EB0C7C009D8468 /* ScriptController.cpp in Sources */,
</span><span class="cx">                                 A83E1C740E49042C00140B9C /* ScriptControllerMac.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsDictionaryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/Dictionary.h (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx">     bool getWithUndefinedOrNullCheck(const char* propertyName, String&amp; value) const;
</span><span class="cx"> 
</span><span class="cx">     JSC::ExecState* execState() const { return m_dictionary.execState(); }
</span><ins>+    JSC::JSObject* initializerObject() const { return m_dictionary.initializerObject(); }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     template&lt;typename T&gt; JSC::JSObject* asJSObject(T*) const;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-06-28  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        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&lt;WebCore::PaymentMerchantSession&gt;::encode):
+        (IPC::ArgumentCoder&lt;WebCore::PaymentMerchantSession&gt;::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.
+
</ins><span class="cx"> 2016-06-28  Brian Burg  &lt;bburg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         RunLoop::Timer should use constructor templates instead of class templates
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCocoaWebCoreArgumentCodersCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> SOFT_LINK_CLASS(PassKit, PKContact);
</span><span class="cx"> SOFT_LINK_CLASS(PassKit, PKPayment);
</span><span class="cx"> SOFT_LINK_CLASS(PassKit, PKPaymentMethod);
</span><ins>+SOFT_LINK_CLASS(PassKit, PKPaymentMerchantSession);
</ins><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -116,29 +117,36 @@
</span><span class="cx"> 
</span><span class="cx"> void ArgumentCoder&lt;WebCore::PaymentMerchantSession&gt;::encode(ArgumentEncoder&amp; encoder, const WebCore::PaymentMerchantSession&amp; paymentMerchantSession)
</span><span class="cx"> {
</span><del>-    encoder &lt;&lt; paymentMerchantSession.merchantIdentifier;
-    encoder &lt;&lt; paymentMerchantSession.sessionIdentifier;
-    encoder &lt;&lt; paymentMerchantSession.nonce;
-    encoder &lt;&lt; paymentMerchantSession.domainName;
-    encoder &lt;&lt; paymentMerchantSession.epochTimestamp;
-    encoder &lt;&lt; paymentMerchantSession.signature;
</del><ins>+    auto data = adoptNS([[NSMutableData alloc] init]);
+    auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
+
+    [archiver setRequiresSecureCoding:YES];
+
+    [archiver encodeObject:paymentMerchantSession.pkPaymentMerchantSession() forKey:NSKeyedArchiveRootObjectKey];
+    [archiver finishEncoding];
+
+    encoder &lt;&lt; DataReference(static_cast&lt;const uint8_t*&gt;([data bytes]), [data length]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ArgumentCoder&lt;WebCore::PaymentMerchantSession&gt;::decode(ArgumentDecoder&amp; decoder, WebCore::PaymentMerchantSession&amp; paymentMerchantSession)
</span><span class="cx"> {
</span><del>-    if (!decoder.decode(paymentMerchantSession.merchantIdentifier))
</del><ins>+    IPC::DataReference dataReference;
+    if (!decoder.decode(dataReference))
</ins><span class="cx">         return false;
</span><del>-    if (!decoder.decode(paymentMerchantSession.sessionIdentifier))
</del><ins>+
+    auto data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast&lt;void*&gt;(static_cast&lt;const void*&gt;(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(&quot;Failed to decode PKPaymentMerchantSession: %@&quot;, exception);
</ins><span class="cx">         return false;
</span><del>-    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;
</del><ins>+    }
</ins><span class="cx"> 
</span><ins>+    [unarchiver finishDecoding];
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessApplePayWebPaymentCoordinatorProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -41,9 +41,9 @@
</span><span class="cx"> enum class PaymentAuthorizationStatus;
</span><span class="cx"> class Payment;
</span><span class="cx"> class PaymentContact;
</span><ins>+class PaymentMerchantSession;
</ins><span class="cx"> class PaymentMethod;
</span><span class="cx"> class URL;
</span><del>-struct PaymentMerchantSession;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> OBJC_CLASS NSWindow;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessApplePayWebPaymentCoordinatorProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx">     CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName, uint64_t requestID)
</span><span class="cx"> 
</span><span class="cx">     ShowPaymentUI(String originatingURLString, Vector&lt;String&gt; linkIconURLStrings, WebCore::PaymentRequest paymentRequest)
</span><del>-    CompleteMerchantValidation(struct WebCore::PaymentMerchantSession paymentMerchantSession);
</del><ins>+    CompleteMerchantValidation(WebCore::PaymentMerchantSession paymentMerchantSession);
</ins><span class="cx">     CompleteShippingMethodSelection(uint32_t opaqueStatus, Optional&lt;WebCore::PaymentRequest::TotalAndLineItems&gt; newTotalAndItems)
</span><span class="cx">     CompleteShippingContactSelection(uint32_t opaqueStatus, Vector&lt;WebCore::PaymentRequest::ShippingMethod&gt; newShippingMethods, Optional&lt;WebCore::PaymentRequest::TotalAndLineItems&gt; newTotalAndItems)
</span><span class="cx">     CompletePaymentMethodSelection(Optional&lt;WebCore::PaymentRequest::TotalAndLineItems&gt; newTotalAndItems)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessApplePaycocoaWebPaymentCoordinatorProxyCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (202580 => 202581)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -330,20 +330,6 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static RetainPtr&lt;PKPaymentMerchantSession&gt; toPKPaymentMerchantSession(const WebCore::PaymentMerchantSession&amp; paymentMerchantSession)
-{
-    NSDictionary *dictionary = @{
-        @&quot;merchantSessionIdentifier&quot; : paymentMerchantSession.sessionIdentifier,
-        @&quot;merchantIdentifier&quot; : paymentMerchantSession.merchantIdentifier,
-        @&quot;nOnce&quot; : paymentMerchantSession.nonce,
-        @&quot;epochTimestamp&quot; : @(static_cast&lt;NSUInteger&gt;(paymentMerchantSession.epochTimestamp)),
-        @&quot;FQDN&quot; : paymentMerchantSession.domainName,
-        @&quot;signature&quot; : paymentMerchantSession.signature,
-    };
-
-    return adoptNS([allocPKPaymentMerchantSessionInstance() initWithDictionary:dictionary]);
-}
-
</del><span class="cx"> RetainPtr&lt;PKPaymentRequest&gt; toPKPaymentRequest(const WebCore::URL&amp; originatingURL, const Vector&lt;WebCore::URL&gt;&amp; linkIconURLs, const WebCore::PaymentRequest&amp; paymentRequest)
</span><span class="cx"> {
</span><span class="cx">     auto result = adoptNS([allocPKPaymentRequestInstance() init]);
</span><span class="lines">@@ -434,7 +420,7 @@
</span><span class="cx">     ASSERT(m_paymentAuthorizationViewController);
</span><span class="cx">     ASSERT(m_paymentAuthorizationViewControllerDelegate);
</span><span class="cx"> 
</span><del>-    m_paymentAuthorizationViewControllerDelegate-&gt;_sessionBlock(toPKPaymentMerchantSession(paymentMerchantSession).get(), nullptr);
</del><ins>+    m_paymentAuthorizationViewControllerDelegate-&gt;_sessionBlock(paymentMerchantSession.pkPaymentMerchantSession(), nullptr);
</ins><span class="cx">     m_paymentAuthorizationViewControllerDelegate-&gt;_sessionBlock = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>