Commit 36f318dc authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][IdentityDisc] Show identity disc when user is signed in

This CL shows the identity disc when user is signed-in. The
corresponding tests will be added in the subsequent CL after we add the
new sign-in methods to AccountManagerFacade.

Bug: 1131920
Change-Id: Ic5992cf9c0561206ceee3f9e68c53bda72661468
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2428929
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810289}
parent 1319d722
......@@ -169,7 +169,7 @@ public class IdentityDiscController implements NativeInitObserver, ProfileDataCa
return;
}
String email = CoreAccountInfo.getEmailFrom(getSyncAccountInfo());
String email = CoreAccountInfo.getEmailFrom(getSignedInAccountInfo());
mState = email == null ? IdentityDiscState.NONE : IdentityDiscState.SMALL;
ensureProfileDataCache(email, mState);
......@@ -235,7 +235,7 @@ public class IdentityDiscController implements NativeInitObserver, ProfileDataCa
if (mState == IdentityDiscState.NONE) return;
assert mProfileDataCache[mState] != null;
if (accountEmail.equals(CoreAccountInfo.getEmailFrom(getSyncAccountInfo()))) {
if (accountEmail.equals(CoreAccountInfo.getEmailFrom(getSignedInAccountInfo()))) {
notifyObservers(true);
}
}
......@@ -295,8 +295,13 @@ public class IdentityDiscController implements NativeInitObserver, ProfileDataCa
* null for off-the-record ones.
* @return account info for the current profile. Returns null for OTR profile.
*/
private CoreAccountInfo getSyncAccountInfo() {
return mIdentityManager != null ? mIdentityManager.getPrimaryAccountInfo(ConsentLevel.SYNC)
private CoreAccountInfo getSignedInAccountInfo() {
@ConsentLevel
int consentLevel =
ChromeFeatureList.isEnabled(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)
? ConsentLevel.NOT_REQUIRED
: ConsentLevel.SYNC;
return mIdentityManager != null ? mIdentityManager.getPrimaryAccountInfo(consentLevel)
: null;
}
......
......@@ -31,12 +31,14 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.NewTabPageTestUtils;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule;
import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.content_public.common.ContentUrlConstants;
......@@ -46,6 +48,7 @@ import org.chromium.content_public.common.ContentUrlConstants;
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
@Features.DisableFeatures({ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY})
public class IdentityDiscControllerTest {
private final ChromeTabbedActivityTestRule mActivityTestRule =
new ChromeTabbedActivityTestRule();
......
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