Chromium 屏蔽“缺少 Google API 密钥,因此 Chromium 的部分功能将无法使用。”提示 c++

新编译的Chromium工程默认gn参数如下:

可以利用gn args --list out/debug >1.txt 导出默认参数

google_api_key
    Current value (from the default) = ""
      From //google_apis/BUILD.gn:43

    Set these to bake the specified API keys and OAuth client
    IDs/secrets into your build.
   
    If you create a build without values baked in, you can instead
    set environment variables to provide the keys at runtime (see
    src/google_apis/google_api_keys.h for details).  Features that
    require server-side APIs may fail to work if no keys are
    provided.
   
    Note that if `use_official_google_api_keys` has been set to true
    (explicitly or implicitly), these values will be ignored and the official
    keys will be used instead.

google_default_client_id
    Current value (from the default) = ""
      From //google_apis/BUILD.gn:46

    See google_api_key.

google_default_client_secret
    Current value (from the default) = ""
      From //google_apis/BUILD.gn:49

    See google_api_key.

============================================================

第一次运行编译出来的谷歌浏览器效果会提示:

 屏蔽缺少 Google API 密钥,因此 Chromium 的部分功能将无法使用。

那么如何屏蔽此功能呢?

一、先根据提示"屏蔽缺少 Google API 密钥,因此 Chromium 的部分功能将无法使用。"找到对应ID,那么如何查找呢?看下面介绍:

1、先去chrome\app\resources\chromium_strings_zh-CN.xtb文件里面搜索该字符串,

<translation id="328888136576916638">缺少 Google API 密钥,因此 Chromium 的部分功能将无法使用。</translation>

2、根据 id="328888136576916638" 去chrome\app\resources\chromium_strings_en-GB.xtb 搜索该ID对应的英文

<translation id="328888136576916638">Google API keys are missing. Some functionality of Chromium will be disabled.</translation>

3、根据标红的英文去搜索chrome\app\google_chrome_strings.grd文件,

      <!-- Google API keys info bar -->

      <message name="IDS_MISSING_GOOGLE_API_KEYS" desc="Message shown when Google API keys are missing. This message is followed by a 'Learn more' link.">

        Google API keys are missing. Some functionality of Google Chrome will be disabled.

      </message>

这样就可以搜到该文字对应的ID = IDS_MISSING_GOOGLE_API_KEYS

【注意字符查找对应关系,其他的内容也是如此查找】

 

二、内容对应IDS_MISSING_GOOGLE_API_KEYS已经找到,再根据此ID找到c++代码。

chrome\browser\ui\startup\google_api_keys_infobar_delegate.cc

// static
void GoogleApiKeysInfoBarDelegate::Create(infobars::ContentInfoBarManager* infobar_manager) {infobar_manager->AddInfoBar(CreateConfirmInfoBar(std::unique_ptr<ConfirmInfoBarDelegate>(new GoogleApiKeysInfoBarDelegate())));
}GoogleApiKeysInfoBarDelegate::GoogleApiKeysInfoBarDelegate(): ConfirmInfoBarDelegate() {
}infobars::InfoBarDelegate::InfoBarIdentifier
GoogleApiKeysInfoBarDelegate::GetIdentifier() const {return GOOGLE_API_KEYS_INFOBAR_DELEGATE;
}std::u16string GoogleApiKeysInfoBarDelegate::GetLinkText() const {return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
}GURL GoogleApiKeysInfoBarDelegate::GetLinkURL() const {return GURL(google_apis::kAPIKeysDevelopersHowToURL);
}std::u16string GoogleApiKeysInfoBarDelegate::GetMessageText() const {return l10n_util::GetStringUTF16(IDS_MISSING_GOOGLE_API_KEYS);
}int GoogleApiKeysInfoBarDelegate::GetButtons() const {return BUTTON_NONE;
}

三、已经找到了GoogleApiKeysInfoBarDelegate类是弹出提示的类。

四、调用的类在chrome\browser\ui\startup\infobar_utils.cc

       if (!google_apis::HasAPIKeyConfigured())
      GoogleApiKeysInfoBarDelegate::Create(infobar_manager);
