xref: /aosp_15_r20/external/cronet/net/cert/test_keychain_search_list_mac.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2016 The Chromium Authors
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 NET_CERT_TEST_KEYCHAIN_SEARCH_LIST_MAC_H_
6 #define NET_CERT_TEST_KEYCHAIN_SEARCH_LIST_MAC_H_
7 
8 #include <memory>
9 
10 #include <CoreServices/CoreServices.h>
11 #include <Security/Security.h>
12 
13 #include "base/apple/scoped_cftyperef.h"
14 #include "net/base/net_export.h"
15 
16 namespace net {
17 
18 class NET_EXPORT TestKeychainSearchList {
19  public:
20   ~TestKeychainSearchList();
21 
22   // Creates a TestKeychainSearchList, which will be used by HasInstance and
23   // GetInstance.
24   // Only one TestKeychainSearchList object may exist at a time, returns nullptr
25   // if one exists already.
26   static std::unique_ptr<TestKeychainSearchList> Create();
27 
28   // Returns true if a TestKeychainSearchList currently exists.
29   static bool HasInstance();
30 
31   // Returns the current TestKeychainSearchList instance, if any.
32   static TestKeychainSearchList* GetInstance();
33 
34   // Copies the test keychain search list into |keychain_search_list|.
35   OSStatus CopySearchList(CFArrayRef* keychain_search_list) const;
36 
37   // Adds |keychain| to the end of the test keychain search list.
38   void AddKeychain(SecKeychainRef keychain);
39 
40  private:
41   TestKeychainSearchList();
42 
43   base::apple::ScopedCFTypeRef<CFMutableArrayRef> scoped_keychain_search_list;
44 };
45 
46 }  // namespace net
47 
48 #endif  // NET_CERT_TEST_KEYCHAIN_SEARCH_LIST_MAC_H_
49