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