blob: 2784c14ab358830ae11d1a295e09e78b548d31f9 [file] [log] [blame]
[email protected]557737f72013-12-06 22:24:071// 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"
avi6846aef2015-12-26 01:09:3812#include "build/build_config.h"
[email protected]557737f72013-12-06 22:24:0713#include "crypto/scoped_nss_types.h"
14
[email protected]69295ba2014-01-28 06:17:0015class Profile;
16
[email protected]057ad5f2013-12-20 19:00:5717namespace net {
18class NSSCertDatabase;
19}
20
[email protected]557737f72013-12-06 22:24:0721namespace content {
22class ResourceContext;
23} // namespace content
24
[email protected]057ad5f2013-12-20 19:00:5725// 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]30bb28102014-07-25 10:09:5230// Must be called only on the IO thread.
[email protected]057ad5f2013-12-20 19:00:5731net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext(
32 content::ResourceContext* context,
Minggang Wang93eb72e2020-07-22 02:00:0733 base::OnceCallback<void(net::NSSCertDatabase*)> callback)
[email protected]057ad5f2013-12-20 19:00:5734 WARN_UNUSED_RESULT;
35
[email protected]442233d42014-08-02 07:37:2436#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.
40void EnableNSSSystemKeySlotForResourceContext(
41 content::ResourceContext* context);
42#endif
43
[email protected]69295ba2014-01-28 06:17:0044// 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.
49void GetNSSCertDatabaseForProfile(
50 Profile* profile,
Minggang Wang93eb72e2020-07-22 02:00:0751 const base::RepeatingCallback<void(net::NSSCertDatabase*)>& callback);
[email protected]69295ba2014-01-28 06:17:0052
[email protected]557737f72013-12-06 22:24:0753#endif // CHROME_BROWSER_NET_NSS_CONTEXT_H_