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..fab26a36ff7b6b01b954fc9413d156cb5879b4bf |
--- /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) { |
+ 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()) { |
+ usernames.push_back(password_form->username_value); |
+ } |
+ } else { |
+ usernames.push_back( |
+ update_password_delegate->GetUsernameForOneAccountCase()); |
+ } |
+ |
+ base::android::ScopedJavaLocalRef<jobjectArray> java_usernames = |
+ base::android::ToJavaArrayOfStrings(env, usernames); |
+ return 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()); |
+} |
+ |
+void UpdatePasswordInfoBar::OnLinkClicked(JNIEnv* env, |
+ const JavaParamRef<jobject>& obj) { |
+ GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB); |
+} |
+ |
+void UpdatePasswordInfoBar::OnUpdateClicked(JNIEnv* env, |
+ jobject obj, |
+ jint form_id) { |
+ UpdatePasswordInfoBarDelegate* update_password_delegate = |
+ static_cast<UpdatePasswordInfoBarDelegate*>(delegate()); |
+ update_password_delegate->UpdatePassword(form_id); |
+ RemoveSelf(); |
gone
2016/01/26 19:59:22
I don't think this is right. onButtonClicked() fr
|
+} |
+ |
+bool UpdatePasswordInfoBar::Register(JNIEnv* env) { |
+ return RegisterNativesImpl(env); |
+} |
+ |
+scoped_ptr<infobars::InfoBar> CreateUpdatePasswordInfoBar( |
+ scoped_ptr<UpdatePasswordInfoBarDelegate> delegate) { |
+ return make_scoped_ptr(new UpdatePasswordInfoBar(std::move(delegate))); |
+} |