Chromium Code Reviews| 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..51b4b3f056ea6629465eb4a3acd373c028c26029 100644 |
| --- a/ios/chrome/browser/ui/payments/address_edit_mediator.mm |
| +++ b/ios/chrome/browser/ui/payments/address_edit_mediator.mm |
| @@ -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 is a valid country code or a valid |
|
macourteau
2017/07/04 13:53:45
s/has //
Moe
2017/07/04 15:47:06
Done.
|
| + // 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(1 == [[countries allKeysForObject:country] count]); |
|
macourteau
2017/07/04 13:53:45
DCHECK -> DCHECK_EQ
Moe
2017/07/04 15:47:06
Done.
|
| + _selectedCountryCode = [countries allKeysForObject:country][0]; |
| + } else { |
| + _selectedCountryCode = |
| + base::SysUTF8ToNSString(countryModel.GetDefaultCountryCode()); |
| + } |
| } |
| // Queries the region names based on the selected country code. |