Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1571)

Unified Diff: chrome/browser/ui/android/infobars/account_chooser_infobar.cc

Issue 925593006: Pass all info to account chooser infobar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@java_cpp_enum
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/password_manager/credential_android.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « chrome/browser/password_manager/credential_android.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698