Commit 38122dcf authored by Xi Han's avatar Xi Han Committed by Commit Bot

[Instant Start] Fix IdentityDisc button isn't shown on Start surface.

When Instant Start is enabled, the calculateButtonData() is called
pre-native and early exits without calling the
IdentityDiscController#ensureProfileDataCache(). As a result, the
IdentityDiscController misses the event of the onProfileDataUpdated()
and thus doesn't notify its observer StartSurfaceToolbarMediator to
update the visibility of the identity disc button.

To fix the issue, we call notifyObservers(true) in setProfile() when the
Profile is created. It will notify the Start surface which calls
IdentityDiscController#getForStartSurface() to create a ProfileDataCache
if hasn't yet and listen to the event when Profile is updated.

Bug: 1137535
Change-Id: I187ab8734144d61ae0a2eff761494792594e7b21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2547200
Commit-Queue: Xi Han <hanxi@chromium.org>
Reviewed-by: default avatarPavel Yatsuk <pavely@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828913}
parent b439d993
......@@ -236,6 +236,13 @@ public class IdentityDiscController implements NativeInitObserver, ProfileDataCa
assert mProfileDataCache[mState] != null;
if (accountEmail.equals(CoreAccountInfo.getEmailFrom(getSignedInAccountInfo()))) {
/**
* We need to call {@link notifyObservers(false)} before caling
* {@link notifyObservers(true)}. This is because {@link notifyObservers(true)} has been
* called in {@link setProfile()}, and without calling {@link notifyObservers(false)},
* the ObservableSupplierImpl doesn't propagate the call. See https://cubug.com/1137535.
*/
notifyObservers(false);
notifyObservers(true);
}
}
......@@ -324,6 +331,7 @@ public class IdentityDiscController implements NativeInitObserver, ProfileDataCa
} else {
mIdentityManager = IdentityServicesProvider.get().getIdentityManager(profile);
mIdentityManager.addObserver(this);
notifyObservers(true);
}
}
}
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