0
点赞
收藏
分享

微信扫一扫

重载(Overloading)与重写(Overriding)的区别

引言

在上一篇文章中,我们介绍了Geolocation API的定义、作用及其在浏览器指纹中的重要性。我们还讨论了修改Geolocation API返回值以保护用户隐私的必要性。本篇文章将深入Chromium源码,找到Geolocation API的实现位置,并分析其关键属性,为后续的修改提供基础。

1. Chromium源码中的Geolocation API

1.1 查找Geolocation API的实现位置

Chromium项目是一个庞大的开源浏览器项目,其源码包含了众多模块和功能。要找到Geolocation API的实现位置,我们可以从以下几个步骤入手:

  1. 搜索相关文件:在下载完成后,我们可以使用搜索工具在源码中查找与Geolocation API相关的文件。通常,Geolocation API的实现会涉及到geolocationposition等关键词。
  2. 分析关键文件:找到相关文件后,我们需要分析这些文件,了解Geolocation API的具体实现细节。

1.2 关键文件和目录

在Chromium源码中,Geolocation API的实现主要涉及以下几个文件和目录:

  • geolocation目录:该目录通常包含了与地理位置相关的核心实现文件。
  • geolocation_service_impl.ccgeolocation_service_impl.h:这些文件实现了Geolocation API的服务逻辑。

通过分析这些文件,我们可以找到Geolocation API的具体实现位置,并了解其关键属性和方法。

2. 通过Chromium官网搜索相关内容

我们可以通过官网https://source.chromium.org/chromium/chromium/src/来寻找到相关的内容,比如我们要修改Geolocation,所以我选择搜索Geolocation。

由于我们修改的JavaScript的返回值修改,这个与render层高度相关,所以我们寻找到了这个文件

3.查看源码验证是否寻找正确

// Connects to the Geolocation mojo service and starts polling for updates.
  void StartUpdating(GeoNotifier*);

  void StopUpdating();

  void UpdateGeolocationConnection(GeoNotifier*);
  void QueryNextPosition();

  // Attempts to obtain a position for the given notifier, either by using
  // the cached position or by requesting one from the Geolocation service.
  // Sets a fatal error if permission is denied or no position can be
  // obtained.
  void StartRequest(GeoNotifier*);

  bool HaveSuitableCachedPosition(const PositionOptions*);

  // Record whether the origin trying to access Geolocation would be
  // allowed to access a feature that can only be accessed by secure origins.
  // See https://goo.gl/Y0ZkNV
  void RecordOriginTypeAccess() const;

  void OnPositionUpdated(device::mojom::blink::GeopositionResultPtr);

  void OnGeolocationConnectionError();

  void OnGeolocationPermissionStatusUpdated(GeoNotifier*,
                                            mojom::PermissionStatus);

通过这几个函数名我们可以大概看出来在返回的Geolocation请求是在这个文件中处理的,所以我们基本上可以锁定这个文件。通过修改对应的.cc实现,我们可以做到修改API返回值的效果。

4.结语

本文深入分析了Chromium源码中的Geolocation API实现位置。通过修改Geolocation API的返回值,我们可以有效地保护用户的隐私,减少用户被跟踪和识别的风险。

在接下来的文章中,我将进一步探讨如何在Chromium源码中修改API,分析相关代码,并提供详细的步骤和示例代码,帮助读者更好地理解和应用这些技术。

举报

相关推荐

0 条评论