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/options/advanced_options_utils.h" | 5 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <cryptuiapi.h> | 8 #include <cryptuiapi.h> |
9 #pragma comment(lib, "cryptui.lib") | 9 #pragma comment(lib, "cryptui.lib") |
10 #include <shellapi.h> | 10 #include <shellapi.h> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | |
14 #include "base/location.h" | |
15 #include "base/memory/ref_counted.h" | |
16 #include "base/message_loop/message_loop.h" | |
13 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/single_thread_task_runner.h" | |
14 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
15 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
16 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "ui/shell_dialogs/base_shell_dialog_win.h" | |
18 #include "ui/views/win/hwnd_util.h" | 24 #include "ui/views/win/hwnd_util.h" |
19 | 25 |
20 using content::BrowserThread; | 26 using content::BrowserThread; |
21 using content::WebContents; | 27 using content::WebContents; |
22 | 28 |
23 namespace options { | 29 namespace options { |
24 | 30 |
31 namespace { | |
32 | |
33 // Shows a Windows certificate management dialog on the dialog thread. | |
34 class ManageCertificatesDialog : public ui::BaseShellDialogImpl { | |
35 public: | |
36 explicit ManageCertificatesDialog(WebContents* web_contents) | |
37 : ui_task_runner_(base::MessageLoopForUI::current()->task_runner()) { | |
38 HWND parent = | |
39 views::HWNDForNativeWindow(web_contents->GetTopLevelNativeWindow()); | |
40 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.
| |
41 } | |
42 | |
43 ~ManageCertificatesDialog() override { EndRun(run_state_); } | |
44 | |
45 // Shows the dialog and calls |callback| when the dialog closes. The caller | |
46 // must ensure the ManageCertificatesDialog remains valid until then. | |
47 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.
| |
48 run_state_.dialog_thread->task_runner()->PostTaskAndReply( | |
49 FROM_HERE, base::Bind(&ManageCertificatesDialog::ShowOnDialogThread, | |
50 base::Unretained(this)), | |
51 callback); | |
52 } | |
53 | |
54 private: | |
55 void ShowOnDialogThread() { | |
56 CRYPTUI_CERT_MGR_STRUCT cert_mgr = {0}; | |
57 cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT); | |
58 cert_mgr.hwndParent = run_state_.owner; | |
59 ::CryptUIDlgCertMgr(&cert_mgr); | |
60 DisableOwner(run_state_.owner); | |
61 } | |
62 | |
63 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.
| |
64 RunState run_state_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(ManageCertificatesDialog); | |
67 }; | |
68 | |
69 } // namespace | |
70 | |
25 // Callback that opens the Internet Options control panel dialog with the | 71 // Callback that opens the Internet Options control panel dialog with the |
26 // Connections tab selected. | 72 // Connections tab selected. |
27 void OpenConnectionDialogCallback() { | 73 void OpenConnectionDialogCallback() { |
28 // Using rundll32 seems better than LaunchConnectionDialog which causes a | 74 // Using rundll32 seems better than LaunchConnectionDialog which causes a |
29 // new dialog to be made for each call. rundll32 uses the same global | 75 // new dialog to be made for each call. rundll32 uses the same global |
30 // dialog and it seems to share with the shortcut in control panel. | 76 // dialog and it seems to share with the shortcut in control panel. |
31 base::FilePath rundll32; | 77 base::FilePath rundll32; |
32 PathService::Get(base::DIR_SYSTEM, &rundll32); | 78 PathService::Get(base::DIR_SYSTEM, &rundll32); |
33 rundll32 = rundll32.AppendASCII("rundll32.exe"); | 79 rundll32 = rundll32.AppendASCII("rundll32.exe"); |
34 | 80 |
(...skipping 16 matching lines...) Expand all Loading... | |
51 void AdvancedOptionsUtilities::ShowNetworkProxySettings( | 97 void AdvancedOptionsUtilities::ShowNetworkProxySettings( |
52 WebContents* web_contents) { | 98 WebContents* web_contents) { |
53 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::FILE)); | 99 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::FILE)); |
54 BrowserThread::PostTask(BrowserThread::FILE, | 100 BrowserThread::PostTask(BrowserThread::FILE, |
55 FROM_HERE, | 101 FROM_HERE, |
56 base::Bind(&OpenConnectionDialogCallback)); | 102 base::Bind(&OpenConnectionDialogCallback)); |
57 } | 103 } |
58 | 104 |
59 void AdvancedOptionsUtilities::ShowManageSSLCertificates( | 105 void AdvancedOptionsUtilities::ShowManageSSLCertificates( |
60 WebContents* web_contents) { | 106 WebContents* web_contents) { |
61 CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 }; | 107 ManageCertificatesDialog* dialog = new ManageCertificatesDialog(web_contents); |
62 cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT); | 108 dialog->Show(base::Bind(&base::DeletePointer<ManageCertificatesDialog>, |
63 cert_mgr.hwndParent = views::HWNDForNativeWindow( | 109 dialog)); |
64 web_contents->GetTopLevelNativeWindow()); | |
65 ::CryptUIDlgCertMgr(&cert_mgr); | |
66 } | 110 } |
67 | 111 |
68 } // namespace options | 112 } // namespace options |
OLD | NEW |