| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/android/password_ui_view_android.h" | 5 #include "chrome/browser/android/password_ui_view_android.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/jni_weak_ref.h" | 10 #include "base/android/jni_weak_ref.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 const base::string16& password_value) { | 72 const base::string16& password_value) { |
| 73 NOTIMPLEMENTED(); | 73 NOTIMPLEMENTED(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void PasswordUIViewAndroid::SetPasswordList( | 76 void PasswordUIViewAndroid::SetPasswordList( |
| 77 const std::vector<std::unique_ptr<autofill::PasswordForm>>& password_list) { | 77 const std::vector<std::unique_ptr<autofill::PasswordForm>>& password_list) { |
| 78 JNIEnv* env = base::android::AttachCurrentThread(); | 78 JNIEnv* env = base::android::AttachCurrentThread(); |
| 79 ScopedJavaLocalRef<jobject> ui_controller = weak_java_ui_controller_.get(env); | 79 ScopedJavaLocalRef<jobject> ui_controller = weak_java_ui_controller_.get(env); |
| 80 if (!ui_controller.is_null()) { | 80 if (!ui_controller.is_null()) { |
| 81 Java_PasswordUIView_passwordListAvailable( | 81 Java_PasswordUIView_passwordListAvailable( |
| 82 env, ui_controller.obj(), static_cast<int>(password_list.size())); | 82 env, ui_controller, static_cast<int>(password_list.size())); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 void PasswordUIViewAndroid::SetPasswordExceptionList( | 86 void PasswordUIViewAndroid::SetPasswordExceptionList( |
| 87 const std::vector<std::unique_ptr<autofill::PasswordForm>>& | 87 const std::vector<std::unique_ptr<autofill::PasswordForm>>& |
| 88 password_exception_list) { | 88 password_exception_list) { |
| 89 JNIEnv* env = base::android::AttachCurrentThread(); | 89 JNIEnv* env = base::android::AttachCurrentThread(); |
| 90 ScopedJavaLocalRef<jobject> ui_controller = weak_java_ui_controller_.get(env); | 90 ScopedJavaLocalRef<jobject> ui_controller = weak_java_ui_controller_.get(env); |
| 91 if (!ui_controller.is_null()) { | 91 if (!ui_controller.is_null()) { |
| 92 Java_PasswordUIView_passwordExceptionListAvailable( | 92 Java_PasswordUIView_passwordExceptionListAvailable( |
| 93 env, | 93 env, ui_controller, static_cast<int>(password_exception_list.size())); |
| 94 ui_controller.obj(), | |
| 95 static_cast<int>(password_exception_list.size())); | |
| 96 } | 94 } |
| 97 } | 95 } |
| 98 | 96 |
| 99 void PasswordUIViewAndroid::UpdatePasswordLists(JNIEnv* env, | 97 void PasswordUIViewAndroid::UpdatePasswordLists(JNIEnv* env, |
| 100 const JavaParamRef<jobject>&) { | 98 const JavaParamRef<jobject>&) { |
| 101 password_manager_presenter_.UpdatePasswordLists(); | 99 password_manager_presenter_.UpdatePasswordLists(); |
| 102 } | 100 } |
| 103 | 101 |
| 104 ScopedJavaLocalRef<jobject> PasswordUIViewAndroid::GetSavedPasswordEntry( | 102 ScopedJavaLocalRef<jobject> PasswordUIViewAndroid::GetSavedPasswordEntry( |
| 105 JNIEnv* env, | 103 JNIEnv* env, |
| 106 const JavaParamRef<jobject>&, | 104 const JavaParamRef<jobject>&, |
| 107 int index) { | 105 int index) { |
| 108 const autofill::PasswordForm* form = | 106 const autofill::PasswordForm* form = |
| 109 password_manager_presenter_.GetPassword(index); | 107 password_manager_presenter_.GetPassword(index); |
| 110 if (!form) { | 108 if (!form) { |
| 111 return Java_PasswordUIView_createSavedPasswordEntry( | 109 return Java_PasswordUIView_createSavedPasswordEntry( |
| 112 env, | 110 env, ConvertUTF8ToJavaString(env, std::string()), |
| 113 ConvertUTF8ToJavaString(env, std::string()).obj(), | 111 ConvertUTF16ToJavaString(env, base::string16())); |
| 114 ConvertUTF16ToJavaString(env, base::string16()).obj()); | |
| 115 } | 112 } |
| 116 std::string human_readable_origin = GetDisplayOriginForSettings(*form); | 113 std::string human_readable_origin = GetDisplayOriginForSettings(*form); |
| 117 return Java_PasswordUIView_createSavedPasswordEntry( | 114 return Java_PasswordUIView_createSavedPasswordEntry( |
| 118 env, ConvertUTF8ToJavaString(env, human_readable_origin).obj(), | 115 env, ConvertUTF8ToJavaString(env, human_readable_origin), |
| 119 ConvertUTF16ToJavaString(env, form->username_value).obj()); | 116 ConvertUTF16ToJavaString(env, form->username_value)); |
| 120 } | 117 } |
| 121 | 118 |
| 122 ScopedJavaLocalRef<jstring> PasswordUIViewAndroid::GetSavedPasswordException( | 119 ScopedJavaLocalRef<jstring> PasswordUIViewAndroid::GetSavedPasswordException( |
| 123 JNIEnv* env, | 120 JNIEnv* env, |
| 124 const JavaParamRef<jobject>&, | 121 const JavaParamRef<jobject>&, |
| 125 int index) { | 122 int index) { |
| 126 const autofill::PasswordForm* form = | 123 const autofill::PasswordForm* form = |
| 127 password_manager_presenter_.GetPasswordException(index); | 124 password_manager_presenter_.GetPasswordException(index); |
| 128 if (!form) | 125 if (!form) |
| 129 return ConvertUTF8ToJavaString(env, std::string()); | 126 return ConvertUTF8ToJavaString(env, std::string()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 159 |
| 163 // static | 160 // static |
| 164 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 161 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 165 PasswordUIViewAndroid* controller = new PasswordUIViewAndroid(env, obj); | 162 PasswordUIViewAndroid* controller = new PasswordUIViewAndroid(env, obj); |
| 166 return reinterpret_cast<intptr_t>(controller); | 163 return reinterpret_cast<intptr_t>(controller); |
| 167 } | 164 } |
| 168 | 165 |
| 169 bool PasswordUIViewAndroid::RegisterPasswordUIViewAndroid(JNIEnv* env) { | 166 bool PasswordUIViewAndroid::RegisterPasswordUIViewAndroid(JNIEnv* env) { |
| 170 return RegisterNativesImpl(env); | 167 return RegisterNativesImpl(env); |
| 171 } | 168 } |
| OLD | NEW |