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

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

Issue 2945803002: Use ContainsValue() instead of std::find() in ios/ (Closed)
Patch Set: Fixed compilation error. 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 "base/containers/adapters.h" 7 #include "base/containers/adapters.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/stl_util.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/core/browser/autofill_data_util.h" 11 #include "components/autofill/core/browser/autofill_data_util.h"
11 #include "components/autofill/core/browser/autofill_profile.h" 12 #include "components/autofill/core/browser/autofill_profile.h"
12 #include "components/autofill/core/browser/credit_card.h" 13 #include "components/autofill/core/browser/credit_card.h"
13 #include "components/autofill/core/browser/personal_data_manager.h" 14 #include "components/autofill/core/browser/personal_data_manager.h"
14 #include "components/autofill/core/browser/region_data_loader_impl.h" 15 #include "components/autofill/core/browser/region_data_loader_impl.h"
15 #include "components/payments/core/currency_formatter.h" 16 #include "components/payments/core/currency_formatter.h"
16 #include "components/payments/core/payment_request_data_util.h" 17 #include "components/payments/core/payment_request_data_util.h"
17 #include "ios/chrome/browser/application_context.h" 18 #include "ios/chrome/browser/application_context.h"
18 #include "ios/chrome/browser/autofill/validation_rules_storage_factory.h" 19 #include "ios/chrome/browser/autofill/validation_rules_storage_factory.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Return early if the user has no stored credit cards. 201 // Return early if the user has no stored credit cards.
201 if (credit_cards_to_suggest.empty()) 202 if (credit_cards_to_suggest.empty())
202 return; 203 return;
203 204
204 credit_card_cache_.reserve(credit_cards_to_suggest.size()); 205 credit_card_cache_.reserve(credit_cards_to_suggest.size());
205 206
206 for (const auto* credit_card : credit_cards_to_suggest) { 207 for (const auto* credit_card : credit_cards_to_suggest) {
207 std::string spec_issuer_network = 208 std::string spec_issuer_network =
208 autofill::data_util::GetPaymentRequestData(credit_card->network()) 209 autofill::data_util::GetPaymentRequestData(credit_card->network())
209 .basic_card_issuer_network; 210 .basic_card_issuer_network;
210 if (std::find(supported_card_networks_.begin(), 211 if (base::ContainsValue(supported_card_networks_, spec_issuer_network)) {
211 supported_card_networks_.end(),
212 spec_issuer_network) != supported_card_networks_.end()) {
213 credit_card_cache_.push_back( 212 credit_card_cache_.push_back(
214 base::MakeUnique<autofill::CreditCard>(*credit_card)); 213 base::MakeUnique<autofill::CreditCard>(*credit_card));
215 } 214 }
216 } 215 }
217 } 216 }
218 217
219 void PaymentRequest::PopulateAvailableCreditCards() { 218 void PaymentRequest::PopulateAvailableCreditCards() {
220 if (credit_card_cache_.empty()) 219 if (credit_card_cache_.empty())
221 return; 220 return;
222 221
(...skipping 23 matching lines...) Expand all
246 void PaymentRequest::SetSelectedShippingOption() { 245 void PaymentRequest::SetSelectedShippingOption() {
247 // If more than one option has |selected| set, the last one in the sequence 246 // If more than one option has |selected| set, the last one in the sequence
248 // should be treated as the selected item. 247 // should be treated as the selected item.
249 for (auto* shipping_option : base::Reversed(shipping_options_)) { 248 for (auto* shipping_option : base::Reversed(shipping_options_)) {
250 if (shipping_option->selected) { 249 if (shipping_option->selected) {
251 selected_shipping_option_ = shipping_option; 250 selected_shipping_option_ = shipping_option;
252 break; 251 break;
253 } 252 }
254 } 253 }
255 } 254 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/passwords/password_generation_agent.mm ('k') | ios/chrome/browser/reading_list/url_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698