Commit 7d165b17 authored by Erik Chen's avatar Erik Chen Committed by Commit Bot

Allow ash-chrome to pass arguments to lacros-chrome.

Currently, when developing lacros-chrome on a ChromeOS device, passing
new arguments requires rebuilding ash-chrome. With this CL, the new flag
--lacros-chrome-additional-args can be used to pass flags from
ash-chrome directly to lacros-chrome. This means that developers can
modify /etc/chrome_dev.conf to pass flags to lacros-chrome without
rebuilding ash-chrome.

Bug: 1107936
Change-Id: I81d1d51451dce0e256c8c5d5d8e94016b4defa79
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2316812
Commit-Queue: Erik Chen <erikchen@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Auto-Submit: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791378}
parent bc961340
......@@ -18,6 +18,7 @@
#include "base/process/launch.h"
#include "base/process/process_handle.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "chrome/browser/chromeos/crosapi/ash_chrome_service_impl.h"
......@@ -178,6 +179,16 @@ bool LacrosManager::Start() {
"--lang=en-US",
"--enable-crashpad"};
std::string additional_flags =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
chromeos::switches::kLacrosChromeAdditionalArgs);
std::vector<std::string> delimited_flags = base::SplitStringUsingSubstr(
additional_flags, "####", base::TRIM_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);
for (const std::string& flag : delimited_flags) {
argv.push_back(flag);
}
// We assume that if there's a custom chrome path, that this is a developer
// and they want to enable logging.
bool custom_chrome_path = base::CommandLine::ForCurrentProcess()->HasSwitch(
......
......@@ -413,6 +413,14 @@ const char kIgnoreUserProfileMappingForTests[] =
// chrome://flags
const char kKernelnextRestrictVMs[] = "kernelnext-restrict-vms";
// If this switch is set, then ash-chrome will pass additional arguments when
// launching lacros-chrome. The string '####' is used as a delimiter. Example:
// --lacros-chrome-additional-args="--foo=5####--bar=/tmp/dir name". Will
// result in two arguments passed to lacros-chrome:
// --foo=5
// --bar=/tmp/dir name
const char kLacrosChromeAdditionalArgs[] = "lacros-chrome-additional-args";
// 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
// path should be to a directory that contains a binary named 'chrome'.
......
......@@ -169,6 +169,8 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kHomedir[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kIgnoreUserProfileMappingForTests[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kKernelnextRestrictVMs[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kLacrosChromeAdditionalArgs[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kLacrosChromePath[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kLoginManager[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kLoginProfile[];
......
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