Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/android/infobars/update_password_infobar.h" | |
| 6 | |
| 7 #include <vector> | |
| 8 | |
| 9 #include "base/android/jni_android.h" | |
| 10 #include "base/android/jni_array.h" | |
| 11 #include "base/android/jni_string.h" | |
| 12 #include "components/password_manager/core/common/credential_manager_types.h" | |
| 13 #include "jni/UpdatePasswordInfoBar_jni.h" | |
| 14 | |
| 15 UpdatePasswordInfoBar::UpdatePasswordInfoBar( | |
| 16 scoped_ptr<UpdatePasswordInfoBarDelegate> delegate) | |
| 17 : ConfirmInfoBar(std::move(delegate)) {} | |
| 18 | |
| 19 UpdatePasswordInfoBar::~UpdatePasswordInfoBar() {} | |
| 20 | |
| 21 base::android::ScopedJavaLocalRef<jobject> | |
| 22 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.
| |
| 23 using base::android::ConvertUTF16ToJavaString; | |
| 24 using base::android::ScopedJavaLocalRef; | |
| 25 UpdatePasswordInfoBarDelegate* update_password_delegate = | |
| 26 static_cast<UpdatePasswordInfoBarDelegate*>(delegate()); | |
| 27 ScopedJavaLocalRef<jstring> ok_button_text = ConvertUTF16ToJavaString( | |
| 28 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK)); | |
| 29 ScopedJavaLocalRef<jstring> cancel_button_text = ConvertUTF16ToJavaString( | |
| 30 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL)); | |
| 31 ScopedJavaLocalRef<jstring> branding_text = | |
| 32 ConvertUTF16ToJavaString(env, update_password_delegate->branding()); | |
| 33 | |
| 34 std::vector<base::string16> usernames; | |
| 35 if (update_password_delegate->ShowMultipleAccounts()) { | |
| 36 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.
| |
| 37 usernames.push_back(password_form->username_value); | |
| 38 } | |
| 39 } else { | |
| 40 usernames.push_back( | |
| 41 update_password_delegate->GetUsernameForOneAccountCase()); | |
| 42 } | |
| 43 | |
| 44 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.
| |
| 45 base::android::ToJavaArrayOfStrings(env, usernames); | |
| 46 base::android::ScopedJavaLocalRef<jobject> infobar; | |
| 47 infobar.Reset(Java_UpdatePasswordInfoBar_show( | |
| 48 env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(), | |
| 49 java_usernames.obj(), ok_button_text.obj(), cancel_button_text.obj(), | |
| 50 branding_text.obj(), update_password_delegate->ShowMultipleAccounts(), | |
| 51 update_password_delegate->is_smartlock_branding_enabled())); | |
| 52 | |
| 53 java_infobar_.Reset(env, infobar.obj()); | |
| 54 return infobar; | |
| 55 } | |
| 56 | |
| 57 void UpdatePasswordInfoBar::OnLinkClicked(JNIEnv* env, | |
| 58 const JavaParamRef<jobject>& obj) { | |
| 59 GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB); | |
| 60 } | |
| 61 | |
| 62 int UpdatePasswordInfoBar::GetIdOfSelectedUsername() { | |
| 63 return Java_UpdatePasswordInfoBar_getSelectedUsername( | |
| 64 base::android::AttachCurrentThread(), java_infobar_.obj()); | |
| 65 } | |
| 66 | |
| 67 bool UpdatePasswordInfoBar::Register(JNIEnv* env) { | |
| 68 return RegisterNativesImpl(env); | |
| 69 } | |
| 70 | |
| 71 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.
| |
| 72 scoped_ptr<UpdatePasswordInfoBarDelegate> delegate) { | |
| 73 return make_scoped_ptr(new UpdatePasswordInfoBar(std::move(delegate))); | |
| 74 } | |
| OLD | NEW |