| 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.h" | 5 #include "components/payments/content/payment_request.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 autofill::data_util::GetPaymentRequestData(selected_credit_card_->type()) | 291 autofill::data_util::GetPaymentRequestData(selected_credit_card_->type()) |
| 292 .basic_card_payment_type; | 292 .basic_card_payment_type; |
| 293 return !supported_card_networks_.empty() && | 293 return !supported_card_networks_.empty() && |
| 294 std::find(supported_card_networks_.begin(), | 294 std::find(supported_card_networks_.begin(), |
| 295 supported_card_networks_.end(), | 295 supported_card_networks_.end(), |
| 296 basic_card_payment_type) != supported_card_networks_.end(); | 296 basic_card_payment_type) != supported_card_networks_.end(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool PaymentRequest::ArePaymentOptionsSatisfied() { | 299 bool PaymentRequest::ArePaymentOptionsSatisfied() { |
| 300 // TODO(mathp): Have a measure of shipping address completeness. | 300 // TODO(mathp): Have a measure of shipping address completeness. |
| 301 if (options_->request_shipping && selected_shipping_profile_ == nullptr) | 301 if (request_shipping() && selected_shipping_profile_ == nullptr) |
| 302 return false; | 302 return false; |
| 303 | 303 |
| 304 // TODO(mathp): Make an encompassing class to validate contact info. | 304 // TODO(mathp): Make an encompassing class to validate contact info. |
| 305 const std::string& app_locale = delegate_->GetApplicationLocale(); | 305 const std::string& app_locale = delegate_->GetApplicationLocale(); |
| 306 if (options_->request_payer_name && | 306 if (request_payer_name() && |
| 307 (selected_contact_profile_ == nullptr || | 307 (selected_contact_profile_ == nullptr || |
| 308 selected_contact_profile_ | 308 selected_contact_profile_ |
| 309 ->GetInfo(autofill::AutofillType(autofill::NAME_FULL), app_locale) | 309 ->GetInfo(autofill::AutofillType(autofill::NAME_FULL), app_locale) |
| 310 .empty())) { | 310 .empty())) { |
| 311 return false; | 311 return false; |
| 312 } | 312 } |
| 313 if (options_->request_payer_email && | 313 if (request_payer_email() && |
| 314 (selected_contact_profile_ == nullptr || | 314 (selected_contact_profile_ == nullptr || |
| 315 selected_contact_profile_ | 315 selected_contact_profile_ |
| 316 ->GetInfo(autofill::AutofillType(autofill::EMAIL_ADDRESS), | 316 ->GetInfo(autofill::AutofillType(autofill::EMAIL_ADDRESS), |
| 317 app_locale) | 317 app_locale) |
| 318 .empty())) { | 318 .empty())) { |
| 319 return false; | 319 return false; |
| 320 } | 320 } |
| 321 if (options_->request_payer_phone && | 321 if (request_payer_phone() && |
| 322 (selected_contact_profile_ == nullptr || | 322 (selected_contact_profile_ == nullptr || |
| 323 selected_contact_profile_ | 323 selected_contact_profile_ |
| 324 ->GetInfo(autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER), | 324 ->GetInfo(autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER), |
| 325 app_locale) | 325 app_locale) |
| 326 .empty())) { | 326 .empty())) { |
| 327 return false; | 327 return false; |
| 328 } | 328 } |
| 329 | 329 |
| 330 return true; | 330 return true; |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace payments | 333 } // namespace payments |
| OLD | NEW |