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 "chrome/browser/net/nss_context.h" | 5 #include "chrome/browser/net/nss_context.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile_io_data.h" | 7 #include "chrome/browser/profiles/profile_io_data.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "crypto/nss_util_internal.h" | 9 #include "crypto/nss_util_internal.h" |
| 10 #include "net/cert/nss_cert_database.h" |
| 11 |
| 12 #if defined(OS_CHROMEOS) |
| 13 #include "net/cert/nss_cert_database_chromeos.h" |
| 14 #endif |
10 | 15 |
11 namespace { | 16 namespace { |
12 std::string GetUsername(content::ResourceContext* context) { | 17 std::string GetUsername(content::ResourceContext* context) { |
13 return ProfileIOData::FromResourceContext(context)->username_hash(); | 18 return ProfileIOData::FromResourceContext(context)->username_hash(); |
14 } | 19 } |
15 } // namespace | 20 } // namespace |
16 | 21 |
17 crypto::ScopedPK11Slot GetPublicNSSKeySlotForResourceContext( | 22 crypto::ScopedPK11Slot GetPublicNSSKeySlotForResourceContext( |
18 content::ResourceContext* context) { | 23 content::ResourceContext* context) { |
19 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 24 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
20 return crypto::GetPublicSlotForChromeOSUser(GetUsername(context)); | 25 return crypto::GetPublicSlotForChromeOSUser(GetUsername(context)); |
21 } | 26 } |
22 | 27 |
23 crypto::ScopedPK11Slot GetPrivateNSSKeySlotForResourceContext( | 28 crypto::ScopedPK11Slot GetPrivateNSSKeySlotForResourceContext( |
24 content::ResourceContext* context, | 29 content::ResourceContext* context, |
25 const base::Callback<void(crypto::ScopedPK11Slot)>& callback) { | 30 const base::Callback<void(crypto::ScopedPK11Slot)>& callback) { |
26 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 31 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
27 return crypto::GetPrivateSlotForChromeOSUser(GetUsername(context), callback); | 32 return crypto::GetPrivateSlotForChromeOSUser(GetUsername(context), callback); |
28 } | 33 } |
29 | 34 |
| 35 net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext( |
| 36 content::ResourceContext* context, |
| 37 const base::Callback<void(net::NSSCertDatabase*)>& callback) { |
| 38 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 39 return net::NSSCertDatabaseChromeOS::GetForUser(GetUsername(context), |
| 40 callback); |
| 41 } |
OLD | NEW |