| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/AccountChooserInfoBar.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AccountChooserInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AccountChooserInfoBar.java
|
| index 0bf059b6545a836af34a4609bd81afe890dccb7e..0f35999e9774f033f11166a3b6cdad724f0d3775 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AccountChooserInfoBar.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AccountChooserInfoBar.java
|
| @@ -18,6 +18,7 @@ import android.widget.TextView;
|
| import org.chromium.base.CalledByNative;
|
| import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.ResourceId;
|
| +import org.chromium.chrome.browser.password_manager.Credential;
|
|
|
| /**
|
| * An infobar offers the user the ability to choose credentials for
|
| @@ -25,46 +26,32 @@ import org.chromium.chrome.browser.ResourceId;
|
| * full name in case they are available.
|
| */
|
| public class AccountChooserInfoBar extends InfoBar {
|
| - private enum CredentialType {
|
| - EMPTY(0),
|
| - LOCAL(1),
|
| - FEDERATED(2);
|
| -
|
| - private final int mType;
|
| - private CredentialType(int type) {
|
| - mType = type;
|
| - };
|
| -
|
| - public int getValue() {
|
| - return mType;
|
| - }
|
| - }
|
| -
|
| - private final String[] mUsernames;
|
| + private final Credential[] mCredentials;
|
|
|
| /**
|
| * Creates and shows the infobar wich allows user to choose credentials for login.
|
| * @param nativeInfoBar Pointer to the native infobar.
|
| * @param enumeratedIconId Enum ID corresponding to the icon that the infobar will show.
|
| - * @param usernames Usernames to display in the infobar.
|
| + * @param credentials Credentials to display in the infobar.
|
| */
|
| @CalledByNative
|
| - private static InfoBar show(long nativeInfoBar, int enumeratedIconId, String[] usernames) {
|
| + private static InfoBar show(
|
| + long nativeInfoBar, int enumeratedIconId, Credential[] credentials) {
|
| return new AccountChooserInfoBar(
|
| - nativeInfoBar, ResourceId.mapToDrawableId(enumeratedIconId), usernames);
|
| + nativeInfoBar, ResourceId.mapToDrawableId(enumeratedIconId), credentials);
|
| }
|
|
|
| /**
|
| * Creates and shows the infobar which allows user to choose credentials.
|
| * @param nativeInfoBar Pointer to the native infobar.
|
| * @param iconDrawableId Drawable ID corresponding to the icon that the infobar will show.
|
| - * @param usernames list of usernames to display in infobar.
|
| + * @param credentials Credentials to display in the infobar.
|
| */
|
| - public AccountChooserInfoBar(long nativeInfoBar, int iconDrawableId, String[] usernames) {
|
| + public AccountChooserInfoBar(long nativeInfoBar, int iconDrawableId, Credential[] credentials) {
|
| super(null /* Infobar Listener */, iconDrawableId, null /* bitmap*/,
|
| null /* message to show */);
|
| setNativeInfoBar(nativeInfoBar);
|
| - mUsernames = usernames.clone();
|
| + mCredentials = credentials.clone();
|
| }
|
|
|
|
|
| @@ -89,7 +76,7 @@ public class AccountChooserInfoBar extends InfoBar {
|
| private void createAccountsView(InfoBarLayout layout) {
|
| ViewGroup accountsView = (ViewGroup) LayoutInflater.from(getContext()).inflate(
|
| R.layout.account_chooser_infobar_list, null, false);
|
| - ArrayAdapter<String> adapter = generateAccountsArrayAdapter(getContext(), mUsernames);
|
| + ArrayAdapter<Credential> adapter = generateAccountsArrayAdapter(getContext(), mCredentials);
|
| ListView listView = (ListView) accountsView.findViewById(R.id.account_list);
|
| listView.setAdapter(adapter);
|
| float numVisibleItems = adapter.getCount() > 2 ? 2.5f : adapter.getCount();
|
| @@ -100,8 +87,9 @@ public class AccountChooserInfoBar extends InfoBar {
|
| layout.setCustomContent(accountsView);
|
| }
|
|
|
| - private ArrayAdapter<String> generateAccountsArrayAdapter(Context context, String[] usernames) {
|
| - return new ArrayAdapter<String>(context, 0, usernames) {
|
| + private ArrayAdapter<Credential> generateAccountsArrayAdapter(
|
| + Context context, Credential[] credentials) {
|
| + return new ArrayAdapter<Credential>(context, 0, credentials) {
|
| @Override
|
| public View getView(int position, View convertView, ViewGroup parent) {
|
| if (convertView == null) {
|
| @@ -111,19 +99,19 @@ public class AccountChooserInfoBar extends InfoBar {
|
| ImageView avatarView = (ImageView) convertView.findViewById(R.id.profile_image);
|
| TextView usernameView = (TextView) convertView.findViewById(R.id.username);
|
| TextView displayNameView = (TextView) convertView.findViewById(R.id.display_name);
|
| - String username = getItem(position);
|
| - usernameView.setText(username);
|
| - // TODO(melandory): View should show the full name. Temporarily the view shows
|
| - // username.
|
| - displayNameView.setText(username);
|
| + Credential credential = getItem(position);
|
| + usernameView.setText(credential.getUsername());
|
| + displayNameView.setText(credential.getDisplayName());
|
| // TODO(melandory): View should show proper avatar. Temporarily the view shows
|
| // blue man icon.
|
| avatarView.setImageResource(R.drawable.account_management_no_picture);
|
| - final int currentCredentialIndex = position;
|
| + final int currentCredentialIndex = credential.getIndex();
|
| + final int credentialType = credential.getType();
|
| convertView.setOnClickListener(new View.OnClickListener() {
|
| @Override
|
| public void onClick(View view) {
|
| - passCredentialsToNative(currentCredentialIndex);
|
| + nativeOnCredentialClicked(
|
| + mNativeInfoBarPtr, currentCredentialIndex, credentialType);
|
| }
|
| });
|
| return convertView;
|
| @@ -141,14 +129,6 @@ public class AccountChooserInfoBar extends InfoBar {
|
| layout.setCustomViewInButtonRow(OverflowSelector.createOverflowSelector(getContext()));
|
| }
|
|
|
| - private void passCredentialsToNative(int credentialIndex) {
|
| - // TODO(melandory): Adding federated login support should change this
|
| - // code.
|
| - nativeOnCredentialClicked(
|
| - mNativeInfoBarPtr, credentialIndex, CredentialType.LOCAL.getValue());
|
| - }
|
| -
|
| -
|
| private native void nativeOnCredentialClicked(
|
| long nativeAccountChooserInfoBar, int credentialId, int credentialType);
|
| }
|
|
|