Title: [213609] trunk/Source/WebKit2
- Revision
- 213609
- Author
- ander...@apple.com
- Date
- 2017-03-08 16:43:31 -0800 (Wed, 08 Mar 2017)
Log Message
Clean up WebPaymentCoordinatorProxy
https://bugs.webkit.org/show_bug.cgi?id=169393
Part of rdar://problem/28880714.
Reviewed by Beth Dakin.
* UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewControllerDidFinish:]):
Move this to where it belongs.
(WebKit::toPKPaymentSummaryItems):
Add a new helper function.
(WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingMethodSelection):
(WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingContactSelection):
Use the new helper function.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (213608 => 213609)
--- trunk/Source/WebKit2/ChangeLog 2017-03-09 00:34:36 UTC (rev 213608)
+++ trunk/Source/WebKit2/ChangeLog 2017-03-09 00:43:31 UTC (rev 213609)
@@ -1,3 +1,22 @@
+2017-03-08 Anders Carlsson <ander...@apple.com>
+
+ Clean up WebPaymentCoordinatorProxy
+ https://bugs.webkit.org/show_bug.cgi?id=169393
+ Part of rdar://problem/28880714.
+
+ Reviewed by Beth Dakin.
+
+ * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+ (-[WKPaymentAuthorizationViewControllerDelegate paymentAuthorizationViewControllerDidFinish:]):
+ Move this to where it belongs.
+
+ (WebKit::toPKPaymentSummaryItems):
+ Add a new helper function.
+
+ (WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingMethodSelection):
+ (WebKit::WebPaymentCoordinatorProxy::platformCompleteShippingContactSelection):
+ Use the new helper function.
+
2017-03-08 Brent Fulgham <bfulg...@apple.com>
[Mac][WK2] Whitelist a local cache needed by CFNetwork
Modified: trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (213608 => 213609)
--- trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm 2017-03-09 00:34:36 UTC (rev 213608)
+++ trunk/Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm 2017-03-09 00:43:31 UTC (rev 213609)
@@ -122,17 +122,6 @@
_webPaymentCoordinatorProxy->didAuthorizePayment(WebCore::Payment(payment));
}
-- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller
-{
- if (!_webPaymentCoordinatorProxy)
- return;
-
- if (!_didReachFinalState)
- _webPaymentCoordinatorProxy->didCancelPayment();
-
- _webPaymentCoordinatorProxy->hidePaymentUI();
-}
-
static WebCore::PaymentRequest::ShippingMethod toShippingMethod(PKShippingMethod *shippingMethod)
{
ASSERT(shippingMethod);
@@ -183,6 +172,17 @@
_webPaymentCoordinatorProxy->didSelectPaymentMethod(WebCore::PaymentMethod(paymentMethod));
}
+- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller
+{
+ if (!_webPaymentCoordinatorProxy)
+ return;
+
+ if (!_didReachFinalState)
+ _webPaymentCoordinatorProxy->didCancelPayment();
+
+ _webPaymentCoordinatorProxy->hidePaymentUI();
+}
+
@end
// FIXME: Once rdar://problem/24420024 has been fixed, import PKPaymentRequest_Private.h instead.
@@ -274,6 +274,20 @@
return [getPKPaymentSummaryItemClass() summaryItemWithLabel:lineItem.label amount:toDecimalNumber(lineItem.amount.value_or(0)).get() type:toPKPaymentSummaryItemType(lineItem.type)];
}
+static RetainPtr<NSArray> toPKPaymentSummaryItems(const WebCore::PaymentRequest::TotalAndLineItems& totalAndLineItems)
+{
+ auto paymentSummaryItems = adoptNS([[NSMutableArray alloc] init]);
+ for (auto& lineItem : totalAndLineItems.lineItems) {
+ if (auto summaryItem = toPKPaymentSummaryItem(lineItem))
+ [paymentSummaryItems addObject:summaryItem.get()];
+ }
+
+ if (auto totalItem = toPKPaymentSummaryItem(totalAndLineItems.total))
+ [paymentSummaryItems addObject:totalItem.get()];
+
+ return paymentSummaryItems;
+}
+
static PKMerchantCapability toPKMerchantCapabilities(const WebCore::PaymentRequest::MerchantCapabilities& merchantCapabilities)
{
PKMerchantCapability result = 0;
@@ -479,19 +493,9 @@
auto status = update ? update->status : WebCore::PaymentAuthorizationStatus::Success;
- if (update) {
- auto paymentSummaryItems = adoptNS([[NSMutableArray alloc] init]);
- for (auto& lineItem : update->newTotalAndLineItems.lineItems) {
- if (auto summaryItem = toPKPaymentSummaryItem(lineItem))
- [paymentSummaryItems addObject:summaryItem.get()];
- }
+ if (update)
+ m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems = toPKPaymentSummaryItems(update->newTotalAndLineItems);
- if (auto totalItem = toPKPaymentSummaryItem(update->newTotalAndLineItems.total))
- [paymentSummaryItems addObject:totalItem.get()];
-
- m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems = WTFMove(paymentSummaryItems);
- }
-
m_paymentAuthorizationViewControllerDelegate->_didSelectShippingMethodCompletion(toPKPaymentAuthorizationStatus(status), m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems.get());
m_paymentAuthorizationViewControllerDelegate->_didSelectShippingMethodCompletion = nullptr;
}
@@ -504,17 +508,8 @@
auto status = update ? update->status : WebCore::PaymentAuthorizationStatus::Success;
if (update) {
- auto paymentSummaryItems = adoptNS([[NSMutableArray alloc] init]);
- for (auto& lineItem : update->newTotalAndLineItems.lineItems) {
- if (auto summaryItem = toPKPaymentSummaryItem(lineItem))
- [paymentSummaryItems addObject:summaryItem.get()];
- }
+ m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems = toPKPaymentSummaryItems(update->newTotalAndLineItems);
- if (auto totalItem = toPKPaymentSummaryItem(update->newTotalAndLineItems.total))
- [paymentSummaryItems addObject:totalItem.get()];
-
- m_paymentAuthorizationViewControllerDelegate->_paymentSummaryItems = WTFMove(paymentSummaryItems);
-
auto shippingMethods = adoptNS([[NSMutableArray alloc] init]);
for (auto& shippingMethod : update->newShippingMethods)
[shippingMethods addObject:toPKShippingMethod(shippingMethod).get()];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes