| 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.
|
|
|