| 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 17 matching lines...) Expand all Loading... |
| 28 const std::string& app_locale, | 28 const std::string& app_locale, |
| 29 autofill::PersonalDataManager* personal_data_manager, | 29 autofill::PersonalDataManager* personal_data_manager, |
| 30 PaymentRequestDelegate* payment_request_delegate) | 30 PaymentRequestDelegate* payment_request_delegate) |
| 31 : is_ready_to_pay_(false), | 31 : is_ready_to_pay_(false), |
| 32 is_waiting_for_merchant_validation_(false), | 32 is_waiting_for_merchant_validation_(false), |
| 33 app_locale_(app_locale), | 33 app_locale_(app_locale), |
| 34 spec_(spec), | 34 spec_(spec), |
| 35 delegate_(delegate), | 35 delegate_(delegate), |
| 36 personal_data_manager_(personal_data_manager), | 36 personal_data_manager_(personal_data_manager), |
| 37 selected_shipping_profile_(nullptr), | 37 selected_shipping_profile_(nullptr), |
| 38 selected_shipping_option_error_profile_(nullptr), |
| 38 selected_contact_profile_(nullptr), | 39 selected_contact_profile_(nullptr), |
| 39 selected_instrument_(nullptr), | 40 selected_instrument_(nullptr), |
| 40 payment_request_delegate_(payment_request_delegate), | 41 payment_request_delegate_(payment_request_delegate), |
| 41 profile_comparator_(app_locale, *spec) { | 42 profile_comparator_(app_locale, *spec) { |
| 42 PopulateProfileCache(); | 43 PopulateProfileCache(); |
| 43 SetDefaultProfileSelections(); | 44 SetDefaultProfileSelections(); |
| 44 spec_->AddObserver(this); | 45 spec_->AddObserver(this); |
| 45 } | 46 } |
| 46 PaymentRequestState::~PaymentRequestState() {} | 47 PaymentRequestState::~PaymentRequestState() {} |
| 47 | 48 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 } | 59 } |
| 59 | 60 |
| 60 void PaymentRequestState::OnCouldNotNormalize( | 61 void PaymentRequestState::OnCouldNotNormalize( |
| 61 const autofill::AutofillProfile& profile) { | 62 const autofill::AutofillProfile& profile) { |
| 62 // Since the phone number is formatted in either case, this profile should be | 63 // Since the phone number is formatted in either case, this profile should be |
| 63 // used. | 64 // used. |
| 64 OnAddressNormalized(profile); | 65 OnAddressNormalized(profile); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void PaymentRequestState::OnSpecUpdated() { | 68 void PaymentRequestState::OnSpecUpdated() { |
| 69 if (spec_->selected_shipping_option_error().empty()) { |
| 70 selected_shipping_option_error_profile_ = nullptr; |
| 71 } else { |
| 72 selected_shipping_option_error_profile_ = selected_shipping_profile_; |
| 73 selected_shipping_profile_ = nullptr; |
| 74 } |
| 68 is_waiting_for_merchant_validation_ = false; | 75 is_waiting_for_merchant_validation_ = false; |
| 69 UpdateIsReadyToPayAndNotifyObservers(); | 76 UpdateIsReadyToPayAndNotifyObservers(); |
| 70 } | 77 } |
| 71 | 78 |
| 72 bool PaymentRequestState::CanMakePayment() const { | 79 bool PaymentRequestState::CanMakePayment() const { |
| 73 for (const std::unique_ptr<PaymentInstrument>& instrument : | 80 for (const std::unique_ptr<PaymentInstrument>& instrument : |
| 74 available_instruments_) { | 81 available_instruments_) { |
| 75 if (instrument->IsValidForCanMakePayment()) { | 82 if (instrument->IsValidForCanMakePayment()) { |
| 76 // AddAutofillPaymentInstrument() filters out available instruments based | 83 // AddAutofillPaymentInstrument() filters out available instruments based |
| 77 // on supported card networks. | 84 // on supported card networks. |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 if (is_waiting_for_merchant_validation_) | 323 if (is_waiting_for_merchant_validation_) |
| 317 return false; | 324 return false; |
| 318 | 325 |
| 319 if (!profile_comparator()->IsShippingComplete(selected_shipping_profile_)) | 326 if (!profile_comparator()->IsShippingComplete(selected_shipping_profile_)) |
| 320 return false; | 327 return false; |
| 321 | 328 |
| 322 return profile_comparator()->IsContactInfoComplete(selected_contact_profile_); | 329 return profile_comparator()->IsContactInfoComplete(selected_contact_profile_); |
| 323 } | 330 } |
| 324 | 331 |
| 325 } // namespace payments | 332 } // namespace payments |
| OLD | NEW |