test_keychain_search_list_mac.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2016 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. #ifndef NET_CERT_TEST_KEYCHAIN_SEARCH_LIST_MAC_H_
  5. #define NET_CERT_TEST_KEYCHAIN_SEARCH_LIST_MAC_H_
  6. #include <memory>
  7. #include <CoreServices/CoreServices.h>
  8. #include <Security/Security.h>
  9. #include "base/mac/scoped_cftyperef.h"
  10. #include "net/base/net_export.h"
  11. namespace net {
  12. class NET_EXPORT TestKeychainSearchList {
  13. public:
  14. ~TestKeychainSearchList();
  15. // Creates a TestKeychainSearchList, which will be used by HasInstance and
  16. // GetInstance.
  17. // Only one TestKeychainSearchList object may exist at a time, returns nullptr
  18. // if one exists already.
  19. static std::unique_ptr<TestKeychainSearchList> Create();
  20. // Returns true if a TestKeychainSearchList currently exists.
  21. static bool HasInstance();
  22. // Returns the current TestKeychainSearchList instance, if any.
  23. static TestKeychainSearchList* GetInstance();
  24. // Copies the test keychain search list into |keychain_search_list|.
  25. OSStatus CopySearchList(CFArrayRef* keychain_search_list) const;
  26. // Adds |keychain| to the end of the test keychain search list.
  27. void AddKeychain(SecKeychainRef keychain);
  28. private:
  29. TestKeychainSearchList();
  30. base::ScopedCFTypeRef<CFMutableArrayRef> scoped_keychain_search_list;
  31. };
  32. } // namespace net
  33. #endif // NET_CERT_TEST_KEYCHAIN_SEARCH_LIST_MAC_H_