chromium 23 chromium中google updateres相关的代码

版权声明:技术分享,csdn longji https://blog.csdn.net/longji/article/details/85681295

01 google updateres

chrome的自动更新组件叫google updateres。默认安装会在C:\Program Files (x86)\Google\Update目录下。
C:\Program Files (x86)\Google\Update\GoogleUpdate.exe
C:\Program Files (x86)\Google\Update\1.3.33.23\*目录下有很多更新必须的文件。
google updateres是由独立于chromium的团队维护的。

chromium代码最直接和这部分相关的是菜单中的关于菜单。代码位置:
src\chrome\browser\ui\webui\help\
默认chromimu使用的是
version_updater_basic.cc
version_updater_basic.h
google updateres使用的是
version_updater_win.cc
version_updater_win.h
追查VersionUpdaterWin的 BeginUpdateCheck 函数,既可以找到全部线索。

如果完全开启应该在gn gen 命令中加入 is_chrome_branded=true。自己没这么测试过。

如果想在chromium编译模式下is_chrome_branded=false(默认值)开启chromium代码中和google updateres相关的代码。牵涉到的修改文件较多。

02 71.0.3578.49版本中 google updateres相关部分。

修改一下涉及到的内容,基本可以调试google updateres相关的chromium内部的代码逻辑。

最终,会在chrome\browser\google\google_update_win.ccCreateGoogleUpdate3WebClass函数中因调用src\google_update\google_update_idl.idl中定义的GoogleUpdate3WebUserClass而失败。

如果要完全模拟google updateres,需要自己打造一个update.exe,并且实现src\google_update\google_update_idl.idl的com接口。

下面牵涉的修改内容,仅仅是通过性测试,可以方便调试google_update相关的chromium内部代码逻辑。其实不修改光看看也差不多,因为代码量不大,主要集中在google_update_win.ccversion_updater_win.cc两个文件中。

另外 upgrade_detector.ccupgrade_detector_impl.cc也有很大借鉴作用。

主要相关源码文件

# 需要修改或注释代码的文件
src/chrome/browser/BUILD.gn
chrome/browser/ui/BUILD.gn
chrome/app/settings_strings.grdp
chrome\browser\component_updater\third_party_module_list_component_installer_win.cc
chrome\browser\conflicts\incompatible_applications_updater_win.cc
chrome\browser\conflicts\module_blacklist_cache_updater_win.cc
chrome\browser\conflicts\uninstall_application_win.cc
chrome\browser\first_run\upgrade_util_win.cc
chrome\browser\google\google_update_win.cc
chrome\browser\upgrade_detector\upgrade_detector_impl.cc
chrome\browser\upgrade_detector\upgrade_detector_impl.h
chrome\common\chrome_features.h
chrome\common\pref_names.h
# 下面的未必需要修改
chrome\install_static\chromium_install_modes.cc
chrome\install_static\install_modes.cc
chrome\installer\mini_installer\mini_installer_constants.cc
chrome\installer\util\util_constants.cc
chrome\installer\setup\setup_main.cc

