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
3 // found in the LICENSE file.
5 #include "chrome/browser/password_manager/credential_android.h"
7 #include "base/android/jni_string.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "jni/Credential_jni.h"
11 #include "ui/base/l10n/l10n_util.h"
13 base::android::ScopedJavaLocalRef
<jobject
> CreateNativeCredential(
15 const autofill::PasswordForm
& password_form
,
18 using base::android::ConvertUTF16ToJavaString
;
19 using base::android::ConvertUTF8ToJavaString
;
20 std::string federation
=
21 password_form
.federation_url
.is_empty()
23 : l10n_util::GetStringFUTF8(
24 IDS_PASSWORDS_VIA_FEDERATION
,
25 base::ASCIIToUTF16(password_form
.federation_url
.host()));
26 return Java_Credential_createCredential(
27 env
, ConvertUTF16ToJavaString(env
, password_form
.username_value
).obj(),
28 ConvertUTF16ToJavaString(env
, password_form
.display_name
).obj(),
29 ConvertUTF8ToJavaString(env
, federation
).obj(), type
, position
);
32 base::android::ScopedJavaLocalRef
<jobjectArray
> CreateNativeCredentialArray(
35 return Java_Credential_createCredentialArray(env
, static_cast<int>(size
));
38 bool RegisterCredential(JNIEnv
* env
) {
39 return RegisterNativesImpl(env
);