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

Changeset 285898 in webkit


Ignore:
Timestamp:
Nov 16, 2021, 4:30:29 PM (5 years ago)
Author:
Devin Rousso
Message:

[Apple Pay] handle unknown setup features
https://bugs.webkit.org/show_bug.cgi?id=233212

Reviewed by Wenson Hsieh.

Source/WebCore:

  • Modules/applepay/ApplePaySetupFeatureWebCore.h:
  • Modules/applepay/ApplePaySetupFeature.mm:

(WebCore::ApplePaySetupFeature::supportsFeature): Added.
(WebCore::ApplePaySetupFeature::type const):

  • Modules/applepay/PaymentInstallmentConfiguration.mm:

(WebCore::applePaySetupFeatureType):
(WebCore::platformFeatureType):
(WebCore::PaymentInstallmentConfiguration::applePayInstallmentConfiguration const):
If the PKPaymentSetupFeatureType is unknown/unsupported, return an empty ApplePayInstallmentConfiguration.
Drive-by: Replace all PKPaymentSetupFeatureTypeApplePay_X with PKPaymentSetupFeatureTypeAppleCard.

Source/WebCore/PAL:

  • pal/spi/cocoa/PassKitSPI.h:

Drive-by: Replace all PKPaymentSetupFeatureTypeApplePay_X with PKPaymentSetupFeatureTypeAppleCard.

Source/WebKit:

  • Shared/ApplePay/ApplePayPaymentSetupFeatures.mm:

(WebKit::PaymentSetupFeatures::operator Vector<Ref<WebCore::ApplePaySetupFeature>> const):
Skip PKPaymentSetupFeature that have an unknown PKPaymentSetupFeatureType. This ensures
that WebCore::ApplePaySetupFeature will only ever be created with known/supported PKPaymentSetupFeatureType.

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r285893 r285898  
     12021-11-16  Devin Rousso  <drousso@apple.com>
     2
     3        [Apple Pay] handle unknown setup features
     4        https://bugs.webkit.org/show_bug.cgi?id=233212
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * Modules/applepay/ApplePaySetupFeatureWebCore.h:
     9        * Modules/applepay/ApplePaySetupFeature.mm:
     10        (WebCore::ApplePaySetupFeature::supportsFeature): Added.
     11        (WebCore::ApplePaySetupFeature::type const):
     12
     13        * Modules/applepay/PaymentInstallmentConfiguration.mm:
     14        (WebCore::applePaySetupFeatureType):
     15        (WebCore::platformFeatureType):
     16        (WebCore::PaymentInstallmentConfiguration::applePayInstallmentConfiguration const):
     17        If the `PKPaymentSetupFeatureType` is unknown/unsupported, return an empty `ApplePayInstallmentConfiguration`.
     18        Drive-by: Replace all `PKPaymentSetupFeatureTypeApplePay_X` with `PKPaymentSetupFeatureTypeAppleCard`.
     19
    1202021-11-16  Nikolaos Mouchtaris  <nmouchtaris@apple.com>
    221
  • trunk/Source/WebCore/Modules/applepay/ApplePaySetupFeature.mm

    r264058 r285898  
    3535namespace WebCore {
    3636
     37bool ApplePaySetupFeature::supportsFeature(PKPaymentSetupFeature *feature)
     38{
     39    switch (feature.type) {
     40    case PKPaymentSetupFeatureTypeApplePay:
     41    case PKPaymentSetupFeatureTypeAppleCard:
     42        return true;
     43
     44    default:
     45        return false;
     46    }
     47}
     48
    3749ApplePaySetupFeature::ApplePaySetupFeature() = default;
    3850ApplePaySetupFeature::~ApplePaySetupFeature() = default;
     
    4355    case PKPaymentSetupFeatureTypeApplePay:
    4456        return ApplePaySetupFeatureType::ApplePay;
    45         ALLOW_DEPRECATED_DECLARATIONS_BEGIN
    46     case PKPaymentSetupFeatureTypeApplePay_X:
    47         ALLOW_DEPRECATED_DECLARATIONS_END
     57
     58    case PKPaymentSetupFeatureTypeAppleCard:
    4859        return ApplePaySetupFeatureType::AppleCard;
     60
     61    default:
     62        ASSERT(!supportsFeature(m_feature.get()));
     63        return ApplePaySetupFeatureType::ApplePay;
    4964    }
    5065}
  • trunk/Source/WebCore/Modules/applepay/ApplePaySetupFeatureWebCore.h

    r262714 r285898  
    4444        return adoptRef(*new ApplePaySetupFeature(feature));
    4545    }
     46
     47    WEBCORE_EXPORT static bool supportsFeature(PKPaymentSetupFeature *);
    4648   
    4749    WEBCORE_EXPORT virtual ~ApplePaySetupFeature();
  • trunk/Source/WebCore/Modules/applepay/PaymentInstallmentConfiguration.mm

    r282844 r285898  
    5858}
    5959
    60 static ApplePaySetupFeatureType applePaySetupFeatureType(PKPaymentSetupFeatureType featureType)
     60static std::optional<ApplePaySetupFeatureType> applePaySetupFeatureType(PKPaymentSetupFeatureType featureType)
    6161{
    6262    switch (featureType) {
    6363    case PKPaymentSetupFeatureTypeApplePay:
    6464        return ApplePaySetupFeatureType::ApplePay;
    65     ALLOW_DEPRECATED_DECLARATIONS_BEGIN
    66     case PKPaymentSetupFeatureTypeApplePay_X:
    67     ALLOW_DEPRECATED_DECLARATIONS_END
     65
     66    case PKPaymentSetupFeatureTypeAppleCard:
    6867        return ApplePaySetupFeatureType::AppleCard;
     68
     69    default:
     70        ASSERT_NOT_REACHED();
     71        return std::nullopt;
    6972    }
    7073}
     
    7679        return PKPaymentSetupFeatureTypeApplePay;
    7780    case ApplePaySetupFeatureType::AppleCard:
    78         ALLOW_DEPRECATED_DECLARATIONS_BEGIN
    79         return PKPaymentSetupFeatureTypeApplePay_X;
    80         ALLOW_DEPRECATED_DECLARATIONS_END
     81        return PKPaymentSetupFeatureTypeAppleCard;
    8182    }
    8283}
     
    234235        return installmentConfiguration;
    235236
    236     installmentConfiguration.featureType = applePaySetupFeatureType([m_configuration feature]);
     237    if (auto featureType = applePaySetupFeatureType([m_configuration feature]))
     238        installmentConfiguration.featureType = *featureType;
     239    else
     240        return installmentConfiguration;
    237241
    238242    installmentConfiguration.bindingTotalAmount = fromDecimalNumber([m_configuration bindingTotalAmount]);
  • trunk/Source/WebCore/PAL/ChangeLog

    r285881 r285898  
     12021-11-16  Devin Rousso  <drousso@apple.com>
     2
     3        [Apple Pay] handle unknown setup features
     4        https://bugs.webkit.org/show_bug.cgi?id=233212
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * pal/spi/cocoa/PassKitSPI.h:
     9        Drive-by: Replace all `PKPaymentSetupFeatureTypeApplePay_X` with `PKPaymentSetupFeatureTypeAppleCard`.
     10
    1112021-11-16  Myles C. Maxfield  <mmaxfield@apple.com>
    212
  • trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h

    r285521 r285898  
    369369    PKPaymentSetupFeatureTypeApplePay,
    370370    PKPaymentSetupFeatureTypeAppleCard,
    371     PKPaymentSetupFeatureTypeApplePay_X API_DEPRECATED_WITH_REPLACEMENT("PKPaymentSetupFeatureTypeAppleCard", ios(12.3, 12.3), macos(10.14.5, 10.14.5)) = PKPaymentSetupFeatureTypeAppleCard,
    372371};
    373372
  • trunk/Source/WebKit/ChangeLog

    r285893 r285898  
     12021-11-16  Devin Rousso  <drousso@apple.com>
     2
     3        [Apple Pay] handle unknown setup features
     4        https://bugs.webkit.org/show_bug.cgi?id=233212
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * Shared/ApplePay/ApplePayPaymentSetupFeatures.mm:
     9        (WebKit::PaymentSetupFeatures::operator Vector<Ref<WebCore::ApplePaySetupFeature>> const):
     10        Skip `PKPaymentSetupFeature` that have an unknown `PKPaymentSetupFeatureType`. This ensures
     11        that `WebCore::ApplePaySetupFeature` will only ever be created with known/supported `PKPaymentSetupFeatureType`.
     12
    1132021-11-16  Nikolaos Mouchtaris  <nmouchtaris@apple.com>
    214
  • trunk/Source/WebKit/Shared/ApplePay/ApplePayPaymentSetupFeatures.mm

    r278253 r285898  
    8686    Vector<Ref<WebCore::ApplePaySetupFeature>> features;
    8787    features.reserveInitialCapacity([m_platformFeatures count]);
    88     for (PKPaymentSetupFeature *platformFeature in m_platformFeatures.get())
    89         features.uncheckedAppend(WebCore::ApplePaySetupFeature::create(platformFeature));
     88    for (PKPaymentSetupFeature *platformFeature in m_platformFeatures.get()) {
     89        if (WebCore::ApplePaySetupFeature::supportsFeature(platformFeature))
     90            features.uncheckedAppend(WebCore::ApplePaySetupFeature::create(platformFeature));
     91    }
    9092    return features;
    9193}
Note: See TracChangeset for help on using the changeset viewer.