For Developers‎ > ‎Design Documents‎ > ‎


Here's how to hide a feature behind a flag that can be changed from the chrome://flags page in Chrome, or with a command line flag. We'll use an example from the following revision 84971 which hides the compact navigation bar behind such a flag.
  • First, you need to add a string for your command line switch.
    For example: chrome_switches.h &

  • Then you need strings to be displayed on the chrome://flags page for the name and description of your experiment.
    For example, the two strings with IDs starting with IDS_FLAGS_ENABLE ingenerated_resources.grd

  • And then add all this info to a new entry in the Experiments array.
    For example:
    • The first string (e.g., "compact-navigation") is an identifier for the preference that will be saved in the user profile based on the settings chosen by the user on the chrome://flags page.
    • The the resource IDs for the name and description strings.
    • Then which OS should expose it.
    • And finally, the access to the command line flag, using one of the following macros:

  • And finally, use the CommandLine::ForCurrentProcess()->HasSwitch(<your flag>) to check its state.
    For example: uses it to decide whether we show the Hide toolbar option in the tab contextual menu or not.