<!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<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.</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 <andersca@apple.com>
+
+ 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 <bburg@apple.com>
</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<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 };
-}
-
</del><span class="cx"> void ApplePaySession::completeMerchantValidation(const Dictionary& merchantSessionDictionary, ExceptionCode& ec)
</span><span class="cx"> {
</span><span class="cx"> if (!canCompleteMerchantValidation()) {
</span><span class="lines">@@ -859,8 +818,10 @@
</span><span class="cx"> auto& document = *downcast<Document>(scriptExecutionContext());
</span><span class="cx"> auto& 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 <wtf/text/WTFString.h>
</del><ins>+#include <wtf/Forward.h>
+#include <wtf/RetainPtr.h>
</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<PaymentMerchantSession> fromJS(JSC::ExecState&, JSC::JSValue, String& errorMessage);
+
+ PKPaymentMerchantSession *pkPaymentMerchantSession() const { return m_pkPaymentMerchantSession.get(); }
+
+private:
+ RetainPtr<PKPaymentMerchantSession> 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 "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
</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 = "<group>"; };
</span><span class="cx">                 1AD8F81911CAB9E900E93E54 /* PlatformStrategies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformStrategies.h; sourceTree = "<group>"; };
</span><span class="cx">                 1AD8F81A11CAB9E900E93E54 /* PlatformStrategies.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformStrategies.cpp; sourceTree = "<group>"; };
</span><ins>+                1ADA4A1B1D22F2C0005A9A15 /* PaymentMerchantSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PaymentMerchantSessionCocoa.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 1AE00D57182DAC8D00087DD7 /* KeyedCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedCoding.h; sourceTree = "<group>"; };
</span><span class="cx">                 1AE2A9F00A1CDA5700B42B25 /* HTMLAreaElement.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = HTMLAreaElement.idl; sourceTree = "<group>"; };
</span><span class="cx">                 1AE2A9F10A1CDA5700B42B25 /* HTMLBaseFontElement.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = HTMLBaseFontElement.idl; sourceTree = "<group>"; };
</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 = "<group>";
</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& 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<typename T> 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 <andersca@apple.com>
+
+ 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.
+
</ins><span class="cx"> 2016-06-28 Brian Burg <bburg@apple.com>
</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<WebCore::PaymentMerchantSession>::encode(ArgumentEncoder& encoder, const WebCore::PaymentMerchantSession& paymentMerchantSession)
</span><span class="cx"> {
</span><del>- encoder << paymentMerchantSession.merchantIdentifier;
- encoder << paymentMerchantSession.sessionIdentifier;
- encoder << paymentMerchantSession.nonce;
- encoder << paymentMerchantSession.domainName;
- encoder << paymentMerchantSession.epochTimestamp;
- encoder << 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 << DataReference(static_cast<const uint8_t*>([data bytes]), [data length]);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool ArgumentCoder<WebCore::PaymentMerchantSession>::decode(ArgumentDecoder& decoder, WebCore::PaymentMerchantSession& 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<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);
</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<String> 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<WebCore::PaymentRequest::TotalAndLineItems> newTotalAndItems)
</span><span class="cx"> CompleteShippingContactSelection(uint32_t opaqueStatus, Vector<WebCore::PaymentRequest::ShippingMethod> newShippingMethods, Optional<WebCore::PaymentRequest::TotalAndLineItems> newTotalAndItems)
</span><span class="cx"> CompletePaymentMethodSelection(Optional<WebCore::PaymentRequest::TotalAndLineItems> 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<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]);
-}
-
</del><span class="cx"> RetainPtr<PKPaymentRequest> toPKPaymentRequest(const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLs, const WebCore::PaymentRequest& 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->_sessionBlock(toPKPaymentMerchantSession(paymentMerchantSession).get(), nullptr);
</del><ins>+ m_paymentAuthorizationViewControllerDelegate->_sessionBlock(paymentMerchantSession.pkPaymentMerchantSession(), nullptr);
</ins><span class="cx"> m_paymentAuthorizationViewControllerDelegate->_sessionBlock = nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>