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

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

Issue 2805263003: [Payments] Selecting incomplete items will open editors (Closed)
Patch Set: addressed comments 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 0a1a487b5aaf6c6f85399733044507f0f384f124..4d9e0650909485acf10964308326c6a04957edd8 100644
--- a/components/payments/content/payment_request_state.cc
+++ b/components/payments/content/payment_request_state.cc
@@ -41,7 +41,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;
@@ -179,9 +179,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 =
@@ -209,7 +206,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()
@@ -233,8 +230,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() {

Powered by Google App Engine
This is Rietveld 408576698