OLD | NEW |
(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 #ifndef UI_SHELL_DIALOGS_CERTIFICATE_VIEWER_DIALOG_WIN_H_ |
| 6 #define UI_SHELL_DIALOGS_CERTIFICATE_VIEWER_DIALOG_WIN_H_ |
| 7 |
| 8 #include <windows.h> |
| 9 #include <cryptuiapi.h> |
| 10 |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/message_loop/message_loop_proxy.h" |
| 15 #include "ui/shell_dialogs/base_shell_dialog_win.h" |
| 16 #include "ui/shell_dialogs/shell_dialogs_export.h" |
| 17 |
| 18 namespace net { |
| 19 class X509Certificate; |
| 20 } |
| 21 |
| 22 namespace ui { |
| 23 |
| 24 // A thin wrapper around the native certificate viewer dialog that uses |
| 25 // BaseShellDialog to have the dialog run on a background thread. This needs |
| 26 // to be on a background thread so that base::MessageLoop can keep running |
| 27 // and run delayed tasks (mostly importantly the gpu messages that do |
| 28 // painting). |
| 29 class SHELL_DIALOGS_EXPORT CertificateViewerDialogWin |
| 30 : public BaseShellDialogImpl { |
| 31 public: |
| 32 // Called to open the certificate dialog on a background thread. |
| 33 // |owning_window| is the parent HWND, and |certificate| is the certificate |
| 34 // to be displayed. |
| 35 static void Show(HWND owning_window, const net::X509Certificate& certificate); |
| 36 |
| 37 private: |
| 38 CertificateViewerDialogWin(HWND owning_window, |
| 39 const net::X509Certificate& certificate); |
| 40 |
| 41 // A struct for holding all the state necessary for displaying the |
| 42 // certificate viewer dialog. |
| 43 struct ExecuteCertificateViewerParams { |
| 44 ExecuteCertificateViewerParams(RunState run_state, |
| 45 HWND owner, |
| 46 PCCERT_CONTEXT cert_list) |
| 47 : run_state(run_state), |
| 48 owner(owner), |
| 49 cert_list(cert_list), |
| 50 ui_proxy(base::MessageLoopForUI::current()->message_loop_proxy()) {} |
| 51 |
| 52 RunState run_state; |
| 53 HWND owner; |
| 54 PCCERT_CONTEXT cert_list; |
| 55 scoped_refptr<base::MessageLoopProxy> ui_proxy; |
| 56 }; |
| 57 |
| 58 // Runs the certificate viewer dialog. Should be run on the the |
| 59 // BaseShellDialogImpl thread. Posts back to CertificateViewerCompleted on |
| 60 // the UI thread on completion. |
| 61 void ExecuteCertificateViewer(const ExecuteCertificateViewerParams& params); |
| 62 |
| 63 // Handler for the result of the certificate viewer dialog. Should be run on |
| 64 // the UI thread. |
| 65 void CertificateViewerCompleted(const ExecuteCertificateViewerParams& params); |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialogWin); |
| 68 }; |
| 69 |
| 70 } // namespace ui |
| 71 |
| 72 #endif // UI_SHELL_DIALOGS_CERTIFICATE_VIEWER_DIALOG_WIN_H_ |
OLD | NEW |