OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/password_manager/credential_android.h" | 5 #include "chrome/browser/password_manager/credential_android.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/grit/generated_resources.h" |
8 #include "jni/Credential_jni.h" | 10 #include "jni/Credential_jni.h" |
| 11 #include "ui/base/l10n/l10n_util.h" |
9 | 12 |
10 base::android::ScopedJavaLocalRef<jobject> CreateNativeCredential( | 13 base::android::ScopedJavaLocalRef<jobject> CreateNativeCredential( |
11 JNIEnv* env, | 14 JNIEnv* env, |
12 const autofill::PasswordForm& password_form, | 15 const autofill::PasswordForm& password_form, |
13 int position, | 16 int position, |
14 int type) { | 17 int type) { |
15 using base::android::ConvertUTF16ToJavaString; | 18 using base::android::ConvertUTF16ToJavaString; |
16 using base::android::ConvertUTF8ToJavaString; | 19 using base::android::ConvertUTF8ToJavaString; |
| 20 std::string federation = |
| 21 password_form.federation_url.is_empty() |
| 22 ? "" |
| 23 : l10n_util::GetStringFUTF8( |
| 24 IDS_MANAGE_PASSWORDS_IDENTITY_PROVIDER, |
| 25 base::ASCIIToUTF16(password_form.federation_url.host())); |
17 return Java_Credential_createCredential( | 26 return Java_Credential_createCredential( |
18 env, ConvertUTF16ToJavaString(env, password_form.username_value).obj(), | 27 env, ConvertUTF16ToJavaString(env, password_form.username_value).obj(), |
19 ConvertUTF16ToJavaString(env, password_form.display_name).obj(), type, | 28 ConvertUTF16ToJavaString(env, password_form.display_name).obj(), |
20 position); | 29 ConvertUTF8ToJavaString(env, federation).obj(), type, position); |
21 } | 30 } |
22 | 31 |
23 base::android::ScopedJavaLocalRef<jobjectArray> CreateNativeCredentialArray( | 32 base::android::ScopedJavaLocalRef<jobjectArray> CreateNativeCredentialArray( |
24 JNIEnv* env, | 33 JNIEnv* env, |
25 size_t size) { | 34 size_t size) { |
26 return Java_Credential_createCredentialArray(env, static_cast<int>(size)); | 35 return Java_Credential_createCredentialArray(env, static_cast<int>(size)); |
27 } | 36 } |
28 | 37 |
29 bool RegisterCredential(JNIEnv* env) { | 38 bool RegisterCredential(JNIEnv* env) { |
30 return RegisterNativesImpl(env); | 39 return RegisterNativesImpl(env); |
31 } | 40 } |
OLD | NEW |