| 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/ui/android/certificate_viewer_android.h" | 5 #include "chrome/browser/ui/android/certificate_viewer_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 10 #include "jni/CertificateViewer_jni.h" | 10 #include "jni/CertificateViewer_jni.h" |
| 11 #include "net/cert/x509_certificate.h" | 11 #include "net/cert/x509_certificate.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 | 13 |
| 14 using base::android::ConvertUTF8ToJavaString; | 14 using base::android::ConvertUTF8ToJavaString; |
| 15 using base::android::ScopedJavaLocalRef; | 15 using base::android::ScopedJavaLocalRef; |
| 16 | 16 |
| 17 void ShowCertificateViewer(content::WebContents* web_contents, | 17 void ShowCertificateViewer(content::WebContents* web_contents, |
| 18 gfx::NativeWindow parent, | 18 gfx::NativeWindow parent, |
| 19 net::X509Certificate* cert) { | 19 net::X509Certificate* cert) { |
| 20 // For Android, showing the certificate is always handled in Java. | 20 // For Android, showing the certificate is always handled in Java. |
| 21 NOTREACHED(); | 21 NOTREACHED(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 static jstring GetCertIssuedToText(JNIEnv* env, jclass) { | 24 static ScopedJavaLocalRef<jstring> GetCertIssuedToText(JNIEnv* env, jclass) { |
| 25 return ConvertUTF8ToJavaString( | 25 return ConvertUTF8ToJavaString( |
| 26 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SUBJECT_GROUP)).Release(); | 26 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SUBJECT_GROUP)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 static jstring GetCertInfoCommonNameText(JNIEnv* env, jclass) { | 29 static ScopedJavaLocalRef<jstring> GetCertInfoCommonNameText(JNIEnv* env, |
| 30 jclass) { |
| 30 return ConvertUTF8ToJavaString( | 31 return ConvertUTF8ToJavaString( |
| 31 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL)).Release(); | 32 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL)); |
| 32 } | 33 } |
| 33 | 34 |
| 34 static jstring GetCertInfoOrganizationText(JNIEnv* env, jclass) { | 35 static ScopedJavaLocalRef<jstring> GetCertInfoOrganizationText(JNIEnv* env, |
| 36 jclass) { |
| 35 return ConvertUTF8ToJavaString( | 37 return ConvertUTF8ToJavaString( |
| 36 env, l10n_util::GetStringUTF8( | 38 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATION_LABEL)); |
| 37 IDS_CERT_INFO_ORGANIZATION_LABEL)).Release(); | |
| 38 } | 39 } |
| 39 | 40 |
| 40 static jstring GetCertInfoSerialNumberText(JNIEnv* env, jclass) { | 41 static ScopedJavaLocalRef<jstring> GetCertInfoSerialNumberText(JNIEnv* env, |
| 42 jclass) { |
| 41 return ConvertUTF8ToJavaString( | 43 return ConvertUTF8ToJavaString( |
| 42 env, l10n_util::GetStringUTF8( | 44 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SERIAL_NUMBER_LABEL)); |
| 43 IDS_CERT_INFO_SERIAL_NUMBER_LABEL)).Release(); | |
| 44 } | 45 } |
| 45 | 46 |
| 46 static jstring GetCertInfoOrganizationUnitText(JNIEnv* env, jclass) { | 47 static ScopedJavaLocalRef<jstring> GetCertInfoOrganizationUnitText(JNIEnv* env, |
| 48 jclass) { |
| 47 return ConvertUTF8ToJavaString( | 49 return ConvertUTF8ToJavaString( |
| 48 env, l10n_util::GetStringUTF8( | 50 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL)); |
| 49 IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL)).Release(); | |
| 50 } | 51 } |
| 51 | 52 |
| 52 static jstring GetCertIssuedByText(JNIEnv* env, jclass) { | 53 static ScopedJavaLocalRef<jstring> GetCertIssuedByText(JNIEnv* env, jclass) { |
| 53 return ConvertUTF8ToJavaString( | 54 return ConvertUTF8ToJavaString( |
| 54 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUER_GROUP)).Release(); | 55 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUER_GROUP)); |
| 55 } | 56 } |
| 56 | 57 |
| 57 static jstring GetCertValidityText(JNIEnv* env, jclass) { | 58 static ScopedJavaLocalRef<jstring> GetCertValidityText(JNIEnv* env, jclass) { |
| 58 return ConvertUTF8ToJavaString( | 59 return ConvertUTF8ToJavaString( |
| 59 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_VALIDITY_GROUP)).Release(); | 60 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_VALIDITY_GROUP)); |
| 60 } | 61 } |
| 61 | 62 |
| 62 static jstring GetCertIssuedOnText(JNIEnv* env, jclass) { | 63 static ScopedJavaLocalRef<jstring> GetCertIssuedOnText(JNIEnv* env, jclass) { |
| 63 return ConvertUTF8ToJavaString( | 64 return ConvertUTF8ToJavaString( |
| 64 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUED_ON_LABEL)).Release(); | 65 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUED_ON_LABEL)); |
| 65 } | 66 } |
| 66 | 67 |
| 67 static jstring GetCertExpiresOnText(JNIEnv* env, jclass) { | 68 static ScopedJavaLocalRef<jstring> GetCertExpiresOnText(JNIEnv* env, jclass) { |
| 68 return ConvertUTF8ToJavaString( | 69 return ConvertUTF8ToJavaString( |
| 69 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_EXPIRES_ON_LABEL)).Release(); | 70 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_EXPIRES_ON_LABEL)); |
| 70 } | 71 } |
| 71 | 72 |
| 72 static jstring GetCertFingerprintsText(JNIEnv* env, jclass) { | 73 static ScopedJavaLocalRef<jstring> GetCertFingerprintsText(JNIEnv* env, |
| 74 jclass) { |
| 73 return ConvertUTF8ToJavaString( | 75 return ConvertUTF8ToJavaString( |
| 74 env, l10n_util::GetStringUTF8( | 76 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_FINGERPRINTS_GROUP)); |
| 75 IDS_CERT_INFO_FINGERPRINTS_GROUP)).Release(); | |
| 76 } | 77 } |
| 77 | 78 |
| 78 static jstring GetCertSHA256FingerprintText(JNIEnv* env, jclass) { | 79 static ScopedJavaLocalRef<jstring> GetCertSHA256FingerprintText(JNIEnv* env, |
| 80 jclass) { |
| 79 return ConvertUTF8ToJavaString( | 81 return ConvertUTF8ToJavaString( |
| 80 env, l10n_util::GetStringUTF8( | 82 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL)); |
| 81 IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL)).Release(); | |
| 82 } | 83 } |
| 83 | 84 |
| 84 static jstring GetCertSHA1FingerprintText(JNIEnv* env, jclass) { | 85 static ScopedJavaLocalRef<jstring> GetCertSHA1FingerprintText(JNIEnv* env, |
| 86 jclass) { |
| 85 return ConvertUTF8ToJavaString( | 87 return ConvertUTF8ToJavaString( |
| 86 env, l10n_util::GetStringUTF8( | 88 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL)); |
| 87 IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL)).Release(); | |
| 88 } | 89 } |
| 89 | 90 |
| 90 bool RegisterCertificateViewer(JNIEnv* env) { | 91 bool RegisterCertificateViewer(JNIEnv* env) { |
| 91 return RegisterNativesImpl(env); | 92 return RegisterNativesImpl(env); |
| 92 } | 93 } |
| OLD | NEW |