Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: net/base/temporary_root_certs_mac.cc

Issue 4646001: Implement LoadTemporaryRoot for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/net/base
Patch Set: Feedback from phajdan.jr and bulach Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 "net/base/temporary_root_certs.h"
6
7 #include <Security/Security.h>
8
9 #include "net/base/x509_certificate.h"
10
11 namespace net {
12
13 namespace {
14
15 Boolean OurSecCertificateEqual(const void* value1, const void* value2) {
16 if (CFGetTypeID(value1) != SecCertificateGetTypeID() ||
17 CFGetTypeID(value2) != SecCertificateGetTypeID())
18 return CFEqual(value1, value2);
19 return X509Certificate::IsSameOSCert(
20 reinterpret_cast<SecCertificateRef>(const_cast<void*>(value1)),
21 reinterpret_cast<SecCertificateRef>(const_cast<void*>(value2)));
bulach 2010/11/09 16:21:09 indent+2 the 20-21
22 }
23
24 const void* DummyRetain(CFAllocatorRef unused, const void* value) {
bulach 2010/11/09 16:21:09 maybe RetainWrapper?
25 return CFRetain(value);
26 }
27
28 void DummyRelease(CFAllocatorRef unused, const void* value) {
bulach 2010/11/09 16:21:09 maybe ReleaseWrapper?
29 CFRelease(value);
30 }
31
32 // CFEqual prior to 10.6 only performed pointer checks on SecCertificateRefs,
33 // rather than checking if they were the same (logical) certificate, so a
34 // custom structure is used for the array callbacks.
35 static CFArrayCallBacks kCertArrayCallbacks = {
bulach 2010/11/09 16:21:09 const? also, since it's in a local namespace, coul
36 0, /* version */
wtc 2010/11/16 23:24:01 Nit: use C++ style comment: 0, // version
37 DummyRetain,
38 DummyRelease,
39 CFCopyDescription,
40 OurSecCertificateEqual
41 };
42
43 } // namespace
44
45 bool TemporaryRootCerts::Add(X509Certificate* certificate) {
46 if (CFArrayContainsValue(temporary_roots_,
47 CFRangeMake(0, CFArrayGetCount(temporary_roots_)),
48 certificate->os_cert_handle()))
49 return true;
50 CFArrayAppendValue(temporary_roots_, certificate->os_cert_handle());
51 return true;
52 }
53
54 void TemporaryRootCerts::Remove(X509Certificate* certificate) {
55 CFIndex cert_index = CFArrayGetFirstIndexOfValue(
56 temporary_roots_,
57 CFRangeMake(0, CFArrayGetCount(temporary_roots_)),
58 certificate->os_cert_handle());
59 if (cert_index == -1)
60 return;
61 CFArrayRemoveValueAtIndex(temporary_roots_, cert_index);
62 }
63
64 TemporaryRootCerts::TemporaryRootCerts() {
65 temporary_roots_.reset(CFArrayCreateMutable(kCFAllocatorDefault, 0,
66 &kCertArrayCallbacks));
67 }
68
69 TemporaryRootCerts::~TemporaryRootCerts() {
70 }
71
72 bool TemporaryRootCerts::IsEmpty() const {
73 return CFArrayGetCount(temporary_roots_) == 0;
74 }
75
76 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698