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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/options/advanced_options_utils.h"
8 #include <cryptuiapi.h>
9 #pragma comment(lib, "cryptui.lib")
12 #include "base/bind.h"
13 #include "base/path_service.h"
14 #include "base/threading/thread.h"
15 #include "chrome/browser/browser_process.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/web_contents.h"
18 #include "ui/views/win/hwnd_util.h"
20 using content::BrowserThread
;
21 using content::WebContents
;
25 // Callback that opens the Internet Options control panel dialog with the
26 // Connections tab selected.
27 void OpenConnectionDialogCallback() {
28 // Using rundll32 seems better than LaunchConnectionDialog which causes a
29 // 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.
31 base::FilePath rundll32
;
32 PathService::Get(base::DIR_SYSTEM
, &rundll32
);
33 rundll32
= rundll32
.AppendASCII("rundll32.exe");
35 base::FilePath shell32dll
;
36 PathService::Get(base::DIR_SYSTEM
, &shell32dll
);
37 shell32dll
= shell32dll
.AppendASCII("shell32.dll");
39 base::FilePath inetcpl
;
40 PathService::Get(base::DIR_SYSTEM
, &inetcpl
);
41 inetcpl
= inetcpl
.AppendASCII("inetcpl.cpl,,4");
43 std::wstring
args(shell32dll
.value());
44 args
.append(L
",Control_RunDLL ");
45 args
.append(inetcpl
.value());
47 ShellExecute(NULL
, L
"open", rundll32
.value().c_str(), args
.c_str(), NULL
,
51 void AdvancedOptionsUtilities::ShowNetworkProxySettings(
52 WebContents
* web_contents
) {
53 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::FILE));
54 BrowserThread::PostTask(BrowserThread::FILE,
56 base::Bind(&OpenConnectionDialogCallback
));
59 void AdvancedOptionsUtilities::ShowManageSSLCertificates(
60 WebContents
* web_contents
) {
61 CRYPTUI_CERT_MGR_STRUCT cert_mgr
= { 0 };
62 cert_mgr
.dwSize
= sizeof(CRYPTUI_CERT_MGR_STRUCT
);
63 cert_mgr
.hwndParent
= views::HWNDForNativeWindow(
64 web_contents
->GetTopLevelNativeWindow());
65 ::CryptUIDlgCertMgr(&cert_mgr
);
68 } // namespace options