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

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

Issue 2971003002: [Payment Request] Queries application locale from payments::PaymentRequest (Closed)
Patch Set: rebase 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
« no previous file with comments | « no previous file | ios/chrome/browser/payments/payment_request_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 personal_data_manager_(personal_data_manager), 66 personal_data_manager_(personal_data_manager),
67 payment_request_ui_delegate_(payment_request_ui_delegate), 67 payment_request_ui_delegate_(payment_request_ui_delegate),
68 address_normalizer_(new AddressNormalizerImpl( 68 address_normalizer_(new AddressNormalizerImpl(
69 GetAddressInputSource( 69 GetAddressInputSource(
70 personal_data_manager_->GetURLRequestContextGetter()), 70 personal_data_manager_->GetURLRequestContextGetter()),
71 GetAddressInputStorage())), 71 GetAddressInputStorage())),
72 selected_shipping_profile_(nullptr), 72 selected_shipping_profile_(nullptr),
73 selected_contact_profile_(nullptr), 73 selected_contact_profile_(nullptr),
74 selected_payment_method_(nullptr), 74 selected_payment_method_(nullptr),
75 selected_shipping_option_(nullptr), 75 selected_shipping_option_(nullptr),
76 profile_comparator_(GetApplicationContext()->GetApplicationLocale(), 76 profile_comparator_(GetApplicationLocale(), *this),
77 *this),
78 journey_logger_(IsIncognito(), GetLastCommittedURL(), GetUkmRecorder()) { 77 journey_logger_(IsIncognito(), GetLastCommittedURL(), GetUkmRecorder()) {
79 PopulateAvailableShippingOptions(); 78 PopulateAvailableShippingOptions();
80 PopulateProfileCache(); 79 PopulateProfileCache();
81 PopulateAvailableProfiles(); 80 PopulateAvailableProfiles();
82 PopulatePaymentMethodCache(); 81 PopulatePaymentMethodCache();
83 PopulateAvailablePaymentMethods(); 82 PopulateAvailablePaymentMethods();
84 83
85 SetSelectedShippingOption(); 84 SetSelectedShippingOption();
86 85
87 if (request_shipping()) { 86 if (request_shipping()) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 145
147 AddressNormalizer* PaymentRequest::GetAddressNormalizer() { 146 AddressNormalizer* PaymentRequest::GetAddressNormalizer() {
148 return address_normalizer_; 147 return address_normalizer_;
149 } 148 }
150 149
151 autofill::RegionDataLoader* PaymentRequest::GetRegionDataLoader() { 150 autofill::RegionDataLoader* PaymentRequest::GetRegionDataLoader() {
152 return new autofill::RegionDataLoaderImpl( 151 return new autofill::RegionDataLoaderImpl(
153 GetAddressInputSource( 152 GetAddressInputSource(
154 personal_data_manager_->GetURLRequestContextGetter()) 153 personal_data_manager_->GetURLRequestContextGetter())
155 .release(), 154 .release(),
156 GetAddressInputStorage().release(), 155 GetAddressInputStorage().release(), GetApplicationLocale());
157 GetApplicationContext()->GetApplicationLocale());
158 } 156 }
159 157
160 ukm::UkmRecorder* PaymentRequest::GetUkmRecorder() { 158 ukm::UkmRecorder* PaymentRequest::GetUkmRecorder() {
161 return GetApplicationContext()->GetUkmRecorder(); 159 return GetApplicationContext()->GetUkmRecorder();
162 } 160 }
163 161
164 std::string PaymentRequest::GetAuthenticatedEmail() const { 162 std::string PaymentRequest::GetAuthenticatedEmail() const {
165 const SigninManager* signin_manager = 163 const SigninManager* signin_manager =
166 ios::SigninManagerFactory::GetForBrowserStateIfExists(browser_state_); 164 ios::SigninManagerFactory::GetForBrowserStateIfExists(browser_state_);
167 if (signin_manager && signin_manager->IsAuthenticated()) 165 if (signin_manager && signin_manager->IsAuthenticated())
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 PaymentShippingType PaymentRequest::shipping_type() const { 197 PaymentShippingType PaymentRequest::shipping_type() const {
200 return web_payment_request_.options.shipping_type; 198 return web_payment_request_.options.shipping_type;
201 } 199 }
202 200
203 CurrencyFormatter* PaymentRequest::GetOrCreateCurrencyFormatter() { 201 CurrencyFormatter* PaymentRequest::GetOrCreateCurrencyFormatter() {
204 if (!currency_formatter_) { 202 if (!currency_formatter_) {
205 currency_formatter_.reset(new CurrencyFormatter( 203 currency_formatter_.reset(new CurrencyFormatter(
206 base::UTF16ToASCII(web_payment_request_.details.total.amount.currency), 204 base::UTF16ToASCII(web_payment_request_.details.total.amount.currency),
207 base::UTF16ToASCII( 205 base::UTF16ToASCII(
208 web_payment_request_.details.total.amount.currency_system), 206 web_payment_request_.details.total.amount.currency_system),
209 GetApplicationContext()->GetApplicationLocale())); 207 GetApplicationLocale()));
210 } 208 }
211 return currency_formatter_.get(); 209 return currency_formatter_.get();
212 } 210 }
213 211
214 autofill::AutofillProfile* PaymentRequest::AddAutofillProfile( 212 autofill::AutofillProfile* PaymentRequest::AddAutofillProfile(
215 const autofill::AutofillProfile& profile) { 213 const autofill::AutofillProfile& profile) {
216 profile_cache_.push_back( 214 profile_cache_.push_back(
217 base::MakeUnique<autofill::AutofillProfile>(profile)); 215 base::MakeUnique<autofill::AutofillProfile>(profile));
218 216
219 PopulateAvailableProfiles(); 217 PopulateAvailableProfiles();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // merchant has requested exactly. This should be false for unknown card 281 // merchant has requested exactly. This should be false for unknown card
284 // types, if the merchant cannot accept some card types. 282 // types, if the merchant cannot accept some card types.
285 bool matches_merchant_card_type_exactly = 283 bool matches_merchant_card_type_exactly =
286 credit_card.card_type() != autofill::CreditCard::CARD_TYPE_UNKNOWN || 284 credit_card.card_type() != autofill::CreditCard::CARD_TYPE_UNKNOWN ||
287 supported_card_types_set_.size() == kTotalNumberOfCardTypes; 285 supported_card_types_set_.size() == kTotalNumberOfCardTypes;
288 286
289 // AutofillPaymentInstrument makes a copy of |credit_card| so it is 287 // AutofillPaymentInstrument makes a copy of |credit_card| so it is
290 // effectively owned by this object. 288 // effectively owned by this object.
291 payment_method_cache_.push_back(base::MakeUnique<AutofillPaymentInstrument>( 289 payment_method_cache_.push_back(base::MakeUnique<AutofillPaymentInstrument>(
292 method_name, credit_card, matches_merchant_card_type_exactly, 290 method_name, credit_card, matches_merchant_card_type_exactly,
293 billing_profiles(), GetApplicationContext()->GetApplicationLocale(), 291 billing_profiles(), GetApplicationLocale(), this));
294 this));
295 292
296 PopulateAvailablePaymentMethods(); 293 PopulateAvailablePaymentMethods();
297 294
298 return static_cast<AutofillPaymentInstrument*>( 295 return static_cast<AutofillPaymentInstrument*>(
299 payment_method_cache_.back().get()); 296 payment_method_cache_.back().get());
300 } 297 }
301 298
302 PaymentsProfileComparator* PaymentRequest::profile_comparator() { 299 PaymentsProfileComparator* PaymentRequest::profile_comparator() {
303 return &profile_comparator_; 300 return &profile_comparator_;
304 } 301 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // should be treated as the selected item. 390 // should be treated as the selected item.
394 for (auto* shipping_option : base::Reversed(shipping_options_)) { 391 for (auto* shipping_option : base::Reversed(shipping_options_)) {
395 if (shipping_option->selected) { 392 if (shipping_option->selected) {
396 selected_shipping_option_ = shipping_option; 393 selected_shipping_option_ = shipping_option;
397 break; 394 break;
398 } 395 }
399 } 396 }
400 } 397 }
401 398
402 } // namespace payments 399 } // namespace payments
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/payments/payment_request_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698