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

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

Issue 2721553004: Remove auto raw pointer deduction from non-linux specific code. (Closed)
Patch Set: Created 3 years, 9 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 <unordered_set> 7 #include <unordered_set>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/core/browser/autofill_data_util.h" 10 #include "components/autofill/core/browser/autofill_data_util.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 currency_formatter_.reset(new payments::CurrencyFormatter( 46 currency_formatter_.reset(new payments::CurrencyFormatter(
47 base::UTF16ToASCII(web_payment_request_->details.total.amount.currency), 47 base::UTF16ToASCII(web_payment_request_->details.total.amount.currency),
48 base::UTF16ToASCII( 48 base::UTF16ToASCII(
49 web_payment_request_->details.total.amount.currency_system), 49 web_payment_request_->details.total.amount.currency_system),
50 GetApplicationContext()->GetApplicationLocale())); 50 GetApplicationContext()->GetApplicationLocale()));
51 } 51 }
52 return currency_formatter_.get(); 52 return currency_formatter_.get();
53 } 53 }
54 54
55 void PaymentRequest::PopulateProfileCache() { 55 void PaymentRequest::PopulateProfileCache() {
56 for (const auto& profile : personal_data_manager_->GetProfilesToSuggest()) { 56 for (auto* profile : personal_data_manager_->GetProfilesToSuggest()) {
57 profile_cache_.push_back( 57 profile_cache_.push_back(
58 base::MakeUnique<autofill::AutofillProfile>(*profile)); 58 base::MakeUnique<autofill::AutofillProfile>(*profile));
59 profiles_.push_back(profile_cache_.back().get()); 59 profiles_.push_back(profile_cache_.back().get());
60 } 60 }
61 61
62 if (!profiles_.empty()) 62 if (!profiles_.empty())
63 selected_shipping_profile_ = profiles_[0]; 63 selected_shipping_profile_ = profiles_[0];
64 } 64 }
65 65
66 void PaymentRequest::PopulateCreditCardCache() { 66 void PaymentRequest::PopulateCreditCardCache() {
67 DCHECK(web_payment_request_); 67 DCHECK(web_payment_request_);
68 std::unordered_set<base::string16> supported_method_types; 68 std::unordered_set<base::string16> supported_method_types;
69 for (const auto& method_data : web_payment_request_->method_data) { 69 for (const auto& method_data : web_payment_request_->method_data) {
70 for (const auto& supported_method : method_data.supported_methods) 70 for (const auto& supported_method : method_data.supported_methods)
71 supported_method_types.insert(supported_method); 71 supported_method_types.insert(supported_method);
72 } 72 }
73 73
74 std::vector<autofill::CreditCard*> credit_cards = 74 std::vector<autofill::CreditCard*> credit_cards =
75 personal_data_manager_->GetCreditCardsToSuggest(); 75 personal_data_manager_->GetCreditCardsToSuggest();
76 76
77 for (const auto& credit_card : credit_cards) { 77 for (auto* credit_card : credit_cards) {
78 std::string spec_card_type = 78 std::string spec_card_type =
79 autofill::data_util::GetPaymentRequestData(credit_card->type()) 79 autofill::data_util::GetPaymentRequestData(credit_card->type())
80 .basic_card_payment_type; 80 .basic_card_payment_type;
81 if (supported_method_types.find(base::ASCIIToUTF16(spec_card_type)) != 81 if (supported_method_types.find(base::ASCIIToUTF16(spec_card_type)) !=
82 supported_method_types.end()) { 82 supported_method_types.end()) {
83 credit_card_cache_.push_back( 83 credit_card_cache_.push_back(
84 base::MakeUnique<autofill::CreditCard>(*credit_card)); 84 base::MakeUnique<autofill::CreditCard>(*credit_card));
85 credit_cards_.push_back(credit_card_cache_.back().get()); 85 credit_cards_.push_back(credit_card_cache_.back().get());
86 } 86 }
87 } 87 }
88 88
89 if (!credit_cards_.empty()) 89 if (!credit_cards_.empty())
90 selected_credit_card_ = credit_cards_[0]; 90 selected_credit_card_ = credit_cards_[0];
91 } 91 }
92 92
93 void PaymentRequest::PopulateShippingOptionCache() { 93 void PaymentRequest::PopulateShippingOptionCache() {
94 DCHECK(web_payment_request_); 94 DCHECK(web_payment_request_);
95 shipping_options_.clear(); 95 shipping_options_.clear();
96 shipping_options_.reserve( 96 shipping_options_.reserve(
97 web_payment_request_->details.shipping_options.size()); 97 web_payment_request_->details.shipping_options.size());
98 std::transform(std::begin(web_payment_request_->details.shipping_options), 98 std::transform(std::begin(web_payment_request_->details.shipping_options),
99 std::end(web_payment_request_->details.shipping_options), 99 std::end(web_payment_request_->details.shipping_options),
100 std::back_inserter(shipping_options_), 100 std::back_inserter(shipping_options_),
101 [](web::PaymentShippingOption& option) { return &option; }); 101 [](web::PaymentShippingOption& option) { return &option; });
102 102
103 selected_shipping_option_ = nullptr; 103 selected_shipping_option_ = nullptr;
104 for (const auto& shipping_option : shipping_options_) { 104 for (auto* shipping_option : shipping_options_) {
105 if (shipping_option->selected) { 105 if (shipping_option->selected) {
106 // If more than one option has |selected| set, the last one in the 106 // If more than one option has |selected| set, the last one in the
107 // sequence should be treated as the selected item. 107 // sequence should be treated as the selected item.
108 selected_shipping_option_ = shipping_option; 108 selected_shipping_option_ = shipping_option;
109 } 109 }
110 } 110 }
111 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698