Commit c3ad19ae authored by Fabrice de Gans-Riberi's avatar Fabrice de Gans-Riberi Committed by Chromium LUCI CQ

[fuchsia] Move SetAPIKey call to WebEngineMainDelegate::BasicStartupComplete()

In https://crrev.com/c/2613649, a call to google_apis::SetAPIKey() was
added in the main() function. However, there is no AtExitManager
registered by that point, resulting in a crash in builds with dchecks
enabled. This moves the call to google_apis::SetAPIKey() to be done in
WebEngineMainDelegate::BasicStartupComplete() instead.

Bug: 1168325
Change-Id: Iee034fb20c7d4d8563cbd9973943d87339619b71
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2638634
Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org>
Reviewed-by: default avatarSharon Yang <yangsharon@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845004}
parent bd19f4af
......@@ -112,6 +112,7 @@ component("web_engine_core") {
"//fuchsia/base:message_port",
"//fuchsia/base:modular",
"//fuchsia/cast_streaming",
"//google_apis",
"//gpu/command_buffer/service",
"//media",
"//media/fuchsia/cdm/service",
......@@ -258,11 +259,9 @@ source_set("switches") {
executable("web_engine_exe") {
deps = [
":switches",
":web_engine_core",
"//base",
"//content/public/app",
"//google_apis",
]
sources = [ "web_engine_main.cc" ]
visibility = [ ":*" ]
......
......@@ -9,16 +9,14 @@
#include "content/public/common/content_switches.h"
#include "fuchsia/engine/context_provider_impl.h"
#include "fuchsia/engine/context_provider_main.h"
#include "fuchsia/engine/switches.h"
#include "fuchsia/engine/web_engine_main_delegate.h"
#include "google_apis/google_api_keys.h"
int main(int argc, const char** argv) {
base::CommandLine::Init(argc, argv);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
std::string process_type =
command_line->GetSwitchValueASCII(switches::kProcessType);
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessType);
fidl::InterfaceRequest<fuchsia::web::Context> context;
if (process_type.empty()) {
......@@ -43,10 +41,5 @@ int main(int argc, const char** argv) {
params.argc = 0;
params.argv = nullptr;
if (command_line->HasSwitch(switches::kGoogleApiKey)) {
google_apis::SetAPIKey(
command_line->GetSwitchValueASCII(switches::kGoogleApiKey));
}
return content::ContentMain(params);
}
......@@ -20,6 +20,7 @@
#include "fuchsia/engine/common/web_engine_content_client.h"
#include "fuchsia/engine/renderer/web_engine_content_renderer_client.h"
#include "fuchsia/engine/switches.h"
#include "google_apis/google_api_keys.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
......@@ -86,6 +87,11 @@ bool WebEngineMainDelegate::BasicStartupComplete(int* exit_code) {
return true;
}
if (command_line->HasSwitch(switches::kGoogleApiKey)) {
google_apis::SetAPIKey(
command_line->GetSwitchValueASCII(switches::kGoogleApiKey));
}
SetCorsExemptHeaders(base::SplitString(
base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
switches::kCorsExemptHeaders),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment