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

news2024/10/1 6:13:14

新编译的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();
    }
#endif

    if (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.coloradmin.cn/o/2181713.html

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

相关文章

NR不同小区带宽的RB数

1. FR1 下表为FR1中不同小区带宽对应的最大RB数量。 SCS (kHz) 5 MHz 10 MHz 15 MHz 20 MHz 25 MHz 30 MHz 40 MHz 50 MHz 60 MHz 70 MHz 80 MHz 90 MHz 100 MHz 15 25 52 79 106 133 160 216 270 N/A N/A N/A N/A N/A 30 11 24 38 51 6…

登录功能开发 P167重点

会话技术&#xff1a; cookie jwt令牌会话技术&#xff1a; jwt生成&#xff1a; Claims&#xff1a;jwt中的第二部分 过滤器&#xff1a; 拦截器&#xff1a; 前端无法识别controller方法&#xff0c;因此存在Dispa什么的

仿真设计|基于51单片机的双机通信控制数码管显示

目录 具体实现功能 设计介绍 51单片机简介 资料内容 仿真实现&#xff08;protues8.7&#xff09; 程序&#xff08;Keil5&#xff09; 全部内容 资料获取 具体实现功能 &#xff08;1&#xff09;双机通信系统分为通讯发送端和通讯接收端。 &#xff08;2&#xff09;…

5G上的时敏网络:带有IEEE 802.1Qbv流量的混合5G和TSN系统的实验评估

论文标题&#xff1a;Time-Sensitive Networking over 5G: Experimental Evaluation of a Hybrid 5G and TSN System with IEEE 802.1Qbv Traffic 作者信息&#xff1a;Adnan Aijaz 和 Sajida Gufran&#xff0c;来自英国布里斯托尔的Toshiba Europe Ltd.的Bristol Research a…

Vue 技术进阶 day2 数据监视的原理、其他内置指令、自定义指令、生命周期、组件化、VueComponent构造函数

目录 1.Vue监测数据的原理 1.1 原理 1.1.1 数据劫持 1.1.2 观察者模式(Vue内部的实现) 1.1.3 更新组件 1.1.4 计算属性和侦听器 1.2 后添加属性做响应式&#xff08;Vue.set / vm.$set&#xff09; 1.3 对象和数组的响应式 1.4 数据监视案例 2.指令 2.1 内置指令 2.…

threejs三维可视化完全开源案例突破100个了

好激动呀&#xff0c;经过不断努力&#xff0c;三维开源案例&#xff0c;已经突破100个共享 赶快来逛逛吧&#xff01; 官网&#xff1a;https://threelab.cn/ 源码地址&#xff1a;https://github.com/AivoGenX/threelab-threejs-webgpu-vue-js

OkHttp 详细使用步骤,以及异步请求和同步请求

&#x1f604;作者简介&#xff1a; 小曾同学.com,一个致力于测试开发的博主⛽️&#xff0c;主要职责&#xff1a;测试开发、CI/CD 如果文章知识点有错误的地方&#xff0c;还请大家指正&#xff0c;让我们一起学习&#xff0c;一起进步。 &#x1f60a; 座右铭&#xff1a;不…

springboot+vue+elementui大文件分片上传

工具类方法&#xff1a; /*** 大文件分片上传* param fileName 文件名* param file 文件* param fileKey 文件key* param shardIndex 当前分片下标* param shardTotal 分片总量*/public static void bigUpload(String fileName,MultipartFile file, String fileKey, L…

【数据结构】MapSet

【概念】 Map和Set是一种专门用于搜索的数据结构&#xff0c;其搜索效率与具体实例化的子类数量有关&#xff0c;本质上是一颗二叉搜索树 搜索的关键数据为关键字“Key”&#xff0c;关键字对应的数据为值“Value”&#xff0c;将其称为“Key-Value键值对” 【关于Map】 Ma…

8 种渗透测试类型

渗透测试是对网络、硬件或软件系统进行有计划的攻击&#xff0c;目的是揭露可能破坏系统完整性并危及有价值数据的安全缺陷。虽然渗透测试的类型不同&#xff0c;但它们都旨在利用漏洞和弱点来测试现有安全措施的有效性。 渗透测试 不同类型的渗透测试取决于人们希望在特定系…

初识Linux · O(1)调度算法

目录 前言&#xff1a; O(1)调度算法 前言&#xff1a; 在初识进程的那一块&#xff0c;我们已经知道了进程并不是一直占用cpu资源的&#xff0c;而是存在时间片的概念&#xff0c;即&#xff0c;每个进程都有一定的时间来执行该进程&#xff0c;时间一到&#xff0c;该进程…

会议平台后端优化方案

会议平台后端优化方案 通过RTC的学习&#xff0c;我了解到了端对端技术&#xff0c;就想着做一个节省服务器资源的会议平台 之前做了这个项目&#xff0c;快手二面被问到卡着不知如何介绍&#xff0c;便有了这篇文章 分析当下机制 相对于传统视频平台&#xff08;SFU&#xff…

windows 驱动实例分析系列-定时日志的COM驱动

本文章的前置文章为: windows 驱动编写原则 windows COM驱动 案例 windows COM驱动的I/O处理 在前面的设计中,主要是对windows提供的VirtualSerial源代码的讲解,但是那个驱动其实是一个空壳驱动,用于学习的,在I/O处理中,也讲述了serial I/O处理的本质,接下来会将这些…

PGMP-03战略一致性

1.概要 program strategy alignment&#xff1a;战略一致性 2.详细

css的背景background属性

CSS的background属性是一个简写属性&#xff0c;它允许你同时设置元素的多个背景相关的子属性。使用这个属性可以简化代码&#xff0c;使其更加清晰和易于维护。background属性可以设置不同的子属性。 background子属性 定义背景颜色 使用background-color属性 格式&#x…

经典文献阅读之--WiROS(用于机器人的WiFi感知工具箱)

0. 简介 近期的许多研究探索了使用基于WiFi的感知技术来改善SLAM&#xff08;同时定位与地图构建&#xff09;、机器人操控或探索。此外&#xff0c;WiFi的广泛可用性使其成为最具优势的射频信号。但WiFi传感器缺乏一个准确、易处理、多功能的工具箱&#xff0c;这限制了它们与…

MicoZone-Maven

一、理论 Maven 是 Apache 软件基金会组织维护的一款专门为 Java 项目提供项目构建和依赖管理支持的工具。 通过Maven管理依赖的优势&#xff1a; 1、通过在pom.xml中指定jar包坐标即可自动从仓库下载依赖 2、如果jar包存在子依赖会自动下载子依赖包 3、如果jar包之间存在冲突…

Web安全 - 服务端请求伪造SSRF(Server-Side Request Forgery)

文章目录 OWASP 2023 TOP 10SSRF 导图SSRF 概念SSRF的工作原理SSRF攻击场景SSRF防御策略1. 严格验证用户输入2. 禁用或限制对内部网络的访问3. 强制使用外部API代理4. 禁止直接访问敏感资源5. 输入内容长度限制6. 检测和监控7. 确保对HTTP请求的处理安全 SSRF防御实现方案1. 白…

【鸿蒙开发】05 登录Demo解析

文章目录 一、功能介绍 在鸿蒙开发中&#xff0c;一个完善的登录功能是许多应用程序的基础需求。本文将详细介绍一个鸿蒙 App 登录 Demo&#xff0c;包括其功能介绍、代码解析以及代码 demo 的下载地址。 本文初始代码从华为开发者网站下载&#xff0c;根据该Demo进行内容调整。…

【Fast-LIO系列】Fast-LIO、Fast-LIO2、Faster-LIO系列特点分析

【FAST-LIO】Fast-LIO系列特点分析 1. FAST-LIO核心贡献1.将IMU和Lidar特征点紧耦合在一起2.使用反向传播考虑到了运动补偿3. 基于IESKF中的 卡尔曼增益更新 K 2. FAST-LIO2核心贡献(2021年)1. 不用线&#xff0c;面特征点而使用全局点云2. 使用ikd-tree存储点云3. ikd-Tree 3.…