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

Side by Side Diff: ios/chrome/browser/payments/payment_request_util.mm

Issue 2952503002: [Payment Request] Updates name, phone number, and email labels (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "components/autofill/core/browser/autofill_profile.h" 11 #include "components/autofill/core/browser/autofill_profile.h"
12 #include "components/autofill/core/browser/field_types.h" 12 #include "components/autofill/core/browser/field_types.h"
13 #include "components/autofill/core/browser/personal_data_manager.h" 13 #include "components/autofill/core/browser/personal_data_manager.h"
14 #include "components/payments/core/payment_request_data_util.h"
14 #include "components/payments/core/strings_util.h" 15 #include "components/payments/core/strings_util.h"
15 #include "components/strings/grit/components_strings.h" 16 #include "components/strings/grit/components_strings.h"
16 #include "ios/chrome/browser/application_context.h" 17 #include "ios/chrome/browser/application_context.h"
17 #include "ios/chrome/browser/payments/payment_request.h" 18 #include "ios/chrome/browser/payments/payment_request.h"
18 #include "ios/web/public/payments/payment_request.h" 19 #include "ios/web/public/payments/payment_request.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 21
21 #if !defined(__has_feature) || !__has_feature(objc_arc) 22 #if !defined(__has_feature) || !__has_feature(objc_arc)
22 #error "This file requires ARC support." 23 #error "This file requires ARC support."
23 #endif 24 #endif
24 25
25 namespace payment_request_util { 26 namespace payment_request_util {
26 27
27 NSString* GetNameLabelFromAutofillProfile( 28 NSString* GetNameLabelFromAutofillProfile(
28 const autofill::AutofillProfile& profile) { 29 const autofill::AutofillProfile& profile) {
29 return base::SysUTF16ToNSString( 30 base::string16 label =
30 profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL), 31 profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL),
31 GetApplicationContext()->GetApplicationLocale())); 32 GetApplicationContext()->GetApplicationLocale());
33 return !label.empty() ? base::SysUTF16ToNSString(label) : nil;
32 } 34 }
33 35
34 NSString* GetShippingAddressLabelFromAutofillProfile( 36 NSString* GetShippingAddressLabelFromAutofillProfile(
35 const autofill::AutofillProfile& profile) { 37 const autofill::AutofillProfile& profile) {
36 base::string16 label = payments::GetShippingAddressLabelFormAutofillProfile( 38 base::string16 label = payments::GetShippingAddressLabelFormAutofillProfile(
37 profile, GetApplicationContext()->GetApplicationLocale()); 39 profile, GetApplicationContext()->GetApplicationLocale());
38 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; 40 return !label.empty() ? base::SysUTF16ToNSString(label) : nil;
39 } 41 }
40 42
41 NSString* GetBillingAddressLabelFromAutofillProfile( 43 NSString* GetBillingAddressLabelFromAutofillProfile(
42 const autofill::AutofillProfile& profile) { 44 const autofill::AutofillProfile& profile) {
43 base::string16 label = payments::GetBillingAddressLabelFromAutofillProfile( 45 base::string16 label = payments::GetBillingAddressLabelFromAutofillProfile(
44 profile, GetApplicationContext()->GetApplicationLocale()); 46 profile, GetApplicationContext()->GetApplicationLocale());
45 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; 47 return !label.empty() ? base::SysUTF16ToNSString(label) : nil;
46 } 48 }
47 49
48 NSString* GetPhoneNumberLabelFromAutofillProfile( 50 NSString* GetPhoneNumberLabelFromAutofillProfile(
49 const autofill::AutofillProfile& profile) { 51 const autofill::AutofillProfile& profile) {
50 base::string16 label = profile.GetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER); 52 base::string16 label = payments::data_util::GetFormattedPhoneNumberForDisplay(
53 profile, GetApplicationContext()->GetApplicationLocale());
51 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; 54 return !label.empty() ? base::SysUTF16ToNSString(label) : nil;
52 } 55 }
53 56
54 NSString* GetEmailLabelFromAutofillProfile( 57 NSString* GetEmailLabelFromAutofillProfile(
55 const autofill::AutofillProfile& profile) { 58 const autofill::AutofillProfile& profile) {
56 base::string16 label = profile.GetRawInfo(autofill::EMAIL_ADDRESS); 59 base::string16 label =
60 profile.GetInfo(autofill::AutofillType(autofill::EMAIL_ADDRESS),
61 GetApplicationContext()->GetApplicationLocale());
57 return !label.empty() ? base::SysUTF16ToNSString(label) : nil; 62 return !label.empty() ? base::SysUTF16ToNSString(label) : nil;
58 } 63 }
59 64
60 NSString* GetShippingSectionTitle(payments::PaymentShippingType shipping_type) { 65 NSString* GetShippingSectionTitle(payments::PaymentShippingType shipping_type) {
61 switch (shipping_type) { 66 switch (shipping_type) {
62 case payments::PaymentShippingType::SHIPPING: 67 case payments::PaymentShippingType::SHIPPING:
63 return l10n_util::GetNSString(IDS_PAYMENTS_SHIPPING_SUMMARY_LABEL); 68 return l10n_util::GetNSString(IDS_PAYMENTS_SHIPPING_SUMMARY_LABEL);
64 case payments::PaymentShippingType::DELIVERY: 69 case payments::PaymentShippingType::DELIVERY:
65 return l10n_util::GetNSString(IDS_PAYMENTS_DELIVERY_SUMMARY_LABEL); 70 return l10n_util::GetNSString(IDS_PAYMENTS_DELIVERY_SUMMARY_LABEL);
66 case payments::PaymentShippingType::PICKUP: 71 case payments::PaymentShippingType::PICKUP:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return l10n_util::GetNSString(IDS_PAYMENTS_UNSUPPORTED_DELIVERY_OPTION); 106 return l10n_util::GetNSString(IDS_PAYMENTS_UNSUPPORTED_DELIVERY_OPTION);
102 case payments::PaymentShippingType::PICKUP: 107 case payments::PaymentShippingType::PICKUP:
103 return l10n_util::GetNSString(IDS_PAYMENTS_UNSUPPORTED_PICKUP_OPTION); 108 return l10n_util::GetNSString(IDS_PAYMENTS_UNSUPPORTED_PICKUP_OPTION);
104 default: 109 default:
105 NOTREACHED(); 110 NOTREACHED();
106 return nil; 111 return nil;
107 } 112 }
108 } 113 }
109 114
110 } // namespace payment_request_util 115 } // namespace payment_request_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698