blob: 7a66fcf3ee27c231cbdb3cdc5777315bc8af43d6 [file] [log] [blame] [view]
Elly Fong-Jonesbf59dbb2019-02-15 18:01:271# Configuration: Prefs, Settings, Features, Switches & Flags
2
3This document outlines all the runtime configuration surfaces of Chromium,
4and discusses appropriate uses and standard patterns for each of them. Some of
5these are intended for use by users, some by developers, and some by system
6administrators.
7
Ming-Ying Chungc23505d62022-09-22 10:07:338[TOC]
9
Elly Fong-Jonesbf59dbb2019-02-15 18:01:2710## Prefs
11
12Example: prefs::kAllowDinosaurEasterEgg aka "allow_dinosaur_easter_egg"
13
14Prefs are implemented by registering them with a central pref service, usually
15via [Profile::RegisterProfilePrefs][profile-register]. They store typed values,
16which persist across restarts and may be synced between browser instances via
17the Sync service. There are several pref stores, which are documented in detail
18in the [prefs docs][prefs]. They can be directly configured via enterprise
19policy.
20
21Prefs:
22
23* *Are not* directly surfaced to the user
24* *Are not* localized into the user's language
Christian Flach35ff4d4c2023-09-12 15:08:5625* *Are* configurable via enterprise policy if a policy exists for the pref
26 (there is no catch-all policy that allows setting arbitrary prefs)
Elly Fong-Jonesbf59dbb2019-02-15 18:01:2727* *Are not* reported via UMA when in use
28* *Are not* included in chrome://version
29* *Are* automatically persistent across restarts (usually)
30
31## Features
32
33Example: base::kDCheckIsFatalFeature
34
35These are implemented via creating a [base::Feature][base-feature] anywhere.
36These can be enabled via server-side experimentation or via the command-line
Owen Min3e52abb92021-04-16 19:55:0237using "--enable-features". Which features are in use is tracked by UMA metrics,
Elly Fong-Jonesbf59dbb2019-02-15 18:01:2738and is visible in chrome://version as the "Variations" field. Do note that in
39release builds, only a series of hashes show up in chrome://version rather than
40the string names of the variations, but these hashes can be turned back into
Victor Vianna815abdf2025-06-25 17:39:2941string names if needed. This is done by consulting a Google-internal tool.
Elly Fong-Jonesbf59dbb2019-02-15 18:01:2742
43*Features are the best way to add runtime conditional behavior.*
44
45Features:
46
47* *Are not* directly surfaced to the user
48* *Are not* localized into the user's language
49* *Are not* configurable via enterprise policy
50* *Are* reported via UMA/crash when in use
51* *Are* included in chrome://version
52* *Are not* automatically persistent across restarts
53
54## Switches
55
56Example: switches::kIncognito aka "--incognito"
57
58These are implemented by testing anywhere in the codebase for the presence or
59value of a switch in [base::CommandLine::ForCurrentProcess][base-commandline].
60There is no centralized registry of switches and they can be used for
61essentially any purpose.
62
63Switches:
64
65* *Are not* directly surfaced to the user
66* *Are not* localized into the user's language
Elly Fong-Jones2af8c722023-05-12 14:47:1467* *Are not* configurable via enterprise policy (except on Chrome OS, via FeatureFlagsProto)
Elly Fong-Jonesbf59dbb2019-02-15 18:01:2768* *Are not* reported via UMA when in use
69* *Are* included in chrome://version
70* *Are not* automatically persistent across restarts
71
72In general, switches are inferior to use of base::Feature, which has the same
73capabilities and low engineering overhead but ties into UMA reporting. New code
74should use base::Feature instead of switches. An exception to this is when the
75configuration value is a string, since features can't take an arbitrary string
76value.
77
78## Flags
79
Corentin Walleze660b152020-07-15 16:07:5480Example: chrome://flags/#ignore-gpu-blocklist
Elly Fong-Jonesbf59dbb2019-02-15 18:01:2781
82These are implemented by adding an entry in [about_flags.cc][about-flags]
83describing the flag, as well as metadata in [flag-metadata][flag-metadata].
84Flags have a name and description, and show up in chrome://flags. Flags also
85have an expiration milestone, after which they will be hidden from that UI and
86disabled, then later removed. Flags are backed by either a feature or a set of
87switches, which they enable at browser startup depending on the value of the
88flag.
89
90Flags should usually be temporary, to allow for pre-launch testing of a feature.
91Permanent flags (those with expiration -1) should only be used when either:
92
93* The flag is regularly used for support/debugging purposes, by asking users to
Corentin Walleze660b152020-07-15 16:07:5494 flip it to eliminate a possible problem (such as ignore-gpu-blocklist)
Elly Fong-Jonesbf59dbb2019-02-15 18:01:2795* The flag is used for ongoing QA/test purposes in environments where command-line
96 switches can't be used (e.g. on mobile)
97
98"Users might need to turn the feature on/off" is not a sufficient justification
99for a permanent flag. If at all possible, we should design features such that
100users don't want or need to turn them off, but if we need to retain that choice,
101we should promote it to a full setting (see below) with translations and
102support. "Developers/QA might need to turn the feature on/off", on the other
103hand, is justification for a permanent flag.
104
105Flags:
106
107* *Are* directly surfaced to the user
108* *Are not* localized into the user's language
Owen Min4de63322023-07-17 19:11:57109* *Are not* configurable via enterprise policy
Elly Fong-Jonesbf59dbb2019-02-15 18:01:27110* *Are* reported via UMA when in use (via Launch.FlagsAtStartup)
111* *Are not* included in chrome://version
112* *Are* automatically persistent across restarts
113
114## Settings
115
116Example: "Show home button"
117
118Settings are implemented in WebUI, and show up in chrome://settings or one of
119its subpages. They generally are bound to a pref which stores the value of that
120setting. These are comparatively expensive to add, since they require
121localization and some amount of UX involvement to figure out how to fit them
122into chrome://settings, plus documentation and support material. Many settings
123are implemented via prefs, but not all prefs correspond to settings; some are
124used for tracking internal browser state across restarts.
125
126Settings:
127
128* *Are* directly surfaced to the user
129* *Are* localized into the user's language
130* *Are not* configurable via enterprise policy (but their backing prefs may be)
131* *Are not* reported via UMA when in use
132* *Are not* included in chrome://version
133* *Are* automatically persistent across restarts (via their backing prefs)
134
135You should add a setting if end-users might want to change this behavior. A
136decent litmus test for whether something should be a flag or a setting is: "will
137someone who can't read or write code want to change this?"
138
Jan Kosiatyb9f32ae2023-05-12 05:37:32139## Summary Table
140| | Prefs | Features | Switches | Flags | Settings |
141| :- | :- | :- | :--: | :--: | :- |
142| Directly surfaced to the user | | | | | |
143| Localized into the user's language | ❌ | ❌ | ❌ | ❌ | ✅ |
Christian Flach35ff4d4c2023-09-12 15:08:56144| Configurable via enterprise policy | ✅ if a policy<br>maps to the pref | ❌ | ❌ except on ChromeOS | ❌ | ❌ but their backing prefs may be |
Jan Kosiatyb9f32ae2023-05-12 05:37:32145| Reported when in use | ❌ | via UMA/crash | ❌ | via UMA<br> `Launch.FlagsAtStartup` | ❌ |
146| Included in chrome://version | ❌ | ✅ | ✅ | ❌ | ❌ |
147| Automatically persistent<br> across restarts | ✅ usually | ❌ | ❌ | ✅ | ✅ via backing prefs |
148
Ming-Ying Chungc23505d62022-09-22 10:07:33149## Related Documents
150
151* [Chromium Feature API & Finch (Googler-only)](http://go/finch-feature-api)
152* [Adding a new feature flag in chrome://flags](how_to_add_your_feature_flag.md)
153* [Runtime Enabled Features](../third_party/blink/renderer/platform/RuntimeEnabledFeatures.md)
154* [Initialization of Blink runtime features in content layer](initialize_blink_features.md)
155* [Integrating a feature with the origin trials framework](origin_trials_integration.md)
156
Elly Fong-Jonesbf59dbb2019-02-15 18:01:27157[base-commandline]: https://cs.chromium.org/chromium/src/base/command_line.h?type=cs&l=98
158[base-feature]: https://cs.chromium.org/chromium/src/base/feature_list.h?sq=package:chromium&g=0&l=53
159[about-flags]: https://cs.chromium.org/chromium/src/chrome/browser/about_flags.cc
160[fieldtrial-config]: https://cs.chromium.org/chromium/src/testing/variations/fieldtrial_testing_config.json
161[flag-metadata]: https://cs.chromium.org/chromium/src/chrome/browser/flag-metadata.json
162[prefs]: https://www.chromium.org/developers/design-documents/preferences
Ming-Ying Chungc23505d62022-09-22 10:07:33163[profile-register]: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/profiles/profile.h;l=189;drc=b0378e4b67a5dbdb15acf0341ccd51acda81c8e0