OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 7 #include <windows.h> |
8 #include <cryptuiapi.h> | 8 #include <cryptuiapi.h> |
9 #pragma comment(lib, "cryptui.lib") | 9 #pragma comment(lib, "cryptui.lib") |
10 | 10 |
11 #include "base/logging.h" | |
11 #include "net/base/x509_certificate.h" | 12 #include "net/base/x509_certificate.h" |
12 | 13 |
13 void ShowCertificateViewer(gfx::NativeWindow parent, | 14 void ShowCertificateViewer(gfx::NativeWindow parent, |
14 net::X509Certificate* cert) { | 15 net::X509Certificate* cert) { |
16 net::X509Certificate::OSCertListHandle cert_list = | |
17 cert->CreateOSCertListHandle(); | |
18 CHECK(cert_list); | |
19 | |
15 CRYPTUI_VIEWCERTIFICATE_STRUCT view_info = { 0 }; | 20 CRYPTUI_VIEWCERTIFICATE_STRUCT view_info = { 0 }; |
16 view_info.dwSize = sizeof(view_info); | 21 view_info.dwSize = sizeof(view_info); |
17 // We set our parent to the tab window. This makes the cert dialog created | 22 // We set our parent to the tab window. This makes the cert dialog created |
18 // in CryptUIDlgViewCertificate modal to the browser. | 23 // in CryptUIDlgViewCertificate modal to the browser. |
19 view_info.hwndParent = parent; | 24 view_info.hwndParent = parent; |
20 view_info.dwFlags = CRYPTUI_DISABLE_EDITPROPERTIES | | 25 view_info.dwFlags = CRYPTUI_DISABLE_EDITPROPERTIES | |
21 CRYPTUI_DISABLE_ADDTOSTORE; | 26 CRYPTUI_DISABLE_ADDTOSTORE; |
22 view_info.pCertContext = cert->os_cert_handle(); | 27 view_info.pCertContext = cert_list; |
23 // Search the cert store that 'cert' is in when building the cert chain. | 28 // Search the cert store that 'cert' is in when building the cert chain. |
24 HCERTSTORE cert_store = view_info.pCertContext->hCertStore; | 29 HCERTSTORE cert_store = const_cast<const HCERTSTORE>(cert_list->hCertStore); |
wtc
2011/10/04 00:26:34
Is this const_cast necessary? Also, we should not
| |
25 view_info.cStores = 1; | 30 view_info.cStores = 1; |
26 view_info.rghStores = &cert_store; | 31 view_info.rghStores = &cert_store; |
27 BOOL properties_changed; | 32 BOOL properties_changed; |
28 | 33 |
29 // This next call blocks but keeps processing windows messages, making it | 34 // This next call blocks but keeps processing windows messages, making it |
30 // modal to the browser window. | 35 // modal to the browser window. |
31 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed); | 36 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed); |
37 | |
38 net::X509Certificate::FreeOSCertListHandle(cert_list); | |
32 } | 39 } |
OLD | NEW |