Upload upstream chromium 67.0.3396
[platform/framework/web/chromium-efl.git] / crypto / apple_keychain_mac.mm
1 // Copyright (c) 2012 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 #include "crypto/apple_keychain.h"
6
7 #import <Foundation/Foundation.h>
8
9 #include "base/synchronization/lock.h"
10 #include "crypto/mac_security_services_lock.h"
11
12 namespace crypto {
13
14 AppleKeychain::AppleKeychain() {}
15
16 AppleKeychain::~AppleKeychain() {}
17
18 OSStatus AppleKeychain::ItemDelete(SecKeychainItemRef itemRef) const {
19   base::AutoLock lock(GetMacSecurityServicesLock());
20   return SecKeychainItemDelete(itemRef);
21 }
22
23 OSStatus AppleKeychain::FindGenericPassword(CFTypeRef keychainOrArray,
24                                             UInt32 serviceNameLength,
25                                             const char* serviceName,
26                                             UInt32 accountNameLength,
27                                             const char* accountName,
28                                             UInt32* passwordLength,
29                                             void** passwordData,
30                                             SecKeychainItemRef* itemRef) const {
31   base::AutoLock lock(GetMacSecurityServicesLock());
32   return SecKeychainFindGenericPassword(keychainOrArray,
33                                         serviceNameLength,
34                                         serviceName,
35                                         accountNameLength,
36                                         accountName,
37                                         passwordLength,
38                                         passwordData,
39                                         itemRef);
40 }
41
42 OSStatus AppleKeychain::ItemFreeContent(SecKeychainAttributeList* attrList,
43                                         void* data) const {
44   base::AutoLock lock(GetMacSecurityServicesLock());
45   return SecKeychainItemFreeContent(attrList, data);
46 }
47
48 OSStatus AppleKeychain::AddGenericPassword(SecKeychainRef keychain,
49                                            UInt32 serviceNameLength,
50                                            const char* serviceName,
51                                            UInt32 accountNameLength,
52                                            const char* accountName,
53                                            UInt32 passwordLength,
54                                            const void* passwordData,
55                                            SecKeychainItemRef* itemRef) const {
56   base::AutoLock lock(GetMacSecurityServicesLock());
57   return SecKeychainAddGenericPassword(keychain,
58                                        serviceNameLength,
59                                        serviceName,
60                                        accountNameLength,
61                                        accountName,
62                                        passwordLength,
63                                        passwordData,
64                                        itemRef);
65 }
66
67 }  // namespace crypto