Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ios/chrome/browser/payments/payment_request.h" | 5 #include "ios/chrome/browser/payments/payment_request.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "components/autofill/core/browser/autofill_data_util.h" | 9 #include "components/autofill/core/browser/autofill_data_util.h" |
| 10 #include "components/autofill/core/browser/autofill_profile.h" | 10 #include "components/autofill/core/browser/autofill_profile.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 // contact profiles. | 70 // contact profiles. |
| 71 | 71 |
| 72 if (!shipping_profiles_.empty()) | 72 if (!shipping_profiles_.empty()) |
| 73 selected_shipping_profile_ = shipping_profiles_[0]; | 73 selected_shipping_profile_ = shipping_profiles_[0]; |
| 74 if (!contact_profiles_.empty()) | 74 if (!contact_profiles_.empty()) |
| 75 selected_contact_profile_ = contact_profiles_[0]; | 75 selected_contact_profile_ = contact_profiles_[0]; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void PaymentRequest::PopulateCreditCardCache() { | 78 void PaymentRequest::PopulateCreditCardCache() { |
| 79 for (const auto& method_data : web_payment_request_.method_data) { | 79 for (const auto& method_data : web_payment_request_.method_data) { |
| 80 for (const auto& supported_method : method_data.supported_methods) { | 80 for (const std::string& supported_method : method_data.supported_methods) { |
| 81 // Reject non-ASCII supported methods. | 81 // Reject non-ASCII supported methods. |
| 82 if (base::IsStringASCII(supported_method)) { | 82 if (base::IsStringASCII(supported_method)) |
|
Moe
2017/04/05 13:54:08
should we have this check in payment_method_data.c
Mathieu
2017/04/05 13:59:18
Yes sounds like a good idea! Also made the change
| |
| 83 supported_card_networks_.push_back( | 83 supported_card_networks_.push_back(supported_method); |
| 84 base::UTF16ToASCII(supported_method)); | |
| 85 } | |
| 86 } | 84 } |
| 87 } | 85 } |
| 88 | 86 |
| 89 const std::vector<autofill::CreditCard*>& credit_cards_to_suggest = | 87 const std::vector<autofill::CreditCard*>& credit_cards_to_suggest = |
| 90 personal_data_manager_->GetCreditCardsToSuggest(); | 88 personal_data_manager_->GetCreditCardsToSuggest(); |
| 91 credit_card_cache_.reserve(credit_cards_to_suggest.size()); | 89 credit_card_cache_.reserve(credit_cards_to_suggest.size()); |
| 92 | 90 |
| 93 // TODO(crbug.com/602666): Update the following logic to allow basic card | 91 // TODO(crbug.com/602666): Update the following logic to allow basic card |
| 94 // payment. https://w3c.github.io/webpayments-methods-card/ | 92 // payment. https://w3c.github.io/webpayments-methods-card/ |
| 95 // new PaymentRequest([{supportedMethods: ['basic-card'], | 93 // new PaymentRequest([{supportedMethods: ['basic-card'], |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 124 | 122 |
| 125 selected_shipping_option_ = nullptr; | 123 selected_shipping_option_ = nullptr; |
| 126 for (auto* shipping_option : shipping_options_) { | 124 for (auto* shipping_option : shipping_options_) { |
| 127 if (shipping_option->selected) { | 125 if (shipping_option->selected) { |
| 128 // If more than one option has |selected| set, the last one in the | 126 // If more than one option has |selected| set, the last one in the |
| 129 // sequence should be treated as the selected item. | 127 // sequence should be treated as the selected item. |
| 130 selected_shipping_option_ = shipping_option; | 128 selected_shipping_option_ = shipping_option; |
| 131 } | 129 } |
| 132 } | 130 } |
| 133 } | 131 } |
| OLD | NEW |