OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "content/browser/tab_contents/tab_contents_view.h" | 18 #include "content/browser/tab_contents/tab_contents_view.h" |
| 19 #include "content/public/browser/browser_thread.h" |
| 20 |
| 21 using content::BrowserThread; |
19 | 22 |
20 // Callback that opens the Internet Options control panel dialog with the | 23 // Callback that opens the Internet Options control panel dialog with the |
21 // Connections tab selected. | 24 // Connections tab selected. |
22 void OpenConnectionDialogCallback() { | 25 void OpenConnectionDialogCallback() { |
23 // Using rundll32 seems better than LaunchConnectionDialog which causes a | 26 // Using rundll32 seems better than LaunchConnectionDialog which causes a |
24 // new dialog to be made for each call. rundll32 uses the same global | 27 // new dialog to be made for each call. rundll32 uses the same global |
25 // dialog and it seems to share with the shortcut in control panel. | 28 // dialog and it seems to share with the shortcut in control panel. |
26 FilePath rundll32; | 29 FilePath rundll32; |
27 PathService::Get(base::DIR_SYSTEM, &rundll32); | 30 PathService::Get(base::DIR_SYSTEM, &rundll32); |
28 rundll32 = rundll32.AppendASCII("rundll32.exe"); | 31 rundll32 = rundll32.AppendASCII("rundll32.exe"); |
29 | 32 |
30 FilePath shell32dll; | 33 FilePath shell32dll; |
31 PathService::Get(base::DIR_SYSTEM, &shell32dll); | 34 PathService::Get(base::DIR_SYSTEM, &shell32dll); |
32 shell32dll = shell32dll.AppendASCII("shell32.dll"); | 35 shell32dll = shell32dll.AppendASCII("shell32.dll"); |
33 | 36 |
34 FilePath inetcpl; | 37 FilePath inetcpl; |
35 PathService::Get(base::DIR_SYSTEM, &inetcpl); | 38 PathService::Get(base::DIR_SYSTEM, &inetcpl); |
36 inetcpl = inetcpl.AppendASCII("inetcpl.cpl,,4"); | 39 inetcpl = inetcpl.AppendASCII("inetcpl.cpl,,4"); |
37 | 40 |
38 std::wstring args(shell32dll.value()); | 41 std::wstring args(shell32dll.value()); |
39 args.append(L",Control_RunDLL "); | 42 args.append(L",Control_RunDLL "); |
40 args.append(inetcpl.value()); | 43 args.append(inetcpl.value()); |
41 | 44 |
42 ShellExecute(NULL, L"open", rundll32.value().c_str(), args.c_str(), NULL, | 45 ShellExecute(NULL, L"open", rundll32.value().c_str(), args.c_str(), NULL, |
43 SW_SHOWNORMAL); | 46 SW_SHOWNORMAL); |
44 } | 47 } |
45 | 48 |
46 void AdvancedOptionsUtilities::ShowNetworkProxySettings( | 49 void AdvancedOptionsUtilities::ShowNetworkProxySettings( |
47 TabContents* tab_contents) { | 50 TabContents* tab_contents) { |
48 base::Thread* thread = g_browser_process->file_thread(); | 51 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::FILE)); |
49 DCHECK(thread); | 52 BrowserThread::PostTask(BrowserThread::FILE, |
50 thread->message_loop()->PostTask(FROM_HERE, | 53 FROM_HERE, |
51 base::Bind(&OpenConnectionDialogCallback)); | 54 base::Bind(&OpenConnectionDialogCallback)); |
52 } | 55 } |
53 | 56 |
54 void AdvancedOptionsUtilities::ShowManageSSLCertificates( | 57 void AdvancedOptionsUtilities::ShowManageSSLCertificates( |
55 TabContents* tab_contents) { | 58 TabContents* tab_contents) { |
56 CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 }; | 59 CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 }; |
57 cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT); | 60 cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT); |
58 cert_mgr.hwndParent = | 61 cert_mgr.hwndParent = |
59 #if defined(USE_AURA) | 62 #if defined(USE_AURA) |
60 NULL; | 63 NULL; |
61 #else | 64 #else |
62 tab_contents->view()->GetTopLevelNativeWindow(); | 65 tab_contents->view()->GetTopLevelNativeWindow(); |
63 #endif | 66 #endif |
64 ::CryptUIDlgCertMgr(&cert_mgr); | 67 ::CryptUIDlgCertMgr(&cert_mgr); |
65 } | 68 } |
OLD | NEW |