当前位置: 首页 > news >正文

Chromium 设置页面打开系统代理源码分析c++

1、前端页面调用showProxySettings() {chrome.send("showProxySettings")}
2、c++ 响应代码如下 chrome\browser\ui\webui\settings\system_handler.ccvoid SystemHandler::RegisterMessages() {web_ui()->RegisterMessageCallback("showProxySettings",base::BindRepeating(&SystemHandler::HandleShowProxySettings,base::Unretained(this)));
}void SystemHandler::HandleShowProxySettings(const base::Value::List& args) {base::RecordAction(base::UserMetricsAction("Options_ShowProxySettings"));settings_utils::ShowNetworkProxySettings(web_ui()->GetWebContents());
}3、chrome\browser\ui\webui\settings\settings_utils_win.cc// Connections tab selected.
void OpenConnectionDialogCallback() {// Using rundll32 seems better than LaunchConnectionDialog which causes a// new dialog to be made for each call.  rundll32 uses the same global// dialog and it seems to share with the shortcut in control panel.base::FilePath rundll32;base::PathService::Get(base::DIR_SYSTEM, &rundll32);rundll32 = rundll32.AppendASCII("rundll32.exe");base::FilePath shell32dll;base::PathService::Get(base::DIR_SYSTEM, &shell32dll);shell32dll = shell32dll.AppendASCII("shell32.dll");base::FilePath inetcpl;base::PathService::Get(base::DIR_SYSTEM, &inetcpl);inetcpl = inetcpl.AppendASCII("inetcpl.cpl,,4");std::wstring args(shell32dll.value());args.append(L",Control_RunDLL ");args.append(inetcpl.value());//通过shell方式启动系统代理设置//win10以下打开IE代理ShellExecute(NULL, L"open", rundll32.value().c_str(), args.c_str(), NULL,SW_SHOWNORMAL);
}void ShowNetworkProxySettings(content::WebContents* web_contents) {if (base::win::GetVersion() >= base::win::Version::WIN10) {// See启动的是SystemSettings.exe 代理// https://docs.microsoft.com/en-us/windows/uwp/launch-resume/launch-settings-app#network--internetplatform_util::OpenExternal(Profile::FromBrowserContext(web_contents->GetBrowserContext()),GURL("ms-settings:network-proxy"));} else {base::ThreadPool::PostTask(FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()},base::BindOnce(&OpenConnectionDialogCallback));}
}

win10效果:

win7系统效果:                                  

http://www.lryc.cn/news/453700.html

相关文章:

  • 信号检测理论(Signal Detection Theory, SDT)
  • Flink源码剖析
  • [Python学习日记-39] 闭包是个什么东西?
  • XSLT 实例:掌握 XML 转换的艺术
  • 【C++】第一节:C++入门
  • CSP-S 2021 T1廊桥分配
  • 项目配置说明
  • linux网络编程实战
  • 网络基础 【HTTP】
  • [Linux#61][UDP] port | netstat | udp缓冲区 | stm32
  • 定义类方法的错误总结
  • Redis --- 第三讲 --- 通用命令
  • 【Linux】进程间关系与守护进程
  • 【可视化大屏】将柱状图引入到html页面中
  • gm/ID设计方法学习笔记(一)
  • 高度细化的SAGA模式实现:基于Spring Boot与RabbitMQ的跨服务事务
  • Vue工程化开发
  • Ray_Tracing_The_Next_Week下
  • ES索引生命周期管理
  • Oracle数据库体系结构基础
  • QT学习笔记4.5(文件、参数文件)
  • 服务器虚拟化的详细学习要点
  • 创建一个Java Web API项目
  • 对称加密算法的使用Java和C#
  • 10款好用的开源 HarmonyOS 工具库
  • ubuntu22.04中备份Iptables的设置
  • (PyTorch) 深度学习框架-介绍篇
  • 若依从redis中获取用户列表
  • 文件上传之%00截断(00截断)以及pikachu靶场
  • Chainlit集成LlamaIndex并使用通义千问实现和数据库交互的网页对话应用(text2sql)