Home | History | Annotate | Download | only in options
      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
      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/file_util.h"
     13 #include "base/path_service.h"
     14 #include "base/threading/thread.h"
     15 #include "chrome/browser/browser_process.h"
     16 #include "content/browser/tab_contents/tab_contents.h"
     17 #include "content/browser/tab_contents/tab_contents_view.h"
     18 
     19 // A helper method that opens the Internet Options control panel dialog with
     20 // the Connections tab selected.
     21 class OpenConnectionDialogTask : public Task {
     22  public:
     23   OpenConnectionDialogTask() {}
     24 
     25   virtual void Run() {
     26     // Using rundll32 seems better than LaunchConnectionDialog which causes a
     27     // 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     FilePath rundll32;
     30     PathService::Get(base::DIR_SYSTEM, &rundll32);
     31     rundll32 = rundll32.AppendASCII("rundll32.exe");
     32 
     33     FilePath shell32dll;
     34     PathService::Get(base::DIR_SYSTEM, &shell32dll);
     35     shell32dll = shell32dll.AppendASCII("shell32.dll");
     36 
     37     FilePath inetcpl;
     38     PathService::Get(base::DIR_SYSTEM, &inetcpl);
     39     inetcpl = inetcpl.AppendASCII("inetcpl.cpl,,4");
     40 
     41     std::wstring args(shell32dll.value());
     42     args.append(L",Control_RunDLL ");
     43     args.append(inetcpl.value());
     44 
     45     ShellExecute(NULL, L"open", rundll32.value().c_str(), args.c_str(), NULL,
     46                  SW_SHOWNORMAL);
     47   }
     48 
     49  private:
     50   DISALLOW_COPY_AND_ASSIGN(OpenConnectionDialogTask);
     51 };
     52 
     53 void AdvancedOptionsUtilities::ShowNetworkProxySettings(
     54       TabContents* tab_contents) {
     55   base::Thread* thread = g_browser_process->file_thread();
     56   DCHECK(thread);
     57   thread->message_loop()->PostTask(FROM_HERE, new OpenConnectionDialogTask);
     58 }
     59 
     60 void AdvancedOptionsUtilities::ShowManageSSLCertificates(
     61       TabContents* tab_contents) {
     62   CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 };
     63   cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT);
     64   cert_mgr.hwndParent =
     65   tab_contents->view()->GetTopLevelNativeWindow();
     66   ::CryptUIDlgCertMgr(&cert_mgr);
     67 }
     68