Chromium Code Reviews| Index: chrome/browser/ui/webui/options/advanced_options_utils_win.cc |
| diff --git a/chrome/browser/ui/webui/options/advanced_options_utils_win.cc b/chrome/browser/ui/webui/options/advanced_options_utils_win.cc |
| index de9080e41af4f25e8b6f3c8bfcbf0786521984b4..38e1c9899c132963f01714f244197f481cfe334b 100644 |
| --- a/chrome/browser/ui/webui/options/advanced_options_utils_win.cc |
| +++ b/chrome/browser/ui/webui/options/advanced_options_utils_win.cc |
| @@ -10,11 +10,16 @@ |
| #include <shellapi.h> |
| #include "base/bind.h" |
| +#include "base/location.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/message_loop/message_loop.h" |
| #include "base/path_service.h" |
| +#include "base/single_thread_task_runner.h" |
| #include "base/threading/thread.h" |
| #include "chrome/browser/browser_process.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/web_contents.h" |
| +#include "ui/shell_dialogs/base_shell_dialog_win.h" |
| #include "ui/views/win/hwnd_util.h" |
| using content::BrowserThread; |
| @@ -22,6 +27,50 @@ using content::WebContents; |
| namespace options { |
| +namespace { |
| + |
| +// Shows a Windows certificate management dialog on the dialog thread. Deletes |
| +// itself when the dialog is closed. |
|
davidben
2015/07/23 19:49:33
I hate self-deleting classes, but the dialog is fi
|
| +class ManageCertificatesDialog : public ui::BaseShellDialogImpl { |
| + public: |
| + explicit ManageCertificatesDialog(WebContents* web_contents) |
| + : ui_task_runner_(base::MessageLoopForUI::current()->task_runner()) { |
| + HWND parent = |
| + views::HWNDForNativeWindow(web_contents->GetTopLevelNativeWindow()); |
| + run_state_ = BeginRun(parent); |
| + run_state_.dialog_thread->message_loop()->PostTask( |
|
mmenke
2015/07/23 20:03:34
PostTaskAndReply? (You'll need to use task_runner
davidben
2015/07/23 20:21:55
Done.
|
| + FROM_HERE, |
| + base::Bind(&ManageCertificatesDialog::Show, base::Unretained(this))); |
| + } |
| + |
| + private: |
| + ~ManageCertificatesDialog() override {} |
| + |
| + void Show() { |
| + CRYPTUI_CERT_MGR_STRUCT cert_mgr = {0}; |
| + cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT); |
| + cert_mgr.hwndParent = run_state_.owner; |
| + ::CryptUIDlgCertMgr(&cert_mgr); |
| + DisableOwner(run_state_.owner); |
|
davidben
2015/07/23 19:49:33
This seems kinda unnecessary since we're not doing
mmenke
2015/07/23 20:03:34
Doesn't BeginRun already do this?
davidben
2015/07/23 20:21:55
BeginRun disables it, but CryptUIDlgCertMgr will r
ananta
2015/07/23 20:32:57
Does CryptUIDlgCertMgr display a modal dialog?. Fr
mmenke
2015/07/23 20:34:29
Enabling an already enabled window should be fine.
davidben
2015/07/24 22:43:35
I was just going by the documentation of DisableOw
|
| + |
| + ui_task_runner_->PostTask( |
| + FROM_HERE, base::Bind(&ManageCertificatesDialog::DialogClosed, |
| + base::Unretained(this))); |
| + } |
| + |
| + void DialogClosed() { |
| + EndRun(run_state_); |
|
mmenke
2015/07/23 20:03:34
Could you just do this in the destructor, and use
davidben
2015/07/23 20:21:55
Done. Made it no longer self-owning.
|
| + delete this; |
| + } |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| + RunState run_state_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ManageCertificatesDialog); |
| +}; |
| + |
| +} // namespace |
| + |
| // Callback that opens the Internet Options control panel dialog with the |
| // Connections tab selected. |
| void OpenConnectionDialogCallback() { |
| @@ -58,11 +107,7 @@ void AdvancedOptionsUtilities::ShowNetworkProxySettings( |
| void AdvancedOptionsUtilities::ShowManageSSLCertificates( |
| WebContents* web_contents) { |
| - CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 }; |
| - cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT); |
| - cert_mgr.hwndParent = views::HWNDForNativeWindow( |
| - web_contents->GetTopLevelNativeWindow()); |
| - ::CryptUIDlgCertMgr(&cert_mgr); |
| + new ManageCertificatesDialog(web_contents); |
| } |
| } // namespace options |