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

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