Changeset 244092 in webkit
- Timestamp:
- Apr 9, 2019, 12:53:35 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Modules/applepay/PaymentCoordinator.cpp (modified) (22 diffs)
-
WebCore/Modules/applepay/PaymentCoordinatorClient.h (modified) (1 diff)
-
WebCore/platform/Logging.h (modified) (1 diff)
-
WebCore/testing/MockPaymentCoordinator.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp (modified) (1 diff)
-
WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r244086 r244092 1 2019-04-09 Andy Estes <aestes@apple.com> 2 3 [Apple Pay] Add release logging to PaymentCoordinator 4 https://bugs.webkit.org/show_bug.cgi?id=196738 5 6 Reviewed by Alex Christensen. 7 8 When allowed, log interactions with PaymentCoordinator to os_log to help diagnose Apple Pay bugs. 9 10 The following information might be logged: names of functions called, merchant API versions, 11 boolean results of canMakePayments(), boolean results of beginPaymentSession(), whether 12 completePaymentSession() was called with a final state result, boolean results of 13 shouldAllowApplePay(), whether a document has evaluated user agent scripts or is running 14 user scripts, and whether a client supports unrestricted Apple Pay. 15 16 * Modules/applepay/PaymentCoordinator.cpp: 17 (WebCore::PaymentCoordinator::supportsVersion const): 18 (WebCore::PaymentCoordinator::canMakePayments): 19 (WebCore::PaymentCoordinator::canMakePaymentsWithActiveCard): 20 (WebCore::PaymentCoordinator::openPaymentSetup): 21 (WebCore::PaymentCoordinator::beginPaymentSession): 22 (WebCore::PaymentCoordinator::completeMerchantValidation): 23 (WebCore::PaymentCoordinator::completeShippingMethodSelection): 24 (WebCore::PaymentCoordinator::completeShippingContactSelection): 25 (WebCore::PaymentCoordinator::completePaymentMethodSelection): 26 (WebCore::PaymentCoordinator::completePaymentSession): 27 (WebCore::PaymentCoordinator::abortPaymentSession): 28 (WebCore::PaymentCoordinator::cancelPaymentSession): 29 (WebCore::PaymentCoordinator::validateMerchant): 30 (WebCore::PaymentCoordinator::didAuthorizePayment): 31 (WebCore::PaymentCoordinator::didSelectPaymentMethod): 32 (WebCore::PaymentCoordinator::didSelectShippingMethod): 33 (WebCore::PaymentCoordinator::didSelectShippingContact): 34 (WebCore::PaymentCoordinator::didCancelPaymentSession): 35 (WebCore::PaymentCoordinator::shouldAllowApplePay const): 36 (WebCore::PaymentCoordinator::shouldAllowUserAgentScripts const): 37 * Modules/applepay/PaymentCoordinatorClient.h: 38 (WebCore::PaymentCoordinatorClient::isAlwaysOnLoggingAllowed const): 39 * platform/Logging.h: 40 * testing/MockPaymentCoordinator.h: 41 1 42 2019-04-09 John Wilander <wilander@apple.com> 2 43 -
trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp
r243324 r244092 31 31 #include "Document.h" 32 32 #include "LinkIconCollector.h" 33 #include "Logging.h" 33 34 #include "PaymentAuthorizationStatus.h" 34 35 #include "PaymentCoordinatorClient.h" … … 37 38 #include <wtf/URL.h> 38 39 40 #undef RELEASE_LOG_ERROR_IF_ALLOWED 41 #undef RELEASE_LOG_IF_ALLOWED 42 #define RELEASE_LOG_ERROR_IF_ALLOWED(fmt, ...) RELEASE_LOG_ERROR_IF(m_client.isAlwaysOnLoggingAllowed(), ApplePay, "%p - PaymentCoordinator::" fmt, this, ##__VA_ARGS__) 43 #define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(m_client.isAlwaysOnLoggingAllowed(), ApplePay, "%p - PaymentCoordinator::" fmt, this, ##__VA_ARGS__) 44 39 45 namespace WebCore { 40 46 … … 53 59 if (!shouldAllowApplePay(document)) 54 60 return false; 55 return m_client.supportsVersion(version); 61 62 auto supportsVersion = m_client.supportsVersion(version); 63 RELEASE_LOG_IF_ALLOWED("supportsVersion(%d) -> %d", version, supportsVersion); 64 return supportsVersion; 56 65 } 57 66 … … 60 69 if (!shouldAllowApplePay(document)) 61 70 return false; 62 return m_client.canMakePayments(); 71 72 auto canMakePayments = m_client.canMakePayments(); 73 RELEASE_LOG_IF_ALLOWED("canMakePayments() -> %d", canMakePayments); 74 return canMakePayments; 63 75 } 64 76 … … 67 79 if (!shouldAllowApplePay(document)) 68 80 return completionHandler(false); 81 82 RELEASE_LOG_IF_ALLOWED("canMakePaymentsWithActiveCard()"); 69 83 m_client.canMakePaymentsWithActiveCard(merchantIdentifier, document.domain(), WTFMove(completionHandler)); 70 84 } … … 74 88 if (!shouldAllowApplePay(document)) 75 89 return completionHandler(false); 90 91 RELEASE_LOG_IF_ALLOWED("openPaymentSetup()"); 76 92 m_client.openPaymentSetup(merchantIdentifier, document.domain(), WTFMove(completionHandler)); 77 93 } … … 88 104 linkIconURLs.append(icon.url); 89 105 90 if (!m_client.showPaymentUI(document.url(), linkIconURLs, paymentRequest)) 106 auto showPaymentUI = m_client.showPaymentUI(document.url(), linkIconURLs, paymentRequest); 107 RELEASE_LOG_IF_ALLOWED("beginPaymentSession() -> %d", showPaymentUI); 108 if (!showPaymentUI) 91 109 return false; 92 110 … … 99 117 { 100 118 ASSERT(m_activeSession); 101 119 RELEASE_LOG_IF_ALLOWED("completeMerchantValidation()"); 102 120 m_client.completeMerchantValidation(paymentMerchantSession); 103 121 } … … 106 124 { 107 125 ASSERT(m_activeSession); 108 126 RELEASE_LOG_IF_ALLOWED("completeShippingMethodSelection()"); 109 127 m_client.completeShippingMethodSelection(WTFMove(update)); 110 128 } … … 113 131 { 114 132 ASSERT(m_activeSession); 115 133 RELEASE_LOG_IF_ALLOWED("completeShippingContactSelection()"); 116 134 m_client.completeShippingContactSelection(WTFMove(update)); 117 135 } … … 120 138 { 121 139 ASSERT(m_activeSession); 122 140 RELEASE_LOG_IF_ALLOWED("completePaymentMethodSelection()"); 123 141 m_client.completePaymentMethodSelection(WTFMove(update)); 124 142 } … … 129 147 130 148 bool isFinalState = isFinalStateResult(result); 131 149 RELEASE_LOG_IF_ALLOWED("completePaymentSession() (isFinalState: %d)", isFinalState); 132 150 m_client.completePaymentSession(WTFMove(result)); 133 151 … … 141 159 { 142 160 ASSERT(m_activeSession); 143 161 RELEASE_LOG_IF_ALLOWED("abortPaymentSession()"); 144 162 m_client.abortPaymentSession(); 145 163 m_activeSession = nullptr; … … 149 167 { 150 168 ASSERT(m_activeSession); 151 169 RELEASE_LOG_IF_ALLOWED("cancelPaymentSession()"); 152 170 m_client.cancelPaymentSession(); 153 171 } … … 160 178 } 161 179 180 RELEASE_LOG_IF_ALLOWED("validateMerchant()"); 162 181 m_activeSession->validateMerchant(WTFMove(validationURL)); 163 182 } … … 170 189 } 171 190 191 RELEASE_LOG_IF_ALLOWED("validateMerchant()"); 172 192 m_activeSession->didAuthorizePayment(payment); 173 193 } … … 180 200 } 181 201 202 RELEASE_LOG_IF_ALLOWED("didSelectPaymentMethod()"); 182 203 m_activeSession->didSelectPaymentMethod(paymentMethod); 183 204 } … … 190 211 } 191 212 213 RELEASE_LOG_IF_ALLOWED("didSelectShippingMethod()"); 192 214 m_activeSession->didSelectShippingMethod(shippingMethod); 193 215 } … … 200 222 } 201 223 224 RELEASE_LOG_IF_ALLOWED("didSelectShippingContact()"); 202 225 m_activeSession->didSelectShippingContact(shippingContact); 203 226 } … … 210 233 } 211 234 235 RELEASE_LOG_IF_ALLOWED("didCancelPaymentSession()"); 212 236 m_activeSession->didCancelPaymentSession(); 213 237 m_activeSession = nullptr; … … 230 254 bool PaymentCoordinator::shouldAllowApplePay(Document& document) const 231 255 { 256 if (m_client.supportsUnrestrictedApplePay()) { 257 RELEASE_LOG_IF_ALLOWED("shouldAllowApplePay() -> true (unrestricted client)"); 258 return true; 259 } 260 261 auto hasEvaluatedUserAgentScripts = document.hasEvaluatedUserAgentScripts(); 262 auto isRunningUserScripts = document.isRunningUserScripts(); 263 if (hasEvaluatedUserAgentScripts || isRunningUserScripts) { 264 ASSERT(shouldAllowUserAgentScripts(document)); 265 RELEASE_LOG_IF_ALLOWED("shouldAllowApplePay() -> false (hasEvaluatedUserAgentScripts: %d, isRunningUserScripts: %d)", hasEvaluatedUserAgentScripts, isRunningUserScripts); 266 return false; 267 } 268 269 RELEASE_LOG_IF_ALLOWED("shouldAllowApplePay() -> true"); 270 return true; 271 } 272 273 bool PaymentCoordinator::shouldAllowUserAgentScripts(Document& document) const 274 { 232 275 if (m_client.supportsUnrestrictedApplePay()) 233 276 return true; 234 277 235 if (document.hasEvaluatedUserAgentScripts() || document.isRunningUserScripts()) {236 ASSERT(shouldAllowUserAgentScripts(document));237 return false;238 }239 240 return true;241 }242 243 bool PaymentCoordinator::shouldAllowUserAgentScripts(Document& document) const244 {245 if (m_client.supportsUnrestrictedApplePay())246 return true;247 248 278 if (document.hasStartedApplePaySession()) { 249 279 ASSERT(shouldAllowApplePay(document)); 280 RELEASE_LOG_ERROR_IF_ALLOWED("shouldAllowUserAgentScripts() -> false (active session)"); 250 281 return false; 251 282 } … … 256 287 } // namespace WebCore 257 288 289 #undef RELEASE_LOG_ERROR_IF_ALLOWED 290 #undef RELEASE_LOG_IF_ALLOWED 291 258 292 #endif // ENABLE(APPLE_PAY) -
trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h
r243324 r244092 67 67 virtual bool isWebPaymentCoordinator() const { return false; } 68 68 69 virtual bool isAlwaysOnLoggingAllowed() const { return false; } 69 70 virtual bool supportsUnrestrictedApplePay() const { return true; } 70 71 -
trunk/Source/WebCore/platform/Logging.h
r243666 r244092 40 40 #define WEBCORE_LOG_CHANNELS(M) \ 41 41 M(Animations) \ 42 M(ApplePay) \ 42 43 M(Archives) \ 43 44 M(Compositing) \ -
trunk/Source/WebCore/testing/MockPaymentCoordinator.h
r243324 r244092 84 84 bool isMockPaymentCoordinator() const final { return true; } 85 85 86 bool isAlwaysOnLoggingAllowed() const final { return true; } 87 86 88 void updateTotalAndLineItems(const ApplePaySessionPaymentRequest::TotalAndLineItems&); 87 89 -
trunk/Source/WebKit/ChangeLog
r244091 r244092 1 2019-04-09 Andy Estes <aestes@apple.com> 2 3 [Apple Pay] Add release logging to PaymentCoordinator 4 https://bugs.webkit.org/show_bug.cgi?id=196738 5 6 Reviewed by Alex Christensen. 7 8 * WebProcess/ApplePay/WebPaymentCoordinator.cpp: 9 (WebKit::WebPaymentCoordinator::isAlwaysOnLoggingAllowed const): 10 * WebProcess/ApplePay/WebPaymentCoordinator.h: 11 1 12 2019-04-09 Jer Noble <jer.noble@apple.com> 2 13 -
trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp
r243443 r244092 143 143 } 144 144 145 bool WebPaymentCoordinator::isAlwaysOnLoggingAllowed() const 146 { 147 return m_webPage.isAlwaysOnLoggingAllowed(); 148 } 149 145 150 bool WebPaymentCoordinator::supportsUnrestrictedApplePay() const 146 151 { -
trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h
r243443 r244092 79 79 bool isWebPaymentCoordinator() const override { return true; } 80 80 81 bool isAlwaysOnLoggingAllowed() const override; 81 82 bool supportsUnrestrictedApplePay() const override; 82 83
Note:
See TracChangeset
for help on using the changeset viewer.