[Fuchsia] Move api-key setup to PreBrowserMain
https://crrev.com/c/5424132 shifted the order of initialization. But FeatureList isn't initialized before accessing api_key_cache and the api-key will be overridden by WebEngineMainDelegate anyway. https://crsrc.org/c/fuchsia_web/webengine/web_engine_main_delegate.cc;drc=59ac8227c5dd59754331b3f7f9f85e1a947f1242;l=83 It would cause an assertion failure. FATAL:feature_list.cc(109)] Check failed: !feature. Accessed feature OverrideAPIKey before FeatureList registration. So this change moved the api-key setup logic to the PreBrowserMain which will be executed after the initialization of FeatureList. The solution eliminates the less preferred fuchsia specific logic in the google_apis/, so that the original CL https://crrev.com/c/5424132 can keep unchanged. This change should be safe, the uses of google_apis::GetAPIKey() won't be before the finish of initialization. But it would be great to monitor the impact. https://source.chromium.org/search?q=google_apis::GetApiKey%20-f:google_apis%2F&sq= Cq-Include-Trybots: luci.chrome.try:fuchsia-smoke-sherlock Bug: 333064918 Change-Id: I906cff72ed944a50aa3a583c38bc414aefba3183 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5491833 Reviewed-by: David Song <wintermelons@google.com> Reviewed-by: Sergey Ulanov <sergeyu@chromium.org> Commit-Queue: David Song <wintermelons@google.com> Auto-Submit: Zijie He <zijiehe@google.com> Cr-Commit-Position: refs/heads/main@{#1293945}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
22c0f98164
commit
aedf947a5a
fuchsia_web/webengine
@ -80,15 +80,6 @@ std::optional<int> WebEngineMainDelegate::BasicStartupComplete() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (command_line->HasSwitch(switches::kGoogleApiKey)) {
|
||||
#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
|
||||
google_apis::SetAPIKey(
|
||||
command_line->GetSwitchValueASCII(switches::kGoogleApiKey));
|
||||
#else
|
||||
LOG(WARNING) << "Ignored " << switches::kGoogleApiKey;
|
||||
#endif
|
||||
}
|
||||
|
||||
SetCorsExemptHeaders(base::SplitString(
|
||||
base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
|
||||
switches::kCorsExemptHeaders),
|
||||
@ -110,6 +101,20 @@ void WebEngineMainDelegate::PreSandboxStartup() {
|
||||
InitializeResources();
|
||||
}
|
||||
|
||||
std::optional<int> WebEngineMainDelegate::PreBrowserMain() {
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kGoogleApiKey)) {
|
||||
#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
|
||||
google_apis::SetAPIKey(
|
||||
command_line->GetSwitchValueASCII(switches::kGoogleApiKey));
|
||||
#else
|
||||
LOG(WARNING) << "Ignored " << switches::kGoogleApiKey;
|
||||
#endif
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
absl::variant<int, content::MainFunctionParams>
|
||||
WebEngineMainDelegate::RunProcess(
|
||||
const std::string& process_type,
|
||||
|
@ -39,6 +39,7 @@ class WEB_ENGINE_EXPORT WebEngineMainDelegate
|
||||
// ContentMainDelegate implementation.
|
||||
std::optional<int> BasicStartupComplete() override;
|
||||
void PreSandboxStartup() override;
|
||||
std::optional<int> PreBrowserMain() override;
|
||||
absl::variant<int, content::MainFunctionParams> RunProcess(
|
||||
const std::string& process_type,
|
||||
content::MainFunctionParams main_function_params) override;
|
||||
|
Reference in New Issue
Block a user