Home | History | Annotate | Download | only in options
      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.
      4 
      5 #include "chrome/browser/ui/webui/options/advanced_options_utils.h"
      6 
      7 #include <windows.h>
      8 #include <cryptuiapi.h>
      9 #pragma comment(lib, "cryptui.lib")
     10 #include <shellapi.h>
     11 
     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"
     19 
     20 using content::BrowserThread;
     21 using content::WebContents;
     22 
     23 namespace options {
     24 
     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");
     34 
     35   base::FilePath shell32dll;
     36   PathService::Get(base::DIR_SYSTEM, &shell32dll);
     37   shell32dll = shell32dll.AppendASCII("shell32.dll");
     38 
     39   base::FilePath inetcpl;
     40   PathService::Get(base::DIR_SYSTEM, &inetcpl);
     41   inetcpl = inetcpl.AppendASCII("inetcpl.cpl,,4");
     42 
     43   std::wstring args(shell32dll.value());
     44   args.append(L",Control_RunDLL ");
     45   args.append(inetcpl.value());
     46 
     47   ShellExecute(NULL, L"open", rundll32.value().c_str(), args.c_str(), NULL,
     48                SW_SHOWNORMAL);
     49 }
     50 
     51 void AdvancedOptionsUtilities::ShowNetworkProxySettings(
     52       WebContents* web_contents) {
     53   DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::FILE));
     54   BrowserThread::PostTask(BrowserThread::FILE,
     55                           FROM_HERE,
     56                           base::Bind(&OpenConnectionDialogCallback));
     57 }
     58 
     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);
     66 }
     67 
     68 }  // namespace options
     69