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

Side by Side Diff: components/payments/content/payment_request_spec.cc

Issue 2963163002: [Payment Request] Displays accepted card types (credit, debit, etc) in iOS (Closed)
Patch Set: Addressed comment Created 3 years, 5 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
« no previous file with comments | « no previous file | components/payments/core/payment_request_data_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_spec.h" 5 #include "components/payments/content/payment_request_spec.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // (credit, debit). 179 // (credit, debit).
180 for (const mojom::BasicCardNetwork& network : 180 for (const mojom::BasicCardNetwork& network :
181 method_data_entry->supported_networks) { 181 method_data_entry->supported_networks) {
182 method_data.supported_networks.push_back( 182 method_data.supported_networks.push_back(
183 GetBasicCardNetworkName(network)); 183 GetBasicCardNetworkName(network));
184 } 184 }
185 for (const mojom::BasicCardType& type : 185 for (const mojom::BasicCardType& type :
186 method_data_entry->supported_types) { 186 method_data_entry->supported_types) {
187 autofill::CreditCard::CardType card_type = GetBasicCardType(type); 187 autofill::CreditCard::CardType card_type = GetBasicCardType(type);
188 method_data.supported_types.insert(card_type); 188 method_data.supported_types.insert(card_type);
189 supported_card_types_set_.insert(card_type);
190 } 189 }
191 190
192 method_data_vector.push_back(std::move(method_data)); 191 method_data_vector.push_back(std::move(method_data));
193 } 192 }
194 193
195 // TODO(rouslan): Parse card types (credit, debit, prepaid) in data_util, so
196 // iOS can use it as well. http://crbug.com/602665
197 data_util::ParseBasicCardSupportedNetworks(method_data_vector, 194 data_util::ParseBasicCardSupportedNetworks(method_data_vector,
198 &supported_card_networks_, 195 &supported_card_networks_,
199 &basic_card_specified_networks_); 196 &basic_card_specified_networks_);
200 supported_card_networks_set_.insert(supported_card_networks_.begin(), 197 supported_card_networks_set_.insert(supported_card_networks_.begin(),
201 supported_card_networks_.end()); 198 supported_card_networks_.end());
202 199
203 // Omitting the card types means all 3 card types are supported. 200 data_util::ParseSupportedCardTypes(method_data_vector,
204 if (supported_card_types_set_.empty()) { 201 &supported_card_types_set_);
205 supported_card_types_set_.insert(autofill::CreditCard::CARD_TYPE_CREDIT);
206 supported_card_types_set_.insert(autofill::CreditCard::CARD_TYPE_DEBIT);
207 supported_card_types_set_.insert(autofill::CreditCard::CARD_TYPE_PREPAID);
208 }
209
210 // Let the user decide whether an unknown card type should be used.
211 supported_card_types_set_.insert(autofill::CreditCard::CARD_TYPE_UNKNOWN);
212 } 202 }
213 203
214 void PaymentRequestSpec::UpdateSelectedShippingOption(bool after_update) { 204 void PaymentRequestSpec::UpdateSelectedShippingOption(bool after_update) {
215 if (!request_shipping()) 205 if (!request_shipping())
216 return; 206 return;
217 207
218 selected_shipping_option_ = nullptr; 208 selected_shipping_option_ = nullptr;
219 selected_shipping_option_error_.clear(); 209 selected_shipping_option_error_.clear();
220 if (details().shipping_options.empty()) { 210 if (details().shipping_options.empty()) {
221 // No options are provided by the merchant. 211 // No options are provided by the merchant.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // return the cached version. 262 // return the cached version.
273 std::pair<std::map<std::string, CurrencyFormatter>::iterator, bool> 263 std::pair<std::map<std::string, CurrencyFormatter>::iterator, bool>
274 emplace_result = currency_formatters_.emplace( 264 emplace_result = currency_formatters_.emplace(
275 std::piecewise_construct, std::forward_as_tuple(currency_code), 265 std::piecewise_construct, std::forward_as_tuple(currency_code),
276 std::forward_as_tuple(currency_code, currency_system, locale_name)); 266 std::forward_as_tuple(currency_code, currency_system, locale_name));
277 267
278 return &(emplace_result.first->second); 268 return &(emplace_result.first->second);
279 } 269 }
280 270
281 } // namespace payments 271 } // namespace payments
OLDNEW
« no previous file with comments | « no previous file | components/payments/core/payment_request_data_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698