OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/options/cert_library.h" | 5 #include "chrome/browser/chromeos/options/cert_library.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/i18n/string_compare.h" | 10 #include "base/i18n/string_compare.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
30 #include "ui/base/l10n/l10n_util_collator.h" | 30 #include "ui/base/l10n/l10n_util_collator.h" |
31 | 31 |
32 namespace chromeos { | 32 namespace chromeos { |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 // Root CA certificates that are built into Chrome use this token name. | 36 // Root CA certificates that are built into Chrome use this token name. |
37 const char kRootCertificateTokenName[] = "Builtin Object Token"; | 37 const char kRootCertificateTokenName[] = "Builtin Object Token"; |
38 | 38 |
39 string16 GetDisplayString(net::X509Certificate* cert, bool hardware_backed) { | 39 base::string16 GetDisplayString(net::X509Certificate* cert, bool hardware_backed
) { |
40 std::string org; | 40 std::string org; |
41 if (!cert->subject().organization_names.empty()) | 41 if (!cert->subject().organization_names.empty()) |
42 org = cert->subject().organization_names[0]; | 42 org = cert->subject().organization_names[0]; |
43 if (org.empty()) | 43 if (org.empty()) |
44 org = cert->subject().GetDisplayName(); | 44 org = cert->subject().GetDisplayName(); |
45 string16 issued_by = UTF8ToUTF16( | 45 base::string16 issued_by = UTF8ToUTF16( |
46 x509_certificate_model::GetIssuerCommonName(cert->os_cert_handle(), | 46 x509_certificate_model::GetIssuerCommonName(cert->os_cert_handle(), |
47 org)); // alternative text | 47 org)); // alternative text |
48 string16 issued_to = UTF8ToUTF16( | 48 base::string16 issued_to = UTF8ToUTF16( |
49 x509_certificate_model::GetCertNameOrNickname(cert->os_cert_handle())); | 49 x509_certificate_model::GetCertNameOrNickname(cert->os_cert_handle())); |
50 | 50 |
51 if (hardware_backed) { | 51 if (hardware_backed) { |
52 return l10n_util::GetStringFUTF16( | 52 return l10n_util::GetStringFUTF16( |
53 IDS_CERT_MANAGER_HARDWARE_BACKED_KEY_FORMAT_LONG, | 53 IDS_CERT_MANAGER_HARDWARE_BACKED_KEY_FORMAT_LONG, |
54 issued_by, | 54 issued_by, |
55 issued_to, | 55 issued_to, |
56 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_HARDWARE_BACKED)); | 56 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_HARDWARE_BACKED)); |
57 } else { | 57 } else { |
58 return l10n_util::GetStringFUTF16( | 58 return l10n_util::GetStringFUTF16( |
(...skipping 16 matching lines...) Expand all Loading... |
75 } // namespace | 75 } // namespace |
76 | 76 |
77 class CertNameComparator { | 77 class CertNameComparator { |
78 public: | 78 public: |
79 explicit CertNameComparator(icu::Collator* collator) | 79 explicit CertNameComparator(icu::Collator* collator) |
80 : collator_(collator) { | 80 : collator_(collator) { |
81 } | 81 } |
82 | 82 |
83 bool operator()(const scoped_refptr<net::X509Certificate>& lhs, | 83 bool operator()(const scoped_refptr<net::X509Certificate>& lhs, |
84 const scoped_refptr<net::X509Certificate>& rhs) const { | 84 const scoped_refptr<net::X509Certificate>& rhs) const { |
85 string16 lhs_name = GetDisplayString(lhs.get(), false); | 85 base::string16 lhs_name = GetDisplayString(lhs.get(), false); |
86 string16 rhs_name = GetDisplayString(rhs.get(), false); | 86 base::string16 rhs_name = GetDisplayString(rhs.get(), false); |
87 if (collator_ == NULL) | 87 if (collator_ == NULL) |
88 return lhs_name < rhs_name; | 88 return lhs_name < rhs_name; |
89 return base::i18n::CompareString16WithCollator( | 89 return base::i18n::CompareString16WithCollator( |
90 collator_, lhs_name, rhs_name) == UCOL_LESS; | 90 collator_, lhs_name, rhs_name) == UCOL_LESS; |
91 } | 91 } |
92 | 92 |
93 private: | 93 private: |
94 icu::Collator* collator_; | 94 icu::Collator* collator_; |
95 }; | 95 }; |
96 | 96 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 return user_certs_; | 275 return user_certs_; |
276 if (type == CERT_TYPE_SERVER) | 276 if (type == CERT_TYPE_SERVER) |
277 return server_certs_; | 277 return server_certs_; |
278 if (type == CERT_TYPE_SERVER_CA) | 278 if (type == CERT_TYPE_SERVER_CA) |
279 return server_ca_certs_; | 279 return server_ca_certs_; |
280 DCHECK(type == CERT_TYPE_DEFAULT); | 280 DCHECK(type == CERT_TYPE_DEFAULT); |
281 return certs_; | 281 return certs_; |
282 } | 282 } |
283 | 283 |
284 } // namespace chromeos | 284 } // namespace chromeos |
OLD | NEW |