02.01 src/chrome/browser/BUILD.gn

    #if (is_chrome_branded) {
    if (!is_chrome_branded) {
      deps += [
        ":conflicts_module_list_proto",
        "//chrome_elf:sha1",
        "//chrome_elf:third_party_shared_defines",
        "//google_update",
      ]
      libs += [ "msi.lib" ]
      sources += [
        "component_updater/third_party_module_list_component_installer_win.cc",
        "component_updater/third_party_module_list_component_installer_win.h",
        "conflicts/incompatible_applications_updater_win.cc",
        "conflicts/incompatible_applications_updater_win.h",
        "conflicts/installed_applications_win.cc",
        "conflicts/installed_applications_win.h",
        "conflicts/module_blacklist_cache_updater_win.cc",
        "conflicts/module_blacklist_cache_updater_win.h",
        "conflicts/module_blacklist_cache_util_win.cc",
        "conflicts/module_blacklist_cache_util_win.h",
        "conflicts/module_list_filter_win.cc",
        "conflicts/module_list_filter_win.h",
        "conflicts/module_load_attempt_log_listener_win.cc",
        "conflicts/module_load_attempt_log_listener_win.h",
        "conflicts/msi_util_win.cc",
        "conflicts/msi_util_win.h",
        "conflicts/registry_key_watcher_win.cc",
        "conflicts/registry_key_watcher_win.h",
        "conflicts/third_party_conflicts_manager_win.cc",
        "conflicts/third_party_conflicts_manager_win.h",
        "conflicts/token_util_win.cc",
        "conflicts/token_util_win.h",
        "conflicts/uninstall_application_win.cc",
        "conflicts/uninstall_application_win.h",
        "google/google_update_win.cc",
        "google/google_update_win.h",

02.02chrome/browser/ui/BUILD.gn

   #if (is_chrome_branded) {
   if (!is_chrome_branded) {
     sources += [
       "webui/help/version_updater_win.cc",
       "webui/help/version_updater_win.h",
       "webui/settings/incompatible_applications_handler_win.cc",
       "webui/settings/incompatible_applications_handler_win.h",
     ]
     deps += [ "//google_update" ]
     deps += [ 
         "//google_update" 
       ]

02.03 chrome/app/settings_strings.grdp

  <!-- if expr="is_win and _google_chrome" -->
  <if expr="is_win">
    <message name="IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_RESET_CARD_TITLE" desc="The title of the Incompatible Applications section of the settings.">
      Update or remove incompatible applications
    </message>
    <message name="IDS_SETTINGS_INCOMPATIBLE_APPLICATIONS_SUBPAGE_SUBTITLE" desc="The subtitle shown in the subpage for incompatible applications.">
      {NUM_APPLICATIONS, plural,
        =1 {This application could prevent Chrome from working properly.}
        other {These applications could prevent Chrome from working properly.}}
    </message>

02.04 chrome\browser\component_updater\third_party_module_list_component_installer_win.cc

//constexpr char kComponentId[] = "ehgidpndbllacpjalkiimkbadgjfnnmc";

  //// Forward the notification to the ThirdPartyConflictsManager on the current
  //// (UI) thread. The manager is responsible for the work of actually loading
  //// the module list, etc, on background threads.
  //ThirdPartyConflictsManager* manager =
  //    ModuleDatabase::GetInstance()->third_party_conflicts_manager();
  //if (!manager)
  //  return;
//manager->LoadModuleList(GetModuleListPath(install_dir));

  //// Check if component is needed. The ThirdPartyConflictsManager instance only
  //// exists when the module list is needed.
  //if (!ModuleDatabase::GetInstance()->third_party_conflicts_manager())
  //  return;

  //auto installer = base::MakeRefCounted<ComponentInstaller>(
  //    std::make_unique<ThirdPartyModuleListComponentInstallerPolicy>());
  //installer->Register(
  //    component_update_service, base::BindOnce([]() {
  //      // Notify the ThirdPartyConflictsManager.
  //      ThirdPartyConflictsManager* manager =
  //          ModuleDatabase::GetInstance()->third_party_conflicts_manager();
  //      if (!manager)
  //        return;
  //      manager->OnModuleListComponentRegistered(kComponentId);
  //    }));

02.05 chrome\browser\conflicts\incompatible_applications_updater_win.cc

  //return base::win::GetVersion() >= base::win::VERSION_WIN10 &&
  //       ModuleDatabase::IsThirdPartyBlockingPolicyEnabled() &&
  //       base::FeatureList::IsEnabled(
  //           features::kIncompatibleApplicationsWarning);
  return false;

02.06 chrome\browser\conflicts\module_blacklist_cache_updater_win.cc

  //// The ThirdPartyConflictsManager can exist even if the blocking is disabled
  //// because that class also controls the warning of incompatible applications.
  //return ModuleDatabase::GetInstance() &&
  //       ModuleDatabase::GetInstance()->third_party_conflicts_manager() &&
  //       base::FeatureList::IsEnabled(features::kThirdPartyModulesBlocking);
  return false;

02.07 chrome\browser\conflicts\uninstall_application_win.cc

  //// Launch the Apps & Features settings page regardless of the |result| of the
  //// initialization. An initialization failure only means that the application
  //// will not be written into the search box.
  //ShellUtil::LaunchUninstallAppsSettings();

02.08 chrome\browser\first_run\upgrade_util_win.cc

//#if defined(GOOGLE_CHROME_BUILD)
//#endif  // GOOGLE_CHROME_BUILD

02.09 chrome\browser\google\google_update_win.cc

GoogleUpdateErrorCode CanUpdateCurrentChrome函数里面的路径

扫描二维码关注公众号,回复: 4767439 查看本文章
// 这两个路径需要根据自己的调试环境调整下
  base::FilePath user_exe_path = installer::GetChromeInstallPath(false);
  base::FilePath machine_exe_path = installer::GetChromeInstallPath(true);

02.10 chrome\browser\upgrade_detector\upgrade_detector_impl.cc

//#if defined(GOOGLE_CHROME_BUILD)
//#endif  // defined(GOOGLE_CHROME_BUILD)
#if defined(OS_WIN)// && defined(GOOGLE_CHROME_BUILD)

02.11 chrome\browser\upgrade_detector\upgrade_detector_impl.h

#if defined(OS_WIN)// && defined(GOOGLE_CHROME_BUILD)

02.12 chrome\common\chrome_features.h

#if defined(OS_WIN) //&& defined(GOOGLE_CHROME_BUILD)

02.13 chrome\common\pref_names.h

//#if defined(GOOGLE_CHROME_BUILD)
//#endif  // defined(GOOGLE_CHROME_BUILD)

02.14 未必修改,但需要关注的内容

chrome\install_static\chromium_install_modes.cc
chrome\install_static\install_modes.cc
chrome\installer\mini_installer\mini_installer_constants.cc
chrome\installer\util\util_constants.cc
chrome\installer\setup\setup_main.cc

猜你喜欢

转载自blog.csdn.net/longji/article/details/85681295