blob: 5707e686f58faa5231dbbacc73ddd892fbb86093 [file] [log] [blame] [view]
# Adding a new feature flag in chrome://flags
This document describes how to add your new feature behind a flag.
## Step 1: Adding a new `base::Feature`
This step would be different between where you want to use the flag.
For example, if you want to use the flag in src/content, you should add a base::Feature to the following files:
* [content/public/common/](
* [content/public/common/content_features.h](
If you want to use the flag in blink, you should also read
[Runtime Enable Features](
You can refer to [this CL](
to see
1. where to add the base::Feature
2. how to use it
3. how to wire the base::Feature to WebRuntimeFeatures
4. how to use it in blink
Also, this patch added a virtual test for running layout tests with the flag.
When you add a flag, you can consider to use that.
## Step 2: Adding the feature flag to the chrome://flags UI.
You have to modify these four files in total.
* [chrome/browser/](
* [chrome/browser/](
* [chrome/browser/flag_descriptions.h](
* [tools/metrics/histograms/enums.xml](
At first you need to add an entry to __about_flags.cc__,
__flag_descriptions.cc__ and __flag_descriptions.h__. After that, try running the following test.
# Build unit_tests
ninja -C out/Default unit_tests
# Run AboutFlagsHistogramTest.CheckHistograms
./out/Default/unit_tests --gtest_filter=AboutFlagsHistogramTest.CheckHistograms
That test will ask you to add several entries to enums.xml.
You can refer to [this CL]( as an example.