Chromium Code Reviews| 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_util.h" | 5 #import "ios/chrome/browser/payments/payment_request_util.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.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" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 namespace payment_request_util { | 25 namespace payment_request_util { |
| 26 | 26 |
| 27 NSString* GetNameLabelFromAutofillProfile( | 27 NSString* GetNameLabelFromAutofillProfile( |
| 28 const autofill::AutofillProfile& profile) { | 28 const autofill::AutofillProfile& profile) { |
| 29 return base::SysUTF16ToNSString( | 29 return base::SysUTF16ToNSString( |
| 30 profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), | 30 profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), |
| 31 GetApplicationContext()->GetApplicationLocale())); | 31 GetApplicationContext()->GetApplicationLocale())); |
| 32 } | 32 } |
| 33 | 33 |
| 34 NSString* GetAddressLabelFromAutofillProfile( | 34 NSString* GetShippingAddressLabelFromAutofillProfile( |
| 35 const autofill::AutofillProfile& profile) { | 35 const autofill::AutofillProfile& profile) { |
| 36 // Name and country are not included in the shipping address label. | 36 // Name and country are not included in the shipping address label. |
| 37 std::vector<autofill::ServerFieldType> label_fields; | 37 std::vector<autofill::ServerFieldType> label_fields; |
| 38 label_fields.push_back(autofill::COMPANY_NAME); | 38 label_fields.push_back(autofill::COMPANY_NAME); |
| 39 label_fields.push_back(autofill::ADDRESS_HOME_LINE1); | 39 label_fields.push_back(autofill::ADDRESS_HOME_LINE1); |
| 40 label_fields.push_back(autofill::ADDRESS_HOME_LINE2); | 40 label_fields.push_back(autofill::ADDRESS_HOME_LINE2); |
| 41 label_fields.push_back(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY); | 41 label_fields.push_back(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY); |
| 42 label_fields.push_back(autofill::ADDRESS_HOME_CITY); | 42 label_fields.push_back(autofill::ADDRESS_HOME_CITY); |
| 43 label_fields.push_back(autofill::ADDRESS_HOME_STATE); | 43 label_fields.push_back(autofill::ADDRESS_HOME_STATE); |
| 44 label_fields.push_back(autofill::ADDRESS_HOME_ZIP); | 44 label_fields.push_back(autofill::ADDRESS_HOME_ZIP); |
| 45 label_fields.push_back(autofill::ADDRESS_HOME_SORTING_CODE); | 45 label_fields.push_back(autofill::ADDRESS_HOME_SORTING_CODE); |
| 46 | 46 |
| 47 base::string16 label = profile.ConstructInferredLabel( | 47 base::string16 label = profile.ConstructInferredLabel( |
| 48 label_fields, label_fields.size(), | 48 label_fields, label_fields.size(), |
| 49 GetApplicationContext()->GetApplicationLocale()); | 49 GetApplicationContext()->GetApplicationLocale()); |
| 50 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; | 50 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; |
| 51 } | 51 } |
| 52 | 52 |
| 53 NSString* GetBillingAddressLabelFromAutofillProfile( | |
|
lpromero
2017/03/13 16:54:09
This could go in its own CL maybe? Also, could you
Moe
2017/03/16 01:35:32
Done. Moved to its own CL.
| |
| 54 const autofill::AutofillProfile& profile) { | |
| 55 // Name, company, and country are not included in the billing address label. | |
| 56 std::vector<autofill::ServerFieldType> label_fields; | |
| 57 label_fields.push_back(autofill::ADDRESS_HOME_LINE1); | |
| 58 label_fields.push_back(autofill::ADDRESS_HOME_LINE2); | |
| 59 label_fields.push_back(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY); | |
| 60 label_fields.push_back(autofill::ADDRESS_HOME_CITY); | |
| 61 label_fields.push_back(autofill::ADDRESS_HOME_STATE); | |
| 62 label_fields.push_back(autofill::ADDRESS_HOME_ZIP); | |
| 63 label_fields.push_back(autofill::ADDRESS_HOME_SORTING_CODE); | |
| 64 | |
| 65 base::string16 label = profile.ConstructInferredLabel( | |
| 66 label_fields, label_fields.size(), | |
| 67 GetApplicationContext()->GetApplicationLocale()); | |
| 68 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; | |
| 69 } | |
| 70 | |
| 53 NSString* GetPhoneNumberLabelFromAutofillProfile( | 71 NSString* GetPhoneNumberLabelFromAutofillProfile( |
| 54 const autofill::AutofillProfile& profile) { | 72 const autofill::AutofillProfile& profile) { |
| 55 base::string16 label = profile.GetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER); | 73 base::string16 label = profile.GetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER); |
| 56 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; | 74 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; |
| 57 } | 75 } |
| 58 | 76 |
| 59 NSString* GetEmailLabelFromAutofillProfile( | 77 NSString* GetEmailLabelFromAutofillProfile( |
| 60 const autofill::AutofillProfile& profile) { | 78 const autofill::AutofillProfile& profile) { |
| 61 base::string16 label = profile.GetRawInfo(autofill::EMAIL_ADDRESS); | 79 base::string16 label = profile.GetRawInfo(autofill::EMAIL_ADDRESS); |
| 62 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; | 80 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 return l10n_util::GetNSString(IDS_PAYMENTS_UNSUPPORTED_DELIVERY_OPTION); | 224 return l10n_util::GetNSString(IDS_PAYMENTS_UNSUPPORTED_DELIVERY_OPTION); |
| 207 case web::PaymentShippingType::PICKUP: | 225 case web::PaymentShippingType::PICKUP: |
| 208 return l10n_util::GetNSString(IDS_PAYMENTS_UNSUPPORTED_PICKUP_OPTION); | 226 return l10n_util::GetNSString(IDS_PAYMENTS_UNSUPPORTED_PICKUP_OPTION); |
| 209 default: | 227 default: |
| 210 NOTREACHED(); | 228 NOTREACHED(); |
| 211 return @""; | 229 return @""; |
| 212 } | 230 } |
| 213 } | 231 } |
| 214 | 232 |
| 215 } // namespace payment_request_util | 233 } // namespace payment_request_util |
| OLD | NEW |