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

Side by Side Diff: ios/chrome/browser/ui/payments/address_edit_mediator.mm

Issue 2956433002: [Payment Request] keyboardType, autoCapitalizationType, etc for text fields (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
OLDNEW
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_mediator.h" 5 #import "ios/chrome/browser/ui/payments/address_edit_mediator.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 [self fieldValueFromProfile:self.address 253 [self fieldValueFromProfile:self.address
254 fieldType:autofill::GetFieldTypeFromString( 254 fieldType:autofill::GetFieldTypeFromString(
255 autofillType)]; 255 autofillType)];
256 BOOL required = autofillUIType != AutofillUITypeProfileCompanyName; 256 BOOL required = autofillUIType != AutofillUITypeProfileCompanyName;
257 field = 257 field =
258 [[EditorField alloc] initWithAutofillUIType:autofillUIType 258 [[EditorField alloc] initWithAutofillUIType:autofillUIType
259 fieldType:EditorFieldTypeTextField 259 fieldType:EditorFieldTypeTextField
260 label:nil 260 label:nil
261 value:value 261 value:value
262 required:required]; 262 required:required];
263 // Set the keyboardType and autoCapitalizationType as appropriate.
264 if (autofillUIType == AutofillUITypeProfileEmailAddress) {
265 field.keyboardType = UIKeyboardTypeEmailAddress;
266 field.autoCapitalizationType = UITextAutocapitalizationTypeNone;
267 } else if (autofillUIType == AutofillUITypeProfileHomeAddressZip) {
268 field.autoCapitalizationType =
269 UITextAutocapitalizationTypeAllCharacters;
270 }
271
263 [self.fieldsMap setObject:field forKey:fieldKey]; 272 [self.fieldsMap setObject:field forKey:fieldKey];
264 } 273 }
265 274
266 std::string fieldLabel; 275 std::string fieldLabel;
267 if (!component->GetString(autofill::kFieldNameKey, &fieldLabel)) { 276 if (!component->GetString(autofill::kFieldNameKey, &fieldLabel)) {
268 NOTREACHED(); 277 NOTREACHED();
269 return @[]; 278 return @[];
270 } 279 }
271 field.label = base::SysUTF8ToNSString(fieldLabel); 280 field.label = base::SysUTF8ToNSString(fieldLabel);
272 281
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 payments::data_util::GetFormattedPhoneNumberForDisplay( 323 payments::data_util::GetFormattedPhoneNumberForDisplay(
315 *self.address, 324 *self.address,
316 GetApplicationContext()->GetApplicationLocale())) 325 GetApplicationContext()->GetApplicationLocale()))
317 : nil; 326 : nil;
318 field = [[EditorField alloc] 327 field = [[EditorField alloc]
319 initWithAutofillUIType:AutofillUITypeProfileHomePhoneWholeNumber 328 initWithAutofillUIType:AutofillUITypeProfileHomePhoneWholeNumber
320 fieldType:EditorFieldTypeTextField 329 fieldType:EditorFieldTypeTextField
321 label:l10n_util::GetNSString(IDS_IOS_AUTOFILL_PHONE) 330 label:l10n_util::GetNSString(IDS_IOS_AUTOFILL_PHONE)
322 value:value 331 value:value
323 required:YES]; 332 required:YES];
333 field.keyboardType = UIKeyboardTypePhonePad;
334 field.returnKeyType = UIReturnKeyDone;
324 [self.fieldsMap setObject:field forKey:phoneNumberFieldKey]; 335 [self.fieldsMap setObject:field forKey:phoneNumberFieldKey];
325 } 336 }
326 [self.fields addObject:field]; 337 [self.fields addObject:field];
327 338
328 return self.fields; 339 return self.fields;
329 } 340 }
330 341
331 // Takes in an autofill profile and an autofill field type and returns the 342 // Takes in an autofill profile and an autofill field type and returns the
332 // corresponding field value. Returns nil if |profile| is nullptr. 343 // corresponding field value. Returns nil if |profile| is nullptr.
333 - (NSString*)fieldValueFromProfile:(autofill::AutofillProfile*)profile 344 - (NSString*)fieldValueFromProfile:(autofill::AutofillProfile*)profile
334 fieldType:(autofill::ServerFieldType)fieldType { 345 fieldType:(autofill::ServerFieldType)fieldType {
335 return profile ? base::SysUTF16ToNSString(profile->GetInfo( 346 return profile ? base::SysUTF16ToNSString(profile->GetInfo(
336 autofill::AutofillType(fieldType), 347 autofill::AutofillType(fieldType),
337 GetApplicationContext()->GetApplicationLocale())) 348 GetApplicationContext()->GetApplicationLocale()))
338 : nil; 349 : nil;
339 } 350 }
340 351
341 @end 352 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698