OLD | NEW |
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 "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "chrome/browser/ui/host_desktop.h" |
13 #include "net/cert/x509_certificate.h" | 14 #include "net/cert/x509_certificate.h" |
14 | |
15 #if defined(USE_AURA) | |
16 #include "chrome/browser/ui/host_desktop.h" | |
17 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
18 #include "ui/aura/window_tree_host.h" | 16 #include "ui/aura/window_tree_host.h" |
19 #endif | |
20 | 17 |
21 namespace { | 18 namespace { |
22 | 19 |
23 void ShowCertificateViewerImpl(content::WebContents* web_contents, | 20 void ShowCertificateViewerImpl(content::WebContents* web_contents, |
24 HWND parent, | 21 HWND parent, |
25 net::X509Certificate* cert) { | 22 net::X509Certificate* cert) { |
26 // Create a new cert context and store containing just the certificate | 23 // Create a new cert context and store containing just the certificate |
27 // and its intermediate certificates. | 24 // and its intermediate certificates. |
28 PCCERT_CONTEXT cert_list = cert->CreateOSCertChainForCert(); | 25 PCCERT_CONTEXT cert_list = cert->CreateOSCertChainForCert(); |
29 CHECK(cert_list); | 26 CHECK(cert_list); |
(...skipping 18 matching lines...) Expand all Loading... |
48 base::MessageLoop::current()); | 45 base::MessageLoop::current()); |
49 // This next call blocks but keeps processing windows messages, making it | 46 // This next call blocks but keeps processing windows messages, making it |
50 // modal to the browser window. | 47 // modal to the browser window. |
51 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed); | 48 BOOL rv = ::CryptUIDlgViewCertificate(&view_info, &properties_changed); |
52 | 49 |
53 CertFreeCertificateContext(cert_list); | 50 CertFreeCertificateContext(cert_list); |
54 } | 51 } |
55 | 52 |
56 } // namespace | 53 } // namespace |
57 | 54 |
58 #if defined(USE_AURA) | |
59 void ShowCertificateViewer(content::WebContents* web_contents, | 55 void ShowCertificateViewer(content::WebContents* web_contents, |
60 gfx::NativeWindow parent, | 56 gfx::NativeWindow parent, |
61 net::X509Certificate* cert) { | 57 net::X509Certificate* cert) { |
62 if (chrome::GetHostDesktopTypeForNativeWindow(parent) != | 58 if (chrome::GetHostDesktopTypeForNativeWindow(parent) != |
63 chrome::HOST_DESKTOP_TYPE_ASH) { | 59 chrome::HOST_DESKTOP_TYPE_ASH) { |
64 ShowCertificateViewerImpl( | 60 ShowCertificateViewerImpl( |
65 web_contents, | 61 web_contents, |
66 parent->GetHost()->GetAcceleratedWidget(), cert); | 62 parent->GetHost()->GetAcceleratedWidget(), cert); |
67 } else { | 63 } else { |
68 NOTIMPLEMENTED(); | 64 NOTIMPLEMENTED(); |
69 } | 65 } |
70 } | 66 } |
71 #else | |
72 void ShowCertificateViewer(content::WebContents* web_contents, | |
73 gfx::NativeWindow parent, | |
74 net::X509Certificate* cert) { | |
75 ShowCertificateViewerImpl(web_contents, parent, cert); | |
76 } | |
77 #endif | |
OLD | NEW |