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

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

Issue 2588913002: EarlGrey tests for Payment Request (base CL) (Closed)
Patch Set: Moved the experimental flag back to the BVC Created 3 years, 11 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 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),
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
29 NSString* FormattedCurrencyString(NSDecimalNumber* value, 36 NSString* FormattedCurrencyString(NSDecimalNumber* value,
30 NSString* currencyCode) { 37 NSString* currencyCode) {
31 NSNumberFormatter* currencyFormatter = 38 NSNumberFormatter* currencyFormatter =
32 [[[NSNumberFormatter alloc] init] autorelease]; 39 [[[NSNumberFormatter alloc] init] autorelease];
33 [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; 40 [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
34 [currencyFormatter setCurrencyCode:currencyCode]; 41 [currencyFormatter setCurrencyCode:currencyCode];
35 return [currencyFormatter stringFromNumber:value]; 42 return [currencyFormatter stringFromNumber:value];
36 } 43 }
37 44
45 NSString* PhoneNumberLabelFromAutofillProfile(
46 autofill::AutofillProfile* profile) {
47 return base::SysUTF16ToNSString(profile->GetInfo(
48 autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER),
49 GetApplicationContext()->GetApplicationLocale()));
50 }
51
38 } // namespace payment_request_utils 52 } // namespace payment_request_utils
OLDNEW
« no previous file with comments | « ios/chrome/browser/payments/payment_request_utils.h ('k') | ios/chrome/browser/payments/payment_request_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698