Bug 1928997: Update tabs icon in Unified Search popup r=desktop-theme-reviewers,daleh...
[gecko.git] / security / manager / ssl / KeychainSecret.h
blob7a0850a0012196095f27ec4924281aaef97ace78
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef KeychainSecret_h
8 #define KeychainSecret_h
10 #include "CoreFoundation/CFBase.h"
12 #include "OSKeyStore.h"
13 #include "nsString.h"
15 template <typename T>
16 class ScopedCFType {
17 public:
18 explicit ScopedCFType(T value) : mValue(value) {}
20 MOZ_IMPLICIT ScopedCFType(decltype(nullptr)) : mValue(nullptr) {}
22 ~ScopedCFType() {
23 if (mValue) {
24 CFRelease((CFTypeRef)mValue);
28 T get() { return mValue; }
30 explicit operator bool() const { return mValue != nullptr; }
32 private:
33 T mValue;
36 class KeychainSecret final : public AbstractOSKeyStore {
37 public:
38 KeychainSecret();
40 virtual nsresult RetrieveSecret(const nsACString& label,
41 /* out */ nsACString& secret) override;
42 virtual nsresult StoreSecret(const nsACString& secret,
43 const nsACString& label) override;
44 virtual nsresult DeleteSecret(const nsACString& label) override;
46 virtual ~KeychainSecret();
49 #endif // KeychainSecret_h