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

Unified Diff: ios/chrome/browser/payments/payment_request.mm

Issue 2972643003: [Payment Request] Records the use of data models used in Payment Request. (Closed)
Patch Set: Addressed comments Created 3 years, 5 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: ios/chrome/browser/payments/payment_request.mm
diff --git a/ios/chrome/browser/payments/payment_request.mm b/ios/chrome/browser/payments/payment_request.mm
index 406ba1e571fe95afe59983eb71142e9db87b298b..3885edb41feb6fa1fe4d4258cf40d3d8b8d62faf 100644
--- a/ios/chrome/browser/payments/payment_request.mm
+++ b/ios/chrome/browser/payments/payment_request.mm
@@ -73,18 +73,22 @@ PaymentRequest::PaymentRequest(
SetSelectedShippingOption();
- // If the merchant provided a default shipping option, and the highest-ranking
- // shipping profile is usable, select it.
- if (selected_shipping_option_ && !shipping_profiles_.empty() &&
- profile_comparator_.IsShippingComplete(shipping_profiles_[0])) {
- selected_shipping_profile_ = shipping_profiles_[0];
+ if (request_shipping()) {
+ // If the merchant provided a default shipping option, and the
+ // highest-ranking shipping profile is usable, select it.
+ if (selected_shipping_option_ && !shipping_profiles_.empty() &&
+ profile_comparator_.IsShippingComplete(shipping_profiles_[0])) {
+ selected_shipping_profile_ = shipping_profiles_[0];
+ }
}
- // If the highest-ranking contact profile is usable, select it. Otherwise,
- // select none.
- if (!contact_profiles_.empty() &&
- profile_comparator_.IsContactInfoComplete(contact_profiles_[0])) {
- selected_contact_profile_ = contact_profiles_[0];
+ if (request_payer_name() || request_payer_email() || request_payer_phone()) {
+ // If the highest-ranking contact profile is usable, select it. Otherwise,
+ // select none.
+ if (!contact_profiles_.empty() &&
+ profile_comparator_.IsContactInfoComplete(contact_profiles_[0])) {
+ selected_contact_profile_ = contact_profiles_[0];
+ }
}
// TODO(crbug.com/702063): Change this code to prioritize credit cards by use
@@ -273,6 +277,26 @@ bool PaymentRequest::CanMakePayment() const {
return false;
}
+void PaymentRequest::RecordUseStats() {
+ if (request_shipping()) {
+ DCHECK(selected_shipping_profile_);
+ personal_data_manager_->RecordUseOf(*selected_shipping_profile_);
+ }
+
+ if (request_payer_name() || request_payer_email() || request_payer_phone()) {
+ DCHECK(selected_contact_profile_);
+ // If the same address was used for both contact and shipping, the stats
+ // should be updated only once.
+ if (!request_shipping() || (selected_shipping_profile_->guid() !=
+ selected_contact_profile_->guid())) {
+ personal_data_manager_->RecordUseOf(*selected_contact_profile_);
+ }
+ }
+
+ DCHECK(selected_credit_card_);
+ personal_data_manager_->RecordUseOf(*selected_credit_card_);
+}
+
void PaymentRequest::PopulateCreditCardCache() {
for (const payments::PaymentMethodData& method_data_entry :
web_payment_request_.method_data) {
« no previous file with comments | « ios/chrome/browser/payments/payment_request.h ('k') | ios/chrome/browser/payments/payment_request_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698