| 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..4f0f8a0e517317e0a7ac32a8e064caae438baef0 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,15 @@
|
| #include <shellapi.h>
|
|
|
| #include "base/bind.h"
|
| +#include "base/bind_helpers.h"
|
| +#include "base/location.h"
|
| +#include "base/message_loop/message_loop.h"
|
| #include "base/path_service.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 +26,49 @@ using content::WebContents;
|
|
|
| namespace options {
|
|
|
| +namespace {
|
| +
|
| +// Shows a Windows certificate management dialog on the dialog thread.
|
| +class ManageCertificatesDialog : public ui::BaseShellDialogImpl {
|
| + public:
|
| + ManageCertificatesDialog() {}
|
| +
|
| + // Shows the dialog and calls |callback| when the dialog closes. The caller
|
| + // must ensure the ManageCertificatesDialog remains valid until then.
|
| + void Show(HWND parent, const base::Closure& callback) {
|
| + if (IsRunningDialogForOwner(parent)) {
|
| + base::MessageLoop::current()->PostTask(FROM_HERE, callback);
|
| + return;
|
| + }
|
| +
|
| + RunState run_state = BeginRun(parent);
|
| + run_state.dialog_thread->task_runner()->PostTaskAndReply(
|
| + FROM_HERE, base::Bind(&ManageCertificatesDialog::ShowOnDialogThread,
|
| + base::Unretained(this), run_state),
|
| + base::Bind(&ManageCertificatesDialog::OnDialogClosed,
|
| + base::Unretained(this), run_state, callback));
|
| + }
|
| +
|
| + private:
|
| + void ShowOnDialogThread(const RunState& run_state) {
|
| + CRYPTUI_CERT_MGR_STRUCT cert_mgr = {0};
|
| + cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT);
|
| + cert_mgr.hwndParent = run_state.owner;
|
| + ::CryptUIDlgCertMgr(&cert_mgr);
|
| + }
|
| +
|
| + void OnDialogClosed(const RunState& run_state,
|
| + const base::Closure& callback) {
|
| + EndRun(run_state);
|
| + // May delete |this|.
|
| + callback.Run();
|
| + }
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ManageCertificatesDialog);
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| // Callback that opens the Internet Options control panel dialog with the
|
| // Connections tab selected.
|
| void OpenConnectionDialogCallback() {
|
| @@ -58,11 +105,13 @@ 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);
|
| + HWND parent =
|
| + views::HWNDForNativeWindow(web_contents->GetTopLevelNativeWindow());
|
| +
|
| + ManageCertificatesDialog* dialog = new ManageCertificatesDialog;
|
| + dialog->Show(
|
| + parent,
|
| + base::Bind(&base::DeletePointer<ManageCertificatesDialog>, dialog));
|
| }
|
|
|
| } // namespace options
|
|
|