⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244092 in webkit


Ignore:
Timestamp:
Apr 9, 2019, 12:53:35 PM (7 years ago)
Author:
aestes@apple.com
Message:

[Apple Pay] Add release logging to PaymentCoordinator
https://bugs.webkit.org/show_bug.cgi?id=196738

Reviewed by Alex Christensen.

Source/WebCore:

When allowed, log interactions with PaymentCoordinator to os_log to help diagnose Apple Pay bugs.

The following information might be logged: names of functions called, merchant API versions,
boolean results of canMakePayments(), boolean results of beginPaymentSession(), whether
completePaymentSession() was called with a final state result, boolean results of
shouldAllowApplePay(), whether a document has evaluated user agent scripts or is running
user scripts, and whether a client supports unrestricted Apple Pay.

  • Modules/applepay/PaymentCoordinator.cpp:

(WebCore::PaymentCoordinator::supportsVersion const):
(WebCore::PaymentCoordinator::canMakePayments):
(WebCore::PaymentCoordinator::canMakePaymentsWithActiveCard):
(WebCore::PaymentCoordinator::openPaymentSetup):
(WebCore::PaymentCoordinator::beginPaymentSession):
(WebCore::PaymentCoordinator::completeMerchantValidation):
(WebCore::PaymentCoordinator::completeShippingMethodSelection):
(WebCore::PaymentCoordinator::completeShippingContactSelection):
(WebCore::PaymentCoordinator::completePaymentMethodSelection):
(WebCore::PaymentCoordinator::completePaymentSession):
(WebCore::PaymentCoordinator::abortPaymentSession):
(WebCore::PaymentCoordinator::cancelPaymentSession):
(WebCore::PaymentCoordinator::validateMerchant):
(WebCore::PaymentCoordinator::didAuthorizePayment):
(WebCore::PaymentCoordinator::didSelectPaymentMethod):
(WebCore::PaymentCoordinator::didSelectShippingMethod):
(WebCore::PaymentCoordinator::didSelectShippingContact):
(WebCore::PaymentCoordinator::didCancelPaymentSession):
(WebCore::PaymentCoordinator::shouldAllowApplePay const):
(WebCore::PaymentCoordinator::shouldAllowUserAgentScripts const):

  • Modules/applepay/PaymentCoordinatorClient.h:

(WebCore::PaymentCoordinatorClient::isAlwaysOnLoggingAllowed const):

  • platform/Logging.h:
  • testing/MockPaymentCoordinator.h:

Source/WebKit:

  • WebProcess/ApplePay/WebPaymentCoordinator.cpp:

(WebKit::WebPaymentCoordinator::isAlwaysOnLoggingAllowed const):

  • WebProcess/ApplePay/WebPaymentCoordinator.h:
Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r244086 r244092  
     12019-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
    1422019-04-09  John Wilander  <wilander@apple.com>
    243
  • trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp

    r243324 r244092  
    3131#include "Document.h"
    3232#include "LinkIconCollector.h"
     33#include "Logging.h"
    3334#include "PaymentAuthorizationStatus.h"
    3435#include "PaymentCoordinatorClient.h"
     
    3738#include <wtf/URL.h>
    3839
     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
    3945namespace WebCore {
    4046
     
    5359    if (!shouldAllowApplePay(document))
    5460        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;
    5665}
    5766
     
    6069    if (!shouldAllowApplePay(document))
    6170        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;
    6375}
    6476
     
    6779    if (!shouldAllowApplePay(document))
    6880        return completionHandler(false);
     81
     82    RELEASE_LOG_IF_ALLOWED("canMakePaymentsWithActiveCard()");
    6983    m_client.canMakePaymentsWithActiveCard(merchantIdentifier, document.domain(), WTFMove(completionHandler));
    7084}
     
    7488    if (!shouldAllowApplePay(document))
    7589        return completionHandler(false);
     90
     91    RELEASE_LOG_IF_ALLOWED("openPaymentSetup()");
    7692    m_client.openPaymentSetup(merchantIdentifier, document.domain(), WTFMove(completionHandler));
    7793}
     
    88104        linkIconURLs.append(icon.url);
    89105
    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)
    91109        return false;
    92110
     
    99117{
    100118    ASSERT(m_activeSession);
    101 
     119    RELEASE_LOG_IF_ALLOWED("completeMerchantValidation()");
    102120    m_client.completeMerchantValidation(paymentMerchantSession);
    103121}
     
    106124{
    107125    ASSERT(m_activeSession);
    108 
     126    RELEASE_LOG_IF_ALLOWED("completeShippingMethodSelection()");
    109127    m_client.completeShippingMethodSelection(WTFMove(update));
    110128}
     
    113131{
    114132    ASSERT(m_activeSession);
    115 
     133    RELEASE_LOG_IF_ALLOWED("completeShippingContactSelection()");
    116134    m_client.completeShippingContactSelection(WTFMove(update));
    117135}
     
    120138{
    121139    ASSERT(m_activeSession);
    122 
     140    RELEASE_LOG_IF_ALLOWED("completePaymentMethodSelection()");
    123141    m_client.completePaymentMethodSelection(WTFMove(update));
    124142}
     
    129147
    130148    bool isFinalState = isFinalStateResult(result);
    131 
     149    RELEASE_LOG_IF_ALLOWED("completePaymentSession() (isFinalState: %d)", isFinalState);
    132150    m_client.completePaymentSession(WTFMove(result));
    133151
     
    141159{
    142160    ASSERT(m_activeSession);
    143 
     161    RELEASE_LOG_IF_ALLOWED("abortPaymentSession()");
    144162    m_client.abortPaymentSession();
    145163    m_activeSession = nullptr;
     
    149167{
    150168    ASSERT(m_activeSession);
    151 
     169    RELEASE_LOG_IF_ALLOWED("cancelPaymentSession()");
    152170    m_client.cancelPaymentSession();
    153171}
     
    160178    }
    161179
     180    RELEASE_LOG_IF_ALLOWED("validateMerchant()");
    162181    m_activeSession->validateMerchant(WTFMove(validationURL));
    163182}
     
    170189    }
    171190
     191    RELEASE_LOG_IF_ALLOWED("validateMerchant()");
    172192    m_activeSession->didAuthorizePayment(payment);
    173193}
     
    180200    }
    181201
     202    RELEASE_LOG_IF_ALLOWED("didSelectPaymentMethod()");
    182203    m_activeSession->didSelectPaymentMethod(paymentMethod);
    183204}
     
    190211    }
    191212
     213    RELEASE_LOG_IF_ALLOWED("didSelectShippingMethod()");
    192214    m_activeSession->didSelectShippingMethod(shippingMethod);
    193215}
     
    200222    }
    201223
     224    RELEASE_LOG_IF_ALLOWED("didSelectShippingContact()");
    202225    m_activeSession->didSelectShippingContact(shippingContact);
    203226}
     
    210233    }
    211234
     235    RELEASE_LOG_IF_ALLOWED("didCancelPaymentSession()");
    212236    m_activeSession->didCancelPaymentSession();
    213237    m_activeSession = nullptr;
     
    230254bool PaymentCoordinator::shouldAllowApplePay(Document& document) const
    231255{
     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
     273bool PaymentCoordinator::shouldAllowUserAgentScripts(Document& document) const
     274{
    232275    if (m_client.supportsUnrestrictedApplePay())
    233276        return true;
    234277
    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) const
    244 {
    245     if (m_client.supportsUnrestrictedApplePay())
    246         return true;
    247 
    248278    if (document.hasStartedApplePaySession()) {
    249279        ASSERT(shouldAllowApplePay(document));
     280        RELEASE_LOG_ERROR_IF_ALLOWED("shouldAllowUserAgentScripts() -> false (active session)");
    250281        return false;
    251282    }
     
    256287} // namespace WebCore
    257288
     289#undef RELEASE_LOG_ERROR_IF_ALLOWED
     290#undef RELEASE_LOG_IF_ALLOWED
     291
    258292#endif // ENABLE(APPLE_PAY)
  • trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h

    r243324 r244092  
    6767    virtual bool isWebPaymentCoordinator() const { return false; }
    6868
     69    virtual bool isAlwaysOnLoggingAllowed() const { return false; }
    6970    virtual bool supportsUnrestrictedApplePay() const { return true; }
    7071
  • trunk/Source/WebCore/platform/Logging.h

    r243666 r244092  
    4040#define WEBCORE_LOG_CHANNELS(M) \
    4141    M(Animations) \
     42    M(ApplePay) \
    4243    M(Archives) \
    4344    M(Compositing) \
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.h

    r243324 r244092  
    8484    bool isMockPaymentCoordinator() const final { return true; }
    8585
     86    bool isAlwaysOnLoggingAllowed() const final { return true; }
     87
    8688    void updateTotalAndLineItems(const ApplePaySessionPaymentRequest::TotalAndLineItems&);
    8789
  • trunk/Source/WebKit/ChangeLog

    r244091 r244092  
     12019-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
    1122019-04-09  Jer Noble  <jer.noble@apple.com>
    213
  • trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp

    r243443 r244092  
    143143}
    144144
     145bool WebPaymentCoordinator::isAlwaysOnLoggingAllowed() const
     146{
     147    return m_webPage.isAlwaysOnLoggingAllowed();
     148}
     149
    145150bool WebPaymentCoordinator::supportsUnrestrictedApplePay() const
    146151{
  • trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h

    r243443 r244092  
    7979    bool isWebPaymentCoordinator() const override { return true; }
    8080
     81    bool isAlwaysOnLoggingAllowed() const override;
    8182    bool supportsUnrestrictedApplePay() const override;
    8283
Note: See TracChangeset for help on using the changeset viewer.