NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / advanced_options_utils_win.cc
blobac1ca8255c726fb48154775e01ff16275a06752c
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"
7 #include <windows.h>
8 #include <cryptuiapi.h>
9 #pragma comment(lib, "cryptui.lib")
10 #include <shellapi.h>
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 "content/public/browser/web_contents_view.h"
19 #include "ui/views/win/hwnd_util.h"
21 using content::BrowserThread;
22 using content::WebContents;
24 namespace options {
26 // Callback that opens the Internet Options control panel dialog with the
27 // Connections tab selected.
28 void OpenConnectionDialogCallback() {
29 // Using rundll32 seems better than LaunchConnectionDialog which causes a
30 // new dialog to be made for each call. rundll32 uses the same global
31 // dialog and it seems to share with the shortcut in control panel.
32 base::FilePath rundll32;
33 PathService::Get(base::DIR_SYSTEM, &rundll32);
34 rundll32 = rundll32.AppendASCII("rundll32.exe");
36 base::FilePath shell32dll;
37 PathService::Get(base::DIR_SYSTEM, &shell32dll);
38 shell32dll = shell32dll.AppendASCII("shell32.dll");
40 base::FilePath inetcpl;
41 PathService::Get(base::DIR_SYSTEM, &inetcpl);
42 inetcpl = inetcpl.AppendASCII("inetcpl.cpl,,4");
44 std::wstring args(shell32dll.value());
45 args.append(L",Control_RunDLL ");
46 args.append(inetcpl.value());
48 ShellExecute(NULL, L"open", rundll32.value().c_str(), args.c_str(), NULL,
49 SW_SHOWNORMAL);
52 void AdvancedOptionsUtilities::ShowNetworkProxySettings(
53 WebContents* web_contents) {
54 DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::FILE));
55 BrowserThread::PostTask(BrowserThread::FILE,
56 FROM_HERE,
57 base::Bind(&OpenConnectionDialogCallback));
60 void AdvancedOptionsUtilities::ShowManageSSLCertificates(
61 WebContents* web_contents) {
62 CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 };
63 cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT);
64 cert_mgr.hwndParent = views::HWNDForNativeWindow(
65 web_contents->GetView()->GetTopLevelNativeWindow());
66 ::CryptUIDlgCertMgr(&cert_mgr);
69 } // namespace options