blob: 5d5890e2c159e89d14bdbc9e2adba548d7ba4dc1 [file] [log] [blame] [view]
Daniel Eratbe44a2f2017-07-27 02:28:431# Passing Chrome flags from `session_manager`
2
Daniel Erat240572b2018-04-25 20:03:223## Runtime configuration
4
Daniel Eratbe44a2f2017-07-27 02:28:435Chrome sometimes needs to behave differently on different Chrome OS devices.
6It's preferable to test for the hardware features that you care about directly
7within Chrome: if you want to do something special on Chromebooks that have
8accelerometers, just check if an accelerometer device is present.
9
Daniel Erat240572b2018-04-25 20:03:2210## Build-time configuration
11
Daniel Eratbe44a2f2017-07-27 02:28:4312Sometimes it's not possible to check for these features from within Chrome,
13though. In that case, the recommended approach is to add a command-line flag to
14Chrome and update `session_manager` to pass it with the appropriate value (if
15any).
16
17Chrome's command line is constructed by [chrome_setup.cc]. This file uses the
Hidehiko Abe40f15282024-10-11 05:25:2118[ChromiumCommandBuilder] class to create directories
Daniel Eratbe44a2f2017-07-27 02:28:4319needed by Chrome, configure its environment, and build its command line.
20
21`ChromiumCommandBuilder` reads a subset of the Portage USE flags that were set
22when the system was built from `/etc/ui_use_flags.txt`; these can be used to
23determine which flags should be passed. To start using a new USE flag (including
24a board name), add it to the [libchromeos-use-flags] ebuild file. (Relegating
25this file to a tiny dedicated package allows us to use the same prebuilt
26`chromeos-chrome` and `chromeos-login` packages on devices that have different
27sets of USE flags.)
28
Daniel Erat240572b2018-04-25 20:03:2229### Configuration location
30
Daniel Eratbe44a2f2017-07-27 02:28:4331Configuration that would apply both to the Chrome browser and to other products
32that could be built using the Chromium codebase (e.g. a simple shell that runs a
33dedicated web app) should be placed in `ChromiumCommandBuilder`. This includes
34most compositor- and audio-related flags.
35
36Configuration that is specific to the Chrome browser should instead be placed in
37[chrome_setup.cc]. This includes most flags that are implemented within Chrome's
38`//ash` and `//chrome` directories.
39
Jack Rosenthalc89e49a2021-04-29 22:16:5340### Translating chromeos-config to switches
41
42The preferred way to add model-specific switches to the command line
43is to use [chromeos-config] to specify the model specific
44configuration.
45
46To do so, no changes to `session_manager` are required. Simply
47generate the corresponding switches in [cros_config_schema] (search
48for `AshSwitches`).
49
Daniel Erat240572b2018-04-25 20:03:2250### Use feature-based USE flags
51
Jack Rosenthalc89e49a2021-04-29 22:16:5352If you need a model-specific configuration for a pre-unibuild device
53(2016 and before), or you need to apply a feature to experimental
54builds, the best way to do this is USE flags.
55
56Note: USE flags are not able to introduce model-specific switches in
57the unibuild world.
58
Daniel Erat240572b2018-04-25 20:03:2259If possible, introduce a new USE flag named after the feature that you're adding
60and set it in the appropriate [board overlays] rather than making
61`session_manager` examine board USE flags like `samus` or `eve`. Using
62feature-specific USE flags reduces the number of changes needed to enable the
63feature for a new board — just set the USE flag in the new board's overlay. In
64contrast, if `session_manager` contains an expression like this:
65
66```c++
67if (builder->UseFlagIsSet("samus") || builder->UseFlagIsSet("eve"))
68 builder->AddArgs("--enable-my-feature");
69```
70
71then additionally enabling the feature for `newboard` will require:
72
73* Adding `newboard` to `IUSE` in [libchromeos-use-flags] if it's not there
74 already
75* Updating `session_manager` to additionally check for the `newboard` USE flag
76
Daniel Eratbe44a2f2017-07-27 02:28:4377## Making quick changes
78
79[/etc/chrome_dev.conf] can be modified on dev-mode Chrome OS systems (after
80making the root partition writable) to add or remove flags from Chrome's command
81line or modify Chrome's environment. The file contains documentation about its
82format.
83
84[chrome_setup.cc]: ../chrome_setup.cc
Hidehiko Abe40f15282024-10-11 05:25:2185[ChromiumCommandBuilder]: https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/login_manager/chromium_command_builder.h
Keith Leeb132e742021-05-05 04:25:2486[libchromeos-use-flags]: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/HEAD/chromeos-base/libchromeos-use-flags/libchromeos-use-flags-9999.ebuild
Tom Hughes18251f92020-12-07 21:38:1487[board overlays]: https://chromium.googlesource.com/chromiumos/overlays/board-overlays/+/HEAD
88[chromeos-config]: https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/chromeos-config/
Jack Rosenthalc89e49a2021-04-29 22:16:5389[cros_config_schema]: https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/chromeos-config/cros_config_host/cros_config_schema.py
Daniel Eratbe44a2f2017-07-27 02:28:4390[/etc/chrome_dev.conf]: ../chrome_dev.conf