| 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 <set> | 8 #include <set> |
| 9 #include <utility> |
| 8 | 10 |
| 9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/autofill/core/browser/autofill_data_util.h" | 12 #include "components/autofill/core/browser/autofill_data_util.h" |
| 11 #include "components/autofill/core/browser/autofill_profile.h" | 13 #include "components/autofill/core/browser/autofill_profile.h" |
| 12 #include "components/autofill/core/browser/credit_card.h" | 14 #include "components/autofill/core/browser/credit_card.h" |
| 13 #include "components/autofill/core/browser/personal_data_manager.h" | 15 #include "components/autofill/core/browser/personal_data_manager.h" |
| 14 #include "components/payments/content/payment_request_spec.h" | 16 #include "components/payments/content/payment_request_spec.h" |
| 15 #include "components/payments/content/payment_response_helper.h" | 17 #include "components/payments/content/payment_response_helper.h" |
| 16 #include "components/payments/core/autofill_payment_instrument.h" | 18 #include "components/payments/core/autofill_payment_instrument.h" |
| 17 #include "components/payments/core/payment_instrument.h" | 19 #include "components/payments/core/payment_instrument.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 105 } |
| 104 | 106 |
| 105 const std::string& PaymentRequestState::GetApplicationLocale() { | 107 const std::string& PaymentRequestState::GetApplicationLocale() { |
| 106 return app_locale_; | 108 return app_locale_; |
| 107 } | 109 } |
| 108 | 110 |
| 109 autofill::PersonalDataManager* PaymentRequestState::GetPersonalDataManager() { | 111 autofill::PersonalDataManager* PaymentRequestState::GetPersonalDataManager() { |
| 110 return personal_data_manager_; | 112 return personal_data_manager_; |
| 111 } | 113 } |
| 112 | 114 |
| 115 std::unique_ptr<const ::i18n::addressinput::Source> |
| 116 PaymentRequestState::GetAddressInputSource() { |
| 117 return payment_request_delegate_->GetAddressInputSource(); |
| 118 } |
| 119 |
| 120 std::unique_ptr<::i18n::addressinput::Storage> |
| 121 PaymentRequestState::GetAddressInputStorage() { |
| 122 return payment_request_delegate_->GetAddressInputStorage(); |
| 123 } |
| 124 |
| 113 void PaymentRequestState::PopulateProfileCache() { | 125 void PaymentRequestState::PopulateProfileCache() { |
| 114 std::vector<autofill::AutofillProfile*> profiles = | 126 std::vector<autofill::AutofillProfile*> profiles = |
| 115 personal_data_manager_->GetProfilesToSuggest(); | 127 personal_data_manager_->GetProfilesToSuggest(); |
| 116 | 128 |
| 117 // PaymentRequest may outlive the Profiles returned by the Data Manager. | 129 // PaymentRequest may outlive the Profiles returned by the Data Manager. |
| 118 // Thus, we store copies, and return a vector of pointers to these copies | 130 // Thus, we store copies, and return a vector of pointers to these copies |
| 119 // whenever Profiles are requested. The same is true for credit cards. | 131 // whenever Profiles are requested. The same is true for credit cards. |
| 120 for (size_t i = 0; i < profiles.size(); i++) { | 132 for (size_t i = 0; i < profiles.size(); i++) { |
| 121 profile_cache_.push_back( | 133 profile_cache_.push_back( |
| 122 base::MakeUnique<autofill::AutofillProfile>(*profiles[i])); | 134 base::MakeUnique<autofill::AutofillProfile>(*profiles[i])); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 bool PaymentRequestState::ArePaymentOptionsSatisfied() { | 219 bool PaymentRequestState::ArePaymentOptionsSatisfied() { |
| 208 // TODO(mathp): Have a measure of shipping address completeness. | 220 // TODO(mathp): Have a measure of shipping address completeness. |
| 209 if (spec_->request_shipping() && selected_shipping_profile_ == nullptr) | 221 if (spec_->request_shipping() && selected_shipping_profile_ == nullptr) |
| 210 return false; | 222 return false; |
| 211 | 223 |
| 212 profile_util::PaymentsProfileComparator comparator(app_locale_, *spec_); | 224 profile_util::PaymentsProfileComparator comparator(app_locale_, *spec_); |
| 213 return comparator.IsContactInfoComplete(selected_contact_profile_); | 225 return comparator.IsContactInfoComplete(selected_contact_profile_); |
| 214 } | 226 } |
| 215 | 227 |
| 216 } // namespace payments | 228 } // namespace payments |
| OLD | NEW |