| OLD | NEW |
| 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/logging.h" |
| 13 #include "base/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 SecCertificateRef cert_mac = cert->os_cert_handle(); |
| 19 if (!cert_mac) | 19 if (!cert_mac) |
| 20 return; | 20 return; |
| 21 | 21 |
| 22 scoped_cftyperef<CFMutableArrayRef> certificates( | 22 base::mac::ScopedCFTypeRef<CFMutableArrayRef> certificates( |
| 23 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); | 23 CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); |
| 24 if (!certificates.get()) { | 24 if (!certificates.get()) { |
| 25 NOTREACHED(); | 25 NOTREACHED(); |
| 26 return; | 26 return; |
| 27 } | 27 } |
| 28 CFArrayAppendValue(certificates, cert_mac); | 28 CFArrayAppendValue(certificates, cert_mac); |
| 29 | 29 |
| 30 // Server certificate must be first in the array; subsequent certificates | 30 // Server certificate must be first in the array; subsequent certificates |
| 31 // in the chain can be in any order. | 31 // in the chain can be in any order. |
| 32 const std::vector<SecCertificateRef>& ca_certs = | 32 const std::vector<SecCertificateRef>& ca_certs = |
| 33 cert->GetIntermediateCertificates(); | 33 cert->GetIntermediateCertificates(); |
| 34 for (size_t i = 0; i < ca_certs.size(); ++i) | 34 for (size_t i = 0; i < ca_certs.size(); ++i) |
| 35 CFArrayAppendValue(certificates, ca_certs[i]); | 35 CFArrayAppendValue(certificates, ca_certs[i]); |
| 36 | 36 |
| 37 [[[SFCertificatePanel alloc] init] | 37 [[[SFCertificatePanel alloc] init] |
| 38 beginSheetForWindow:parent | 38 beginSheetForWindow:parent |
| 39 modalDelegate:nil | 39 modalDelegate:nil |
| 40 didEndSelector:NULL | 40 didEndSelector:NULL |
| 41 contextInfo:NULL | 41 contextInfo:NULL |
| 42 certificates:reinterpret_cast<NSArray*>(certificates.get()) | 42 certificates:reinterpret_cast<NSArray*>(certificates.get()) |
| 43 showGroup:YES]; | 43 showGroup:YES]; |
| 44 // The SFCertificatePanel releases itself when the sheet is dismissed. | 44 // The SFCertificatePanel releases itself when the sheet is dismissed. |
| 45 } | 45 } |
| OLD | NEW |