Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Unified Diff: components/payments/content/payment_request_state.cc

Issue 2805263003: [Payments] Selecting incomplete items will open editors (Closed)
Patch Set: fix ios test for realz Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/payments/content/payment_request_state.cc
diff --git a/components/payments/content/payment_request_state.cc b/components/payments/content/payment_request_state.cc
index 2f7850ced4235d8701b99e5f56ed4316e3620a28..81d254594aa7b94c7b9c86e890082c23337ac9b3 100644
--- a/components/payments/content/payment_request_state.cc
+++ b/components/payments/content/payment_request_state.cc
@@ -42,7 +42,7 @@ PaymentRequestState::~PaymentRequestState() {}
bool PaymentRequestState::CanMakePayment() const {
for (const std::unique_ptr<PaymentInstrument>& instrument :
available_instruments_) {
- if (instrument.get()->IsValid() &&
+ if (instrument->IsValidForCanMakePayment() &&
spec_->supported_card_networks_set().count(
instrument.get()->method_name())) {
return true;
@@ -190,9 +190,6 @@ void PaymentRequestState::PopulateProfileCache() {
if (!supported_card_networks.count(basic_card_network))
continue;
- // TODO(crbug.com/701952): Should use the method name preferred by the
- // merchant (either "basic-card" or the basic card network e.g. "visa").
-
// Copy the credit cards as part of AutofillPaymentInstrument so they are
// indirectly owned by this object.
std::unique_ptr<PaymentInstrument> instrument =
@@ -220,7 +217,7 @@ void PaymentRequestState::SetDefaultProfileSelections() {
auto first_complete_instrument =
std::find_if(instruments.begin(), instruments.end(),
[](const std::unique_ptr<PaymentInstrument>& instrument) {
- return instrument->IsValid();
+ return instrument->IsCompleteForPayment();
});
selected_instrument_ = first_complete_instrument == instruments.end()
@@ -244,8 +241,8 @@ void PaymentRequestState::NotifyOnSelectedInformationChanged() {
bool PaymentRequestState::ArePaymentDetailsSatisfied() {
// There is no need to check for supported networks, because only supported
// instruments are listed/created in the flow.
- // TODO(crbug.com/702063): A masked card may not satisfy IsValid().
- return selected_instrument_ != nullptr && selected_instrument_->IsValid();
+ return selected_instrument_ != nullptr &&
+ selected_instrument_->IsCompleteForPayment();
}
bool PaymentRequestState::ArePaymentOptionsSatisfied() {
« no previous file with comments | « components/autofill/core/browser/autofill_test_utils.cc ('k') | components/payments/content/payment_request_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698