[email protected] | 557737f7 | 2013-12-06 22:24:07 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef CHROME_BROWSER_NET_NSS_CONTEXT_H_ | ||||
6 | #define CHROME_BROWSER_NET_NSS_CONTEXT_H_ | ||||
7 | |||||
8 | #include <string> | ||||
9 | |||||
10 | #include "base/callback.h" | ||||
11 | #include "base/compiler_specific.h" | ||||
avi | 6846aef | 2015-12-26 01:09:38 | [diff] [blame] | 12 | #include "build/build_config.h" |
[email protected] | 557737f7 | 2013-12-06 22:24:07 | [diff] [blame] | 13 | #include "crypto/scoped_nss_types.h" |
14 | |||||
[email protected] | 69295ba | 2014-01-28 06:17:00 | [diff] [blame] | 15 | class Profile; |
16 | |||||
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 17 | namespace net { |
18 | class NSSCertDatabase; | ||||
19 | } | ||||
20 | |||||
[email protected] | 557737f7 | 2013-12-06 22:24:07 | [diff] [blame] | 21 | namespace content { |
22 | class ResourceContext; | ||||
23 | } // namespace content | ||||
24 | |||||
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 25 | // Returns a pointer to the NSSCertDatabase for the user associated with |
26 | // |context|, if it is ready. If it is not ready and |callback| is non-null, the | ||||
27 | // |callback| will be run once the DB is initialized. Ownership is not | ||||
28 | // transferred, but the caller may save the pointer, which will remain valid for | ||||
29 | // the lifetime of the ResourceContext. | ||||
[email protected] | 30bb2810 | 2014-07-25 10:09:52 | [diff] [blame] | 30 | // Must be called only on the IO thread. |
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 31 | net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext( |
32 | content::ResourceContext* context, | ||||
Minggang Wang | 93eb72e | 2020-07-22 02:00:07 | [diff] [blame] | 33 | base::OnceCallback<void(net::NSSCertDatabase*)> callback) |
[email protected] | 057ad5f | 2013-12-20 19:00:57 | [diff] [blame] | 34 | WARN_UNUSED_RESULT; |
35 | |||||
[email protected] | 442233d4 | 2014-08-02 07:37:24 | [diff] [blame] | 36 | #if defined(OS_CHROMEOS) |
37 | // Enables the system key slot in the NSSCertDatabase for the user associated | ||||
38 | // with |context|. | ||||
39 | // Must be called only on the IO thread. | ||||
40 | void EnableNSSSystemKeySlotForResourceContext( | ||||
41 | content::ResourceContext* context); | ||||
42 | #endif | ||||
43 | |||||
[email protected] | 69295ba | 2014-01-28 06:17:00 | [diff] [blame] | 44 | // Gets a pointer to the NSSCertDatabase for the user associated with |context|. |
45 | // It's a wrapper around |GetNSSCertDatabaseForResourceContext| which makes | ||||
46 | // sure it's called on IO thread (with |profile|'s resource context). The | ||||
47 | // callback will be called on the originating message loop. | ||||
48 | // It's accessing profile, so it should be called on the UI thread. | ||||
49 | void GetNSSCertDatabaseForProfile( | ||||
50 | Profile* profile, | ||||
Minggang Wang | 93eb72e | 2020-07-22 02:00:07 | [diff] [blame] | 51 | const base::RepeatingCallback<void(net::NSSCertDatabase*)>& callback); |
[email protected] | 69295ba | 2014-01-28 06:17:00 | [diff] [blame] | 52 | |
[email protected] | 557737f7 | 2013-12-06 22:24:07 | [diff] [blame] | 53 | #endif // CHROME_BROWSER_NET_NSS_CONTEXT_H_ |