Chromium Code Reviews| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/autofill/core/browser/autofill_data_util.h" | 10 #include "components/autofill/core/browser/autofill_data_util.h" |
| 11 #include "components/autofill/core/browser/autofill_profile.h" | 11 #include "components/autofill/core/browser/autofill_profile.h" |
| 12 #include "components/autofill/core/browser/credit_card.h" | 12 #include "components/autofill/core/browser/credit_card.h" |
| 13 #include "components/autofill/core/browser/personal_data_manager.h" | 13 #include "components/autofill/core/browser/personal_data_manager.h" |
| 14 #include "components/payments/content/payment_request_delegate.h" | |
|
please use gerrit instead
2017/03/30 13:14:09
I don't think this is necessary, because you don't
anthonyvd
2017/03/30 15:43:41
Yeah it's required for the compiler to know that P
| |
| 14 #include "components/payments/content/payment_request_spec.h" | 15 #include "components/payments/content/payment_request_spec.h" |
| 15 #include "components/payments/content/payment_response_helper.h" | 16 #include "components/payments/content/payment_response_helper.h" |
| 16 #include "components/payments/core/autofill_payment_instrument.h" | 17 #include "components/payments/core/autofill_payment_instrument.h" |
| 17 | 18 |
| 18 namespace payments { | 19 namespace payments { |
| 19 | 20 |
| 20 PaymentRequestState::PaymentRequestState( | 21 PaymentRequestState::PaymentRequestState( |
| 21 PaymentRequestSpec* spec, | 22 PaymentRequestSpec* spec, |
| 22 Delegate* delegate, | 23 Delegate* delegate, |
| 23 const std::string& app_locale, | 24 const std::string& app_locale, |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 if (!supported_card_networks.count(basic_card_network)) | 175 if (!supported_card_networks.count(basic_card_network)) |
| 175 continue; | 176 continue; |
| 176 | 177 |
| 177 // TODO(crbug.com/701952): Should use the method name preferred by the | 178 // TODO(crbug.com/701952): Should use the method name preferred by the |
| 178 // merchant (either "basic-card" or the basic card network e.g. "visa"). | 179 // merchant (either "basic-card" or the basic card network e.g. "visa"). |
| 179 | 180 |
| 180 // Copy the credit cards as part of AutofillPaymentInstrument so they are | 181 // Copy the credit cards as part of AutofillPaymentInstrument so they are |
| 181 // indirectly owned by this object. | 182 // indirectly owned by this object. |
| 182 std::unique_ptr<PaymentInstrument> instrument = | 183 std::unique_ptr<PaymentInstrument> instrument = |
| 183 base::MakeUnique<AutofillPaymentInstrument>( | 184 base::MakeUnique<AutofillPaymentInstrument>( |
| 184 basic_card_network, *card, shipping_profiles_, app_locale_); | 185 basic_card_network, *card, shipping_profiles_, app_locale_, |
| 186 delegate_->GetPaymentRequestDelegate()); | |
| 185 available_instruments_.push_back(std::move(instrument)); | 187 available_instruments_.push_back(std::move(instrument)); |
| 186 } | 188 } |
| 187 } | 189 } |
| 188 | 190 |
| 189 void PaymentRequestState::SetDefaultProfileSelections() { | 191 void PaymentRequestState::SetDefaultProfileSelections() { |
| 190 if (!shipping_profiles().empty()) | 192 if (!shipping_profiles().empty()) |
| 191 selected_shipping_profile_ = shipping_profiles()[0]; | 193 selected_shipping_profile_ = shipping_profiles()[0]; |
| 192 | 194 |
| 193 if (!contact_profiles().empty()) | 195 if (!contact_profiles().empty()) |
| 194 selected_contact_profile_ = contact_profiles()[0]; | 196 selected_contact_profile_ = contact_profiles()[0]; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 spec_->details().shipping_options.rend(), | 274 spec_->details().shipping_options.rend(), |
| 273 [](const payments::mojom::PaymentShippingOptionPtr& element) { | 275 [](const payments::mojom::PaymentShippingOptionPtr& element) { |
| 274 return element->selected; | 276 return element->selected; |
| 275 }); | 277 }); |
| 276 if (selected_shipping_option_it != spec_->details().shipping_options.rend()) { | 278 if (selected_shipping_option_it != spec_->details().shipping_options.rend()) { |
| 277 selected_shipping_option_ = selected_shipping_option_it->get(); | 279 selected_shipping_option_ = selected_shipping_option_it->get(); |
| 278 } | 280 } |
| 279 } | 281 } |
| 280 | 282 |
| 281 } // namespace payments | 283 } // namespace payments |
| OLD | NEW |