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

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

Issue 8771019: Don't require login to enable CA cert settings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use CertLibrary::CertificatesLoading() instead Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/observer_list_threadsafe.h" 9 #include "base/observer_list_threadsafe.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // are already terminated. 70 // are already terminated.
71 class CertLibraryImpl 71 class CertLibraryImpl
72 : public CertLibrary, 72 : public CertLibrary,
73 public net::CertDatabase::Observer { 73 public net::CertDatabase::Observer {
74 public: 74 public:
75 typedef ObserverListThreadSafe<CertLibrary::Observer> CertLibraryObserverList; 75 typedef ObserverListThreadSafe<CertLibrary::Observer> CertLibraryObserverList;
76 76
77 CertLibraryImpl() : 77 CertLibraryImpl() :
78 observer_list_(new CertLibraryObserverList), 78 observer_list_(new CertLibraryObserverList),
79 user_logged_in_(false), 79 user_logged_in_(false),
80 certificates_requested_(false),
80 certificates_loaded_(false), 81 certificates_loaded_(false),
81 ALLOW_THIS_IN_INITIALIZER_LIST(certs_(this)), 82 ALLOW_THIS_IN_INITIALIZER_LIST(certs_(this)),
82 ALLOW_THIS_IN_INITIALIZER_LIST(user_certs_(this)), 83 ALLOW_THIS_IN_INITIALIZER_LIST(user_certs_(this)),
83 ALLOW_THIS_IN_INITIALIZER_LIST(server_certs_(this)), 84 ALLOW_THIS_IN_INITIALIZER_LIST(server_certs_(this)),
84 ALLOW_THIS_IN_INITIALIZER_LIST(server_ca_certs_(this)) { 85 ALLOW_THIS_IN_INITIALIZER_LIST(server_ca_certs_(this)) {
85 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 86 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
86 net::CertDatabase::AddObserver(this); 87 net::CertDatabase::AddObserver(this);
87 } 88 }
88 89
89 ~CertLibraryImpl() { 90 ~CertLibraryImpl() {
90 DCHECK(request_task_.is_null()); 91 DCHECK(request_task_.is_null());
91 net::CertDatabase::RemoveObserver(this); 92 net::CertDatabase::RemoveObserver(this);
92 } 93 }
93 94
94 // CertLibrary implementation. 95 // CertLibrary implementation.
95 virtual void RequestCertificates() OVERRIDE { 96 virtual void RequestCertificates() OVERRIDE {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
97 98
99 certificates_requested_ = true;
100
98 if (!UserManager::Get()->user_is_logged_in()) { 101 if (!UserManager::Get()->user_is_logged_in()) {
99 // If we are not logged in, we cannot load any certificates. 102 // If we are not logged in, we cannot load any certificates.
100 // Set 'loaded' to true for the UI, since we are not waiting on loading. 103 // Set 'loaded' to true for the UI, since we are not waiting on loading.
101 LOG(WARNING) << "Requesting certificates before login."; 104 LOG(WARNING) << "Requesting certificates before login.";
102 certificates_loaded_ = true; 105 certificates_loaded_ = true;
103 return; 106 return;
104 } 107 }
105 108
106 if (!user_logged_in_) { 109 if (!user_logged_in_) {
107 user_logged_in_ = true; 110 user_logged_in_ = true;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 147 }
145 148
146 virtual void AddObserver(CertLibrary::Observer* observer) OVERRIDE { 149 virtual void AddObserver(CertLibrary::Observer* observer) OVERRIDE {
147 observer_list_->AddObserver(observer); 150 observer_list_->AddObserver(observer);
148 } 151 }
149 152
150 virtual void RemoveObserver(CertLibrary::Observer* observer) OVERRIDE { 153 virtual void RemoveObserver(CertLibrary::Observer* observer) OVERRIDE {
151 observer_list_->RemoveObserver(observer); 154 observer_list_->RemoveObserver(observer);
152 } 155 }
153 156
157 virtual bool CertificatesLoading() const OVERRIDE {
158 return certificates_requested_ && !certificates_loaded_;
159 }
160
154 virtual bool CertificatesLoaded() const OVERRIDE { 161 virtual bool CertificatesLoaded() const OVERRIDE {
155 return certificates_loaded_; 162 return certificates_loaded_;
156 } 163 }
157 164
158 virtual bool IsHardwareBacked() const OVERRIDE { 165 virtual bool IsHardwareBacked() const OVERRIDE {
159 return !tpm_token_name_.empty(); 166 return !tpm_token_name_.empty();
160 } 167 }
161 168
162 virtual const CertList& GetCertificates() const OVERRIDE { 169 virtual const CertList& GetCertificates() const OVERRIDE {
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 const scoped_refptr<CertLibraryObserverList> observer_list_; 330 const scoped_refptr<CertLibraryObserverList> observer_list_;
324 331
325 // Active request task for re-requests while waiting for TPM init. 332 // Active request task for re-requests while waiting for TPM init.
326 base::Closure request_task_; 333 base::Closure request_task_;
327 334
328 // Cached TPM token name. 335 // Cached TPM token name.
329 std::string tpm_token_name_; 336 std::string tpm_token_name_;
330 337
331 // Local state. 338 // Local state.
332 bool user_logged_in_; 339 bool user_logged_in_;
340 bool certificates_requested_;
333 bool certificates_loaded_; 341 bool certificates_loaded_;
334 342
335 // Certificates. 343 // Certificates.
336 CertList certs_; 344 CertList certs_;
337 CertList user_certs_; 345 CertList user_certs_;
338 CertList server_certs_; 346 CertList server_certs_;
339 CertList server_ca_certs_; 347 CertList server_ca_certs_;
340 348
341 DISALLOW_COPY_AND_ASSIGN(CertLibraryImpl); 349 DISALLOW_COPY_AND_ASSIGN(CertLibraryImpl);
342 }; 350 };
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 net::X509Certificate* cert = GetCertificateAt(index); 411 net::X509Certificate* cert = GetCertificateAt(index);
404 net::X509Certificate::OSCertHandle cert_handle = cert->os_cert_handle(); 412 net::X509Certificate::OSCertHandle cert_handle = cert->os_cert_handle();
405 std::string id = x509_certificate_model::GetPkcs11Id(cert_handle); 413 std::string id = x509_certificate_model::GetPkcs11Id(cert_handle);
406 if (id == pkcs11_id) 414 if (id == pkcs11_id)
407 return index; 415 return index;
408 } 416 }
409 return -1; // Not found. 417 return -1; // Not found.
410 } 418 }
411 419
412 } // chromeos 420 } // chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/cert_library.h ('k') | chrome/browser/chromeos/options/wifi_config_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698