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

Side by Side Diff: chrome/browser/chromeos/cros/cert_library.cc

Issue 14729017: Add NetworkHandler to own network handlers in src/chromeos/network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix chromeos_unittests Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/cros/cert_library.h" 5 #include "chrome/browser/chromeos/cros/cert_library.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/chromeos/chromeos_version.h" 9 #include "base/chromeos/chromeos_version.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 CHECK(g_cert_library) << "CertLibrary::Get() called before Initialize()"; 104 CHECK(g_cert_library) << "CertLibrary::Get() called before Initialize()";
105 return g_cert_library; 105 return g_cert_library;
106 } 106 }
107 107
108 // static 108 // static
109 bool CertLibrary::IsInitialized() { 109 bool CertLibrary::IsInitialized() {
110 return g_cert_library; 110 return g_cert_library;
111 } 111 }
112 112
113 CertLibrary::CertLibrary() { 113 CertLibrary::CertLibrary() {
114 CertLoader::Get()->AddObserver(this); 114 NetworkHandler::Get()->cert_loader()->AddObserver(this);
115 } 115 }
116 116
117 CertLibrary::~CertLibrary() { 117 CertLibrary::~CertLibrary() {
118 CertLoader::Get()->RemoveObserver(this); 118 NetworkHandler::Get()->cert_loader()->RemoveObserver(this);
119 } 119 }
120 120
121 void CertLibrary::AddObserver(CertLibrary::Observer* observer) { 121 void CertLibrary::AddObserver(CertLibrary::Observer* observer) {
122 observer_list_.AddObserver(observer); 122 observer_list_.AddObserver(observer);
123 } 123 }
124 124
125 void CertLibrary::RemoveObserver(CertLibrary::Observer* observer) { 125 void CertLibrary::RemoveObserver(CertLibrary::Observer* observer) {
126 observer_list_.RemoveObserver(observer); 126 observer_list_.RemoveObserver(observer);
127 } 127 }
128 128
129 bool CertLibrary::CertificatesLoading() const { 129 bool CertLibrary::CertificatesLoading() const {
130 return CertLoader::Get()->CertificatesLoading(); 130 return NetworkHandler::Get()->cert_loader()->CertificatesLoading();
131 } 131 }
132 132
133 bool CertLibrary::CertificatesLoaded() const { 133 bool CertLibrary::CertificatesLoaded() const {
134 return CertLoader::Get()->certificates_loaded(); 134 return NetworkHandler::Get()->cert_loader()->certificates_loaded();
135 } 135 }
136 136
137 bool CertLibrary::IsHardwareBacked() const { 137 bool CertLibrary::IsHardwareBacked() const {
138 return CertLoader::Get()->IsHardwareBacked(); 138 return NetworkHandler::Get()->cert_loader()->IsHardwareBacked();
139 } 139 }
140 140
141 int CertLibrary::NumCertificates(CertType type) const { 141 int CertLibrary::NumCertificates(CertType type) const {
142 const net::CertificateList& cert_list = GetCertificateListForType(type); 142 const net::CertificateList& cert_list = GetCertificateListForType(type);
143 return static_cast<int>(cert_list.size()); 143 return static_cast<int>(cert_list.size());
144 } 144 }
145 145
146 string16 CertLibrary::GetCertDisplayStringAt(CertType type, int index) const { 146 string16 CertLibrary::GetCertDisplayStringAt(CertType type, int index) const {
147 net::X509Certificate* cert = GetCertificateAt(type, index); 147 net::X509Certificate* cert = GetCertificateAt(type, index);
148 bool hardware_backed = IsCertHardwareBackedAt(type, index); 148 bool hardware_backed = IsCertHardwareBackedAt(type, index);
149 return GetDisplayString(cert, hardware_backed); 149 return GetDisplayString(cert, hardware_backed);
150 } 150 }
151 151
152 std::string CertLibrary::GetCertNicknameAt(CertType type, int index) const { 152 std::string CertLibrary::GetCertNicknameAt(CertType type, int index) const {
153 net::X509Certificate* cert = GetCertificateAt(type, index); 153 net::X509Certificate* cert = GetCertificateAt(type, index);
154 return x509_certificate_model::GetNickname(cert->os_cert_handle()); 154 return x509_certificate_model::GetNickname(cert->os_cert_handle());
155 } 155 }
156 156
157 std::string CertLibrary::GetCertPkcs11IdAt(CertType type, int index) const { 157 std::string CertLibrary::GetCertPkcs11IdAt(CertType type, int index) const {
158 net::X509Certificate* cert = GetCertificateAt(type, index); 158 net::X509Certificate* cert = GetCertificateAt(type, index);
159 return x509_certificate_model::GetPkcs11Id(cert->os_cert_handle()); 159 return x509_certificate_model::GetPkcs11Id(cert->os_cert_handle());
160 } 160 }
161 161
162 bool CertLibrary::IsCertHardwareBackedAt(CertType type, int index) const { 162 bool CertLibrary::IsCertHardwareBackedAt(CertType type, int index) const {
163 if (!CertLoader::Get()->IsHardwareBacked()) 163 if (!NetworkHandler::Get()->cert_loader()->IsHardwareBacked())
164 return false; 164 return false;
165 net::X509Certificate* cert = GetCertificateAt(type, index); 165 net::X509Certificate* cert = GetCertificateAt(type, index);
166 std::string cert_token_name = 166 std::string cert_token_name =
167 x509_certificate_model::GetTokenName(cert->os_cert_handle()); 167 x509_certificate_model::GetTokenName(cert->os_cert_handle());
168 return cert_token_name == CertLoader::Get()->tpm_token_name(); 168 return cert_token_name ==
169 NetworkHandler::Get()->cert_loader()->tpm_token_name();
169 } 170 }
170 171
171 int CertLibrary::GetCertIndexByNickname(CertType type, 172 int CertLibrary::GetCertIndexByNickname(CertType type,
172 const std::string& nickname) const { 173 const std::string& nickname) const {
173 int num_certs = NumCertificates(type); 174 int num_certs = NumCertificates(type);
174 for (int index = 0; index < num_certs; ++index) { 175 for (int index = 0; index < num_certs; ++index) {
175 net::X509Certificate* cert = GetCertificateAt(type, index); 176 net::X509Certificate* cert = GetCertificateAt(type, index);
176 net::X509Certificate::OSCertHandle cert_handle = cert->os_cert_handle(); 177 net::X509Certificate::OSCertHandle cert_handle = cert->os_cert_handle();
177 std::string nick = x509_certificate_model::GetNickname(cert_handle); 178 std::string nick = x509_certificate_model::GetNickname(cert_handle);
178 if (nick == nickname) 179 if (nick == nickname)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return user_certs_; 267 return user_certs_;
267 if (type == CERT_TYPE_SERVER) 268 if (type == CERT_TYPE_SERVER)
268 return server_certs_; 269 return server_certs_;
269 if (type == CERT_TYPE_SERVER_CA) 270 if (type == CERT_TYPE_SERVER_CA)
270 return server_ca_certs_; 271 return server_ca_certs_;
271 DCHECK(type == CERT_TYPE_DEFAULT); 272 DCHECK(type == CERT_TYPE_DEFAULT);
272 return certs_; 273 return certs_;
273 } 274 }
274 275
275 } // chromeos 276 } // chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/chrome_browser_main_chromeos.cc ('k') | chrome/browser/chromeos/cros/network_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698