Commit 6b93ff75 authored by Tanmoy Mollik's avatar Tanmoy Mollik Committed by Chromium LUCI CQ

[Android] Refactor IdentityManager.Observer API override in IdentityDiscController

Replace IdentityManager.Observer.(onPrimaryAccountSet/Cleared) calls
with onPrimaryAccountChanged call. This cl also fixes an issue where
the IdentityDisc is not shown until first refresh when the user signs
in without sync consent.

Bug: 1132291, 1158855
Change-Id: Iefec79c38f39af8927ac5a30648e19f398e16401
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598915
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarAlice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840220}
parent a1ac016e
......@@ -38,6 +38,7 @@ import org.chromium.components.feature_engagement.Tracker;
import org.chromium.components.signin.base.CoreAccountInfo;
import org.chromium.components.signin.identitymanager.ConsentLevel;
import org.chromium.components.signin.identitymanager.IdentityManager;
import org.chromium.components.signin.identitymanager.PrimaryAccountChangeEvent;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......@@ -250,18 +251,22 @@ public class IdentityDiscController implements NativeInitObserver, ProfileDataCa
/**
* Implements {@link IdentityManager.Observer}.
*
* TODO(https://crbug.com/1132291): This method only observes sign-in with sync, we should also
* observe sign-in without sync.
* IdentityDisc should be shown as long as the user is signed in. Whether the user is syncing
* or not should not matter.
*/
@Override
public void onPrimaryAccountSet(CoreAccountInfo account) {
public void onPrimaryAccountChanged(PrimaryAccountChangeEvent eventDetails) {
switch (eventDetails.getEventTypeFor(ConsentLevel.NOT_REQUIRED)) {
case PrimaryAccountChangeEvent.Type.SET:
resetIdentityDiscCache();
notifyObservers(true);
}
@Override
public void onPrimaryAccountCleared(CoreAccountInfo account) {
break;
case PrimaryAccountChangeEvent.Type.CLEARED:
notifyObservers(false);
break;
case PrimaryAccountChangeEvent.Type.NONE:
break;
}
}
/**
......
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