Commit b5003616 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Better little cleanup for UnifiedConsentMediator

This patch fixes a bug to update the selected identity when the identity
list is updated.

Related to:
crrev.com/c/1025895

Bug: 827072
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I772d3be25f6b280370c9d949487a7c2570fa6fc4
Reviewed-on: https://chromium-review.googlesource.com/1032741
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555363}
parent 0161f2d0
...@@ -56,10 +56,9 @@ ...@@ -56,10 +56,9 @@
return; return;
} }
// nil is allowed only if there is no other identity. // nil is allowed only if there is no other identity.
DCHECK(selectedIdentity || ios::GetChromeBrowserProvider() DCHECK(selectedIdentity || !ios::GetChromeBrowserProvider()
->GetChromeIdentityService() ->GetChromeIdentityService()
->GetAllIdentitiesSortedForDisplay() ->HasIdentities());
.count == 0);
_selectedIdentity = selectedIdentity; _selectedIdentity = selectedIdentity;
self.selectedIdentityAvatar = nil; self.selectedIdentityAvatar = nil;
[self updateViewController]; [self updateViewController];
...@@ -119,10 +118,12 @@ ...@@ -119,10 +118,12 @@
#pragma mark - ChromeIdentityServiceObserver #pragma mark - ChromeIdentityServiceObserver
- (void)identityListChanged { - (void)identityListChanged {
NSArray* identities = ios::GetChromeBrowserProvider() if (!self.selectedIdentity || !ios::GetChromeBrowserProvider()
->GetChromeIdentityService() ->GetChromeIdentityService()
->GetAllIdentitiesSortedForDisplay(); ->IsValidIdentity(self.selectedIdentity)) {
if (![identities containsObject:self.selectedIdentity]) { NSArray* identities = ios::GetChromeBrowserProvider()
->GetChromeIdentityService()
->GetAllIdentitiesSortedForDisplay();
ChromeIdentity* newIdentity = nil; ChromeIdentity* newIdentity = nil;
if (identities.count != 0) { if (identities.count != 0) {
newIdentity = identities[0]; newIdentity = identities[0];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment