Commit 11db8848 authored by James Cook's avatar James Cook Committed by Chromium LUCI CQ

lacros: Add --lacros-chrome-additional-env for environment variables

For Wayland debugging, it's helpful to add WAYLAND_DEBUG=client to
the lacros environment.

Introduce --lacros-chrome-additional-env to set arbitrary additional
environment variables when launching lacros.

Bug: none
Change-Id: Ie44f4edd80459d606216cab733e99027d42fc986
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2636264Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845052}
parent 2cbcb493
...@@ -310,6 +310,21 @@ void BrowserManager::StartWithLogFile(base::ScopedFD logfd) { ...@@ -310,6 +310,21 @@ void BrowserManager::StartWithLogFile(base::ScopedFD logfd) {
// This sets the channel for Lacros. // This sets the channel for Lacros.
options.environment["CHROME_VERSION_EXTRA"] = "dev"; options.environment["CHROME_VERSION_EXTRA"] = "dev";
std::string additional_env =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
chromeos::switches::kLacrosChromeAdditionalEnv);
base::StringPairs env_pairs;
if (base::SplitStringIntoKeyValuePairsUsingSubstr(additional_env, '=', "####",
&env_pairs)) {
for (const auto& env_pair : env_pairs) {
if (!env_pair.first.empty()) {
LOG(WARNING) << "Applying lacros env " << env_pair.first << "="
<< env_pair.second;
options.environment[env_pair.first] = env_pair.second;
}
}
}
options.kill_on_parent_death = true; options.kill_on_parent_death = true;
// Paths are UTF-8 safe on Chrome OS. // Paths are UTF-8 safe on Chrome OS.
......
...@@ -423,6 +423,12 @@ const char kKernelnextRestrictVMs[] = "kernelnext-restrict-vms"; ...@@ -423,6 +423,12 @@ const char kKernelnextRestrictVMs[] = "kernelnext-restrict-vms";
// --bar=/tmp/dir name // --bar=/tmp/dir name
const char kLacrosChromeAdditionalArgs[] = "lacros-chrome-additional-args"; const char kLacrosChromeAdditionalArgs[] = "lacros-chrome-additional-args";
// Additional environment variables set for lacros-chrome. The string '####' is
// used as a delimiter. For example:
// --lacros-chrome-additional-env=WAYLAND_DEBUG=client####FOO=bar
// will enable Wayland protocol logging and set FOO=bar.
const char kLacrosChromeAdditionalEnv[] = "lacros-chrome-additional-env";
// If this switch is set, then ash-chrome will exec the lacros-chrome binary // If this switch is set, then ash-chrome will exec the lacros-chrome binary
// from the indicated path rather than from component updater. Note that the // from the indicated path rather than from component updater. Note that the
// path should be to a directory that contains a binary named 'chrome'. // path should be to a directory that contains a binary named 'chrome'.
......
...@@ -164,6 +164,8 @@ extern const char kInstallLogFastUploadForTests[]; ...@@ -164,6 +164,8 @@ extern const char kInstallLogFastUploadForTests[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kKernelnextRestrictVMs[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kKernelnextRestrictVMs[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kLacrosChromeAdditionalArgs[]; extern const char kLacrosChromeAdditionalArgs[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kLacrosChromeAdditionalEnv[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kLacrosChromePath[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kLacrosChromePath[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kLacrosMojoSocketForTesting[]; extern const char kLacrosMojoSocketForTesting[];
......
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