处,直接看代码:

void AddInfoBarsIfNecessary(Browser* browser,Profile* profile,const base::CommandLine& startup_command_line,chrome::startup::IsFirstRun is_first_run,bool is_web_app) {if (!browser || !profile || browser->tab_strip_model()->count() == 0)return;// Show the Automation info bar unless it has been disabled by policy.bool show_bad_flags_security_warnings = ShouldShowBadFlagsSecurityWarnings();content::WebContents* web_contents =browser->tab_strip_model()->GetActiveWebContents();DCHECK(web_contents);if (show_bad_flags_security_warnings) {
#if BUILDFLAG(CHROME_FOR_TESTING)if (!IsGpuTest()) {ChromeForTestingInfoBarDelegate::Create();}
#endifif (IsAutomationEnabled())AutomationInfoBarDelegate::Create();if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProtectedAudiencesConsentedDebugToken)) {BiddingAndAuctionConsentedDebuggingDelegate::Create(web_contents);}if (base::CommandLine::ForCurrentProcess()->HasSwitch(network::switches::kTestThirdPartyCookiePhaseout)) {TestThirdPartyCookiePhaseoutInfoBarDelegate::Create(web_contents);}}// Do not show any other info bars in Kiosk mode, because it's unlikely that// the viewer can act upon or dismiss them.if (IsKioskModeEnabled())return;// Web apps should not display the session restore bubble (crbug.com/1264121)if (!is_web_app && HasPendingUncleanExit(browser->profile()))SessionCrashedBubble::ShowIfNotOffTheRecordProfile(browser, /*skip_tab_checking=*/false);// These info bars are not shown when the browser is being controlled by// automated tests, so that they don't interfere with tests that assume no// info bars.if (!startup_command_line.HasSwitch(switches::kTestType) &&!IsAutomationEnabled()) {// The below info bars are only added to the first profile which is// launched. Other profiles might be restoring the browsing sessions// asynchronously, so we cannot add the info bars to the focused tabs here.//// We cannot use `chrome::startup::IsProcessStartup` to determine whether// this is the first profile that launched: The browser may be started// without a startup window (`kNoStartupWindow`), or open the profile// picker, which means that `chrome::startup::IsProcessStartup` will already// be `kNo` when the first browser window is opened.static bool infobars_shown = false;if (infobars_shown)return;infobars_shown = true;if (show_bad_flags_security_warnings)chrome::ShowBadFlagsPrompt(web_contents);infobars::ContentInfoBarManager* infobar_manager =infobars::ContentInfoBarManager::FromWebContents(web_contents);if (!google_apis::HasAPIKeyConfigured())GoogleApiKeysInfoBarDelegate::Create(infobar_manager);if (ObsoleteSystem::IsObsoleteNowOrSoon()) {PrefService* local_state = g_browser_process->local_state();if (!local_state ||!local_state->GetBoolean(prefs::kSuppressUnsupportedOSWarning))ObsoleteSystemInfoBarDelegate::Create(infobar_manager);}#if !BUILDFLAG(IS_CHROMEOS_ASH)if (!is_web_app &&!startup_command_line.HasSwitch(switches::kNoDefaultBrowserCheck)) {// The default browser prompt should only be shown after the first run.if (is_first_run == chrome::startup::IsFirstRun::kNo)ShowDefaultBrowserPrompt(profile);}
#endif}
}

总结:

那么直接把       if (!google_apis::HasAPIKeyConfigured())
      GoogleApiKeysInfoBarDelegate::Create(infobar_manager);这段代码屏蔽掉即可。

重新编译运行OK 效果:

GoogleApi主要是谷歌的地图云等服务,可以直接屏蔽。

  • Cloud Search API
  • Geolocation API (requires enabling billing but is free to use; you can skip this one, in which case geolocation features of Chrome will not work)
  • Google Drive API (enable this for Files.app on Chrome OS and SyncFileSystem API)
  • Safe Browsing API
  • Time Zone API
  • Optional
    • Admin SDK
    • Cloud Translation API
    • Geocoding API
    • Google Assistant API
    • Google Calendar API
    • Nearby Messages API

