Skip to content

Commit

Permalink
[basic-card] Remove PaymentApp::Type::AUTOFILL
Browse files Browse the repository at this point in the history
Basic card is now fully deprecated and disabled, and we are removing
its code from the codebase. This CL deletes PaymentApp::Type::AUTOFILL
in both the desktop and Android code.

Bug: 1209835
Change-Id: I165a60b97cedcd81674c06a7c32defaa5a4d9bb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3828148
Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1035120}
  • Loading branch information
stephenmcgruer authored and Chromium LUCI CQ committed Aug 15, 2022
1 parent 54e2923 commit 91bed74
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import androidx.annotation.Nullable;

import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
import org.chromium.chrome.browser.payments.ui.PaymentUiService;
import org.chromium.chrome.browser.tabmodel.TabModel;
Expand Down Expand Up @@ -366,9 +365,7 @@ public void onPaymentDetailsNotUpdated(@Nullable String selectedShippingOptionEr
// Implements BrowserPaymentRequest:
@Override
public void onInstrumentDetailsLoading() {
assert mPaymentUiService.getSelectedPaymentApp() == null
|| mPaymentUiService.getSelectedPaymentApp().getPaymentAppType()
== PaymentAppType.AUTOFILL;
assert mPaymentUiService.getSelectedPaymentApp() == null;
mPaymentUiService.showProcessingMessage();
}

Expand All @@ -383,7 +380,7 @@ public boolean invokePaymentApp(EditableOption selectedShippingAddress,
mPaymentUiService.getSelectedContact(), selectedPaymentApp,
mSpec.getPaymentOptions());
mPaymentRequestService.invokePaymentApp(selectedPaymentApp, paymentResponseHelper);
return selectedPaymentApp.getPaymentAppType() != PaymentAppType.AUTOFILL;
return true;
}

