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

Side by Side Diff: chrome/browser/ui/views/certificate_viewer_win.cc

Issue 7324039: Ensure X509Certificate::OSCertHandles are safe to be used on both UI and IO threads on Win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mac fix Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
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"
13 #include "net/base/x509_util_win.h"
12 14
13 void ShowCertificateViewer(gfx::NativeWindow parent, 15 void ShowCertificateViewer(gfx::NativeWindow parent,
14 net::X509Certificate* cert) { 16 net::X509Certificate* cert) {
17 PCCERT_CONTEXT cert_list = net::x509_util::CreateOSCertChainForCert(cert);
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.
wtc 2011/10/16 14:55:49 Nit: this comment sounds weird since the code now
24 HCERTSTORE cert_store = view_info.pCertContext->hCertStore; 29 HCERTSTORE cert_store = cert_list->hCertStore;
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 CertFreeCertificateContext(cert_list);
32 } 39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698