Commit 719b8398 authored by melandory's avatar melandory Committed by Commit bot

[Smart Lock] Display identity provider information in account chooser infobar.

Federated credentials have identity provider information (IDP) associated with them. IDP for each of federated credential should be shown in account chooser infobar.

BUG=454815

Review URL: https://codereview.chromium.org/1007403003

Cr-Commit-Position: refs/heads/master@{#322539}
parent e0b8b940
......@@ -98,10 +98,13 @@ 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);
TextView smallTextView = (TextView) convertView.findViewById(R.id.display_name);
Credential credential = getItem(position);
usernameView.setText(credential.getUsername());
displayNameView.setText(credential.getDisplayName());
String smallText = credential.getFederation().isEmpty()
? credential.getFederation()
: credential.getDisplayName();
smallTextView.setText(smallText);
// TODO(melandory): View should show proper avatar. Temporarily the view shows
// blue man icon.
avatarView.setImageResource(R.drawable.account_management_no_picture);
......
......@@ -13,6 +13,7 @@ import org.chromium.base.CalledByNative;
public class Credential {
private final String mUsername;
private final String mDisplayName;
private final String mFederation;
private final int mType;
private final int mIndex;
......@@ -21,13 +22,15 @@ public class Credential {
* The value is PasswordForm::username_value.
* @param displayName user friendly name to show in the UI. It can be empty.
* The value is PasswordForm::display_name.
* @param federation Identity provider name for this credential (empty for local credentials).
* @param type type which should be either local or federated. The value corresponds to a
* C++ enum CredentialType.
* @param index position in array of credentials.
*/
public Credential(String username, String displayName, int type, int index) {
public Credential(String username, String displayName, String federation, int type, int index) {
mUsername = username;
mDisplayName = displayName;
mFederation = federation;
mType = type;
mIndex = index;
}
......@@ -40,6 +43,10 @@ public class Credential {
return mDisplayName;
}
public String getFederation() {
return mFederation;
}
public int getIndex() {
return mIndex;
}
......@@ -50,8 +57,8 @@ public class Credential {
@CalledByNative
private static Credential createCredential(
String username, String displayName, int type, int index) {
return new Credential(username, displayName, type, index);
String username, String displayName, String federation, int type, int index) {
return new Credential(username, displayName, federation, type, index);
}
@CalledByNative
......
......@@ -5,7 +5,10 @@
#include "chrome/browser/password_manager/credential_android.h"
#include "base/android/jni_string.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/grit/generated_resources.h"
#include "jni/Credential_jni.h"
#include "ui/base/l10n/l10n_util.h"
base::android::ScopedJavaLocalRef<jobject> CreateNativeCredential(
JNIEnv* env,
......@@ -14,10 +17,16 @@ base::android::ScopedJavaLocalRef<jobject> CreateNativeCredential(
int type) {
using base::android::ConvertUTF16ToJavaString;
using base::android::ConvertUTF8ToJavaString;
std::string federation =
password_form.federation_url.is_empty()
? ""
: l10n_util::GetStringFUTF8(
IDS_MANAGE_PASSWORDS_IDENTITY_PROVIDER,
base::ASCIIToUTF16(password_form.federation_url.host()));
return Java_Credential_createCredential(
env, ConvertUTF16ToJavaString(env, password_form.username_value).obj(),
ConvertUTF16ToJavaString(env, password_form.display_name).obj(), type,
position);
ConvertUTF16ToJavaString(env, password_form.display_name).obj(),
ConvertUTF8ToJavaString(env, federation).obj(), type, position);
}
base::android::ScopedJavaLocalRef<jobjectArray> CreateNativeCredentialArray(
......
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