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

Side by Side Diff: ios/chrome/browser/ui/payments/contact_info_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/contact_info_edit_coordinator.h" 5 #import "ios/chrome/browser/ui/payments/contact_info_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 "components/autofill/core/browser/autofill_country.h" 10 #include "components/autofill/core/browser/autofill_country.h"
11 #include "components/autofill/core/browser/autofill_profile.h" 11 #include "components/autofill/core/browser/autofill_profile.h"
12 #include "components/autofill/core/browser/autofill_type.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 #include "components/payments/core/payments_profile_comparator.h" 16 #include "components/payments/core/payments_profile_comparator.h"
16 #include "components/strings/grit/components_strings.h" 17 #include "components/strings/grit/components_strings.h"
17 #include "ios/chrome/browser/application_context.h" 18 #include "ios/chrome/browser/application_context.h"
18 #include "ios/chrome/browser/payments/payment_request.h" 19 #include "ios/chrome/browser/payments/payment_request.h"
19 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h" 20 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h"
20 #import "ios/chrome/browser/ui/payments/contact_info_edit_mediator.h" 21 #import "ios/chrome/browser/ui/payments/contact_info_edit_mediator.h"
21 #import "ios/chrome/browser/ui/payments/payment_request_editor_field.h" 22 #import "ios/chrome/browser/ui/payments/payment_request_editor_field.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 (PaymentRequestEditViewController*)controller 130 (PaymentRequestEditViewController*)controller
130 didFinishEditingFields:(NSArray<EditorField*>*)fields { 131 didFinishEditingFields:(NSArray<EditorField*>*)fields {
131 // Create an empty autofill profile. If a profile is being edited, copy over 132 // Create an empty autofill profile. If a profile is being edited, copy over
132 // the information. 133 // the information.
133 autofill::AutofillProfile profile = 134 autofill::AutofillProfile profile =
134 self.profile ? *self.profile 135 self.profile ? *self.profile
135 : autofill::AutofillProfile(base::GenerateGUID(), 136 : autofill::AutofillProfile(base::GenerateGUID(),
136 autofill::kSettingsOrigin); 137 autofill::kSettingsOrigin);
137 138
138 for (EditorField* field in fields) { 139 for (EditorField* field in fields) {
139 profile.SetRawInfo(AutofillTypeFromAutofillUIType(field.autofillUIType), 140 profile.SetInfo(autofill::AutofillType(
140 base::SysNSStringToUTF16(field.value)); 141 AutofillTypeFromAutofillUIType(field.autofillUIType)),
142 base::SysNSStringToUTF16(field.value),
143 GetApplicationContext()->GetApplicationLocale());
141 } 144 }
142 145
143 if (!self.profile) { 146 if (!self.profile) {
144 self.paymentRequest->GetPersonalDataManager()->AddProfile(profile); 147 self.paymentRequest->GetPersonalDataManager()->AddProfile(profile);
145 148
146 // Add the profile to the list of profiles in |self.paymentRequest|. 149 // Add the profile to the list of profiles in |self.paymentRequest|.
147 self.profile = self.paymentRequest->AddAutofillProfile(profile); 150 self.profile = self.paymentRequest->AddAutofillProfile(profile);
148 } else { 151 } else {
149 // Override the origin. 152 // Override the origin.
150 profile.set_origin(autofill::kSettingsOrigin); 153 profile.set_origin(autofill::kSettingsOrigin);
151 self.paymentRequest->GetPersonalDataManager()->UpdateProfile(profile); 154 self.paymentRequest->GetPersonalDataManager()->UpdateProfile(profile);
152 155
153 // Cached profile must be invalidated once the profile is modified. 156 // Cached profile must be invalidated once the profile is modified.
154 _paymentRequest->profile_comparator()->Invalidate(profile); 157 _paymentRequest->profile_comparator()->Invalidate(profile);
155 158
156 // Update the original profile instance that is being edited. 159 // Update the original profile instance that is being edited.
157 *self.profile = profile; 160 *self.profile = profile;
158 } 161 }
159 162
160 [self.delegate contactInfoEditCoordinator:self 163 [self.delegate contactInfoEditCoordinator:self
161 didFinishEditingProfile:self.profile]; 164 didFinishEditingProfile:self.profile];
162 } 165 }
163 166
164 - (void)paymentRequestEditViewControllerDidCancel: 167 - (void)paymentRequestEditViewControllerDidCancel:
165 (PaymentRequestEditViewController*)controller { 168 (PaymentRequestEditViewController*)controller {
166 [self.delegate contactInfoEditCoordinatorDidCancel:self]; 169 [self.delegate contactInfoEditCoordinatorDidCancel:self];
167 } 170 }
168 171
169 @end 172 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698