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..b5ce5610e9786d33f6c5151bfa29c2fe07b98753 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,17 @@ |
| #include <shellapi.h> |
| #include "base/bind.h" |
| +#include "base/bind_helpers.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 +28,46 @@ using content::WebContents; |
| namespace options { |
| +namespace { |
| + |
| +// Shows a Windows certificate management dialog on the dialog thread. |
| +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); |
|
mmenke
2015/07/23 20:34:29
Now this seems a bit weird...It really should be i
davidben
2015/07/24 22:43:35
Done.
|
| + } |
| + |
| + ~ManageCertificatesDialog() override { EndRun(run_state_); } |
| + |
| + // Shows the dialog and calls |callback| when the dialog closes. The caller |
| + // must ensure the ManageCertificatesDialog remains valid until then. |
| + void Show(const base::Closure& callback) { |
|
mmenke
2015/07/23 20:34:29
Should we check if (IsRunningDialogForOwner) and j
davidben
2015/07/24 22:43:35
Done.
|
| + run_state_.dialog_thread->task_runner()->PostTaskAndReply( |
| + FROM_HERE, base::Bind(&ManageCertificatesDialog::ShowOnDialogThread, |
| + base::Unretained(this)), |
| + callback); |
| + } |
| + |
| + private: |
| + void ShowOnDialogThread() { |
| + 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); |
| + } |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
|
mmenke
2015/07/23 20:34:29
No longer needed.
davidben
2015/07/24 22:43:35
Done.
|
| + 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 +104,9 @@ 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); |
| + ManageCertificatesDialog* dialog = new ManageCertificatesDialog(web_contents); |
| + dialog->Show(base::Bind(&base::DeletePointer<ManageCertificatesDialog>, |
| + dialog)); |
| } |
| } // namespace options |