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

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

Issue 2963163002: [Payment Request] Displays accepted card types (credit, debit, etc) in iOS (Closed)
Patch Set: 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
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/containers/adapters.h" 9 #include "base/containers/adapters.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "components/autofill/core/browser/autofill_data_util.h" 12 #include "components/autofill/core/browser/autofill_data_util.h"
13 #include "components/autofill/core/browser/autofill_profile.h" 13 #include "components/autofill/core/browser/autofill_profile.h"
14 #include "components/autofill/core/browser/credit_card.h"
15 #include "components/autofill/core/browser/personal_data_manager.h" 14 #include "components/autofill/core/browser/personal_data_manager.h"
16 #include "components/autofill/core/browser/region_data_loader_impl.h" 15 #include "components/autofill/core/browser/region_data_loader_impl.h"
17 #include "components/autofill/core/browser/validation.h" 16 #include "components/autofill/core/browser/validation.h"
18 #include "components/payments/core/address_normalizer_impl.h" 17 #include "components/payments/core/address_normalizer_impl.h"
19 #include "components/payments/core/currency_formatter.h" 18 #include "components/payments/core/currency_formatter.h"
20 #include "components/payments/core/payment_request_data_util.h" 19 #include "components/payments/core/payment_request_data_util.h"
21 #include "ios/chrome/browser/application_context.h" 20 #include "ios/chrome/browser/application_context.h"
22 #include "ios/chrome/browser/autofill/validation_rules_storage_factory.h" 21 #include "ios/chrome/browser/autofill/validation_rules_storage_factory.h"
23 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 22 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
24 #import "ios/chrome/browser/payments/payment_request_util.h" 23 #import "ios/chrome/browser/payments/payment_request_util.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 for (const std::string& method : method_data_entry.supported_methods) { 278 for (const std::string& method : method_data_entry.supported_methods) {
280 stringified_method_data_[method].insert(method_data_entry.data); 279 stringified_method_data_[method].insert(method_data_entry.data);
281 } 280 }
282 } 281 }
283 282
284 // TODO(crbug.com/709036): Validate method data. 283 // TODO(crbug.com/709036): Validate method data.
285 payments::data_util::ParseBasicCardSupportedNetworks( 284 payments::data_util::ParseBasicCardSupportedNetworks(
286 web_payment_request_.method_data, &supported_card_networks_, 285 web_payment_request_.method_data, &supported_card_networks_,
287 &basic_card_specified_networks_); 286 &basic_card_specified_networks_);
288 287
288 payments::data_util::ParseSupportedCardTypes(web_payment_request_.method_data,
289 &supported_card_types_set_);
290
289 const std::vector<autofill::CreditCard*>& credit_cards_to_suggest = 291 const std::vector<autofill::CreditCard*>& credit_cards_to_suggest =
290 personal_data_manager_->GetCreditCardsToSuggest(); 292 personal_data_manager_->GetCreditCardsToSuggest();
291 // Return early if the user has no stored credit cards. 293 // Return early if the user has no stored credit cards.
292 if (credit_cards_to_suggest.empty()) 294 if (credit_cards_to_suggest.empty())
293 return; 295 return;
294 296
295 credit_card_cache_.reserve(credit_cards_to_suggest.size()); 297 credit_card_cache_.reserve(credit_cards_to_suggest.size());
296 298
297 for (const auto* credit_card : credit_cards_to_suggest) { 299 for (const auto* credit_card : credit_cards_to_suggest) {
298 std::string spec_issuer_network = 300 std::string spec_issuer_network =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 void PaymentRequest::SetSelectedShippingOption() { 339 void PaymentRequest::SetSelectedShippingOption() {
338 // If more than one option has |selected| set, the last one in the sequence 340 // If more than one option has |selected| set, the last one in the sequence
339 // should be treated as the selected item. 341 // should be treated as the selected item.
340 for (auto* shipping_option : base::Reversed(shipping_options_)) { 342 for (auto* shipping_option : base::Reversed(shipping_options_)) {
341 if (shipping_option->selected) { 343 if (shipping_option->selected) {
342 selected_shipping_option_ = shipping_option; 344 selected_shipping_option_ = shipping_option;
343 break; 345 break;
344 } 346 }
345 } 347 }
346 } 348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698