OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/payments/payment_request_utils.h" | 5 #import "ios/chrome/browser/payments/payment_request_utils.h" |
6 | 6 |
7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
8 #include "components/autofill/core/browser/autofill_profile.h" | 8 #include "components/autofill/core/browser/autofill_profile.h" |
9 #include "components/autofill/core/browser/field_types.h" | |
9 #include "ios/chrome/browser/application_context.h" | 10 #include "ios/chrome/browser/application_context.h" |
10 | 11 |
11 namespace payment_request_utils { | 12 namespace payment_request_utils { |
12 | 13 |
14 NSString* NameLabelFromAutofillProfile(autofill::AutofillProfile* profile) { | |
15 return base::SysUTF16ToNSString( | |
16 profile->GetInfo(autofill::AutofillType(autofill::NAME_FULL), | |
Justin Donnelly
2016/12/29 18:36:57
Is there a motivation for switching to GetInfo ins
Moe
2017/01/03 17:42:19
There could be cases, like in the test data, that
| |
17 GetApplicationContext()->GetApplicationLocale())); | |
18 } | |
19 | |
13 NSString* AddressLabelFromAutofillProfile(autofill::AutofillProfile* profile) { | 20 NSString* AddressLabelFromAutofillProfile(autofill::AutofillProfile* profile) { |
14 // Name, company, and country are not included in the shipping address label. | 21 // Name, company, and country are not included in the shipping address label. |
15 std::vector<autofill::ServerFieldType> label_fields; | 22 std::vector<autofill::ServerFieldType> label_fields; |
16 label_fields.push_back(autofill::ADDRESS_HOME_LINE1); | 23 label_fields.push_back(autofill::ADDRESS_HOME_LINE1); |
17 label_fields.push_back(autofill::ADDRESS_HOME_LINE2); | 24 label_fields.push_back(autofill::ADDRESS_HOME_LINE2); |
18 label_fields.push_back(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY); | 25 label_fields.push_back(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY); |
19 label_fields.push_back(autofill::ADDRESS_HOME_CITY); | 26 label_fields.push_back(autofill::ADDRESS_HOME_CITY); |
20 label_fields.push_back(autofill::ADDRESS_HOME_STATE); | 27 label_fields.push_back(autofill::ADDRESS_HOME_STATE); |
21 label_fields.push_back(autofill::ADDRESS_HOME_ZIP); | 28 label_fields.push_back(autofill::ADDRESS_HOME_ZIP); |
22 label_fields.push_back(autofill::ADDRESS_HOME_SORTING_CODE); | 29 label_fields.push_back(autofill::ADDRESS_HOME_SORTING_CODE); |
23 | 30 |
24 return base::SysUTF16ToNSString(profile->ConstructInferredLabel( | 31 return base::SysUTF16ToNSString(profile->ConstructInferredLabel( |
25 label_fields, label_fields.size(), | 32 label_fields, label_fields.size(), |
26 GetApplicationContext()->GetApplicationLocale())); | 33 GetApplicationContext()->GetApplicationLocale())); |
27 } | 34 } |
28 | 35 |
36 NSString* PhoneNumberLabelFromAutofillProfile( | |
37 autofill::AutofillProfile* profile) { | |
38 return base::SysUTF16ToNSString(profile->GetInfo( | |
39 autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER), | |
40 GetApplicationContext()->GetApplicationLocale())); | |
41 } | |
42 | |
29 } // namespace payment_request_utils | 43 } // namespace payment_request_utils |
OLD | NEW |