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 #ifndef CHROME_BROWSER_NET_NSS_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_NET_NSS_CONTEXT_H_ |
6 #define CHROME_BROWSER_NET_NSS_CONTEXT_H_ | 6 #define CHROME_BROWSER_NET_NSS_CONTEXT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "crypto/scoped_nss_types.h" | 13 #include "crypto/scoped_nss_types.h" |
14 | 14 |
15 class Profile; | 15 class Profile; |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 class NSSCertDatabase; | 18 class NSSCertDatabase; |
19 } | 19 } |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 class ResourceContext; | 22 class ResourceContext; |
23 } // namespace content | 23 } // namespace content |
24 | 24 |
25 // Returns a reference to the public slot for the user associated with | |
26 // |context|. Should be called only on the IO thread. | |
27 crypto::ScopedPK11Slot GetPublicNSSKeySlotForResourceContext( | |
28 content::ResourceContext* context); | |
29 | |
30 // Returns a reference to the private slot for the user associated with | |
31 // |context|, if it is loaded. If it is not loaded and |callback| is non-null, | |
32 // the |callback| will be run once the slot is loaded. | |
33 // Should be called only on the IO thread. | |
34 crypto::ScopedPK11Slot GetPrivateNSSKeySlotForResourceContext( | |
35 content::ResourceContext* context, | |
36 const base::Callback<void(crypto::ScopedPK11Slot)>& callback) | |
37 WARN_UNUSED_RESULT; | |
38 | |
39 // Returns a pointer to the NSSCertDatabase for the user associated with | 25 // Returns a pointer to the NSSCertDatabase for the user associated with |
40 // |context|, if it is ready. If it is not ready and |callback| is non-null, the | 26 // |context|, if it is ready. If it is not ready and |callback| is non-null, the |
41 // |callback| will be run once the DB is initialized. Ownership is not | 27 // |callback| will be run once the DB is initialized. Ownership is not |
42 // transferred, but the caller may save the pointer, which will remain valid for | 28 // transferred, but the caller may save the pointer, which will remain valid for |
43 // the lifetime of the ResourceContext. | 29 // the lifetime of the ResourceContext. |
44 // Must be called only on the IO thread. | 30 // Must be called only on the IO thread. |
45 net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext( | 31 net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext( |
46 content::ResourceContext* context, | 32 content::ResourceContext* context, |
47 const base::Callback<void(net::NSSCertDatabase*)>& callback) | 33 const base::Callback<void(net::NSSCertDatabase*)>& callback) |
48 WARN_UNUSED_RESULT; | 34 WARN_UNUSED_RESULT; |
49 | 35 |
50 #if defined(OS_CHROMEOS) | 36 #if defined(OS_CHROMEOS) |
51 // Enables the system key slot in the NSSCertDatabase for the user associated | 37 // Enables the system key slot in the NSSCertDatabase for the user associated |
52 // with |context|. | 38 // with |context|. |
53 // Must be called only on the IO thread. | 39 // Must be called only on the IO thread. |
54 void EnableNSSSystemKeySlotForResourceContext( | 40 void EnableNSSSystemKeySlotForResourceContext( |
55 content::ResourceContext* context); | 41 content::ResourceContext* context); |
56 #endif | 42 #endif |
57 | 43 |
58 // Gets a pointer to the NSSCertDatabase for the user associated with |context|. | 44 // Gets a pointer to the NSSCertDatabase for the user associated with |context|. |
59 // It's a wrapper around |GetNSSCertDatabaseForResourceContext| which makes | 45 // It's a wrapper around |GetNSSCertDatabaseForResourceContext| which makes |
60 // sure it's called on IO thread (with |profile|'s resource context). The | 46 // sure it's called on IO thread (with |profile|'s resource context). The |
61 // callback will be called on the originating message loop. | 47 // callback will be called on the originating message loop. |
62 // It's accessing profile, so it should be called on the UI thread. | 48 // It's accessing profile, so it should be called on the UI thread. |
63 void GetNSSCertDatabaseForProfile( | 49 void GetNSSCertDatabaseForProfile( |
64 Profile* profile, | 50 Profile* profile, |
65 const base::Callback<void(net::NSSCertDatabase*)>& callback); | 51 const base::Callback<void(net::NSSCertDatabase*)>& callback); |
66 | 52 |
67 #endif // CHROME_BROWSER_NET_NSS_CONTEXT_H_ | 53 #endif // CHROME_BROWSER_NET_NSS_CONTEXT_H_ |
OLD | NEW |