https://bugs.webkit.org/show_bug.cgi?id=181335
<rdar://problem/
36311296>
Reviewed by Brady Eidson.
When Safari is running in the macOS Base System, PassKit.framework is not available.
If we fail to dlopen PassKit, we should disable Apple Pay.
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetApplePayEnabled):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
* UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
* UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::WebPaymentCoordinatorProxy::availablePaymentNetworks):
(WebKit::WebPaymentCoordinatorProxy::platformSupportsPayments):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226458
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2018-01-05 Andy Estes <aestes@apple.com>
+
+ [Apple Pay] Disable Apple Pay on platforms that don't have PassKit.framework
+ https://bugs.webkit.org/show_bug.cgi?id=181335
+ <rdar://problem/36311296>
+
+ Reviewed by Brady Eidson.
+
+ When Safari is running in the macOS Base System, PassKit.framework is not available.
+ If we fail to dlopen PassKit, we should disable Apple Pay.
+
+ * UIProcess/API/C/WKPreferences.cpp:
+ (WKPreferencesSetApplePayEnabled):
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _initializeWithConfiguration:]):
+ * UIProcess/ApplePay/WebPaymentCoordinatorProxy.h:
+ * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+ (WebKit::WebPaymentCoordinatorProxy::availablePaymentNetworks):
+ (WebKit::WebPaymentCoordinatorProxy::platformSupportsPayments):
+
2018-01-05 Dan Bernstein <mitz@apple.com>
Fixed the build following AppKit API deprecations in a recent SDKs
#include <WebCore/Settings.h>
#include <wtf/RefPtr.h>
+#if ENABLE(APPLE_PAY)
+#include "WebPaymentCoordinatorProxy.h"
+#endif
+
using namespace WebKit;
WKTypeID WKPreferencesGetTypeID()
void WKPreferencesSetApplePayEnabled(WKPreferencesRef preferencesRef, bool enabled)
{
+#if ENABLE(APPLE_PAY)
+ if (!WebPaymentCoordinatorProxy::platformSupportsPayments())
+ enabled = false;
+#endif
WebKit::toImpl(preferencesRef)->setApplePayEnabled(enabled);
}
#import "WebFullScreenManagerProxy.h"
#import "WebPageGroup.h"
#import "WebPageProxy.h"
+#import "WebPaymentCoordinatorProxy.h"
#import "WebPreferencesKeys.h"
#import "WebProcessPool.h"
#import "WebProcessProxy.h"
#endif
#if ENABLE(APPLE_PAY)
- pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::applePayEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _applePayEnabled]));
+ bool applePayEnabled = [_configuration _applePayEnabled] && WebKit::WebPaymentCoordinatorProxy::platformSupportsPayments();
+ pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::applePayEnabledKey(), WebKit::WebPreferencesStore::Value(applePayEnabled));
#endif
pageConfiguration->preferenceValues().set(WebKit::WebPreferencesKey::needsStorageAccessFromFileURLsQuirkKey(), WebKit::WebPreferencesStore::Value(!![_configuration _needsStorageAccessFromFileURLsQuirk]));
void hidePaymentUI();
+ static bool platformSupportsPayments();
static Vector<String> availablePaymentNetworks();
private:
#import <wtf/SoftLinking.h>
#if PLATFORM(MAC)
-SOFT_LINK_PRIVATE_FRAMEWORK(PassKit)
+SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(PassKit)
#else
SOFT_LINK_FRAMEWORK(PassKit)
#endif
Vector<String> WebPaymentCoordinatorProxy::availablePaymentNetworks()
{
+ if (!platformSupportsPayments())
+ return { };
+
NSArray<PKPaymentNetwork> *availableNetworks = [getPKPaymentRequestClass() availableNetworks];
Vector<String> result;
result.reserveInitialCapacity(availableNetworks.count);
return result;
}
+bool WebPaymentCoordinatorProxy::platformSupportsPayments()
+{
+#if PLATFORM(MAC)
+ return PassKitLibrary();
+#else
+ return true;
+#endif
+}
+
} // namespace WebKit
#endif // ENABLE(APPLE_PAY)