Title: [226459] tags/Safari-605.1.19/Source/WebKit

Diff

Modified: tags/Safari-605.1.19/Source/WebKit/ChangeLog (226458 => 226459)


--- tags/Safari-605.1.19/Source/WebKit/ChangeLog	2018-01-05 21:28:05 UTC (rev 226458)
+++ tags/Safari-605.1.19/Source/WebKit/ChangeLog	2018-01-05 21:44:21 UTC (rev 226459)
@@ -1,3 +1,27 @@
+2018-01-05  Jason Marcell  <[email protected]>
+
+        Cherry-pick r226458. rdar://problem/36311296
+
+    2018-01-05  Andy Estes  <[email protected]>
+
+            [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-04  Jason Marcell  <[email protected]>
 
         Cherry-pick r226389. rdar://problem/36289544

Modified: tags/Safari-605.1.19/Source/WebKit/UIProcess/API/C/WKPreferences.cpp (226458 => 226459)


--- tags/Safari-605.1.19/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2018-01-05 21:28:05 UTC (rev 226458)
+++ tags/Safari-605.1.19/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2018-01-05 21:44:21 UTC (rev 226459)
@@ -32,6 +32,10 @@
 #include <WebCore/Settings.h>
 #include <wtf/RefPtr.h>
 
+#if ENABLE(APPLE_PAY)
+#include "WebPaymentCoordinatorProxy.h"
+#endif
+
 using namespace WebKit;
 
 WKTypeID WKPreferencesGetTypeID()
@@ -1777,6 +1781,10 @@
 
 void WKPreferencesSetApplePayEnabled(WKPreferencesRef preferencesRef, bool enabled)
 {
+#if ENABLE(APPLE_PAY)
+    if (!WebPaymentCoordinatorProxy::platformSupportsPayments())
+        enabled = false;
+#endif
     WebKit::toImpl(preferencesRef)->setApplePayEnabled(enabled);
 }
 

Modified: tags/Safari-605.1.19/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (226458 => 226459)


--- tags/Safari-605.1.19/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-01-05 21:28:05 UTC (rev 226458)
+++ tags/Safari-605.1.19/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2018-01-05 21:44:21 UTC (rev 226459)
@@ -74,6 +74,7 @@
 #import "WebFullScreenManagerProxy.h"
 #import "WebPageGroup.h"
 #import "WebPageProxy.h"
+#import "WebPaymentCoordinatorProxy.h"
 #import "WebPreferencesKeys.h"
 #import "WebProcessPool.h"
 #import "WebProcessProxy.h"
@@ -588,7 +589,8 @@
 #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]));

Modified: tags/Safari-605.1.19/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h (226458 => 226459)


--- tags/Safari-605.1.19/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h	2018-01-05 21:28:05 UTC (rev 226458)
+++ tags/Safari-605.1.19/Source/WebKit/UIProcess/ApplePay/WebPaymentCoordinatorProxy.h	2018-01-05 21:44:21 UTC (rev 226459)
@@ -69,6 +69,7 @@
 
     void hidePaymentUI();
 
+    static bool platformSupportsPayments();
     static Vector<String> availablePaymentNetworks();
 
 private:

Modified: tags/Safari-605.1.19/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (226458 => 226459)


--- tags/Safari-605.1.19/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2018-01-05 21:28:05 UTC (rev 226458)
+++ tags/Safari-605.1.19/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2018-01-05 21:44:21 UTC (rev 226459)
@@ -39,7 +39,7 @@
 #import <wtf/SoftLinking.h>
 
 #if PLATFORM(MAC)
-SOFT_LINK_PRIVATE_FRAMEWORK(PassKit)
+SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(PassKit)
 #else
 SOFT_LINK_FRAMEWORK(PassKit)
 #endif
@@ -849,6 +849,9 @@
 
 Vector<String> WebPaymentCoordinatorProxy::availablePaymentNetworks()
 {
+    if (!platformSupportsPayments())
+        return { };
+
     NSArray<PKPaymentNetwork> *availableNetworks = [getPKPaymentRequestClass() availableNetworks];
     Vector<String> result;
     result.reserveInitialCapacity(availableNetworks.count);
@@ -857,6 +860,15 @@
     return result;
 }
 
+bool WebPaymentCoordinatorProxy::platformSupportsPayments()
+{
+#if PLATFORM(MAC)
+    return PassKitLibrary();
+#else
+    return true;
+#endif
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(APPLE_PAY)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to