| 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 ScopedJavaLocalRef<jstring> GetCertIssuedToText(JNIEnv* env, jclass) { | 24 static jstring GetCertIssuedToText(JNIEnv* env, jclass) { |
| 25 return ConvertUTF8ToJavaString( | 25 return ConvertUTF8ToJavaString( |
| 26 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SUBJECT_GROUP)); | 26 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SUBJECT_GROUP)).Release(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 static ScopedJavaLocalRef<jstring> GetCertInfoCommonNameText(JNIEnv* env, | 29 static jstring GetCertInfoCommonNameText(JNIEnv* env, jclass) { |
| 30 jclass) { | |
| 31 return ConvertUTF8ToJavaString( | 30 return ConvertUTF8ToJavaString( |
| 32 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL)); | 31 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL)).Release(); |
| 33 } | 32 } |
| 34 | 33 |
| 35 static ScopedJavaLocalRef<jstring> GetCertInfoOrganizationText(JNIEnv* env, | 34 static jstring GetCertInfoOrganizationText(JNIEnv* env, jclass) { |
| 36 jclass) { | |
| 37 return ConvertUTF8ToJavaString( | 35 return ConvertUTF8ToJavaString( |
| 38 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATION_LABEL)); | 36 env, l10n_util::GetStringUTF8( |
| 37 IDS_CERT_INFO_ORGANIZATION_LABEL)).Release(); |
| 39 } | 38 } |
| 40 | 39 |
| 41 static ScopedJavaLocalRef<jstring> GetCertInfoSerialNumberText(JNIEnv* env, | 40 static jstring GetCertInfoSerialNumberText(JNIEnv* env, jclass) { |
| 42 jclass) { | |
| 43 return ConvertUTF8ToJavaString( | 41 return ConvertUTF8ToJavaString( |
| 44 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SERIAL_NUMBER_LABEL)); | 42 env, l10n_util::GetStringUTF8( |
| 43 IDS_CERT_INFO_SERIAL_NUMBER_LABEL)).Release(); |
| 45 } | 44 } |
| 46 | 45 |
| 47 static ScopedJavaLocalRef<jstring> GetCertInfoOrganizationUnitText(JNIEnv* env, | 46 static jstring GetCertInfoOrganizationUnitText(JNIEnv* env, jclass) { |
| 48 jclass) { | |
| 49 return ConvertUTF8ToJavaString( | 47 return ConvertUTF8ToJavaString( |
| 50 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL)); | 48 env, l10n_util::GetStringUTF8( |
| 49 IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL)).Release(); |
| 51 } | 50 } |
| 52 | 51 |
| 53 static ScopedJavaLocalRef<jstring> GetCertIssuedByText(JNIEnv* env, jclass) { | 52 static jstring GetCertIssuedByText(JNIEnv* env, jclass) { |
| 54 return ConvertUTF8ToJavaString( | 53 return ConvertUTF8ToJavaString( |
| 55 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUER_GROUP)); | 54 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUER_GROUP)).Release(); |
| 56 } | 55 } |
| 57 | 56 |
| 58 static ScopedJavaLocalRef<jstring> GetCertValidityText(JNIEnv* env, jclass) { | 57 static jstring GetCertValidityText(JNIEnv* env, jclass) { |
| 59 return ConvertUTF8ToJavaString( | 58 return ConvertUTF8ToJavaString( |
| 60 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_VALIDITY_GROUP)); | 59 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_VALIDITY_GROUP)).Release(); |
| 61 } | 60 } |
| 62 | 61 |
| 63 static ScopedJavaLocalRef<jstring> GetCertIssuedOnText(JNIEnv* env, jclass) { | 62 static jstring GetCertIssuedOnText(JNIEnv* env, jclass) { |
| 64 return ConvertUTF8ToJavaString( | 63 return ConvertUTF8ToJavaString( |
| 65 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUED_ON_LABEL)); | 64 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUED_ON_LABEL)).Release(); |
| 66 } | 65 } |
| 67 | 66 |
| 68 static ScopedJavaLocalRef<jstring> GetCertExpiresOnText(JNIEnv* env, jclass) { | 67 static jstring GetCertExpiresOnText(JNIEnv* env, jclass) { |
| 69 return ConvertUTF8ToJavaString( | 68 return ConvertUTF8ToJavaString( |
| 70 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_EXPIRES_ON_LABEL)); | 69 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_EXPIRES_ON_LABEL)).Release(); |
| 71 } | 70 } |
| 72 | 71 |
| 73 static ScopedJavaLocalRef<jstring> GetCertFingerprintsText(JNIEnv* env, | 72 static jstring GetCertFingerprintsText(JNIEnv* env, jclass) { |
| 74 jclass) { | |
| 75 return ConvertUTF8ToJavaString( | 73 return ConvertUTF8ToJavaString( |
| 76 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_FINGERPRINTS_GROUP)); | 74 env, l10n_util::GetStringUTF8( |
| 75 IDS_CERT_INFO_FINGERPRINTS_GROUP)).Release(); |
| 77 } | 76 } |
| 78 | 77 |
| 79 static ScopedJavaLocalRef<jstring> GetCertSHA256FingerprintText(JNIEnv* env, | 78 static jstring GetCertSHA256FingerprintText(JNIEnv* env, jclass) { |
| 80 jclass) { | |
| 81 return ConvertUTF8ToJavaString( | 79 return ConvertUTF8ToJavaString( |
| 82 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL)); | 80 env, l10n_util::GetStringUTF8( |
| 81 IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL)).Release(); |
| 83 } | 82 } |
| 84 | 83 |
| 85 static ScopedJavaLocalRef<jstring> GetCertSHA1FingerprintText(JNIEnv* env, | 84 static jstring GetCertSHA1FingerprintText(JNIEnv* env, jclass) { |
| 86 jclass) { | |
| 87 return ConvertUTF8ToJavaString( | 85 return ConvertUTF8ToJavaString( |
| 88 env, l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL)); | 86 env, l10n_util::GetStringUTF8( |
| 87 IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL)).Release(); |
| 89 } | 88 } |
| 90 | 89 |
| 91 bool RegisterCertificateViewer(JNIEnv* env) { | 90 bool RegisterCertificateViewer(JNIEnv* env) { |
| 92 return RegisterNativesImpl(env); | 91 return RegisterNativesImpl(env); |
| 93 } | 92 } |
| OLD | NEW |