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

Side by Side Diff: ios/chrome/browser/ui/payments/credit_card_edit_coordinator.mm

Issue 2949813003: [Payment Request] Formats phone number and credit card number in editors. (Closed)
Patch Set: Fixed broken tests Created 3 years, 6 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 #import "ios/chrome/browser/ui/payments/credit_card_edit_coordinator.h" 5 #import "ios/chrome/browser/ui/payments/credit_card_edit_coordinator.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "components/autofill/core/browser/autofill_type.h"
11 #include "components/autofill/core/browser/credit_card.h" 12 #include "components/autofill/core/browser/credit_card.h"
12 #include "components/autofill/core/browser/personal_data_manager.h" 13 #include "components/autofill/core/browser/personal_data_manager.h"
13 #include "components/autofill/core/browser/validation.h" 14 #include "components/autofill/core/browser/validation.h"
14 #include "components/autofill/core/common/autofill_constants.h" 15 #include "components/autofill/core/common/autofill_constants.h"
15 #import "components/autofill/ios/browser/credit_card_util.h" 16 #import "components/autofill/ios/browser/credit_card_util.h"
16 #include "components/strings/grit/components_strings.h" 17 #include "components/strings/grit/components_strings.h"
18 #include "ios/chrome/browser/application_context.h"
17 #include "ios/chrome/browser/payments/payment_request.h" 19 #include "ios/chrome/browser/payments/payment_request.h"
18 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h" 20 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h"
19 #import "ios/chrome/browser/ui/payments/credit_card_edit_mediator.h" 21 #import "ios/chrome/browser/ui/payments/credit_card_edit_mediator.h"
20 #import "ios/chrome/browser/ui/payments/payment_request_editor_field.h" 22 #import "ios/chrome/browser/ui/payments/payment_request_editor_field.h"
21 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
22 24
23 #if !defined(__has_feature) || !__has_feature(objc_arc) 25 #if !defined(__has_feature) || !__has_feature(objc_arc)
24 #error "This file requires ARC support." 26 #error "This file requires ARC support."
25 #endif 27 #endif
26 28
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 _creditCard ? *_creditCard 182 _creditCard ? *_creditCard
181 : autofill::CreditCard(base::GenerateGUID(), 183 : autofill::CreditCard(base::GenerateGUID(),
182 autofill::kSettingsOrigin); 184 autofill::kSettingsOrigin);
183 185
184 for (EditorField* field in fields) { 186 for (EditorField* field in fields) {
185 if (field.autofillUIType == AutofillUITypeCreditCardSaveToChrome) { 187 if (field.autofillUIType == AutofillUITypeCreditCardSaveToChrome) {
186 saveCreditCard = [field.value boolValue]; 188 saveCreditCard = [field.value boolValue];
187 } else if (field.autofillUIType == AutofillUITypeCreditCardBillingAddress) { 189 } else if (field.autofillUIType == AutofillUITypeCreditCardBillingAddress) {
188 creditCard.set_billing_address_id(base::SysNSStringToUTF8(field.value)); 190 creditCard.set_billing_address_id(base::SysNSStringToUTF8(field.value));
189 } else { 191 } else {
190 creditCard.SetRawInfo( 192 creditCard.SetInfo(autofill::AutofillType(AutofillTypeFromAutofillUIType(
191 AutofillTypeFromAutofillUIType(field.autofillUIType), 193 field.autofillUIType)),
192 base::SysNSStringToUTF16(field.value)); 194 base::SysNSStringToUTF16(field.value),
195 GetApplicationContext()->GetApplicationLocale());
193 } 196 }
194 } 197 }
195 198
196 if (!_creditCard) { 199 if (!_creditCard) {
197 if (saveCreditCard) 200 if (saveCreditCard)
198 _paymentRequest->GetPersonalDataManager()->AddCreditCard(creditCard); 201 _paymentRequest->GetPersonalDataManager()->AddCreditCard(creditCard);
199 202
200 // Add the credit card to the list of credit cards in |_paymentRequest|. 203 // Add the credit card to the list of credit cards in |_paymentRequest|.
201 _creditCard = _paymentRequest->AddCreditCard(creditCard); 204 _creditCard = _paymentRequest->AddCreditCard(creditCard);
202 } else { 205 } else {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 self.billingAddressSelectionCoordinator = nil; 244 self.billingAddressSelectionCoordinator = nil;
242 } 245 }
243 246
244 - (void)billingAddressSelectionCoordinatorDidReturn: 247 - (void)billingAddressSelectionCoordinatorDidReturn:
245 (BillingAddressSelectionCoordinator*)coordinator { 248 (BillingAddressSelectionCoordinator*)coordinator {
246 [self.billingAddressSelectionCoordinator stop]; 249 [self.billingAddressSelectionCoordinator stop];
247 self.billingAddressSelectionCoordinator = nil; 250 self.billingAddressSelectionCoordinator = nil;
248 } 251 }
249 252
250 @end 253 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698