| 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..68d42e924441cca2334454a4059f09a08ee3934e 100644
|
| --- a/chrome/browser/ui/android/infobars/account_chooser_infobar.cc
|
| +++ b/chrome/browser/ui/android/infobars/account_chooser_infobar.cc
|
| @@ -4,13 +4,32 @@
|
|
|
| #include "chrome/browser/ui/android/infobars/account_chooser_infobar.h"
|
|
|
| -#include "base/android/jni_android.h"
|
| -#include "base/android/jni_array.h"
|
| #include "chrome/browser/infobars/infobar_service.h"
|
| #include "chrome/browser/password_manager/account_chooser_infobar_delegate_android.h"
|
| +#include "chrome/browser/password_manager/credential_android.h"
|
| #include "components/password_manager/content/common/credential_manager_types.h"
|
| #include "jni/AccountChooserInfoBar_jni.h"
|
|
|
| +namespace {
|
| +
|
| +void AddElementsToJavaCredentialArray(
|
| + JNIEnv* env,
|
| + ScopedJavaLocalRef<jobjectArray> java_credentials_array,
|
| + const std::vector<const autofill::PasswordForm*>& password_forms,
|
| + password_manager::CredentialType type,
|
| + int indexStart = 0) {
|
| + int index = indexStart;
|
| + for (auto password_form : password_forms) {
|
| + ScopedJavaLocalRef<jobject> java_credential = CreateNativeCredential(
|
| + env, *password_form, index - indexStart, static_cast<int>(type));
|
| + env->SetObjectArrayElement(java_credentials_array.obj(), index,
|
| + java_credential.obj());
|
| + index++;
|
| + }
|
| +}
|
| +
|
| +}; // namespace
|
| +
|
| AccountChooserInfoBar::AccountChooserInfoBar(
|
| scoped_ptr<AccountChooserInfoBarDelegateAndroid> delegate)
|
| : InfoBarAndroid(delegate.Pass()) {
|
| @@ -21,15 +40,21 @@ 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 =
|
| + 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,
|
| + GetDelegate()->local_credentials_forms().size());
|
| return Java_AccountChooserInfoBar_show(env, reinterpret_cast<intptr_t>(this),
|
| GetEnumeratedIconId(),
|
| - java_usernames.obj());
|
| + java_credentials_array.obj());
|
| }
|
|
|
| void AccountChooserInfoBar::OnCredentialClicked(JNIEnv* env,
|
|
|