Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: ios/chrome/browser/payments/payment_request.mm

Issue 2844463004: Rename card 'type' into 'issuer network.' (Closed)
Patch Set: read -> use Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "components/autofill/core/browser/autofill_data_util.h" 8 #include "components/autofill/core/browser/autofill_data_util.h"
9 #include "components/autofill/core/browser/autofill_profile.h" 9 #include "components/autofill/core/browser/autofill_profile.h"
10 #include "components/autofill/core/browser/credit_card.h" 10 #include "components/autofill/core/browser/credit_card.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // TODO(crbug.com/709036): Validate method data. 115 // TODO(crbug.com/709036): Validate method data.
116 payments::data_util::ParseBasicCardSupportedNetworks( 116 payments::data_util::ParseBasicCardSupportedNetworks(
117 web_payment_request_.method_data, &supported_card_networks_, 117 web_payment_request_.method_data, &supported_card_networks_,
118 &basic_card_specified_networks_); 118 &basic_card_specified_networks_);
119 119
120 const std::vector<autofill::CreditCard*>& credit_cards_to_suggest = 120 const std::vector<autofill::CreditCard*>& credit_cards_to_suggest =
121 personal_data_manager_->GetCreditCardsToSuggest(); 121 personal_data_manager_->GetCreditCardsToSuggest();
122 credit_card_cache_.reserve(credit_cards_to_suggest.size()); 122 credit_card_cache_.reserve(credit_cards_to_suggest.size());
123 123
124 for (const auto* credit_card : credit_cards_to_suggest) { 124 for (const auto* credit_card : credit_cards_to_suggest) {
125 std::string spec_card_type = 125 std::string spec_issuer_network =
126 autofill::data_util::GetPaymentRequestData(credit_card->type()) 126 autofill::data_util::GetPaymentRequestData(credit_card->network())
127 .basic_card_payment_type; 127 .basic_card_issuer_network;
128 if (std::find(supported_card_networks_.begin(), 128 if (std::find(supported_card_networks_.begin(),
129 supported_card_networks_.end(), 129 supported_card_networks_.end(),
130 spec_card_type) != supported_card_networks_.end()) { 130 spec_issuer_network) != supported_card_networks_.end()) {
131 credit_card_cache_.push_back(*credit_card); 131 credit_card_cache_.push_back(*credit_card);
132 credit_cards_.push_back(&credit_card_cache_.back()); 132 credit_cards_.push_back(&credit_card_cache_.back());
133 } 133 }
134 } 134 }
135 135
136 // TODO(crbug.com/602666): Implement prioritization rules for credit cards. 136 // TODO(crbug.com/602666): Implement prioritization rules for credit cards.
137 137
138 if (!credit_cards_.empty()) 138 if (!credit_cards_.empty())
139 selected_credit_card_ = credit_cards_[0]; 139 selected_credit_card_ = credit_cards_[0];
140 } 140 }
141 141
142 void PaymentRequest::PopulateShippingOptionCache() { 142 void PaymentRequest::PopulateShippingOptionCache() {
143 shipping_options_.clear(); 143 shipping_options_.clear();
144 shipping_options_.reserve( 144 shipping_options_.reserve(
145 web_payment_request_.details.shipping_options.size()); 145 web_payment_request_.details.shipping_options.size());
146 std::transform(std::begin(web_payment_request_.details.shipping_options), 146 std::transform(std::begin(web_payment_request_.details.shipping_options),
147 std::end(web_payment_request_.details.shipping_options), 147 std::end(web_payment_request_.details.shipping_options),
148 std::back_inserter(shipping_options_), 148 std::back_inserter(shipping_options_),
149 [](web::PaymentShippingOption& option) { return &option; }); 149 [](web::PaymentShippingOption& option) { return &option; });
150 150
151 selected_shipping_option_ = nullptr; 151 selected_shipping_option_ = nullptr;
152 for (auto* shipping_option : shipping_options_) { 152 for (auto* shipping_option : shipping_options_) {
153 if (shipping_option->selected) { 153 if (shipping_option->selected) {
154 // If more than one option has |selected| set, the last one in the 154 // If more than one option has |selected| set, the last one in the
155 // sequence should be treated as the selected item. 155 // sequence should be treated as the selected item.
156 selected_shipping_option_ = shipping_option; 156 selected_shipping_option_ = shipping_option;
157 } 157 }
158 } 158 }
159 } 159 }
OLDNEW
« no previous file with comments | « components/webdata/common/web_database_table.h ('k') | ios/chrome/browser/ui/payments/credit_card_edit_mediator.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698