diff options
author | davidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-07 22:55:27 +0000 |
---|---|---|
committer | davidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-07 22:55:27 +0000 |
commit | 8ae178b1da02c2ab5104060a711c305cb826221d (patch) | |
tree | ad8f723b09064d68239d6db01bf0c7532831137d /chrome/browser/views/certificate_viewer_win.cc | |
parent | 4fe95a617e494a2e279d9d623816f3e3b7aed944 (diff) | |
download | chromium_src-8ae178b1da02c2ab5104060a711c305cb826221d.zip chromium_src-8ae178b1da02c2ab5104060a711c305cb826221d.tar.gz chromium_src-8ae178b1da02c2ab5104060a711c305cb826221d.tar.bz2 |
Refactor certificate viewer code behind ShowCertificateViewer
This abstracts away the platform-specific certificate viewer behind a common
function call.
R=wtc,mattm
BUG=none
TEST=Viewing the certificate information on an SSL session continues to work
Review URL: http://codereview.chromium.org/2815024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51793 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/certificate_viewer_win.cc')
-rw-r--r-- | chrome/browser/views/certificate_viewer_win.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/chrome/browser/views/certificate_viewer_win.cc b/chrome/browser/views/certificate_viewer_win.cc new file mode 100644 index 0000000..ba54267 --- /dev/null +++ b/chrome/browser/views/certificate_viewer_win.cc @@ -0,0 +1,32 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/certificate_viewer.h" + +#include <windows.h> +#include <cryptuiapi.h> +#pragma comment(lib, "cryptui.lib") + +#include "net/base/x509_certificate.h" + +void ShowCertificateViewer(gfx::NativeWindow parent, + net::X509Certificate* cert) { + CRYPTUI_VIEWCERTIFICATE_STRUCT view_info = { 0 }; + view_info.dwSize = sizeof(view_info); + // We set our parent to the tab window. This makes the cert dialog created + // in CryptUIDlgViewCertificate modal to the browser. + view_info.hwndParent = parent; + view_info.dwFlags = CRYPTUI_DISABLE_EDITPROPERTIES | + CRYPTUI_DISABLE_ADDTOSTORE; + view_info.pCertContext = cert->os_cert_handle(); + // Search the cert store that 'cert' is in when building the cert chain. + HCERTSTORE cert_store = view_info.pCertContext->hCertStore; + view_info.cStores = 1; + view_info.rghStores = &cert_store; + BOOL properties_changed; + + // This next call blocks but keeps processing windows messages, making it + // modal to the browser window. + BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed); +} |