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

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

Issue 2797833002: [Payments] base::string16 -> std::string in PaymentMethodData (Closed)
Patch Set: addressed comments 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/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
9 #include "components/autofill/core/browser/autofill_data_util.h" 8 #include "components/autofill/core/browser/autofill_data_util.h"
10 #include "components/autofill/core/browser/autofill_profile.h" 9 #include "components/autofill/core/browser/autofill_profile.h"
11 #include "components/autofill/core/browser/credit_card.h" 10 #include "components/autofill/core/browser/credit_card.h"
12 #include "components/autofill/core/browser/personal_data_manager.h" 11 #include "components/autofill/core/browser/personal_data_manager.h"
13 #include "components/payments/core/currency_formatter.h" 12 #include "components/payments/core/currency_formatter.h"
14 #include "ios/chrome/browser/application_context.h" 13 #include "ios/chrome/browser/application_context.h"
15 #include "ios/web/public/payments/payment_request.h" 14 #include "ios/web/public/payments/payment_request.h"
16 15
17 #if !defined(__has_feature) || !__has_feature(objc_arc) 16 #if !defined(__has_feature) || !__has_feature(objc_arc)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // contact profiles. 69 // contact profiles.
71 70
72 if (!shipping_profiles_.empty()) 71 if (!shipping_profiles_.empty())
73 selected_shipping_profile_ = shipping_profiles_[0]; 72 selected_shipping_profile_ = shipping_profiles_[0];
74 if (!contact_profiles_.empty()) 73 if (!contact_profiles_.empty())
75 selected_contact_profile_ = contact_profiles_[0]; 74 selected_contact_profile_ = contact_profiles_[0];
76 } 75 }
77 76
78 void PaymentRequest::PopulateCreditCardCache() { 77 void PaymentRequest::PopulateCreditCardCache() {
79 for (const auto& method_data : web_payment_request_.method_data) { 78 for (const auto& method_data : web_payment_request_.method_data) {
80 for (const auto& supported_method : method_data.supported_methods) { 79 for (const std::string& supported_method : method_data.supported_methods) {
81 // Reject non-ASCII supported methods. 80 supported_card_networks_.push_back(supported_method);
82 if (base::IsStringASCII(supported_method)) {
83 supported_card_networks_.push_back(
84 base::UTF16ToASCII(supported_method));
85 }
86 } 81 }
87 } 82 }
88 83
89 const std::vector<autofill::CreditCard*>& credit_cards_to_suggest = 84 const std::vector<autofill::CreditCard*>& credit_cards_to_suggest =
90 personal_data_manager_->GetCreditCardsToSuggest(); 85 personal_data_manager_->GetCreditCardsToSuggest();
91 credit_card_cache_.reserve(credit_cards_to_suggest.size()); 86 credit_card_cache_.reserve(credit_cards_to_suggest.size());
92 87
93 // TODO(crbug.com/602666): Update the following logic to allow basic card 88 // TODO(crbug.com/602666): Update the following logic to allow basic card
94 // payment. https://w3c.github.io/webpayments-methods-card/ 89 // payment. https://w3c.github.io/webpayments-methods-card/
95 // new PaymentRequest([{supportedMethods: ['basic-card'], 90 // new PaymentRequest([{supportedMethods: ['basic-card'],
(...skipping 28 matching lines...) Expand all
124 119
125 selected_shipping_option_ = nullptr; 120 selected_shipping_option_ = nullptr;
126 for (auto* shipping_option : shipping_options_) { 121 for (auto* shipping_option : shipping_options_) {
127 if (shipping_option->selected) { 122 if (shipping_option->selected) {
128 // If more than one option has |selected| set, the last one in the 123 // If more than one option has |selected| set, the last one in the
129 // sequence should be treated as the selected item. 124 // sequence should be treated as the selected item.
130 selected_shipping_option_ = shipping_option; 125 selected_shipping_option_ = shipping_option;
131 } 126 }
132 } 127 }
133 } 128 }
OLDNEW
« no previous file with comments | « components/payments/core/payment_method_data_unittest.cc ('k') | ios/chrome/browser/payments/payment_request_test_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698