From 4c54c161df7815f6abdc01f102e112476d7174d3 Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Sun, 11 Dec 2022 13:20:32 -0500 Subject: [PATCH] Initialize component updater URL feature after feature list initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chromium change: https://source.chromium.org/chromium/chromium/src/+/adb1c6128d5ac682478cda00c694174a6faf7413 commit adb1c6128d5ac682478cda00c694174a6faf7413 Author: François Doray Date: Wed Nov 16 22:57:38 2022 +0000 Fail immediately on feature state access without a FeatureList. Since https://crrev.com/c/4006674, registering a FeatureList in a process that previously accessed the state of a feature DCHECKs. Because the DCHECK is delayed until FeatureList registration, the error log isn't as actionnable as it could be. This CL adds FeatureList::FailOnFeatureAccessWithoutFeatureList(), which makes feature state access without a FeatureList is registered fail instantly. FailOnFeatureAccessWithoutFeatureList() is called from ContentMain(). Extra details: - Failing instantly on feature access without a FeatureList can't be the default, because this is tolerated in processes that never register a FeatureList. - We keep track of feature access without a FeatureList even if FeatureList::FailOnFeatureAccessWithoutFeatureList() hasn't been called, because: - FeatureList::FailOnFeatureAccessWithoutFeatureList() may be called later. - We want to catch early accesses in a myriad of test/utility processes that register a FeatureList but don't call FeatureList::FailOnFeatureAccessWithoutFeatureList(). Adding this call a myriad of processes wouldn't be practical or future-proof. Bug: 1358639 --- app/brave_main_delegate.cc | 12 ++++++++++++ app/brave_main_delegate.h | 4 ++-- chromium_src/chrome/app/chrome_main_delegate.cc | 6 ------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/brave_main_delegate.cc b/app/brave_main_delegate.cc index 52bac84900a..0179d799090 100644 --- a/app/brave_main_delegate.cc +++ b/app/brave_main_delegate.cc @@ -144,3 +144,15 @@ void BraveMainDelegate::PreSandboxStartup() { brave::InitializeResourceBundle(); } } + +absl::optional BraveMainDelegate::PostEarlyInitialization( + ChromeMainDelegate::InvokedIn invoked_in) { + auto result = ChromeMainDelegate::PostEarlyInitialization(invoked_in); + BraveCommandLineHelper command_line(base::CommandLine::ForCurrentProcess()); + std::string update_url = GetUpdateURLHost(); + if (!update_url.empty()) { + std::string source = "url-source=" + update_url; + command_line.AppendSwitchASCII(switches::kComponentUpdater, source.c_str()); + } + return result; +} diff --git a/app/brave_main_delegate.h b/app/brave_main_delegate.h index e7b0783dd9b..0adc8fe4b8e 100644 --- a/app/brave_main_delegate.h +++ b/app/brave_main_delegate.h @@ -6,8 +6,6 @@ #ifndef BRAVE_APP_BRAVE_MAIN_DELEGATE_H_ #define BRAVE_APP_BRAVE_MAIN_DELEGATE_H_ -#include - #include "build/build_config.h" #include "chrome/app/chrome_main_delegate.h" @@ -29,6 +27,8 @@ class BraveMainDelegate : public ChromeMainDelegate { content::ContentRendererClient* CreateContentRendererClient() override; content::ContentUtilityClient* CreateContentUtilityClient() override; void PreSandboxStartup() override; + absl::optional PostEarlyInitialization( + ChromeMainDelegate::InvokedIn invoked_in) override; }; #endif // BRAVE_APP_BRAVE_MAIN_DELEGATE_H_ diff --git a/chromium_src/chrome/app/chrome_main_delegate.cc b/chromium_src/chrome/app/chrome_main_delegate.cc index 146a1e93995..1f1e3cdb723 100644 --- a/chromium_src/chrome/app/chrome_main_delegate.cc +++ b/chromium_src/chrome/app/chrome_main_delegate.cc @@ -63,12 +63,6 @@ absl::optional ChromeMainDelegate::BasicStartupComplete() { command_line.AppendSwitch(switches::kDisableDomainReliability); command_line.AppendSwitch(switches::kEnableDomDistiller); - std::string update_url = GetUpdateURLHost(); - if (!update_url.empty()) { - std::string source = "url-source=" + update_url; - command_line.AppendSwitchASCII(switches::kComponentUpdater, source.c_str()); - } - if (!base::CommandLine::ForCurrentProcess()->HasSwitch( embedder_support::kOriginTrialPublicKey)) { command_line.AppendSwitchASCII(embedder_support::kOriginTrialPublicKey,