Print Preview: Changing displayed error message when PDF Viewer is missing.
[chromium-blink-merge.git] / chrome / browser / keychain_mac.h
blobf3c98e08dadfcc0836c032b26c8e3ed491b5c5e3
1 // Copyright (c) 2009 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.
5 #ifndef CHROME_BROWSER_KEYCHAIN_MAC_H_
6 #define CHROME_BROWSER_KEYCHAIN_MAC_H_
7 #pragma once
9 #include <Security/Security.h>
11 #include "base/basictypes.h"
13 // Wraps the KeychainServices API in a very thin layer, to allow it to be
14 // mocked out for testing.
16 // See Keychain Services documentation for function documentation, as these call
17 // through directly to their Keychain Services equivalents (Foo ->
18 // SecKeychainFoo). The only exception is Free, which should be used for
19 // anything returned from this class that would normally be freed with
20 // CFRelease (to aid in testing).
21 class MacKeychain {
22 public:
23 MacKeychain() {}
24 virtual ~MacKeychain() {}
26 virtual OSStatus ItemCopyAttributesAndData(
27 SecKeychainItemRef itemRef, SecKeychainAttributeInfo *info,
28 SecItemClass *itemClass, SecKeychainAttributeList **attrList,
29 UInt32 *length, void **outData) const;
31 virtual OSStatus ItemModifyAttributesAndData(
32 SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList,
33 UInt32 length, const void *data) const;
35 virtual OSStatus ItemFreeAttributesAndData(SecKeychainAttributeList *attrList,
36 void *data) const;
38 virtual OSStatus ItemDelete(SecKeychainItemRef itemRef) const;
40 virtual OSStatus SearchCreateFromAttributes(
41 CFTypeRef keychainOrArray, SecItemClass itemClass,
42 const SecKeychainAttributeList *attrList,
43 SecKeychainSearchRef *searchRef) const;
45 virtual OSStatus SearchCopyNext(SecKeychainSearchRef searchRef,
46 SecKeychainItemRef *itemRef) const;
48 virtual OSStatus AddInternetPassword(SecKeychainRef keychain,
49 UInt32 serverNameLength,
50 const char *serverName,
51 UInt32 securityDomainLength,
52 const char *securityDomain,
53 UInt32 accountNameLength,
54 const char *accountName,
55 UInt32 pathLength, const char *path,
56 UInt16 port, SecProtocolType protocol,
57 SecAuthenticationType authenticationType,
58 UInt32 passwordLength,
59 const void *passwordData,
60 SecKeychainItemRef *itemRef) const;
62 virtual OSStatus FindGenericPassword(CFTypeRef keychainOrArray,
63 UInt32 serviceNameLength,
64 const char *serviceName,
65 UInt32 accountNameLength,
66 const char *accountName,
67 UInt32 *passwordLength,
68 void **passwordData,
69 SecKeychainItemRef *itemRef) const;
71 virtual OSStatus ItemFreeContent(SecKeychainAttributeList *attrList,
72 void *data) const;
74 virtual OSStatus AddGenericPassword(SecKeychainRef keychain,
75 UInt32 serviceNameLength,
76 const char *serviceName,
77 UInt32 accountNameLength,
78 const char *accountName,
79 UInt32 passwordLength,
80 const void *passwordData,
81 SecKeychainItemRef *itemRef) const;
83 // Calls CFRelease on the given ref, after checking that |ref| is non-NULL.
84 virtual void Free(CFTypeRef ref) const;
86 private:
87 DISALLOW_COPY_AND_ASSIGN(MacKeychain);
90 #endif // CHROME_BROWSER_KEYCHAIN_MAC_H_