| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/settings_utils.h" | 5 #include "chrome/browser/ui/webui/settings_utils.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <cryptuiapi.h> | 8 #include <cryptuiapi.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | |
| 16 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 21 #include "ui/shell_dialogs/base_shell_dialog_win.h" | 22 #include "ui/shell_dialogs/base_shell_dialog_win.h" |
| 22 #include "ui/views/win/hwnd_util.h" | 23 #include "ui/views/win/hwnd_util.h" |
| 23 | 24 |
| 24 using content::BrowserThread; | 25 using content::BrowserThread; |
| 25 | 26 |
| 26 namespace settings_utils { | 27 namespace settings_utils { |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // Shows a Windows certificate management dialog on the dialog thread. | 31 // Shows a Windows certificate management dialog on the dialog thread. |
| 31 class ManageCertificatesDialog : public ui::BaseShellDialogImpl { | 32 class ManageCertificatesDialog : public ui::BaseShellDialogImpl { |
| 32 public: | 33 public: |
| 33 ManageCertificatesDialog() {} | 34 ManageCertificatesDialog() {} |
| 34 | 35 |
| 35 // Shows the dialog and calls |callback| when the dialog closes. The caller | 36 // Shows the dialog and calls |callback| when the dialog closes. The caller |
| 36 // must ensure the ManageCertificatesDialog remains valid until then. | 37 // must ensure the ManageCertificatesDialog remains valid until then. |
| 37 void Show(HWND parent, const base::Closure& callback) { | 38 void Show(HWND parent, const base::Closure& callback) { |
| 38 if (IsRunningDialogForOwner(parent)) { | 39 if (IsRunningDialogForOwner(parent)) { |
| 39 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 40 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
| 40 return; | 41 return; |
| 41 } | 42 } |
| 42 | 43 |
| 43 RunState run_state = BeginRun(parent); | 44 RunState run_state = BeginRun(parent); |
| 44 run_state.dialog_thread->task_runner()->PostTaskAndReply( | 45 run_state.dialog_thread->task_runner()->PostTaskAndReply( |
| 45 FROM_HERE, base::Bind(&ManageCertificatesDialog::ShowOnDialogThread, | 46 FROM_HERE, base::Bind(&ManageCertificatesDialog::ShowOnDialogThread, |
| 46 base::Unretained(this), run_state), | 47 base::Unretained(this), run_state), |
| 47 base::Bind(&ManageCertificatesDialog::OnDialogClosed, | 48 base::Bind(&ManageCertificatesDialog::OnDialogClosed, |
| 48 base::Unretained(this), run_state, callback)); | 49 base::Unretained(this), run_state, callback)); |
| 49 } | 50 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 HWND parent = | 106 HWND parent = |
| 106 views::HWNDForNativeWindow(web_contents->GetTopLevelNativeWindow()); | 107 views::HWNDForNativeWindow(web_contents->GetTopLevelNativeWindow()); |
| 107 | 108 |
| 108 ManageCertificatesDialog* dialog = new ManageCertificatesDialog; | 109 ManageCertificatesDialog* dialog = new ManageCertificatesDialog; |
| 109 dialog->Show( | 110 dialog->Show( |
| 110 parent, | 111 parent, |
| 111 base::Bind(&base::DeletePointer<ManageCertificatesDialog>, dialog)); | 112 base::Bind(&base::DeletePointer<ManageCertificatesDialog>, dialog)); |
| 112 } | 113 } |
| 113 | 114 |
| 114 } // namespace settings_utils | 115 } // namespace settings_utils |
| OLD | NEW |