Commit d102c824 authored by Side Yilmaz's avatar Side Yilmaz Committed by Commit Bot

Update deprecated IdentityServicesProvider function in PickerAdapter.

This CL replaces deprecated |IdentityServiceProvider#getIdentityManager|
with the newer getter with profile parameter. PickerAdapter provides
contacts for contacts picker by using email info coming from identity
manager. Since this is read only operation, this CL always passes
|Profile#getLastUsedRegularProfile| to be able to provide contacts
information even in incognito mode.

Note: This is only clean up and does not change any code behaviour.

Bug: 1041781, 1075562
Change-Id: I05c9ded3d5ca1f878bbd855c123d04362dc97a40
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2340963Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799073}
parent 8a3a0fcc
......@@ -22,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView.Adapter;
import org.chromium.base.task.AsyncTask;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.DisplayableProfileData;
import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.chrome.browser.signin.ProfileDataCache;
......@@ -29,6 +30,7 @@ import org.chromium.components.signin.AccountManagerFacade;
import org.chromium.components.signin.AccountManagerFacadeProvider;
import org.chromium.components.signin.base.CoreAccountInfo;
import org.chromium.components.signin.identitymanager.ConsentLevel;
import org.chromium.components.signin.identitymanager.IdentityManager;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......@@ -441,9 +443,7 @@ public class PickerAdapter extends Adapter<RecyclerView.ViewHolder>
private String getOwnerEmail() {
if (sTestOwnerEmail != null) return sTestOwnerEmail;
CoreAccountInfo coreAccountInfo =
IdentityServicesProvider.get().getIdentityManager().getPrimaryAccountInfo(
ConsentLevel.SYNC);
CoreAccountInfo coreAccountInfo = getCoreAccountInfo();
if (coreAccountInfo != null) {
return coreAccountInfo.getEmail();
}
......@@ -508,9 +508,7 @@ public class PickerAdapter extends Adapter<RecyclerView.ViewHolder>
DisplayableProfileData profileData = mProfileDataCache.getProfileDataOrDefault(ownerEmail);
String name = profileData.getFullNameOrEmail();
if (TextUtils.isEmpty(name) || TextUtils.equals(name, ownerEmail)) {
name = CoreAccountInfo.getEmailFrom(
IdentityServicesProvider.get().getIdentityManager().getPrimaryAccountInfo(
ConsentLevel.SYNC));
name = CoreAccountInfo.getEmailFrom(getCoreAccountInfo());
}
ArrayList<String> telephones = new ArrayList<>();
......@@ -522,4 +520,12 @@ public class PickerAdapter extends Adapter<RecyclerView.ViewHolder>
contact.setSelfIcon(icon);
return contact;
}
private CoreAccountInfo getCoreAccountInfo() {
// Since this is read-only operation to obtain email address, always using regular profile
// for both regular and off-the-record profile is safe.
IdentityManager identityManager = IdentityServicesProvider.get().getIdentityManager(
Profile.getLastUsedRegularProfile());
return identityManager.getPrimaryAccountInfo(ConsentLevel.SYNC);
}
}
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