| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chromeos/network/cert_loader.h" | 5 #include "chromeos/network/cert_loader.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/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 net::CertificateList* LoadNSSCertificates() { | 29 net::CertificateList* LoadNSSCertificates() { |
| 30 net::CertificateList* cert_list(new net::CertificateList()); | 30 net::CertificateList* cert_list(new net::CertificateList()); |
| 31 if (base::chromeos::IsRunningOnChromeOS()) | 31 if (base::chromeos::IsRunningOnChromeOS()) |
| 32 net::NSSCertDatabase::GetInstance()->ListCerts(cert_list); | 32 net::NSSCertDatabase::GetInstance()->ListCerts(cert_list); |
| 33 return cert_list; | 33 return cert_list; |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 static CertLoader* g_cert_loader = NULL; | |
| 39 | |
| 40 // static | |
| 41 void CertLoader::Initialize() { | |
| 42 CHECK(!g_cert_loader); | |
| 43 g_cert_loader = new CertLoader(); | |
| 44 } | |
| 45 | |
| 46 // static | |
| 47 void CertLoader::Shutdown() { | |
| 48 CHECK(g_cert_loader); | |
| 49 delete g_cert_loader; | |
| 50 g_cert_loader = NULL; | |
| 51 } | |
| 52 | |
| 53 // static | |
| 54 CertLoader* CertLoader::Get() { | |
| 55 CHECK(g_cert_loader) << "CertLoader::Get() called before Initialize()"; | |
| 56 return g_cert_loader; | |
| 57 } | |
| 58 | |
| 59 // static | |
| 60 bool CertLoader::IsInitialized() { | |
| 61 return g_cert_loader; | |
| 62 } | |
| 63 | |
| 64 CertLoader::CertLoader() | 38 CertLoader::CertLoader() |
| 65 : tpm_token_ready_(false), | 39 : tpm_token_ready_(false), |
| 66 certificates_requested_(false), | 40 certificates_requested_(false), |
| 67 certificates_loaded_(false), | 41 certificates_loaded_(false), |
| 68 key_store_loaded_(false), | 42 key_store_loaded_(false), |
| 69 weak_ptr_factory_(this) { | 43 weak_ptr_factory_(this) { |
| 70 net::CertDatabase::GetInstance()->AddObserver(this); | 44 net::CertDatabase::GetInstance()->AddObserver(this); |
| 71 LoginState::Get()->AddObserver(this); | 45 LoginState::Get()->AddObserver(this); |
| 72 if (LoginState::Get()->IsUserLoggedIn()) | 46 if (LoginState::Get()->IsUserLoggedIn()) |
| 73 RequestCertificates(); | 47 RequestCertificates(); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 StartLoadCertificates(); | 260 StartLoadCertificates(); |
| 287 } | 261 } |
| 288 | 262 |
| 289 void CertLoader::LoggedInStateChanged(LoginState::LoggedInState state) { | 263 void CertLoader::LoggedInStateChanged(LoginState::LoggedInState state) { |
| 290 VLOG(1) << "LoggedInStateChanged: " << state; | 264 VLOG(1) << "LoggedInStateChanged: " << state; |
| 291 if (LoginState::Get()->IsUserLoggedIn() && !certificates_requested_) | 265 if (LoginState::Get()->IsUserLoggedIn() && !certificates_requested_) |
| 292 RequestCertificates(); | 266 RequestCertificates(); |
| 293 } | 267 } |
| 294 | 268 |
| 295 } // namespace chromeos | 269 } // namespace chromeos |
| OLD | NEW |