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

Side by Side Diff: chrome/browser/certificate_manager_model.cc

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added Linux implementation. Created 6 years, 3 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/certificate_manager_model.h" 5 #include "chrome/browser/certificate_manager_model.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/time_formatting.h" 8 #include "base/i18n/time_formatting.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/net/nss_context.h" 11 #include "chrome/browser/net/cert_database_service_factory.h"
12 #include "chrome/browser/ui/crypto_module_password_dialog_nss.h" 12 #include "chrome/browser/ui/crypto_module_password_dialog_nss.h"
13 #include "chrome/common/net/x509_certificate_model.h" 13 #include "chrome/common/net/x509_certificate_model.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "components/cert_database/public/cert_database_service.h"
16 #include "components/cert_database/public/cert_database_service_io_part.h"
15 #include "content/public/browser/browser_context.h" 17 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/resource_context.h" 19 #include "content/public/browser/resource_context.h"
18 #include "crypto/nss_util.h" 20 #include "crypto/nss_util.h"
19 #include "net/base/crypto_module.h" 21 #include "net/base/crypto_module.h"
20 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
21 #include "net/cert/x509_certificate.h" 23 #include "net/cert/x509_certificate.h"
22 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
23 25
24 using content::BrowserThread; 26 using content::BrowserThread;
(...skipping 17 matching lines...) Expand all
42 // crypto::IsTPMTokenEnabledForNSS 44 // crypto::IsTPMTokenEnabledForNSS
43 // v--------------------------------------/ 45 // v--------------------------------------/
44 // CertificateManagerModel::DidGetCertDBOnUIThread 46 // CertificateManagerModel::DidGetCertDBOnUIThread
45 // | 47 // |
46 // new CertificateManagerModel 48 // new CertificateManagerModel
47 // | 49 // |
48 // callback 50 // callback
49 51
50 // static 52 // static
51 void CertificateManagerModel::Create( 53 void CertificateManagerModel::Create(
52 content::BrowserContext* browser_context, 54 content::BrowserContext* context,
53 CertificateManagerModel::Observer* observer, 55 CertificateManagerModel::Observer* observer,
54 const CreationCallback& callback) { 56 const CreationCallback& callback) {
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 CertDatabaseService* cert_db_service =
59 CertDatabaseServiceFactory::GetForBrowserContext(context);
56 BrowserThread::PostTask( 60 BrowserThread::PostTask(
57 BrowserThread::IO, 61 BrowserThread::IO,
58 FROM_HERE, 62 FROM_HERE,
59 base::Bind(&CertificateManagerModel::GetCertDBOnIOThread, 63 base::Bind(&CertificateManagerModel::GetCertDBOnIOThread,
60 browser_context->GetResourceContext(), 64 cert_db_service->GetIOPart(),
61 observer, 65 observer,
62 callback)); 66 callback));
63 } 67 }
64 68
65 CertificateManagerModel::CertificateManagerModel( 69 CertificateManagerModel::CertificateManagerModel(
66 net::NSSCertDatabase* nss_cert_database, 70 net::NSSCertDatabase* nss_cert_database,
67 bool is_tpm_available, 71 bool is_tpm_available,
68 Observer* observer) 72 Observer* observer)
69 : cert_db_(nss_cert_database), 73 : cert_db_(nss_cert_database),
70 is_tpm_available_(is_tpm_available), 74 is_tpm_available_(is_tpm_available),
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 FROM_HERE, 237 FROM_HERE,
234 base::Bind(&CertificateManagerModel::DidGetCertDBOnUIThread, 238 base::Bind(&CertificateManagerModel::DidGetCertDBOnUIThread,
235 cert_db, 239 cert_db,
236 is_tpm_available, 240 is_tpm_available,
237 observer, 241 observer,
238 callback)); 242 callback));
239 } 243 }
240 244
241 // static 245 // static
242 void CertificateManagerModel::GetCertDBOnIOThread( 246 void CertificateManagerModel::GetCertDBOnIOThread(
243 content::ResourceContext* context, 247 base::WeakPtr<CertDatabaseServiceIOPart> cert_db_service_io,
244 CertificateManagerModel::Observer* observer, 248 CertificateManagerModel::Observer* observer,
245 const CreationCallback& callback) { 249 const CreationCallback& callback) {
246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
247 net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext( 251 if (!cert_db_service_io)
248 context, 252 return;
249 base::Bind(&CertificateManagerModel::DidGetCertDBOnIOThread, 253
250 observer, 254 base::Callback<void(net::NSSCertDatabase*)> get_db_callback = base::Bind(
251 callback)); 255 &CertificateManagerModel::DidGetCertDBOnIOThread, observer, callback);
256 net::NSSCertDatabase* cert_db =
257 cert_db_service_io->GetNSSCertDatabase(get_db_callback);
252 if (cert_db) 258 if (cert_db)
253 DidGetCertDBOnIOThread(observer, callback, cert_db); 259 get_db_callback.Run(cert_db);
254 } 260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698