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

Side by Side Diff: ui/shell_dialogs/certificate_viewer_dialog_win.cc

Issue 61093002: Make certificate viewer non-modal using BaseShellDialog to fix aura painting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/shell_dialogs/certificate_viewer_dialog_win.h"
6
7 #include <windows.h>
8 #include <cryptuiapi.h>
9 #pragma comment(lib, "crypt32.lib")
10 #pragma comment(lib, "cryptui.lib")
11
12 #include "base/bind.h"
13 #include "base/threading/thread.h"
14 #include "net/cert/x509_certificate.h"
15
16 namespace ui {
17
18 CertificateViewerDialogWin::CertificateViewerDialogWin(
19 HWND owning_window,
20 net::X509Certificate* certificate) {
21 // Create a new cert context and store containing just the certificate
22 // and its intermediate certificates. We do this here because we don't own
23 // the lifetime of |certificate|.
24 PCCERT_CONTEXT cert_list = certificate->CreateOSCertChainForCert();
25 CHECK(cert_list);
26
27 ExecuteCertificateViewerParams execute_params(
28 BeginRun(owning_window), owning_window, cert_list);
29 execute_params.run_state.dialog_thread->message_loop()->PostTask(
30 FROM_HERE,
31 base::Bind(&CertificateViewerDialogWin::ExecuteCertificateViewer,
32 base::Unretained(this),
33 execute_params));
34 }
35
36 void CertificateViewerDialogWin::Show(HWND owning_window,
37 net::X509Certificate* certificate) {
38 // Frees itself in |CertificateViewerCompleted|.
39 new CertificateViewerDialogWin(owning_window, certificate);
40 }
41
42 void CertificateViewerDialogWin::ExecuteCertificateViewer(
43 const ExecuteCertificateViewerParams& params) {
44 CRYPTUI_VIEWCERTIFICATE_STRUCT view_info = { 0 };
45 view_info.dwSize = sizeof(view_info);
46 // We set our parent to the tab window. This makes the cert dialog created
47 // in CryptUIDlgViewCertificate modal to the browser.
48 view_info.hwndParent = params.owner;
49 view_info.dwFlags = CRYPTUI_DISABLE_EDITPROPERTIES |
50 CRYPTUI_DISABLE_ADDTOSTORE;
51 view_info.pCertContext = params.cert_list;
52 HCERTSTORE cert_store = params.cert_list->hCertStore;
53 view_info.cStores = 1;
54 view_info.rghStores = &cert_store;
55 BOOL properties_changed;
56
57 // This next call blocks.
58 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed);
59 params.ui_proxy->PostTask(
60 FROM_HERE,
61 base::Bind(&CertificateViewerDialogWin::CertificateViewerCompleted,
62 base::Unretained(this),
63 params));
64 }
65
66 void CertificateViewerDialogWin::CertificateViewerCompleted(
67 const ExecuteCertificateViewerParams& params) {
68 // Free back on UI thread.
69 CertFreeCertificateContext(params.cert_list);
70 EndRun(params.run_state);
71 delete this;
72 }
73
74 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698