Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: chrome/browser/certificate_manager_model.cc

Issue 3565006: Decouples certificates viewers from NSS to prepare support for OpenSSL. (Closed)
Patch Set: Comments / ProcessIDN Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/common.gypi ('k') | chrome/browser/gtk/certificate_dialogs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/certificate_manager_model.cc
diff --git a/chrome/browser/certificate_manager_model.cc b/chrome/browser/certificate_manager_model.cc
index 0f07d894c6a4c9765fc6d8ef18c3a57242e17306..c53547cce6c6f54f4a6f6bf1389670284b302b7a 100644
--- a/chrome/browser/certificate_manager_model.cc
+++ b/chrome/browser/certificate_manager_model.cc
@@ -4,52 +4,13 @@
#include "chrome/browser/certificate_manager_model.h"
-#include <cert.h>
-
#include "base/i18n/time_formatting.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
-#include "chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h"
-#include "chrome/third_party/mozilla_security_manager/nsNSSCertificate.h"
+#include "chrome/common/net/x509_certificate_model.h"
#include "net/base/net_errors.h"
#include "net/base/x509_certificate.h"
-// TODO(mattm): Try to make this use only X509Certificate stuff rather than NSS
-// functions in some places. (Not very important at this time since this is only
-// used w/NSS anyway.)
-
-// PSM = Mozilla's Personal Security Manager.
-namespace psm = mozilla_security_manager;
-
-namespace {
-
-// Convert a char* return value from NSS into a std::string and free the NSS
-// memory. If the arg is NULL, an empty string will be returned instead.
-std::string Stringize(char* nss_text) {
- std::string s;
- if (nss_text) {
- s = nss_text;
- PORT_Free(nss_text);
- }
- return s;
-}
-
-std::string GetCertNameOrNickname(CERTCertificate* os_cert) {
- std::string name = psm::ProcessIDN(
- Stringize(CERT_GetCommonName(&os_cert->subject)));
- if (name.empty() && os_cert->nickname) {
- name = os_cert->nickname;
- // Hack copied from mozilla: Cut off text before first :, which seems to
- // just be the token name.
- size_t colon_pos = name.find(':');
- if (colon_pos != std::string::npos)
- name = name.substr(colon_pos + 1);
- }
- return name;
-}
-
-} // namespace
-
CertificateManagerModel::CertificateManagerModel(Observer* observer)
: observer_(observer) {
}
@@ -70,7 +31,8 @@ void CertificateManagerModel::FilterAndBuildOrgGroupingMap(
for (net::CertificateList::const_iterator i = cert_list_.begin();
i != cert_list_.end(); ++i) {
net::X509Certificate* cert = i->get();
- net::CertType type = psm::GetCertType(cert->os_cert_handle());
+ net::CertType type =
+ x509_certificate_model::GetType(cert->os_cert_handle());
if (type != filter_type)
continue;
@@ -90,14 +52,17 @@ string16 CertificateManagerModel::GetColumnText(
string16 rv;
switch (column) {
case COL_SUBJECT_NAME:
- rv = UTF8ToUTF16(GetCertNameOrNickname(cert.os_cert_handle()));
+ rv = UTF8ToUTF16(
+ x509_certificate_model::GetCertNameOrNickname(cert.os_cert_handle()));
break;
case COL_CERTIFICATE_STORE:
- rv = UTF8ToUTF16(psm::GetCertTokenName(cert.os_cert_handle()));
+ rv = UTF8ToUTF16(
+ x509_certificate_model::GetTokenName(cert.os_cert_handle()));
break;
case COL_SERIAL_NUMBER:
- rv = ASCIIToUTF16(Stringize(CERT_Hexify(
- &cert.os_cert_handle()->serialNumber, PR_TRUE)));
+ rv = ASCIIToUTF16(
+ x509_certificate_model::GetSerialNumberHexified(
+ cert.os_cert_handle(), ""));
break;
case COL_EXPIRES_ON:
if (!cert.valid_expiry().is_null()) {
@@ -106,8 +71,8 @@ string16 CertificateManagerModel::GetColumnText(
}
break;
case COL_EMAIL_ADDRESS:
- if (cert.os_cert_handle()->emailAddr)
- rv = UTF8ToUTF16(cert.os_cert_handle()->emailAddr);
+ rv = UTF8ToUTF16(
+ x509_certificate_model::GetEmailAddress(cert.os_cert_handle()));
break;
default:
NOTREACHED();
« no previous file with comments | « build/common.gypi ('k') | chrome/browser/gtk/certificate_dialogs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698