Index: ui/shell_dialogs/certificate_viewer_dialog_win.h |
diff --git a/ui/shell_dialogs/certificate_viewer_dialog_win.h b/ui/shell_dialogs/certificate_viewer_dialog_win.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..53a35ae155589f2bbbf6773776e276a70b6e4aa3 |
--- /dev/null |
+++ b/ui/shell_dialogs/certificate_viewer_dialog_win.h |
@@ -0,0 +1,69 @@ |
+// Copyright 2013 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. |
+ |
+#ifndef UI_SHELL_DIALOGS_CERTIFICATE_VIEWER_DIALOG_WIN_H_ |
+#define UI_SHELL_DIALOGS_CERTIFICATE_VIEWER_DIALOG_WIN_H_ |
+ |
+#include <windows.h> |
+#include <cryptuiapi.h> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/message_loop/message_loop.h" |
+#include "base/message_loop/message_loop_proxy.h" |
+#include "ui/shell_dialogs/base_shell_dialog_win.h" |
+#include "ui/shell_dialogs/shell_dialogs_export.h" |
+ |
+namespace net { |
+class X509Certificate; |
+} |
+ |
+namespace ui { |
+ |
+// A thin wrapper around the native certificate viewer dialog that uses |
+// BaseShellDialog to have the dialog run on a background thread. |
+class SHELL_DIALOGS_EXPORT CertificateViewerDialogWin |
sky
2013/11/05 22:34:03
Document why this runs on a background thread.
scottmg
2013/11/05 23:40:33
Done, and updated CL description.
|
+ : public BaseShellDialogImpl { |
+ public: |
+ // Called to open the certificate dialog on a background thread. |
+ // |owning_window| is the parent HWND, and |certificate| is the certificate |
+ // to be displayed. |
+ static void Show(HWND owning_window, net::X509Certificate* certificate); |
sky
2013/11/05 22:34:03
Can this take a const net::X509C& ?
scottmg
2013/11/05 23:40:33
Done.
|
+ |
+ private: |
+ CertificateViewerDialogWin(HWND owning_window, |
+ net::X509Certificate* certificate); |
+ |
+ // A struct for holding all the state necessary for displaying the |
+ // certificate viewer dialog. |
+ struct ExecuteCertificateViewerParams { |
+ ExecuteCertificateViewerParams(RunState run_state, |
+ HWND owner, |
+ PCCERT_CONTEXT cert_list) |
+ : run_state(run_state), |
+ owner(owner), |
+ cert_list(cert_list), |
+ ui_proxy(base::MessageLoopForUI::current()->message_loop_proxy()) {} |
+ |
+ RunState run_state; |
+ HWND owner; |
+ PCCERT_CONTEXT cert_list; |
sky
2013/11/05 22:34:03
Does this need to be freed? And is this tied to th
scottmg
2013/11/05 23:40:33
Yes, it does. It's freed in CertificateViewerCompl
Ryan Sleevi
2013/11/06 22:47:50
Correct, it copies into a new one, since the dialo
|
+ scoped_refptr<base::MessageLoopProxy> ui_proxy; |
+ }; |
+ |
+ // Runs the certificate viewer dialog. Should be run on the the |
+ // BaseShellDialogImpl thread. Posts back to CertificateViewerCompleted on |
+ // the UI thread on completion. |
+ void ExecuteCertificateViewer(const ExecuteCertificateViewerParams& params); |
+ |
+ // Handler for the result of the certificate viewer dialog. Should be run on |
+ // the UI thread. |
+ void CertificateViewerCompleted(const ExecuteCertificateViewerParams& params); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CertificateViewerDialogWin); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_SHELL_DIALOGS_CERTIFICATE_VIEWER_DIALOG_WIN_H_ |