Chromium Code Reviews| Index: chrome/browser/ui/android/infobars/update_password_infobar.cc |
| diff --git a/chrome/browser/ui/android/infobars/update_password_infobar.cc b/chrome/browser/ui/android/infobars/update_password_infobar.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..63a6d5952692fe76475e9e3dcf49c52751104df1 |
| --- /dev/null |
| +++ b/chrome/browser/ui/android/infobars/update_password_infobar.cc |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/android/infobars/update_password_infobar.h" |
| + |
| +#include <vector> |
| + |
| +#include "base/android/jni_android.h" |
| +#include "base/android/jni_array.h" |
| +#include "base/android/jni_string.h" |
| +#include "components/password_manager/core/common/credential_manager_types.h" |
| +#include "jni/UpdatePasswordInfoBar_jni.h" |
| + |
| +UpdatePasswordInfoBar::UpdatePasswordInfoBar( |
| + scoped_ptr<UpdatePasswordInfoBarDelegate> delegate) |
| + : ConfirmInfoBar(std::move(delegate)) {} |
| + |
| +UpdatePasswordInfoBar::~UpdatePasswordInfoBar() {} |
| + |
| +base::android::ScopedJavaLocalRef<jobject> |
| +UpdatePasswordInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
|
Peter Kasting
2016/02/03 00:56:27
Nit: Function definition order should match declar
melandory
2016/02/12 19:19:37
Done.
|
| + using base::android::ConvertUTF16ToJavaString; |
| + using base::android::ScopedJavaLocalRef; |
| + UpdatePasswordInfoBarDelegate* update_password_delegate = |
| + static_cast<UpdatePasswordInfoBarDelegate*>(delegate()); |
| + ScopedJavaLocalRef<jstring> ok_button_text = ConvertUTF16ToJavaString( |
| + env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK)); |
| + ScopedJavaLocalRef<jstring> cancel_button_text = ConvertUTF16ToJavaString( |
| + env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL)); |
| + ScopedJavaLocalRef<jstring> branding_text = |
| + ConvertUTF16ToJavaString(env, update_password_delegate->branding()); |
| + |
| + std::vector<base::string16> usernames; |
| + if (update_password_delegate->ShowMultipleAccounts()) { |
| + for (auto password_form : update_password_delegate->GetCurrentForms()) { |
|
Peter Kasting
2016/02/03 00:56:27
Nit: No {}
melandory
2016/02/12 19:19:37
Done.
|
| + usernames.push_back(password_form->username_value); |
| + } |
| + } else { |
| + usernames.push_back( |
| + update_password_delegate->GetUsernameForOneAccountCase()); |
| + } |
| + |
| + base::android::ScopedJavaLocalRef<jobjectArray> java_usernames = |
|
Peter Kasting
2016/02/03 00:56:27
Nit: No need to qualify these
melandory
2016/02/12 19:19:37
Done.
|
| + base::android::ToJavaArrayOfStrings(env, usernames); |
| + base::android::ScopedJavaLocalRef<jobject> infobar; |
| + infobar.Reset(Java_UpdatePasswordInfoBar_show( |
| + env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(), |
| + java_usernames.obj(), ok_button_text.obj(), cancel_button_text.obj(), |
| + branding_text.obj(), update_password_delegate->ShowMultipleAccounts(), |
| + update_password_delegate->is_smartlock_branding_enabled())); |
| + |
| + java_infobar_.Reset(env, infobar.obj()); |
| + return infobar; |
| +} |
| + |
| +void UpdatePasswordInfoBar::OnLinkClicked(JNIEnv* env, |
| + const JavaParamRef<jobject>& obj) { |
| + GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB); |
| +} |
| + |
| +int UpdatePasswordInfoBar::GetIdOfSelectedUsername() { |
| + return Java_UpdatePasswordInfoBar_getSelectedUsername( |
| + base::android::AttachCurrentThread(), java_infobar_.obj()); |
| +} |
| + |
| +bool UpdatePasswordInfoBar::Register(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +scoped_ptr<infobars::InfoBar> CreateUpdatePasswordInfoBar( |
|
Peter Kasting
2016/02/03 00:56:27
This function is not declared or referenced anywhe
melandory
2016/02/12 19:19:37
Done.
|
| + scoped_ptr<UpdatePasswordInfoBarDelegate> delegate) { |
| + return make_scoped_ptr(new UpdatePasswordInfoBar(std::move(delegate))); |
| +} |