OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/payments/content/payment_request_state.h" | 5 #include "components/payments/content/payment_request_state.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 void PaymentRequestState::GeneratePaymentResponse() { | 100 void PaymentRequestState::GeneratePaymentResponse() { |
101 DCHECK(is_ready_to_pay()); | 101 DCHECK(is_ready_to_pay()); |
102 | 102 |
103 // Once the response is ready, will call back into OnPaymentResponseReady. | 103 // Once the response is ready, will call back into OnPaymentResponseReady. |
104 response_helper_ = base::MakeUnique<PaymentResponseHelper>( | 104 response_helper_ = base::MakeUnique<PaymentResponseHelper>( |
105 app_locale_, spec_, selected_instrument_, payment_request_delegate_, | 105 app_locale_, spec_, selected_instrument_, payment_request_delegate_, |
106 selected_shipping_profile_, selected_contact_profile_, this); | 106 selected_shipping_profile_, selected_contact_profile_, this); |
107 } | 107 } |
108 | 108 |
| 109 void PaymentRequestState::RecordUseStats() { |
| 110 if (spec_->request_shipping()) { |
| 111 DCHECK(selected_shipping_profile_); |
| 112 personal_data_manager_->RecordUseOf(*selected_shipping_profile_); |
| 113 } |
| 114 |
| 115 if (spec_->request_payer_name() || spec_->request_payer_email() || |
| 116 spec_->request_payer_phone()) { |
| 117 DCHECK(selected_contact_profile_); |
| 118 |
| 119 // If the same address was used for both contact and shipping, the stats |
| 120 // should only be updated once. |
| 121 if (!spec_->request_shipping() || (selected_shipping_profile_->guid() != |
| 122 selected_contact_profile_->guid())) { |
| 123 personal_data_manager_->RecordUseOf(*selected_contact_profile_); |
| 124 } |
| 125 } |
| 126 |
| 127 selected_instrument_->RecordUse(); |
| 128 } |
| 129 |
109 void PaymentRequestState::AddAutofillPaymentInstrument( | 130 void PaymentRequestState::AddAutofillPaymentInstrument( |
110 bool selected, | 131 bool selected, |
111 const autofill::CreditCard& card) { | 132 const autofill::CreditCard& card) { |
112 std::string basic_card_network = | 133 std::string basic_card_network = |
113 autofill::data_util::GetPaymentRequestData(card.network()) | 134 autofill::data_util::GetPaymentRequestData(card.network()) |
114 .basic_card_issuer_network; | 135 .basic_card_issuer_network; |
115 if (!spec_->supported_card_networks_set().count(basic_card_network)) | 136 if (!spec_->supported_card_networks_set().count(basic_card_network)) |
116 return; | 137 return; |
117 | 138 |
118 // AutofillPaymentInstrument makes a copy of |card| so it is effectively | 139 // AutofillPaymentInstrument makes a copy of |card| so it is effectively |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 if (is_waiting_for_merchant_validation_) | 295 if (is_waiting_for_merchant_validation_) |
275 return false; | 296 return false; |
276 | 297 |
277 if (!profile_comparator()->IsShippingComplete(selected_shipping_profile_)) | 298 if (!profile_comparator()->IsShippingComplete(selected_shipping_profile_)) |
278 return false; | 299 return false; |
279 | 300 |
280 return profile_comparator()->IsContactInfoComplete(selected_contact_profile_); | 301 return profile_comparator()->IsContactInfoComplete(selected_contact_profile_); |
281 } | 302 } |
282 | 303 |
283 } // namespace payments | 304 } // namespace payments |
OLD | NEW |