private PaymentHandlerHost getPaymentHandlerHost() {
Expand Down Expand Up @@ -485,15 +482,6 @@ public boolean isPaymentSheetBasedPaymentAppSupported() {
// Implements BrowserPaymentRequest:
@Override
public void onInstrumentDetailsReady() {
// If the payment app was an Autofill credit card with an identifier, record its use.
PaymentApp selectedPaymentApp = mPaymentUiService.getSelectedPaymentApp();
if (selectedPaymentApp != null
&& selectedPaymentApp.getPaymentAppType() == PaymentAppType.AUTOFILL
&& !selectedPaymentApp.getIdentifier().isEmpty()) {
PersonalDataManager.getInstance().recordAndLogCreditCardUse(
selectedPaymentApp.getIdentifier());
}

// Showing the app selector UI if we were previously skipping it so the loading
// spinner shows up until the merchant notifies that payment was completed.
if (mHasSkippedAppSelector) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.chromium.chrome.browser.payments.PaymentPreferencesUtil;
import org.chromium.components.autofill.Completable;
import org.chromium.components.payments.PaymentApp;
import org.chromium.components.payments.PaymentAppType;
import org.chromium.components.payments.PaymentRequestParams;
import org.chromium.payments.mojom.PaymentOptions;

Expand Down Expand Up @@ -82,22 +81,16 @@ private static double getRankingScore(int count, long date) {

/**
* Sorts the payment apps by several rules:
* Rule 1: Non-autofill before autofill.
* Rule 2: Complete apps before incomplete apps.
* Rule 3: When shipping address is requested, apps which will handle shipping address before
* Rule 1: Complete apps before incomplete apps.
* Rule 2: When shipping address is requested, apps which will handle shipping address before
* others.
* Rule 4: When payer's contact information is requested, apps which will handle more required
* Rule 3: When payer's contact information is requested, apps which will handle more required
* contact fields (name, email, phone) come before others.
* Rule 5: Preselectable apps before non-preselectable apps.
* Rule 6: Frequently and recently used apps before rarely and non-recently used apps.
* Rule 4: Preselectable apps before non-preselectable apps.
* Rule 5: Frequently and recently used apps before rarely and non-recently used apps.
*/
@Override
public int compare(PaymentApp a, PaymentApp b) {
// Non-autofill apps first.
int autofill = (a.getPaymentAppType() == PaymentAppType.AUTOFILL ? 1 : 0)
- (b.getPaymentAppType() == PaymentAppType.AUTOFILL ? 1 : 0);
if (autofill != 0) return autofill;

// Complete cards before cards with missing information.
int completeness = compareCompletablesByCompleteness(b, a);
if (completeness != 0) return completeness;
Expand Down Expand Up @@ -142,4 +135,4 @@ public int compare(PaymentApp a, PaymentApp b) {
// More frequently and recently used apps first.
return compareAppsByRankingScore(b, a);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
import org.chromium.components.browser_ui.widget.FadingEdgeScrollView;
import org.chromium.components.browser_ui.widget.animation.FocusAnimator;
import org.chromium.components.browser_ui.widget.animation.Interpolators;
import org.chromium.components.payments.PaymentApp;
import org.chromium.components.payments.PaymentAppType;
import org.chromium.components.payments.PaymentFeatureList;
import org.chromium.components.signin.base.CoreAccountInfo;
import org.chromium.components.signin.identitymanager.ConsentLevel;
Expand Down Expand Up @@ -494,6 +492,7 @@ private void prepareRequestView(
mBottomBar = (ViewGroup) mRequestView.findViewById(R.id.bottom_bar);
mPayButton = (Button) mBottomBar.findViewById(R.id.button_primary);
mPayButton.setOnClickListener(this);
mPayButton.setText(R.string.payments_continue_button);
mEditButton = (Button) mBottomBar.findViewById(R.id.button_secondary);
mEditButton.setOnClickListener(this);

Expand Down Expand Up @@ -1010,13 +1009,6 @@ private void updatePayButtonEnabled() {
&& mPaymentMethodSectionInformation.getSelectedItem() != null
&& !mIsClientCheckingSelection && !mIsEditingPaymentItem && !mIsClosing);

PaymentApp selectedApp = mPaymentMethodSectionInformation == null
? null
: (PaymentApp) mPaymentMethodSectionInformation.getSelectedItem();
mPayButton.setText(
selectedApp != null && selectedApp.getPaymentAppType() != PaymentAppType.AUTOFILL
? R.string.payments_continue_button
: R.string.payments_pay_button);
mReadyToPayNotifierForTest.run();
}

Expand Down
39 changes: 8 additions & 31 deletions chrome/browser/ui/views/payments/payment_method_view_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ class PaymentMethodListItem : public PaymentRequestItemList::Item {
PaymentRequestItemList* list,
base::WeakPtr<PaymentRequestDialogView> dialog,
bool selected)
: PaymentRequestItemList::Item(
spec,
state,
list,
selected,
/*clickable=*/true,
/*show_edit_button=*/app->type() == PaymentApp::Type::AUTOFILL),
: PaymentRequestItemList::Item(spec,
state,
list,
selected,
/*clickable=*/true,
/*show_edit_button=*/false),
app_(app),
dialog_(dialog) {
Init();
Expand All @@ -69,28 +68,6 @@ class PaymentMethodListItem : public PaymentRequestItemList::Item {
~PaymentMethodListItem() override {}

private:
void ShowEditor() {
if (!app_)
return;

switch (app_->type()) {
case PaymentApp::Type::AUTOFILL:
// TODO(https://crbug.com/1209835): Remove this method entirely.
NOTREACHED() << "Autofill payment app is no longer supported";
return;
case PaymentApp::Type::UNDEFINED:
// Intentionally fall through.
case PaymentApp::Type::NATIVE_MOBILE_APP:
// Intentionally fall through.
case PaymentApp::Type::SERVICE_WORKER_APP:
// Intentionally fall through.
case PaymentApp::Type::INTERNAL:
// We cannot edit these types of payment apps.
return;
}
NOTREACHED();
}

// PaymentRequestItemList::Item:
std::unique_ptr<views::View> CreateExtraView() override {
return app_ ? CreateAppIconView(app_->icon_resource_id(),
Expand Down Expand Up @@ -156,9 +133,9 @@ class PaymentMethodListItem : public PaymentRequestItemList::Item {
return app_ && app_->IsCompleteForPayment();
}

void PerformSelectionFallback() override { ShowEditor(); }
void PerformSelectionFallback() override {}

void EditButtonPressed() override { ShowEditor(); }
void EditButtonPressed() override {}

base::WeakPtr<PaymentApp> app_;
base::WeakPtr<PaymentRequestDialogView> dialog_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,7 @@ bool PaymentRequestSheetController::ShouldShowPrimaryButton() {
}

std::u16string PaymentRequestSheetController::GetPrimaryButtonLabel() {
const bool continue_button =
state()->selected_app() &&
state()->selected_app()->type() != PaymentApp::Type::AUTOFILL;
return l10n_util::GetStringUTF16(
continue_button ? IDS_PAYMENTS_CONTINUE_BUTTON : IDS_PAYMENTS_PAY_BUTTON);
return l10n_util::GetStringUTF16(IDS_PAYMENTS_CONTINUE_BUTTON);
}

PaymentRequestSheetController::ButtonCallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ public class PaymentRequestService
/** True if canMakePayment() and hasEnrolledInstrument() are forced to return true. */
private boolean mCanMakePaymentEvenWithoutApps;

/**
* Whether there's at least one app that is not an autofill card. Should be read only after all
* payment apps have been queried.
*/
private boolean mHasNonAutofillApp;

private boolean mIsCanMakePaymentResponsePending;
private boolean mIsHasEnrolledInstrumentResponsePending;
@Nullable
Expand Down Expand Up @@ -776,24 +770,19 @@ public void invokePaymentApp(
private void logSelectedMethod(PaymentApp invokedPaymentApp) {
@PaymentMethodCategory
int category = PaymentMethodCategory.OTHER;
if (invokedPaymentApp.getPaymentAppType() == PaymentAppType.AUTOFILL) {
category = PaymentMethodCategory.BASIC_CARD;
} else {
for (String method : invokedPaymentApp.getInstrumentMethodNames()) {
if (method.equals(MethodStrings.ANDROID_PAY)
|| method.equals(MethodStrings.GOOGLE_PAY)) {
category = PaymentMethodCategory.GOOGLE;
break;
} else if (method.equals(MethodStrings.GOOGLE_PLAY_BILLING)) {
assert invokedPaymentApp.getPaymentAppType()
== PaymentAppType.NATIVE_MOBILE_APP;
category = PaymentMethodCategory.PLAY_BILLING;
break;
} else if (method.equals(MethodStrings.SECURE_PAYMENT_CONFIRMATION)) {
assert invokedPaymentApp.getPaymentAppType() == PaymentAppType.INTERNAL;
category = PaymentMethodCategory.SECURE_PAYMENT_CONFIRMATION;
break;
}
for (String method : invokedPaymentApp.getInstrumentMethodNames()) {
if (method.equals(MethodStrings.ANDROID_PAY)
|| method.equals(MethodStrings.GOOGLE_PAY)) {
category = PaymentMethodCategory.GOOGLE;
break;
} else if (method.equals(MethodStrings.GOOGLE_PLAY_BILLING)) {
assert invokedPaymentApp.getPaymentAppType() == PaymentAppType.NATIVE_MOBILE_APP;
category = PaymentMethodCategory.PLAY_BILLING;
break;
} else if (method.equals(MethodStrings.SECURE_PAYMENT_CONFIRMATION)) {
assert invokedPaymentApp.getPaymentAppType() == PaymentAppType.INTERNAL;
category = PaymentMethodCategory.SECURE_PAYMENT_CONFIRMATION;
break;
}
}

Expand Down Expand Up @@ -1039,13 +1028,8 @@ public void onPaymentAppCreated(PaymentApp paymentApp) {
if (mBrowserPaymentRequest == null) return;
if (!mBrowserPaymentRequest.onPaymentAppCreated(paymentApp)) return;
mHasEnrolledInstrument |= paymentApp.hasEnrolledInstrument();
mHasNonAutofillApp |= paymentApp.getPaymentAppType() != PaymentAppType.AUTOFILL;

// Note that only a test can add autofill payment apps when basic-card feature is disabled.
if (PaymentFeatureList.isEnabled(PaymentFeatureList.PAYMENT_REQUEST_BASIC_CARD)
&& paymentApp.getPaymentAppType() == PaymentAppType.AUTOFILL) {
mJourneyLogger.setAvailableMethod(PaymentMethodCategory.BASIC_CARD);
} else if (paymentApp.getInstrumentMethodNames().contains(MethodStrings.GOOGLE_PAY)
if (paymentApp.getInstrumentMethodNames().contains(MethodStrings.GOOGLE_PAY)
|| paymentApp.getInstrumentMethodNames().contains(MethodStrings.ANDROID_PAY)) {
mJourneyLogger.setAvailableMethod(PaymentMethodCategory.GOOGLE);
} else {
Expand Down Expand Up @@ -1212,8 +1196,7 @@ public static void resetShowingPaymentRequestForTest() {
private static boolean onlySingleAppCanProvideAllRequiredInformation(
PaymentOptions options, List<PaymentApp> allApps) {
if (!PaymentOptionsUtils.requestAnyInformation(options)) {
return allApps.size() == 1
&& allApps.get(0).getPaymentAppType() != PaymentAppType.AUTOFILL;
return allApps.size() == 1;
}

boolean anAppCanProvideAllInfo = false;
Expand Down
4 changes: 0 additions & 4 deletions components/payments/content/payment_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ int GetSortingGroup(const PaymentApp& app) {
case PaymentApp::Type::SERVICE_WORKER_APP:
case PaymentApp::Type::NATIVE_MOBILE_APP:
return 2;
case PaymentApp::Type::AUTOFILL:
// TODO(https://crbug.com/1209835): Remove PaymentApp::Type::AUTOFILL.
NOTREACHED() << "Autofill payment app is no longer supported";
return 99;
case PaymentApp::Type::UNDEFINED:
NOTREACHED();
return 99;
Expand Down
2 changes: 0 additions & 2 deletions components/payments/content/payment_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class PaymentApp {
// Undefined type of payment app. Can be used for setting the default return
// value of an abstract class or an interface.
UNDEFINED,
// The payment app built into the browser that uses the autofill data.
AUTOFILL,
// A 3rd-party platform-specific mobile app, such as an Android app
// integrated via
// https://developers.google.com/web/fundamentals/payments/payment-apps-developer-guide/android-payment-apps
Expand Down
6 changes: 1 addition & 5 deletions components/payments/content/payment_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,7 @@ bool PaymentRequest::OnlySingleAppCanProvideAllRequiredInformation() const {

if (!spec()->request_shipping() && !spec()->request_payer_name() &&
!spec()->request_payer_phone() && !spec()->request_payer_email()) {
return state()->available_apps().size() == 1 &&
state()->available_apps().at(0)->type() !=
PaymentApp::Type::AUTOFILL;
return state()->available_apps().size() == 1;
}

bool an_app_can_provide_all_info = false;
Expand Down Expand Up @@ -916,8 +914,6 @@ JourneyLogger::PaymentMethodCategory PaymentRequest::GetSelectedMethodCategory()
const PaymentApp* selected_app = state_->selected_app();
DCHECK(selected_app);
switch (state_->selected_app()->type()) {
case PaymentApp::Type::AUTOFILL:
return JourneyLogger::PaymentMethodCategory::kBasicCard;
case PaymentApp::Type::SERVICE_WORKER_APP:
// Intentionally fall through.
case PaymentApp::Type::NATIVE_MOBILE_APP: {
Expand Down
7 changes: 2 additions & 5 deletions components/payments/content/payment_request_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,8 @@ bool PaymentRequestState::IsOffTheRecord() const {

void PaymentRequestState::OnPaymentAppCreated(std::unique_ptr<PaymentApp> app) {
if (journey_logger_) {
if (app->type() == PaymentApp::Type::AUTOFILL) {
journey_logger_->SetAvailableMethod(
JourneyLogger::PaymentMethodCategory::kBasicCard);
} else if (base::Contains(app->GetAppMethodNames(), methods::kGooglePay) ||
base::Contains(app->GetAppMethodNames(), methods::kAndroidPay)) {
if (base::Contains(app->GetAppMethodNames(), methods::kGooglePay) ||
base::Contains(app->GetAppMethodNames(), methods::kAndroidPay)) {
journey_logger_->SetAvailableMethod(
JourneyLogger::PaymentMethodCategory::kGoogle);
} else {
Expand Down

0 comments on commit 91bed74

Please sign in to comment.