
UpdateCommandLineFromConfigFile() assumes that the command line contains arguments that were initialized based on the web context parameters. With CFv2 context-specific arguments are passed as argv.json . That file was processed only after loading config, as result some of the parameters in the config were not processed properly. Bug: 268737401 Change-Id: Ia0f2c52b4efc4f70644645d221d635b12263a64a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4251481 Reviewed-by: Wez <wez@chromium.org> Commit-Queue: Wez <wez@chromium.org> Auto-Submit: Sergey Ulanov <sergeyu@chromium.org> Cr-Commit-Position: refs/heads/main@{#1105598}
55 lines
1.9 KiB
C++
55 lines
1.9 KiB
C++
// Copyright 2018 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "base/check.h"
|
|
#include "base/command_line.h"
|
|
#include "base/files/file_path.h"
|
|
#include "components/fuchsia_component_support/append_arguments_from_file.h"
|
|
#include "components/fuchsia_component_support/config_reader.h"
|
|
#include "content/public/app/content_main.h"
|
|
#include "content/public/common/content_switches.h"
|
|
#include "fuchsia_web/webengine/browser/web_engine_config.h"
|
|
#include "fuchsia_web/webengine/context_provider_main.h"
|
|
#include "fuchsia_web/webengine/switches.h"
|
|
#include "fuchsia_web/webengine/web_engine_main_delegate.h"
|
|
|
|
static void LoadConfigAndUpdateCommandLine(base::CommandLine* command_line) {
|
|
// Config file needs to be loaded only in the browser process.
|
|
bool is_browser_process =
|
|
command_line->GetSwitchValueASCII(switches::kProcessType).empty();
|
|
if (!is_browser_process)
|
|
return;
|
|
|
|
CHECK(fuchsia_component_support::AppendArgumentsFromFile(
|
|
base::FilePath(FILE_PATH_LITERAL("/config/command-line/argv.json")),
|
|
*command_line))
|
|
<< "Malformed argv.json file.";
|
|
|
|
if (const auto& config = fuchsia_component_support::LoadPackageConfig();
|
|
config.has_value()) {
|
|
CHECK(UpdateCommandLineFromConfigFile(config.value(), command_line))
|
|
<< "WebEngine config is invalid.";
|
|
}
|
|
}
|
|
|
|
int main(int argc, const char** argv) {
|
|
base::CommandLine::Init(argc, argv);
|
|
|
|
auto* const command_line = base::CommandLine::ForCurrentProcess();
|
|
if (command_line->HasSwitch(switches::kContextProvider))
|
|
return ContextProviderMain();
|
|
|
|
LoadConfigAndUpdateCommandLine(command_line);
|
|
|
|
WebEngineMainDelegate delegate;
|
|
content::ContentMainParams params(&delegate);
|
|
|
|
// Repeated base::CommandLine::Init() is ignored, so it's safe to pass null
|
|
// args here.
|
|
params.argc = 0;
|
|
params.argv = nullptr;
|
|
|
|
return content::ContentMain(std::move(params));
|
|
}
|