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

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

Issue 2847503002: [WebPayments] Show labels on incomplete profiles (Closed)
Patch Set: test fix 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
« no previous file with comments | « components/payments/content/payment_request_state.h ('k') | components/payments/core/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 afa32130a63db2460539c8fc7a29487cc0d0cf75..c43f691dea6a9bc35026a4b39a04087cfa2433fa 100644
--- a/components/payments/content/payment_request_state.cc
+++ b/components/payments/content/payment_request_state.cc
@@ -17,8 +17,8 @@
#include "components/payments/content/payment_response_helper.h"
#include "components/payments/core/autofill_payment_instrument.h"
#include "components/payments/core/payment_instrument.h"
+#include "components/payments/core/payment_request_data_util.h"
#include "components/payments/core/payment_request_delegate.h"
-#include "components/payments/core/profile_util.h"
namespace payments {
@@ -37,7 +37,8 @@ PaymentRequestState::PaymentRequestState(
selected_shipping_profile_(nullptr),
selected_contact_profile_(nullptr),
selected_instrument_(nullptr),
- payment_request_delegate_(payment_request_delegate) {
+ payment_request_delegate_(payment_request_delegate),
+ profile_comparator_(app_locale, *spec) {
PopulateProfileCache();
SetDefaultProfileSelections();
spec_->AddObserver(this);
@@ -163,10 +164,8 @@ void PaymentRequestState::SetSelectedShippingProfile(
// Start the normalization of the shipping address.
// Use the country code from the profile if it is set, otherwise infer it
// from the |app_locale_|.
- std::string country_code = base::UTF16ToUTF8(
- selected_shipping_profile_->GetRawInfo(autofill::ADDRESS_HOME_COUNTRY));
- if (!autofill::data_util::IsValidCountryCode(country_code))
- country_code = autofill::AutofillCountry::CountryCodeForLocale(app_locale_);
+ std::string country_code = data_util::GetCountryCodeWithFallback(
+ selected_shipping_profile_, app_locale_);
payment_request_delegate_->GetAddressNormalizer()->StartAddressNormalization(
*selected_shipping_profile_, country_code, /*timeout_seconds=*/2, this);
}
@@ -218,8 +217,8 @@ void PaymentRequestState::PopulateProfileCache() {
return p.get();
});
- contact_profiles_ = profile_util::FilterProfilesForContact(
- raw_profiles_for_filtering, GetApplicationLocale(), *spec_);
+ contact_profiles_ = profile_comparator()->FilterProfilesForContact(
+ raw_profiles_for_filtering);
// Create the list of available instruments.
const std::vector<autofill::CreditCard*>& cards =
@@ -274,15 +273,13 @@ bool PaymentRequestState::ArePaymentDetailsSatisfied() {
}
bool PaymentRequestState::ArePaymentOptionsSatisfied() {
- // TODO(mathp): Have a measure of shipping address completeness.
- if (spec_->request_shipping() && selected_shipping_profile_ == nullptr)
+ if (is_waiting_for_merchant_validation_)
return false;
- if (is_waiting_for_merchant_validation_)
+ if (!profile_comparator()->IsShippingComplete(selected_shipping_profile_))
return false;
- profile_util::PaymentsProfileComparator comparator(app_locale_, *spec_);
- return comparator.IsContactInfoComplete(selected_contact_profile_);
+ return profile_comparator()->IsContactInfoComplete(selected_contact_profile_);
}
} // namespace payments
« no previous file with comments | « components/payments/content/payment_request_state.h ('k') | components/payments/core/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698