| Index: chrome/browser/ui/android/infobars/account_chooser_infobar.cc
|
| diff --git a/chrome/browser/ui/android/infobars/account_chooser_infobar.cc b/chrome/browser/ui/android/infobars/account_chooser_infobar.cc
|
| index 00fa5fdb2cf895dfdc51cfe1dc9797a9f41135b2..1e4a2a45e1b7804b0c69929a20a3e658e55388bf 100644
|
| --- a/chrome/browser/ui/android/infobars/account_chooser_infobar.cc
|
| +++ b/chrome/browser/ui/android/infobars/account_chooser_infobar.cc
|
| @@ -11,6 +11,26 @@
|
| #include "components/password_manager/content/common/credential_manager_types.h"
|
| #include "jni/AccountChooserInfoBar_jni.h"
|
|
|
| +namespace {
|
| +ScopedJavaLocalRef<jobjectArray> AddElementsToJavaCredentialArray(
|
| + JNIEnv* env,
|
| + ScopedJavaLocalRef<jobjectArray> java_credentials_array,
|
| + const ScopedVector<autofill::PasswordForm>& credentials_forms,
|
| + password_manager::CredentialType type) {
|
| + int index = 0;
|
| + for (auto password_form : credentials_forms) {
|
| + ScopedJavaLocalRef<jobject> java_credential =
|
| + password_form->createNativeCredential(env, index,
|
| + static_cast<int>(type));
|
| + env->SetObjectArrayElement(java_credentials_array.obj(), index,
|
| + java_credential.obj());
|
| + index++;
|
| + }
|
| + return java_credentials_array;
|
| +}
|
| +
|
| +}; // namespace
|
| +
|
| AccountChooserInfoBar::AccountChooserInfoBar(
|
| scoped_ptr<AccountChooserInfoBarDelegateAndroid> delegate)
|
| : InfoBarAndroid(delegate.Pass()) {
|
| @@ -21,15 +41,20 @@ AccountChooserInfoBar::~AccountChooserInfoBar() {
|
|
|
| base::android::ScopedJavaLocalRef<jobject>
|
| AccountChooserInfoBar::CreateRenderInfoBar(JNIEnv* env) {
|
| - std::vector<base::string16> usernames;
|
| - // TODO(melandory): Federated credentials should be processed also.
|
| - for (auto password_form : GetDelegate()->local_credentials_forms())
|
| - usernames.push_back(password_form->username_value);
|
| - base::android::ScopedJavaLocalRef<jobjectArray> java_usernames =
|
| - base::android::ToJavaArrayOfStrings(env, usernames);
|
| + size_t credential_array_size =
|
| + GetDelegate()->local_credentials_forms().size() +
|
| + GetDelegate()->federated_credentials_forms().size();
|
| + ScopedJavaLocalRef<jobjectArray> java_credentials_array =
|
| + autofill::CreateNativeCredentialArray(env, credential_array_size);
|
| + AddElementsToJavaCredentialArray(
|
| + env, java_credentials_array, GetDelegate()->local_credentials_forms(),
|
| + password_manager::CredentialType::CREDENTIAL_TYPE_LOCAL);
|
| + AddElementsToJavaCredentialArray(
|
| + env, java_credentials_array, GetDelegate()->federated_credentials_forms(),
|
| + password_manager::CredentialType::CREDENTIAL_TYPE_FEDERATED);
|
| return Java_AccountChooserInfoBar_show(env, reinterpret_cast<intptr_t>(this),
|
| GetEnumeratedIconId(),
|
| - java_usernames.obj());
|
| + java_credentials_array.obj());
|
| }
|
|
|
| void AccountChooserInfoBar::OnCredentialClicked(JNIEnv* env,
|
|
|