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

Side by Side Diff: chrome/browser/ui/cocoa/certificate_viewer.mm

Issue 2944008: Refactor X509Certificate caching to cache the OS handle, rather than the X509Certificate (Closed)
Patch Set: Rebase to trunk after splitting out 4645001 Created 9 years, 11 months 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/certificate_viewer.h" 5 #include "chrome/browser/certificate_viewer.h"
6 6
7 #include <Security/Security.h> 7 #include <Security/Security.h>
8 #include <SecurityInterface/SFCertificatePanel.h> 8 #include <SecurityInterface/SFCertificatePanel.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/logging.h" 12 #include "base/mac/mac_util.h"
13 #include "base/mac/scoped_cftyperef.h" 13 #include "base/mac/scoped_cftyperef.h"
14 #include "net/base/x509_certificate.h" 14 #include "net/base/x509_certificate.h"
15 15
16 void ShowCertificateViewer(gfx::NativeWindow parent, 16 void ShowCertificateViewer(gfx::NativeWindow parent,
17 net::X509Certificate* cert) { 17 net::X509Certificate* cert) {
18 SecCertificateRef cert_mac = cert->os_cert_handle(); 18 base::mac::ScopedCFTypeRef<CFArrayRef> certificates(
19 if (!cert_mac) 19 cert->CreateOSCertListHandle());
20 return; 20 NSArray* certificates = base::mac::CFToNSCast(certificates.get());
21
22 base::mac::ScopedCFTypeRef<CFMutableArrayRef> certificates(
23 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
24 if (!certificates.get()) {
25 NOTREACHED();
26 return;
27 }
28 CFArrayAppendValue(certificates, cert_mac);
29
30 // Server certificate must be first in the array; subsequent certificates
31 // in the chain can be in any order.
32 const std::vector<SecCertificateRef>& ca_certs =
33 cert->GetIntermediateCertificates();
34 for (size_t i = 0; i < ca_certs.size(); ++i)
35 CFArrayAppendValue(certificates, ca_certs[i]);
36 21
37 [[[SFCertificatePanel alloc] init] 22 [[[SFCertificatePanel alloc] init]
38 beginSheetForWindow:parent 23 beginSheetForWindow:parent
39 modalDelegate:nil 24 modalDelegate:nil
40 didEndSelector:NULL 25 didEndSelector:NULL
41 contextInfo:NULL 26 contextInfo:NULL
42 certificates:reinterpret_cast<NSArray*>(certificates.get()) 27 certificates:certificates
43 showGroup:YES]; 28 showGroup:YES];
44 // The SFCertificatePanel releases itself when the sheet is dismissed. 29 // The SFCertificatePanel releases itself when the sheet is dismissed.
45 } 30 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/certificate_viewer_win.cc » ('j') | net/base/x509_certificate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698