OLD | NEW |
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/address_edit_coordinator.h" | 5 #import "ios/chrome/browser/ui/payments/address_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/address_edit_mediator.h" | 21 #import "ios/chrome/browser/ui/payments/address_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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 (PaymentRequestEditViewController*)controller | 141 (PaymentRequestEditViewController*)controller |
141 didFinishEditingFields:(NSArray<EditorField*>*)fields { | 142 didFinishEditingFields:(NSArray<EditorField*>*)fields { |
142 // Create an empty autofill profile. If an address is being edited, copy over | 143 // Create an empty autofill profile. If an address is being edited, copy over |
143 // the information. | 144 // the information. |
144 autofill::AutofillProfile address = | 145 autofill::AutofillProfile address = |
145 self.address ? *self.address | 146 self.address ? *self.address |
146 : autofill::AutofillProfile(base::GenerateGUID(), | 147 : autofill::AutofillProfile(base::GenerateGUID(), |
147 autofill::kSettingsOrigin); | 148 autofill::kSettingsOrigin); |
148 | 149 |
149 for (EditorField* field in fields) { | 150 for (EditorField* field in fields) { |
150 address.SetRawInfo(AutofillTypeFromAutofillUIType(field.autofillUIType), | 151 address.SetInfo(autofill::AutofillType( |
151 base::SysNSStringToUTF16(field.value)); | 152 AutofillTypeFromAutofillUIType(field.autofillUIType)), |
| 153 base::SysNSStringToUTF16(field.value), |
| 154 GetApplicationContext()->GetApplicationLocale()); |
152 } | 155 } |
153 | 156 |
154 if (!self.address) { | 157 if (!self.address) { |
155 self.paymentRequest->GetPersonalDataManager()->AddProfile(address); | 158 self.paymentRequest->GetPersonalDataManager()->AddProfile(address); |
156 | 159 |
157 // Add the profile to the list of profiles in |self.paymentRequest|. | 160 // Add the profile to the list of profiles in |self.paymentRequest|. |
158 self.address = self.paymentRequest->AddAutofillProfile(address); | 161 self.address = self.paymentRequest->AddAutofillProfile(address); |
159 } else { | 162 } else { |
160 // Override the origin. | 163 // Override the origin. |
161 address.set_origin(autofill::kSettingsOrigin); | 164 address.set_origin(autofill::kSettingsOrigin); |
(...skipping 22 matching lines...) Expand all Loading... |
184 if (self.mediator.selectedCountryCode != countryCode) { | 187 if (self.mediator.selectedCountryCode != countryCode) { |
185 [self.mediator setSelectedCountryCode:countryCode]; | 188 [self.mediator setSelectedCountryCode:countryCode]; |
186 [self.editViewController loadModel]; | 189 [self.editViewController loadModel]; |
187 [self.editViewController.collectionView reloadData]; | 190 [self.editViewController.collectionView reloadData]; |
188 } | 191 } |
189 [self.countrySelectionCoordinator stop]; | 192 [self.countrySelectionCoordinator stop]; |
190 self.countrySelectionCoordinator = nil; | 193 self.countrySelectionCoordinator = nil; |
191 } | 194 } |
192 | 195 |
193 @end | 196 @end |
OLD | NEW |