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

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

Issue 10574040: Remove chromeos::LibraryLoader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 8 years, 6 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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 // base::Unretained(this) in the class is safe. By the time this object is 102 // base::Unretained(this) in the class is safe. By the time this object is
103 // deleted as part of CrosLibrary, the DB thread and the UI message loop 103 // deleted as part of CrosLibrary, the DB thread and the UI message loop
104 // are already terminated. 104 // are already terminated.
105 class CertLibraryImpl 105 class CertLibraryImpl
106 : public CertLibrary, 106 : public CertLibrary,
107 public net::CertDatabase::Observer { 107 public net::CertDatabase::Observer {
108 public: 108 public:
109 typedef ObserverListThreadSafe<CertLibrary::Observer> CertLibraryObserverList; 109 typedef ObserverListThreadSafe<CertLibrary::Observer> CertLibraryObserverList;
110 110
111 CertLibraryImpl() : 111 explicit CertLibraryImpl(bool stub) :
112 observer_list_(new CertLibraryObserverList), 112 observer_list_(new CertLibraryObserverList),
113 tpm_token_ready_(false), 113 tpm_token_ready_(false),
114 user_logged_in_(false), 114 user_logged_in_(false),
115 certificates_requested_(false), 115 certificates_requested_(false),
116 certificates_loaded_(false), 116 certificates_loaded_(false),
117 key_store_loaded_(false), 117 key_store_loaded_(false),
118 is_stub_mode_(stub),
118 ALLOW_THIS_IN_INITIALIZER_LIST(certs_(this)), 119 ALLOW_THIS_IN_INITIALIZER_LIST(certs_(this)),
119 ALLOW_THIS_IN_INITIALIZER_LIST(user_certs_(this)), 120 ALLOW_THIS_IN_INITIALIZER_LIST(user_certs_(this)),
120 ALLOW_THIS_IN_INITIALIZER_LIST(server_certs_(this)), 121 ALLOW_THIS_IN_INITIALIZER_LIST(server_certs_(this)),
121 ALLOW_THIS_IN_INITIALIZER_LIST(server_ca_certs_(this)), 122 ALLOW_THIS_IN_INITIALIZER_LIST(server_ca_certs_(this)),
122 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 123 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
123 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 124 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
124 net::CertDatabase::AddObserver(this); 125 net::CertDatabase::AddObserver(this);
125 } 126 }
126 127
127 ~CertLibraryImpl() { 128 ~CertLibraryImpl() {
(...skipping 19 matching lines...) Expand all
147 crypto::OpenPersistentNSSDB(); 148 crypto::OpenPersistentNSSDB();
148 149
149 // Only load the Opencryptoki library into NSS if we have this switch. 150 // Only load the Opencryptoki library into NSS if we have this switch.
150 // TODO(gspencer): Remove this switch once cryptohomed work is finished: 151 // TODO(gspencer): Remove this switch once cryptohomed work is finished:
151 // http://crosbug.com/12295 and 12304 152 // http://crosbug.com/12295 and 12304
152 // Note: ChromeOS login with or without loginmanager will crash when 153 // Note: ChromeOS login with or without loginmanager will crash when
153 // the CertLibrary is not there (http://crosbug.com/121456). Before removing 154 // the CertLibrary is not there (http://crosbug.com/121456). Before removing
154 // make sure that that case still works. 155 // make sure that that case still works.
155 if (CommandLine::ForCurrentProcess()->HasSwitch( 156 if (CommandLine::ForCurrentProcess()->HasSwitch(
156 switches::kLoadOpencryptoki) || 157 switches::kLoadOpencryptoki) ||
157 CommandLine::ForCurrentProcess()->HasSwitch(switches::kStubCros)) { 158 is_stub_mode_) {
stevenjb 2012/06/20 17:26:47 This really shouldn't be tied to stub_mode, it sho
hashimoto 2012/06/21 06:20:59 Done.
158 crypto::EnableTPMTokenForNSS(); 159 crypto::EnableTPMTokenForNSS();
159 // Note: this calls crypto::EnsureTPMTokenReady() 160 // Note: this calls crypto::EnsureTPMTokenReady()
160 RequestCertificates(); 161 RequestCertificates();
161 } 162 }
162 key_store_loaded_ = true; 163 key_store_loaded_ = true;
163 } 164 }
164 165
165 virtual bool CertificatesLoading() const OVERRIDE { 166 virtual bool CertificatesLoading() const OVERRIDE {
166 return certificates_requested_ && !certificates_loaded_; 167 return certificates_requested_ && !certificates_loaded_;
167 } 168 }
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 503
503 // Local state. 504 // Local state.
504 bool user_logged_in_; 505 bool user_logged_in_;
505 bool certificates_requested_; 506 bool certificates_requested_;
506 bool certificates_loaded_; 507 bool certificates_loaded_;
507 // The key store for the current user has been loaded. This flag is needed to 508 // The key store for the current user has been loaded. This flag is needed to
508 // ensure that the key store will not be loaded twice in the policy recovery 509 // ensure that the key store will not be loaded twice in the policy recovery
509 // "safe-mode". 510 // "safe-mode".
510 bool key_store_loaded_; 511 bool key_store_loaded_;
511 512
513 // True when stub implementation is required.
514 bool is_stub_mode_;
515
512 // Certificates. 516 // Certificates.
513 CertList certs_; 517 CertList certs_;
514 CertList user_certs_; 518 CertList user_certs_;
515 CertList server_certs_; 519 CertList server_certs_;
516 CertList server_ca_certs_; 520 CertList server_ca_certs_;
517 521
518 base::WeakPtrFactory<CertLibraryImpl> weak_ptr_factory_; 522 base::WeakPtrFactory<CertLibraryImpl> weak_ptr_factory_;
519 523
520 DISALLOW_COPY_AND_ASSIGN(CertLibraryImpl); 524 DISALLOW_COPY_AND_ASSIGN(CertLibraryImpl);
521 }; 525 };
522 526
523 ////////////////////////////////////////////////////////////////////////////// 527 //////////////////////////////////////////////////////////////////////////////
524 528
525 CertLibrary::~CertLibrary() { 529 CertLibrary::~CertLibrary() {
526 } 530 }
527 531
528 // static 532 // static
529 CertLibrary* CertLibrary::GetImpl(bool stub) { 533 CertLibrary* CertLibrary::GetImpl(bool stub) {
530 // No libcros dependencies, so always return CertLibraryImpl() (no stub). 534 return new CertLibraryImpl(stub);
531 return new CertLibraryImpl();
532 } 535 }
533 536
534 ////////////////////////////////////////////////////////////////////////////// 537 //////////////////////////////////////////////////////////////////////////////
535 538
536 net::X509Certificate* CertLibrary::CertList::GetCertificateAt(int index) const { 539 net::X509Certificate* CertLibrary::CertList::GetCertificateAt(int index) const {
537 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 540 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
538 DCHECK_GE(index, 0); 541 DCHECK_GE(index, 0);
539 DCHECK_LT(index, static_cast<int>(list_.size())); 542 DCHECK_LT(index, static_cast<int>(list_.size()));
540 return list_[index].get(); 543 return list_[index].get();
541 } 544 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 net::X509Certificate* cert = GetCertificateAt(index); 585 net::X509Certificate* cert = GetCertificateAt(index);
583 net::X509Certificate::OSCertHandle cert_handle = cert->os_cert_handle(); 586 net::X509Certificate::OSCertHandle cert_handle = cert->os_cert_handle();
584 std::string id = x509_certificate_model::GetPkcs11Id(cert_handle); 587 std::string id = x509_certificate_model::GetPkcs11Id(cert_handle);
585 if (id == pkcs11_id) 588 if (id == pkcs11_id)
586 return index; 589 return index;
587 } 590 }
588 return -1; // Not found. 591 return -1; // Not found.
589 } 592 }
590 593
591 } // chromeos 594 } // chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/chrome_browser_main_chromeos.cc ('k') | chrome/browser/chromeos/cros/cros_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698