其他更详细介绍请参考API Keys

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/1551708.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

【IT001】基于springboot+vue实现的在线问卷调查网站系统

作者主页&#xff1a;Java码库 主营内容&#xff1a;SpringBoot、Vue、SSM、HLMT、Jsp、PHP、Nodejs、Python、爬虫、数据可视化、小程序、安卓app等设计与开发。 收藏点赞不迷路 关注作者有好处 文末获取源码 项目描述 在当今信息爆炸的时代&#xff0c;数据收集与分析的重要…

经典文献阅读之--Stereo-NEC(全新双目VIO初始化)

0. 简介 双目VI-SLAM初始化方法分为两种类型&#xff1a;联合方法和分离方法。联合方法通过融合视觉观测和IMU积分来同时处理视觉和惯性参数&#xff0c;但有可能在闭合解中忽视陀螺仪偏置&#xff0c;而且计算成本高。分离方法首先独立解决SfM问题&#xff0c;然后根据纯视觉…

Qt --- 常用控件的介绍---Widget属性介绍

一、控件概述 编程&#xff0c;讲究的是站在巨人的肩膀上&#xff0c;而不是从头发明轮子。一个图形化界面上的内容&#xff0c;不需要咱们全都从零区实现&#xff0c;Qt中已经提供了很多内置的控件了&#xff08;按钮&#xff0c;文本框&#xff0c;单选按钮&#xff0c;复选…

CMake教程(八):添加定制命令和生成的文件

本篇继续 CMake 官网教程的第八篇教程&#xff0c;所用材料是 Step8 目录下的源代码。 本篇教程主要讲解如何通过 CMake 生成一个头文件&#xff0c;该头文件当中包含了 1 到 10 的平方根表格&#xff0c;然后在程序的其它部分包含这个生成的头文件。 出于教学的目的&#xf…

手机实时提取SIM卡打电话的信令声音-新的篇章(二、USB音频线初步探索)

手机实时提取SIM卡打电话的信令声音-新的篇章(二、USB音频线初步探索) 前言 前面的篇章和方案中,我们从架构拓扑和原理的角度分析了使用音频线来绕开手机对SIM卡电话的通话声音的封锁场景的可行性,并尝试拆分和对比模拟3.5mm耳机的音频和USB的数字音频线在使用上的差异。 在…

【ADC】系统误差分析中的统计原理

概述 本文学习于TI 高精度实验室课程&#xff0c;讨论典型和最大数据表规格的统计含义&#xff0c;分析最坏情况分析和查看典型值的统计分析之间的差异。 文章目录 概述一、最坏情况下的误差大小及其概率二、估计误差更好的方法 一、最坏情况下的误差大小及其概率 为了更好地…

【电机-概述及分类】

文章目录 第1章1-1 电机的定义1-2 电机的构成要素1-3 电机的分类1-3-1 直流电机1-3-1-1 永磁励磁型直流电机1-3-1-2 电磁铁励磁型直流电机 第1章 重新认识电机的体系 电机包括许多种类。换个角度来看&#xff0c;并没有完美的电机&#xff0c;某种电机具有所谓A的优点&#xf…

Unreal 对象、属性同步流程

文章目录 类型同步初始化创建 FObjectReplicator创建 FRepLayout、Cmd、ShadowOffset创建 FRepChangedPropertyTracker、FRepState创建 FReplicationChangelistMgr、FRepChangelistState、ShadowBuffer 属性同步属性变化检测查找变化属性&#xff0c;写入ShadowMemory发送数据 …

php email功能实现:详细步骤与配置技巧?

php email发送功能详细教程&#xff1f;如何使用php email服务&#xff1f; 无论是用户注册、密码重置&#xff0c;还是订单确认&#xff0c;电子邮件都是与用户沟通的重要手段。AokSend将详细介绍如何实现php email功能&#xff0c;并提供一些配置技巧&#xff0c;帮助你更好…

读代码UNET

