| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/android/infobars/update_password_infobar.h" | 5 #include "chrome/browser/ui/android/infobars/update_password_infobar.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 } | 27 } |
| 28 | 28 |
| 29 base::android::ScopedJavaLocalRef<jobject> | 29 base::android::ScopedJavaLocalRef<jobject> |
| 30 UpdatePasswordInfoBar::CreateRenderInfoBar(JNIEnv* env) { | 30 UpdatePasswordInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
| 31 using base::android::ConvertUTF16ToJavaString; | 31 using base::android::ConvertUTF16ToJavaString; |
| 32 using base::android::ScopedJavaLocalRef; | 32 using base::android::ScopedJavaLocalRef; |
| 33 UpdatePasswordInfoBarDelegate* update_password_delegate = | 33 UpdatePasswordInfoBarDelegate* update_password_delegate = |
| 34 static_cast<UpdatePasswordInfoBarDelegate*>(delegate()); | 34 static_cast<UpdatePasswordInfoBarDelegate*>(delegate()); |
| 35 ScopedJavaLocalRef<jstring> ok_button_text = ConvertUTF16ToJavaString( | 35 ScopedJavaLocalRef<jstring> ok_button_text = ConvertUTF16ToJavaString( |
| 36 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK)); | 36 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK)); |
| 37 ScopedJavaLocalRef<jstring> cancel_button_text = ConvertUTF16ToJavaString( | |
| 38 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL)); | |
| 39 ScopedJavaLocalRef<jstring> message_text = | 37 ScopedJavaLocalRef<jstring> message_text = |
| 40 ConvertUTF16ToJavaString(env, update_password_delegate->GetMessageText()); | 38 ConvertUTF16ToJavaString(env, update_password_delegate->GetMessageText()); |
| 41 | 39 |
| 42 std::vector<base::string16> usernames; | 40 std::vector<base::string16> usernames; |
| 43 if (update_password_delegate->ShowMultipleAccounts()) { | 41 if (update_password_delegate->ShowMultipleAccounts()) { |
| 44 for (const auto& form : update_password_delegate->GetCurrentForms()) | 42 for (const auto& form : update_password_delegate->GetCurrentForms()) |
| 45 usernames.push_back(form->username_value); | 43 usernames.push_back(form->username_value); |
| 46 } else { | 44 } else { |
| 47 usernames.push_back( | 45 usernames.push_back( |
| 48 update_password_delegate->get_username_for_single_account()); | 46 update_password_delegate->get_username_for_single_account()); |
| 49 } | 47 } |
| 50 | 48 |
| 51 base::android::ScopedJavaLocalRef<jobject> infobar; | 49 base::android::ScopedJavaLocalRef<jobject> infobar; |
| 52 infobar.Reset(Java_UpdatePasswordInfoBar_show( | 50 infobar.Reset(Java_UpdatePasswordInfoBar_show( |
| 53 env, GetEnumeratedIconId(), | 51 env, GetEnumeratedIconId(), |
| 54 base::android::ToJavaArrayOfStrings(env, usernames), message_text, | 52 base::android::ToJavaArrayOfStrings(env, usernames), message_text, |
| 55 update_password_delegate->message_link_range().start(), | 53 update_password_delegate->message_link_range().start(), |
| 56 update_password_delegate->message_link_range().end(), ok_button_text, | 54 update_password_delegate->message_link_range().end(), ok_button_text)); |
| 57 cancel_button_text)); | |
| 58 | 55 |
| 59 java_infobar_.Reset(env, infobar.obj()); | 56 java_infobar_.Reset(env, infobar.obj()); |
| 60 return infobar; | 57 return infobar; |
| 61 } | 58 } |
| 62 | 59 |
| 63 void UpdatePasswordInfoBar::OnLinkClicked(JNIEnv* env, | 60 void UpdatePasswordInfoBar::OnLinkClicked(JNIEnv* env, |
| 64 const JavaParamRef<jobject>& obj) { | 61 const JavaParamRef<jobject>& obj) { |
| 65 GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB); | 62 GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB); |
| 66 } | 63 } |
| OLD | NEW |