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

Side by Side Diff: chrome/browser/ui/views/certificate_viewer_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
« no previous file with comments | « no previous file | ui/shell_dialogs/DEPS » ('j') | ui/shell_dialogs/certificate_viewer_dialog_win.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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 "base/logging.h"
12 #include "net/cert/x509_certificate.h" 12 #include "net/cert/x509_certificate.h"
13 13
14 #if defined(USE_AURA) 14 #if defined(USE_AURA)
15 #include "chrome/browser/ui/host_desktop.h" 15 #include "chrome/browser/ui/host_desktop.h"
16 #include "ui/aura/root_window.h" 16 #include "ui/aura/root_window.h"
17 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
18 #include "ui/shell_dialogs/certificate_viewer_dialog_win.h"
18 #endif 19 #endif
19 20
20 namespace { 21 namespace {
21 22
23 #if !defined(USE_AURA)
22 void ShowCertificateViewerImpl(content::WebContents* web_contents, 24 void ShowCertificateViewerImpl(content::WebContents* web_contents,
23 HWND parent, 25 HWND parent,
24 net::X509Certificate* cert) { 26 net::X509Certificate* cert) {
25 // Create a new cert context and store containing just the certificate 27 // Create a new cert context and store containing just the certificate
26 // and its intermediate certificates. 28 // and its intermediate certificates.
27 PCCERT_CONTEXT cert_list = cert->CreateOSCertChainForCert(); 29 PCCERT_CONTEXT cert_list = cert->CreateOSCertChainForCert();
28 CHECK(cert_list); 30 CHECK(cert_list);
29 31
30 CRYPTUI_VIEWCERTIFICATE_STRUCT view_info = { 0 }; 32 CRYPTUI_VIEWCERTIFICATE_STRUCT view_info = { 0 };
31 view_info.dwSize = sizeof(view_info); 33 view_info.dwSize = sizeof(view_info);
32 // We set our parent to the tab window. This makes the cert dialog created 34 // We set our parent to the tab window. This makes the cert dialog created
33 // in CryptUIDlgViewCertificate modal to the browser. 35 // in CryptUIDlgViewCertificate modal to the browser.
34 view_info.hwndParent = parent; 36 view_info.hwndParent = parent;
35 view_info.dwFlags = CRYPTUI_DISABLE_EDITPROPERTIES | 37 view_info.dwFlags = CRYPTUI_DISABLE_EDITPROPERTIES |
36 CRYPTUI_DISABLE_ADDTOSTORE; 38 CRYPTUI_DISABLE_ADDTOSTORE;
37 view_info.pCertContext = cert_list; 39 view_info.pCertContext = cert_list;
38 HCERTSTORE cert_store = cert_list->hCertStore; 40 HCERTSTORE cert_store = cert_list->hCertStore;
39 view_info.cStores = 1; 41 view_info.cStores = 1;
40 view_info.rghStores = &cert_store; 42 view_info.rghStores = &cert_store;
41 BOOL properties_changed; 43 BOOL properties_changed;
42 44
43 // This next call blocks but keeps processing windows messages, making it 45 // This next call blocks but keeps processing windows messages, making it
44 // modal to the browser window. 46 // modal to the browser window.
45 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed); 47 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed);
46 48
47 CertFreeCertificateContext(cert_list); 49 CertFreeCertificateContext(cert_list);
48 } 50 }
51 #endif
49 52
50 } // namespace 53 } // namespace
51 54
52 #if defined(USE_AURA) 55 #if defined(USE_AURA)
53 void ShowCertificateViewer(content::WebContents* web_contents, 56 void ShowCertificateViewer(content::WebContents* web_contents,
54 gfx::NativeWindow parent, 57 gfx::NativeWindow parent,
55 net::X509Certificate* cert) { 58 net::X509Certificate* cert) {
56 if (chrome::GetHostDesktopTypeForNativeWindow(parent) != 59 if (chrome::GetHostDesktopTypeForNativeWindow(parent) !=
57 chrome::HOST_DESKTOP_TYPE_ASH) { 60 chrome::HOST_DESKTOP_TYPE_ASH) {
58 ShowCertificateViewerImpl( 61 ui::CertificateViewerDialogWin::Show(
59 web_contents, parent->GetDispatcher()->GetAcceleratedWidget(), cert); 62 parent->GetDispatcher()->GetAcceleratedWidget(), cert);
60 } else { 63 } else {
61 NOTIMPLEMENTED(); 64 NOTIMPLEMENTED();
62 } 65 }
63 } 66 }
64 #else 67 #else
65 void ShowCertificateViewer(content::WebContents* web_contents, 68 void ShowCertificateViewer(content::WebContents* web_contents,
66 gfx::NativeWindow parent, 69 gfx::NativeWindow parent,
67 net::X509Certificate* cert) { 70 net::X509Certificate* cert) {
68 ShowCertificateViewerImpl(web_contents, parent, cert); 71 ShowCertificateViewerImpl(web_contents, parent, cert);
69 } 72 }
70 #endif 73 #endif
OLDNEW
« no previous file with comments | « no previous file | ui/shell_dialogs/DEPS » ('j') | ui/shell_dialogs/certificate_viewer_dialog_win.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698