Diff
Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (227334 => 227335)
--- branches/safari-605-branch/Source/WebCore/ChangeLog 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,61 @@
2018-01-22 Jason Marcell <jmarc...@apple.com>
+ Cherry-pick r227274. rdar://problem/36722660
+
+ 2018-01-20 Andy Estes <aes...@apple.com>
+
+ [Apple Pay] Stop eagerly loading PassKit.framework
+ https://bugs.webkit.org/show_bug.cgi?id=181911
+ <rdar://problem/36555369>
+
+ Reviewed by Tim Horton.
+
+ r226458 and r226123 added code that caused PassKit.framework to be eagerly loaded when
+ initializing a WKWebView. This is costly and should only be done when Apple Pay is first used.
+
+ To avoid eagerly loading PassKit, this patch does two things:
+
+ 1. Instead of sending the available payment networks as part of WebPageCreationParameters,
+ PaymentCoordinator asks for them using a syncrhonous message the first time they are needed.
+ 2. Instead of setting the Apple Pay preference to false when PassKit can't be loaded,
+ the following API entry points check for a missing PassKit and return false, or throw
+ exceptions, or reject promises:
+ - ApplePaySession.canMakePayments()
+ - ApplePaySession.canMakePaymentsWithActiveCard()
+ - ApplePaySession.openPaymentSetup()
+ - ApplePaySession.begin()
+
+ No new tests for (1), which causes no change in behavior. (2) was manually verified by
+ locally moving aside PassKit.framework, but that's not possible to do in an automated test.
+
+ * Modules/applepay/PaymentCoordinator.cpp:
+ (WebCore::PaymentCoordinator::PaymentCoordinator):
+ (WebCore::PaymentCoordinator::validatedPaymentNetwork const):
+ (WebCore::toHashSet): Deleted.
+ * Modules/applepay/PaymentCoordinator.h:
+ * Modules/applepay/PaymentCoordinatorClient.h:
+ * loader/EmptyClients.cpp:
+ * page/MainFrame.cpp:
+ (WebCore::MainFrame::MainFrame):
+
+ Removed PaymentCoordinator::m_availablePaymentNetworks and made
+ PaymentCoordinator::validatedPaymentNetwork() call
+ PaymentCoordinatorClient::validatedPaymentNetwork() instead.
+
+ * page/PageConfiguration.h:
+
+ Removed availablePaymentNetworks from PageConfiguration.
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::Internals):
+ * testing/MockPaymentCoordinator.cpp:
+ (WebCore::MockPaymentCoordinator::validatedPaymentNetwork):
+ * testing/MockPaymentCoordinator.h:
+
+ Implemented PaymentCoordinatorClient::validatedPaymentNetwork().
+
+2018-01-22 Jason Marcell <jmarc...@apple.com>
+
Cherry-pick r227272. rdar://problem/36722635
2018-01-20 Jer Noble <jer.no...@apple.com>
Modified: branches/safari-605-branch/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,17 +35,8 @@
namespace WebCore {
-static HashSet<String, ASCIICaseInsensitiveHash> toHashSet(const Vector<String>& values)
-{
- HashSet<String, ASCIICaseInsensitiveHash> result;
- for (auto& value : values)
- result.add(value);
- return result;
-}
-
-PaymentCoordinator::PaymentCoordinator(PaymentCoordinatorClient& client, const Vector<String>& availablePaymentNetworks)
+PaymentCoordinator::PaymentCoordinator(PaymentCoordinatorClient& client)
: m_client { client }
- , m_availablePaymentNetworks { toHashSet(availablePaymentNetworks) }
{
}
@@ -211,11 +202,7 @@
if (version < 3 && equalIgnoringASCIICase(paymentNetwork, "carteBancaire"))
return std::nullopt;
- auto result = m_availablePaymentNetworks.find(paymentNetwork);
- if (result == m_availablePaymentNetworks.end())
- return std::nullopt;
-
- return *result;
+ return m_client.validatedPaymentNetwork(paymentNetwork);
}
} // namespace WebCore
Modified: branches/safari-605-branch/Source/WebCore/Modules/applepay/PaymentCoordinator.h (227334 => 227335)
--- branches/safari-605-branch/Source/WebCore/Modules/applepay/PaymentCoordinator.h 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebCore/Modules/applepay/PaymentCoordinator.h 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,7 +29,6 @@
#include "ApplePaySessionPaymentRequest.h"
#include <wtf/Function.h>
-#include <wtf/text/StringHash.h>
namespace WebCore {
@@ -48,7 +47,7 @@
class PaymentCoordinator {
public:
- WEBCORE_EXPORT PaymentCoordinator(PaymentCoordinatorClient&, const Vector<String>& availablePaymentNetworks);
+ WEBCORE_EXPORT explicit PaymentCoordinator(PaymentCoordinatorClient&);
WEBCORE_EXPORT ~PaymentCoordinator();
bool supportsVersion(unsigned version) const;
@@ -80,7 +79,6 @@
PaymentCoordinatorClient& m_client;
RefPtr<PaymentSession> m_activeSession;
- HashSet<String, ASCIICaseInsensitiveHash> m_availablePaymentNetworks;
};
}
Modified: branches/safari-605-branch/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h (227334 => 227335)
--- branches/safari-605-branch/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -43,6 +43,7 @@
class PaymentCoordinatorClient {
public:
virtual bool supportsVersion(unsigned version) = 0;
+ virtual std::optional<String> validatedPaymentNetwork(const String&) = 0;
virtual bool canMakePayments() = 0;
virtual void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) = 0;
virtual void openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) = 0;
Modified: branches/safari-605-branch/Source/WebCore/loader/EmptyClients.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebCore/loader/EmptyClients.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebCore/loader/EmptyClients.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2006 Eric Seidel <e...@webkit.org>
- * Copyright (C) 2008-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-2018 Apple Inc. All rights reserved.
* Copyright (C) Research In Motion Limited 2011. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -306,6 +306,7 @@
class EmptyPaymentCoordinatorClient final : public PaymentCoordinatorClient {
bool supportsVersion(unsigned) final { return false; }
+ std::optional<String> validatedPaymentNetwork(const String&) final { return std::nullopt; }
bool canMakePayments() final { return false; }
void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&& completionHandler) final { callOnMainThread([completionHandler = WTFMove(completionHandler)] { completionHandler(false); }); }
void openPaymentSetup(const String&, const String&, WTF::Function<void(bool)>&& completionHandler) final { callOnMainThread([completionHandler = WTFMove(completionHandler)] { completionHandler(false); }); }
Modified: branches/safari-605-branch/Source/WebCore/page/MainFrame.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebCore/page/MainFrame.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebCore/page/MainFrame.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -49,7 +49,7 @@
, m_recentWheelEventDeltaFilter(WheelEventDeltaFilter::create())
, m_pageOverlayController(std::make_unique<PageOverlayController>(*this))
#if ENABLE(APPLE_PAY)
- , m_paymentCoordinator(std::make_unique<PaymentCoordinator>(*configuration.paymentCoordinatorClient, configuration.availablePaymentNetworks))
+ , m_paymentCoordinator(std::make_unique<PaymentCoordinator>(*configuration.paymentCoordinatorClient))
#endif
#if ENABLE(APPLICATION_MANIFEST)
, m_applicationManifest(configuration.applicationManifest)
Modified: branches/safari-605-branch/Source/WebCore/page/PageConfiguration.h (227334 => 227335)
--- branches/safari-605-branch/Source/WebCore/page/PageConfiguration.h 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebCore/page/PageConfiguration.h 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -78,7 +78,6 @@
InspectorClient* inspectorClient { nullptr };
#if ENABLE(APPLE_PAY)
PaymentCoordinatorClient* paymentCoordinatorClient { nullptr };
- Vector<String> availablePaymentNetworks;
#endif
#if ENABLE(APPLICATION_MANIFEST)
Modified: branches/safari-605-branch/Source/WebCore/testing/Internals.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebCore/testing/Internals.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebCore/testing/Internals.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
- * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -520,7 +520,7 @@
auto* frame = document.frame();
if (frame && frame->isMainFrame()) {
m_mockPaymentCoordinator = new MockPaymentCoordinator(frame->mainFrame());
- frame->mainFrame().setPaymentCoordinator(std::make_unique<PaymentCoordinator>(*m_mockPaymentCoordinator, m_mockPaymentCoordinator->availablePaymentNetworks()));
+ frame->mainFrame().setPaymentCoordinator(std::make_unique<PaymentCoordinator>(*m_mockPaymentCoordinator));
}
#endif
}
Modified: branches/safari-605-branch/Source/WebCore/testing/MockPaymentCoordinator.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebCore/testing/MockPaymentCoordinator.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebCore/testing/MockPaymentCoordinator.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,15 +41,15 @@
MockPaymentCoordinator::MockPaymentCoordinator(MainFrame& mainFrame)
: m_mainFrame { mainFrame }
{
- m_availablePaymentNetworks.append("amex");
- m_availablePaymentNetworks.append("carteBancaire");
- m_availablePaymentNetworks.append("chinaUnionPay");
- m_availablePaymentNetworks.append("discover");
- m_availablePaymentNetworks.append("interac");
- m_availablePaymentNetworks.append("jcb");
- m_availablePaymentNetworks.append("masterCard");
- m_availablePaymentNetworks.append("privateLabel");
- m_availablePaymentNetworks.append("visa");
+ m_availablePaymentNetworks.add("amex");
+ m_availablePaymentNetworks.add("carteBancaire");
+ m_availablePaymentNetworks.add("chinaUnionPay");
+ m_availablePaymentNetworks.add("discover");
+ m_availablePaymentNetworks.add("interac");
+ m_availablePaymentNetworks.add("jcb");
+ m_availablePaymentNetworks.add("masterCard");
+ m_availablePaymentNetworks.add("privateLabel");
+ m_availablePaymentNetworks.add("visa");
}
bool MockPaymentCoordinator::supportsVersion(unsigned version)
@@ -65,6 +65,14 @@
return version <= currentVersion;
}
+std::optional<String> MockPaymentCoordinator::validatedPaymentNetwork(const String& paymentNetwork)
+{
+ auto result = m_availablePaymentNetworks.find(paymentNetwork);
+ if (result == m_availablePaymentNetworks.end())
+ return std::nullopt;
+ return *result;
+}
+
bool MockPaymentCoordinator::canMakePayments()
{
return true;
Modified: branches/safari-605-branch/Source/WebCore/testing/MockPaymentCoordinator.h (227334 => 227335)
--- branches/safari-605-branch/Source/WebCore/testing/MockPaymentCoordinator.h 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebCore/testing/MockPaymentCoordinator.h 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,6 +30,8 @@
#include "ApplePayLineItem.h"
#include "MockPaymentAddress.h"
#include "PaymentCoordinatorClient.h"
+#include <wtf/HashSet.h>
+#include <wtf/text/StringHash.h>
namespace WebCore {
@@ -48,7 +50,6 @@
const ApplePayLineItem& total() const { return m_total; }
const Vector<ApplePayLineItem>& lineItems() const { return m_lineItems; }
- const Vector<String>& availablePaymentNetworks() const { return m_availablePaymentNetworks; }
void ref() const { }
void deref() const { }
@@ -55,6 +56,7 @@
private:
bool supportsVersion(unsigned) final;
+ std::optional<String> validatedPaymentNetwork(const String&) final;
bool canMakePayments() final;
void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&&);
void openPaymentSetup(const String&, const String&, WTF::Function<void(bool)>&&);
@@ -74,7 +76,7 @@
ApplePayPaymentContact m_shippingAddress;
ApplePayLineItem m_total;
Vector<ApplePayLineItem> m_lineItems;
- Vector<String> m_availablePaymentNetworks;
+ HashSet<String, ASCIICaseInsensitiveHash> m_availablePaymentNetworks;
};
} // namespace WebCore
Modified: branches/safari-605-branch/Source/WebKit/ChangeLog (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/ChangeLog 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/ChangeLog 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,80 @@
2018-01-22 Jason Marcell <jmarc...@apple.com>
+ Cherry-pick r227274. rdar://problem/36722660
+
+ 2018-01-20 Andy Estes <aes...@apple.com>
+
+ [Apple Pay] Stop eagerly loading PassKit.framework
+ https://bugs.webkit.org/show_bug.cgi?id=181911
+ <rdar://problem/36555369>
+
+ Reviewed by Tim Horton.
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+
+ Removed availablePaymentNetworks from WebPageCreationParameters.
+
+ * UIProcess/API/C/WKPreferences.cpp:
+ (WKPreferencesSetApplePayEnabled):
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _initializeWithConfiguration:]):
+
+ Stopped calling WebPaymentCoordinatorProxy::platformSupportsPayments().
+
+ * UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp:
+ (WebKit::WebPaymentCoordinatorProxy::availablePaymentNetworks):
+ * UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
+ * UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in:
+
+ Added message AvailablePaymentNetworks, which synchronously returns a Vector of payment
+ networks.
+
+ * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+ (WebKit::WebPaymentCoordinatorProxy::platformCanMakePayments):
+
+ Returned false if PassKitLibrary() fails.
+
+ (WebKit::WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard):
+ (WebKit::WebPaymentCoordinatorProxy::platformOpenPaymentSetup):
+
+ Called completionHandler with false if PassKitLibrary() fails.
+
+ (WebKit::WebPaymentCoordinatorProxy::platformAvailablePaymentNetworks):
+ (WebKit::WebPaymentCoordinatorProxy::availablePaymentNetworks):
+
+ Renamed availablePaymentNetworks to platformAvailablePaymentNetworks
+
+ (WebKit::WebPaymentCoordinatorProxy::platformSupportsPayments): Deleted.
+
+ * UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
+ (WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI):
+
+ Called completionHandler with false if PassKitLibrary() fails.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::creationParameters):
+
+ Stopped calling WebPaymentCoordinatorProxy::availablePaymentNetworks().
+
+ * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
+ (WebKit::WebPaymentCoordinator::availablePaymentNetworks):
+ (WebKit::WebPaymentCoordinator::validatedPaymentNetwork):
+ * WebProcess/ApplePay/WebPaymentCoordinator.h:
+
+ Implemented PaymentCoordinatorClient::validatedPaymentNetwork(). m_availablePaymentNetworks
+ starts off as std::nullopt, but is initialized by sending the AvailablePaymentNetworks sync
+ message the first time it's accessed.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::WebPage):
+
+ Stopped setting PageConfiguration::availablePaymentNetworks.
+
+2018-01-22 Jason Marcell <jmarc...@apple.com>
+
Cherry-pick r227272. rdar://problem/36722635
2018-01-20 Jer Noble <jer.no...@apple.com>
Modified: branches/safari-605-branch/Source/WebKit/Shared/WebPageCreationParameters.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/Shared/WebPageCreationParameters.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/Shared/WebPageCreationParameters.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -112,9 +112,6 @@
#if ENABLE(CONTENT_EXTENSIONS)
encoder << contentRuleLists;
#endif
-#if ENABLE(APPLE_PAY)
- encoder << availablePaymentNetworks;
-#endif
}
std::optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decoder& decoder)
@@ -321,14 +318,6 @@
parameters.contentRuleLists = WTFMove(*contentRuleLists);
#endif
-#if ENABLE(APPLE_PAY)
- std::optional<Vector<String>> availablePaymentNetworks;
- decoder >> availablePaymentNetworks;
- if (!availablePaymentNetworks)
- return std::nullopt;
- parameters.availablePaymentNetworks = WTFMove(*availablePaymentNetworks);
-#endif
-
return WTFMove(parameters);
}
Modified: branches/safari-605-branch/Source/WebKit/Shared/WebPageCreationParameters.h (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/Shared/WebPageCreationParameters.h 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/Shared/WebPageCreationParameters.h 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -177,10 +177,6 @@
#if ENABLE(CONTENT_EXTENSIONS)
Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
#endif
-
-#if ENABLE(APPLE_PAY)
- Vector<String> availablePaymentNetworks;
-#endif
};
} // namespace WebKit
Modified: branches/safari-605-branch/Source/WebKit/UIProcess/API/C/WKPreferences.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/UIProcess/API/C/WKPreferences.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/API/C/WKPreferences.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,10 +32,6 @@
#include <WebCore/Settings.h>
#include <wtf/RefPtr.h>
-#if ENABLE(APPLE_PAY)
-#include "WebPaymentCoordinatorProxy.h"
-#endif
-
using namespace WebKit;
WKTypeID WKPreferencesGetTypeID()
@@ -1791,10 +1787,6 @@
void WKPreferencesSetApplePayEnabled(WKPreferencesRef preferencesRef, bool enabled)
{
-#if ENABLE(APPLE_PAY)
- if (!WebPaymentCoordinatorProxy::platformSupportsPayments())
- enabled = false;
-#endif
WebKit::toImpl(preferencesRef)->setApplePayEnabled(enabled);
}
Modified: branches/safari-605-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -74,7 +74,6 @@
#import "WebFullScreenManagerProxy.h"
#import "WebPageGroup.h"
#import "WebPageProxy.h"
-#import "WebPaymentCoordinatorProxy.h"
#import "WebPreferencesKeys.h"
#import "WebProcessPool.h"
#import "WebProcessProxy.h"
@@ -596,8 +595,7 @@
#endif
#if ENABLE(APPLE_PAY)
- bool applePayEnabled = [_configuration _applePayEnabled] && WebKit::WebPaymentCoordinatorProxy::platformSupportsPayments();
- pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::applePayEnabledKey(), WebKit::WebPreferencesStore::Value(applePayEnabled));
+ pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::applePayEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _applePayEnabled]));
#endif
pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::needsStorageAccessFromFileURLsQuirkKey(), WebKit::WebPreferencesStore::Value(!![_configuration _needsStorageAccessFromFileURLsQuirk]));
Modified: branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -57,6 +57,11 @@
m_webPageProxy.process().removeMessageReceiver(Messages::WebPaymentCoordinatorProxy::messageReceiverName(), m_webPageProxy.pageID());
}
+void WebPaymentCoordinatorProxy::availablePaymentNetworks(Vector<String>& networks)
+{
+ networks = platformAvailablePaymentNetworks();
+}
+
void WebPaymentCoordinatorProxy::canMakePayments(bool& reply)
{
reply = platformCanMakePayments();
Modified: branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -69,9 +69,6 @@
void hidePaymentUI();
- static bool platformSupportsPayments();
- static Vector<String> availablePaymentNetworks();
-
private:
// IPC::MessageReceiver.
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
@@ -78,6 +75,7 @@
void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
// Message handlers.
+ void availablePaymentNetworks(Vector<String>&);
void canMakePayments(bool& reply);
void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, uint64_t requestID);
void openPaymentSetup(const String& merchantIdentifier, const String& domainName, uint64_t requestID);
@@ -97,6 +95,7 @@
void didReachFinalState();
+ Vector<String> platformAvailablePaymentNetworks();
bool platformCanMakePayments();
void platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler);
void platformOpenPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler);
Modified: branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.messages.in 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015 Apple Inc. All rights reserved.
+# Copyright (C) 2015-2018 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -26,6 +26,7 @@
messages -> WebPaymentCoordinatorProxy {
+ AvailablePaymentNetworks() -> (Vector<String> availablePaymentNetworks)
CanMakePayments() -> (bool result)
CanMakePaymentsWithActiveCard(String merchantIdentifier, String domainName, uint64_t requestID)
OpenPaymentSetup(String merchantIdentifier, String domainName, uint64_t requestID)
Modified: branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -293,11 +293,23 @@
bool WebPaymentCoordinatorProxy::platformCanMakePayments()
{
+#if PLATFORM(MAC)
+ if (!PassKitLibrary())
+ return false;
+#endif
+
return [getPKPaymentAuthorizationViewControllerClass() canMakePayments];
}
void WebPaymentCoordinatorProxy::platformCanMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler)
{
+#if PLATFORM(MAC)
+ if (!PassKitLibrary()) {
+ completionHandler(false);
+ return;
+ }
+#endif
+
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
if (!canLoad_PassKit_PKCanMakePaymentsWithMerchantIdentifierDomainAndSourceApplication()) {
RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {
@@ -335,6 +347,13 @@
void WebPaymentCoordinatorProxy::platformOpenPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler)
{
+#if PLATFORM(MAC)
+ if (!PassKitLibrary()) {
+ completionHandler(false);
+ return;
+ }
+#endif
+
auto passLibrary = adoptNS([allocPKPassLibraryInstance() init]);
[passLibrary openPaymentSetupForMerchantIdentifier:merchantIdentifier domain:domainName completion:BlockPtr<void (BOOL)>::fromCallable([completionHandler = WTFMove(completionHandler)](BOOL result) mutable {
RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), result] {
@@ -847,11 +866,13 @@
m_paymentAuthorizationViewControllerDelegate->_didSelectPaymentMethodCompletion = nullptr;
}
-Vector<String> WebPaymentCoordinatorProxy::availablePaymentNetworks()
+Vector<String> WebPaymentCoordinatorProxy::platformAvailablePaymentNetworks()
{
- if (!platformSupportsPayments())
+#if PLATFORM(MAC)
+ if (!PassKitLibrary())
return { };
-
+#endif
+
NSArray<PKPaymentNetwork> *availableNetworks = [getPKPaymentRequestClass() availableNetworks];
Vector<String> result;
result.reserveInitialCapacity(availableNetworks.count);
@@ -860,15 +881,6 @@
return result;
}
-bool WebPaymentCoordinatorProxy::platformSupportsPayments()
-{
-#if PLATFORM(MAC)
- return PassKitLibrary();
-#else
- return true;
-#endif
-}
-
} // namespace WebKit
#endif // ENABLE(APPLE_PAY)
Modified: branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -34,7 +34,7 @@
#import <wtf/BlockPtr.h>
#import <wtf/SoftLinking.h>
-SOFT_LINK_PRIVATE_FRAMEWORK(PassKit)
+SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(PassKit)
SOFT_LINK_CLASS(PassKit, PKPaymentAuthorizationViewController);
SOFT_LINK_CONSTANT(PassKit, PKExtensionPaymentAuthorizationUIExtensionPointName, NSString *);
@@ -43,6 +43,11 @@
void WebPaymentCoordinatorProxy::platformShowPaymentUI(const WebCore::URL& originatingURL, const Vector<WebCore::URL>& linkIconURLStrings, const WebCore::ApplePaySessionPaymentRequest& request, WTF::Function<void (bool)>&& completionHandler)
{
+ if (!PassKitLibrary()) {
+ completionHandler(false);
+ return;
+ }
+
auto paymentRequest = toPKPaymentRequest(m_webPageProxy, originatingURL, linkIconURLStrings, request);
auto showPaymentUIRequestSeed = m_showPaymentUIRequestSeed;
Modified: branches/safari-605-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
* Copyright (C) 2012 Intel Corporation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -5846,10 +5846,6 @@
parameters.applicationManifest = m_configuration->applicationManifest() ? std::optional<WebCore::ApplicationManifest>(m_configuration->applicationManifest()->applicationManifest()) : std::nullopt;
#endif
-#if ENABLE(APPLE_PAY)
- parameters.availablePaymentNetworks = WebPaymentCoordinatorProxy::availablePaymentNetworks();
-#endif
-
m_process->addWebUserContentControllerProxy(m_userContentController, parameters);
return parameters;
Modified: branches/safari-605-branch/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -64,6 +64,32 @@
return version <= currentVersion;
}
+const WebPaymentCoordinator::AvailablePaymentNetworksSet& WebPaymentCoordinator::availablePaymentNetworks()
+{
+ if (m_availablePaymentNetworks)
+ return *m_availablePaymentNetworks;
+
+ m_availablePaymentNetworks = WebPaymentCoordinator::AvailablePaymentNetworksSet();
+
+ Vector<String> availablePaymentNetworks;
+ using AvailablePaymentNetworksMessage = Messages::WebPaymentCoordinatorProxy::AvailablePaymentNetworks;
+ if (m_webPage.sendSync(AvailablePaymentNetworksMessage(), AvailablePaymentNetworksMessage::Reply(availablePaymentNetworks))) {
+ for (auto& network : availablePaymentNetworks)
+ m_availablePaymentNetworks->add(network);
+ }
+
+ return *m_availablePaymentNetworks;
+}
+
+std::optional<String> WebPaymentCoordinator::validatedPaymentNetwork(const String& paymentNetwork)
+{
+ auto& paymentNetworks = availablePaymentNetworks();
+ auto result = paymentNetworks.find(paymentNetwork);
+ if (result == paymentNetworks.end())
+ return std::nullopt;
+ return *result;
+}
+
bool WebPaymentCoordinator::canMakePayments()
{
bool canMakePayments;
Modified: branches/safari-605-branch/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,6 +32,8 @@
#include <WebCore/PaymentHeaders.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/text/StringHash.h>
namespace IPC {
class DataReference;
@@ -54,6 +56,7 @@
private:
// WebCore::PaymentCoordinatorClient.
bool supportsVersion(unsigned version) override;
+ std::optional<String> validatedPaymentNetwork(const String&) override;
bool canMakePayments() override;
void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) override;
void openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) override;
@@ -83,11 +86,16 @@
void openPaymentSetupReply(uint64_t requestID, bool result);
WebCore::PaymentCoordinator& paymentCoordinator();
+
+ using AvailablePaymentNetworksSet = HashSet<String, ASCIICaseInsensitiveHash>;
+ const AvailablePaymentNetworksSet& availablePaymentNetworks();
WebPage& m_webPage;
HashMap<uint64_t, WTF::Function<void (bool)>> m_pendingCanMakePaymentsWithActiveCardCallbacks;
HashMap<uint64_t, WTF::Function<void (bool)>> m_pendingOpenPaymentSetupCallbacks;
+
+ std::optional<AvailablePaymentNetworksSet> m_availablePaymentNetworks;
};
}
Modified: branches/safari-605-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (227334 => 227335)
--- branches/safari-605-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
* Copyright (C) 2012 Intel Corporation. All rights reserved.
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
*
@@ -421,7 +421,6 @@
#if ENABLE(APPLE_PAY)
pageConfiguration.paymentCoordinatorClient = new WebPaymentCoordinator(*this);
- pageConfiguration.availablePaymentNetworks = WTFMove(parameters.availablePaymentNetworks);
#endif
#if ENABLE(APPLICATION_MANIFEST)
Modified: branches/safari-605-branch/Source/WebKitLegacy/mac/ChangeLog (227334 => 227335)
--- branches/safari-605-branch/Source/WebKitLegacy/mac/ChangeLog 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKitLegacy/mac/ChangeLog 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,23 @@
2018-01-22 Jason Marcell <jmarc...@apple.com>
+ Cherry-pick r227274. rdar://problem/36722660
+
+ 2018-01-20 Andy Estes <aes...@apple.com>
+
+ [Apple Pay] Stop eagerly loading PassKit.framework
+ https://bugs.webkit.org/show_bug.cgi?id=181911
+ <rdar://problem/36555369>
+
+ Reviewed by Tim Horton.
+
+ * WebCoreSupport/WebPaymentCoordinatorClient.h:
+ * WebCoreSupport/WebPaymentCoordinatorClient.mm:
+ (WebPaymentCoordinatorClient::validatedPaymentNetwork):
+
+ Implemented PaymentCoordinatorClient::validatedPaymentNetwork().
+
+2018-01-22 Jason Marcell <jmarc...@apple.com>
+
Cherry-pick r227240. rdar://problem/36722464
2018-01-19 Dean Jackson <d...@apple.com>
Modified: branches/safari-605-branch/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.h (227334 => 227335)
--- branches/safari-605-branch/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.h 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.h 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -37,6 +37,7 @@
~WebPaymentCoordinatorClient();
bool supportsVersion(unsigned) override;
+ std::optional<String> validatedPaymentNetwork(const String&) override;
bool canMakePayments() override;
void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void (bool)>&& completionHandler) override;
void openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler) override;
Modified: branches/safari-605-branch/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm (227334 => 227335)
--- branches/safari-605-branch/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm 2018-01-22 17:58:51 UTC (rev 227334)
+++ branches/safari-605-branch/Source/WebKitLegacy/mac/WebCoreSupport/WebPaymentCoordinatorClient.mm 2018-01-22 17:58:58 UTC (rev 227335)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -43,6 +43,11 @@
return false;
}
+std::optional<String> WebPaymentCoordinatorClient::validatedPaymentNetwork(const String&)
+{
+ return std::nullopt;
+}
+
bool WebPaymentCoordinatorClient::canMakePayments()
{
return false;