当前位置: 首页 > 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.mrgr.cn/news/38227.html

相关文章:

  • Cilium + ebpf 系列文章- (七)Cilium-BGP-自定义定时器-ebgp多跳-优雅重启-MD5加密-传播团体字
  • linux中的软件包格式与库文件
  • OpenStack Yoga版安装笔记(十四)启动一个实例
  • BFS 解决最短路问题详解
  • 什么是具身智能仿真平台
  • crypto-js解密报错malformed utf-8 data
  • [半导体检测-9]:KLA Surfscan SP1 SP3 SP5 SP7各自使用的激光器光源有哪些?
  • 700. 二叉搜索树中的搜索
  • 大模型与智能体的市场调研分析
  • MySQL 索引选择详解
  • 什么东西可以当做GC Root,跨代引用如何处理?
  • 学生台灯买个什么样的好?一文读懂小学生台灯哪个品牌更护眼
  • 微调大模型(Finetuning Large Language Models)—Training tuning(五)
  • 第 18 章 从猫爷借钱说起——事务简介
  • Cadence23中的一些设置
  • 多路复用和事件轮询机制
  • 大厂面试真题-什么是CAS单点登录?什么原理
  • jupyter快捷键
  • 【JavaEE初阶】深入理解wait和notify以及线程饿死的解决
  • MySQL - 单表查询