这个后面这个大小怎么算的&#xff0c;这参数怎么填&#xff0c;怎么来的&#xff1f; 这是怎么看怎么算的&#xff1f; 这些参数设置怎么设置&#xff1f;卷积多大&#xff0c;有什么讲究&#xff1f;

65.【C语言】联合体

目录 目录 1.定义 2.格式 3.例题 答案速查 分析 4.练习 答案速查 分析 5.相同成员的联合体和结构体的对比 6.联合体的大小计算 2条规则 答案速查 分析 练习 答案速查 分析 7.联合体的优点 8.匿名联合体 1.定义 和结构体有所不同,顾名思义:所有成员联合使用同…

软件设计师——计算机网络

&#x1f4d4;个人主页&#x1f4da;&#xff1a;秋邱-CSDN博客☀️专属专栏✨&#xff1a;软考——软件设计师&#x1f3c5;往期回顾&#x1f3c6;&#xff1a;&#x1f31f;其他专栏&#x1f31f;&#xff1a;C语言_秋邱 一、OSI/ RM七层模型(⭐⭐⭐) ​ 层次 名称 主要功…

【STM32单片机_(HAL库)】4-1【定时器TIM】定时器中断点灯实验

1.硬件 STM32单片机最小系统LED灯模块 2.软件 timer驱动文件添加定时器HAL驱动层文件添加GPIO常用函数定时器中断配置流程main.c程序 #include "sys.h" #include "delay.h" #include "led.h" #include "timer.h"int main(void) {H…

latex打出邮箱图标和可点击的orcidID

如图所示&#xff1a; 邮箱的打法 \usepackage{bbding} \inst{(}\Envelope\inst{)}orcidID的打法 \newcommand{\myorcidID}[1]{\href{https://orcid.org/#1}{\includegraphics[width8pt]{res/orcid.png}}} \captionsetup[algorithm]{skip5pt} \definecolor{customblue}{RGB}{…

硬盘数据不翼而飞?2024四大神器帮您找回!

能看到这篇文章的&#xff0c;相信都是一不小心丢失了重要数据的小伙伴。不要慌&#xff0c;以下的这几个硬盘数据恢复软件大家都可以试试&#xff0c;它们大概率能帮助大家找回重要数据&#xff01; 福昕数据恢复 直达链接&#xff08;复制到浏览器打开&#xff09;&#xf…

鸿蒙开发(NEXT/API 12)【穿戴设备信息查询】手机侧应用开发

// 在使用Wear Engine服务前&#xff0c;请导入WearEngine与相关模块 import { wearEngine } from kit.WearEngine; import { BusinessError } from kit.BasicServicesKit;查询穿戴设备是否支持某种WearEngine能力集 注意 该接口的调用需要在开发者联盟申请设备基础信息权限。…

Threejs中使用A*算法寻路导航

<!DOCTYPE html> <html><head><title>Threejs中使用A*算法寻路导航&#xff0c;Threejs室内室外地图导航</title><script type"text/javascript" src"libs/three.js"></script><script type"text/javas…

zabbix7.0监控linux主机案例详解

前言 服务端配置 链接: rocky9.2部署zabbix服务端的详细过程 环境 主机ip应用zabbix-server192.168.10.11zabbix本体zabbix-client192.168.10.12zabbix-agent zabbix-server(服务端已配置) 具体实现过程 zabbix-client配置 安装zabbix-agent 添加扩展包 dnf -y instal…

AD软件的分屏显示功能

1.鼠标右键点击上面的窗格&#xff0c;选择“垂直分布”&#xff0c;即可以将AD软件分屏&#xff0c;左边选择原理图&#xff0c;右边选择PCB即可以方便去设计PCB的布局。实现原理图和pcb文件的同时查看。 还可以建立起2个图之间的联动关系。 比如我们在电路图里面选择stm32 m…

风险函数梳理工具

风险函数梳理工具 在日常的软件开发工作中&#xff0c;代码的安全性和质量至关重要。然而&#xff0c;面对庞大的代码库&#xff0c;手动查找潜在的风险函数不仅耗时&#xff0c;而且容易出错。特别是在团队协作中&#xff0c;代码审查和重构工作往往占据了大量宝贵的时间&…