| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // TODO(crbug.com/702063): Change this code to prioritize instruments by use | 239 // TODO(crbug.com/702063): Change this code to prioritize instruments by use |
| 240 // count and other means, and implement a way to modify this function's return | 240 // count and other means, and implement a way to modify this function's return |
| 241 // value. | 241 // value. |
| 242 const std::vector<std::unique_ptr<PaymentInstrument>>& instruments = | 242 const std::vector<std::unique_ptr<PaymentInstrument>>& instruments = |
| 243 available_instruments(); | 243 available_instruments(); |
| 244 auto first_complete_instrument = | 244 auto first_complete_instrument = |
| 245 std::find_if(instruments.begin(), instruments.end(), | 245 std::find_if(instruments.begin(), instruments.end(), |
| 246 [](const std::unique_ptr<PaymentInstrument>& instrument) { | 246 [](const std::unique_ptr<PaymentInstrument>& instrument) { |
| 247 return instrument->IsCompleteForPayment(); | 247 return instrument->IsCompleteForPayment(); |
| 248 }); | 248 }); |
| 249 | |
| 250 selected_instrument_ = first_complete_instrument == instruments.end() | 249 selected_instrument_ = first_complete_instrument == instruments.end() |
| 251 ? nullptr | 250 ? nullptr |
| 252 : first_complete_instrument->get(); | 251 : first_complete_instrument->get(); |
| 253 | |
| 254 UpdateIsReadyToPayAndNotifyObservers(); | 252 UpdateIsReadyToPayAndNotifyObservers(); |
| 255 } | 253 } |
| 256 | 254 |
| 257 void PaymentRequestState::UpdateIsReadyToPayAndNotifyObservers() { | 255 void PaymentRequestState::UpdateIsReadyToPayAndNotifyObservers() { |
| 258 is_ready_to_pay_ = | 256 is_ready_to_pay_ = |
| 259 ArePaymentDetailsSatisfied() && ArePaymentOptionsSatisfied(); | 257 ArePaymentDetailsSatisfied() && ArePaymentOptionsSatisfied(); |
| 260 NotifyOnSelectedInformationChanged(); | 258 NotifyOnSelectedInformationChanged(); |
| 261 } | 259 } |
| 262 | 260 |
| 263 void PaymentRequestState::NotifyOnSelectedInformationChanged() { | 261 void PaymentRequestState::NotifyOnSelectedInformationChanged() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 276 if (is_waiting_for_merchant_validation_) | 274 if (is_waiting_for_merchant_validation_) |
| 277 return false; | 275 return false; |
| 278 | 276 |
| 279 if (!profile_comparator()->IsShippingComplete(selected_shipping_profile_)) | 277 if (!profile_comparator()->IsShippingComplete(selected_shipping_profile_)) |
| 280 return false; | 278 return false; |
| 281 | 279 |
| 282 return profile_comparator()->IsContactInfoComplete(selected_contact_profile_); | 280 return profile_comparator()->IsContactInfoComplete(selected_contact_profile_); |
| 283 } | 281 } |
| 284 | 282 |
| 285 } // namespace payments | 283 } // namespace payments |
| OLD | NEW |