Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / android / certificate_viewer_android.cc
blobfa2277016e4ae97c66e885f5b9ab171d0576375f
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/ui/android/certificate_viewer_android.h"
7 #include "base/android/jni_string.h"
8 #include "base/logging.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "jni/CertificateViewer_jni.h"
11 #include "net/cert/x509_certificate.h"
12 #include "ui/base/l10n/l10n_util.h"
14 using base::android::ConvertUTF8ToJavaString;
15 using base::android::ScopedJavaLocalRef;
17 void ShowCertificateViewer(content::WebContents* web_contents,
18 gfx::NativeWindow parent,
19 net::X509Certificate* cert) {
20 // For Android, showing the certificate is always handled in Java.
21 NOTREACHED();
24 static ScopedJavaLocalRef<jstring> GetCertIssuedToText(
25 JNIEnv* env,
26 const JavaParamRef<jclass>&) {
27 return ConvertUTF8ToJavaString(
28 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SUBJECT_GROUP));
31 static ScopedJavaLocalRef<jstring> GetCertInfoCommonNameText(
32 JNIEnv* env,
33 const JavaParamRef<jclass>&) {
34 return ConvertUTF8ToJavaString(
35 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL));
38 static ScopedJavaLocalRef<jstring> GetCertInfoOrganizationText(
39 JNIEnv* env,
40 const JavaParamRef<jclass>&) {
41 return ConvertUTF8ToJavaString(
42 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATION_LABEL));
45 static ScopedJavaLocalRef<jstring> GetCertInfoSerialNumberText(
46 JNIEnv* env,
47 const JavaParamRef<jclass>&) {
48 return ConvertUTF8ToJavaString(
49 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SERIAL_NUMBER_LABEL));
52 static ScopedJavaLocalRef<jstring> GetCertInfoOrganizationUnitText(
53 JNIEnv* env,
54 const JavaParamRef<jclass>&) {
55 return ConvertUTF8ToJavaString(
56 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL));
59 static ScopedJavaLocalRef<jstring> GetCertIssuedByText(
60 JNIEnv* env,
61 const JavaParamRef<jclass>&) {
62 return ConvertUTF8ToJavaString(
63 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUER_GROUP));
66 static ScopedJavaLocalRef<jstring> GetCertValidityText(
67 JNIEnv* env,
68 const JavaParamRef<jclass>&) {
69 return ConvertUTF8ToJavaString(
70 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_VALIDITY_GROUP));
73 static ScopedJavaLocalRef<jstring> GetCertIssuedOnText(
74 JNIEnv* env,
75 const JavaParamRef<jclass>&) {
76 return ConvertUTF8ToJavaString(
77 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUED_ON_LABEL));
80 static ScopedJavaLocalRef<jstring> GetCertExpiresOnText(
81 JNIEnv* env,
82 const JavaParamRef<jclass>&) {
83 return ConvertUTF8ToJavaString(
84 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_EXPIRES_ON_LABEL));
87 static ScopedJavaLocalRef<jstring> GetCertFingerprintsText(
88 JNIEnv* env,
89 const JavaParamRef<jclass>&) {
90 return ConvertUTF8ToJavaString(
91 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_FINGERPRINTS_GROUP));
94 static ScopedJavaLocalRef<jstring> GetCertSHA256FingerprintText(
95 JNIEnv* env,
96 const JavaParamRef<jclass>&) {
97 return ConvertUTF8ToJavaString(
98 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL));
101 static ScopedJavaLocalRef<jstring> GetCertSHA1FingerprintText(
102 JNIEnv* env,
103 const JavaParamRef<jclass>&) {
104 return ConvertUTF8ToJavaString(
105 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL));
108 bool RegisterCertificateViewer(JNIEnv* env) {
109 return RegisterNativesImpl(env);