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