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

Unified Diff: ios/chrome/browser/ui/payments/address_edit_mediator.mm

Issue 2964333002: [Payment Request] Populates country field if country code/name is valid. (Closed)
Patch Set: Addressed comments Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/payments/address_edit_mediator.mm
diff --git a/ios/chrome/browser/ui/payments/address_edit_mediator.mm b/ios/chrome/browser/ui/payments/address_edit_mediator.mm
index 1dc7e724b3f71a0774dbe8a21b59b1f0804cf87e..0ee0c5e19c2643d016daa325e23e2d30b5851919 100644
--- a/ios/chrome/browser/ui/payments/address_edit_mediator.mm
+++ b/ios/chrome/browser/ui/payments/address_edit_mediator.mm
@@ -153,7 +153,7 @@
if ([regions objectForKey:region]) {
self.regionField.value = region;
} else if ([[regions allKeysForObject:region] count]) {
- DCHECK(1 == [[regions allKeysForObject:region] count]);
+ DCHECK_EQ(1U, [[regions allKeysForObject:region] count]);
self.regionField.value = [regions allKeysForObject:region][0];
}
}
@@ -189,16 +189,23 @@
}
_countries = countries;
- // If an address is being edited and it has a valid country code, the selected
- // country code is set to that value. Otherwise, it is set to the default
- // country code.
- NSString* countryCode =
+ // If an address is being edited and it has a valid country code or a valid
+ // country name for the autofill::ADDRESS_HOME_COUNTRY field, the selected
+ // country code is set to the respective country code. Otherwise, the selected
+ // country code is set to the default country code.
+ NSString* country =
[self fieldValueFromProfile:_address
fieldType:autofill::ADDRESS_HOME_COUNTRY];
- _selectedCountryCode =
- countryCode && [_countries objectForKey:countryCode]
- ? countryCode
- : base::SysUTF8ToNSString(countryModel.GetDefaultCountryCode());
+
+ if ([countries objectForKey:country]) {
+ _selectedCountryCode = country;
+ } else if ([[countries allKeysForObject:country] count]) {
+ DCHECK_EQ(1U, [[countries allKeysForObject:country] count]);
+ _selectedCountryCode = [countries allKeysForObject:country][0];
+ } else {
+ _selectedCountryCode =
+ base::SysUTF8ToNSString(countryModel.GetDefaultCountryCode());
+ }
}
// Queries the region names based on the selected country code.
« 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