forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscoped_lacontext.h
46 lines (36 loc) · 1.35 KB
/
scoped_lacontext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CRYPTO_SCOPED_LACONTEXT_H_
#define CRYPTO_SCOPED_LACONTEXT_H_
#if defined(__OBJC__)
#import <LocalAuthentication/LocalAuthentication.h>
#endif // defined(__OBJC__)
#include <memory>
#include "crypto/crypto_export.h"
namespace crypto {
// ScopedLAContext can hold an `LAContext` and is safe to pass around from C++.
// ScopedLAContext functions as a unique pointer. The UI can create one with an
// authenticated LAContext, then pass it down to the platform.
class CRYPTO_EXPORT ScopedLAContext {
public:
#if defined(__OBJC__)
// Takes ownership of |lacontext|.
explicit ScopedLAContext(LAContext* lacontext);
#endif // defined(__OBJC__)
~ScopedLAContext();
ScopedLAContext(ScopedLAContext&) = delete;
ScopedLAContext(ScopedLAContext&&);
ScopedLAContext& operator=(const ScopedLAContext&) = delete;
ScopedLAContext& operator=(ScopedLAContext&&);
#if defined(__OBJC__)
// release returns the last `LAContext` passed on construction and drops its
// reference to it. It is invalid to to call release more than once.
LAContext* release();
#endif // defined(__OBJC__)
private:
struct ObjCStorage;
std::unique_ptr<ObjCStorage> storage_;
};
} // namespace crypto
#endif // CRYPTO_SCOPED_LACONTEXT_H_