blob: b0a5fd170eebafb292553a8b6fea8101b1ecdd9d [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
41string names if needed. This is done by consulting [the testing
42config][fieldtrial-config] for Chromium builds, or a Google-internal tool for
43Chrome builds.
44
45*Features are the best way to add runtime conditional behavior.*
46
47Features:
48
49* *Are not* directly surfaced to the user
50* *Are not* localized into the user's language
51* *Are not* configurable via enterprise policy
52* *Are* reported via UMA/crash when in use
53* *Are* included in chrome://version
54* *Are not* automatically persistent across restarts
55
56## Switches
57
58Example: switches::kIncognito aka "--incognito"
59
60These are implemented by testing anywhere in the codebase for the presence or
61value of a switch in [base::CommandLine::ForCurrentProcess][base-commandline].
62There is no centralized registry of switches and they can be used for
63essentially any purpose.
64
65Switches:
66
67* *Are not* directly surfaced to the user
68* *Are not* localized into the user's language
Elly Fong-Jones2af8c722023-05-12 14:47:1469* *Are not* configurable via enterprise policy (except on Chrome OS, via FeatureFlagsProto)
Elly Fong-Jonesbf59dbb2019-02-15 18:01:2770* *Are not* reported via UMA when in use
71* *Are* included in chrome://version
72* *Are not* automatically persistent across restarts
73
74In general, switches are inferior to use of base::Feature, which has the same
75capabilities and low engineering overhead but ties into UMA reporting. New code
76should use base::Feature instead of switches. An exception to this is when the
77configuration value is a string, since features can't take an arbitrary string
78value.
79
80## Flags
81
Corentin Walleze660b152020-07-15 16:07:5482Example: chrome://flags/#ignore-gpu-blocklist
Elly Fong-Jonesbf59dbb2019-02-15 18:01:2783
84These are implemented by adding an entry in [about_flags.cc][about-flags]
85describing the flag, as well as metadata in [flag-metadata][flag-metadata].
86Flags have a name and description, and show up in chrome://flags. Flags also
87have an expiration milestone, after which they will be hidden from that UI and
88disabled, then later removed. Flags are backed by either a feature or a set of
89switches, which they enable at browser startup depending on the value of the
90flag.
91
92Flags should usually be temporary, to allow for pre-launch testing of a feature.
93Permanent flags (those with expiration -1) should only be used when either:
94
95* The flag is regularly used for support/debugging purposes, by asking users to
Corentin Walleze660b152020-07-15 16:07:5496 flip it to eliminate a possible problem (such as ignore-gpu-blocklist)
Elly Fong-Jonesbf59dbb2019-02-15 18:01:2797* The flag is used for ongoing QA/test purposes in environments where command-line
98 switches can't be used (e.g. on mobile)
99
100"Users might need to turn the feature on/off" is not a sufficient justification
101for a permanent flag. If at all possible, we should design features such that
102users don't want or need to turn them off, but if we need to retain that choice,
103we should promote it to a full setting (see below) with translations and
104support. "Developers/QA might need to turn the feature on/off", on the other
105hand, is justification for a permanent flag.
106
107Flags:
108
109* *Are* directly surfaced to the user
110* *Are not* localized into the user's language
Owen Min4de63322023-07-17 19:11:57111* *Are not* configurable via enterprise policy
Elly Fong-Jonesbf59dbb2019-02-15 18:01:27112* *Are* reported via UMA when in use (via Launch.FlagsAtStartup)
113* *Are not* included in chrome://version
114* *Are* automatically persistent across restarts
115
116## Settings
117
118Example: "Show home button"
119
120Settings are implemented in WebUI, and show up in chrome://settings or one of
121its subpages. They generally are bound to a pref which stores the value of that
122setting. These are comparatively expensive to add, since they require
123localization and some amount of UX involvement to figure out how to fit them
124into chrome://settings, plus documentation and support material. Many settings
125are implemented via prefs, but not all prefs correspond to settings; some are
126used for tracking internal browser state across restarts.
127
128Settings:
129
130* *Are* directly surfaced to the user
131* *Are* localized into the user's language
132* *Are not* configurable via enterprise policy (but their backing prefs may be)
133* *Are not* reported via UMA when in use
134* *Are not* included in chrome://version
135* *Are* automatically persistent across restarts (via their backing prefs)
136
137You should add a setting if end-users might want to change this behavior. A
138decent litmus test for whether something should be a flag or a setting is: "will
139someone who can't read or write code want to change this?"
140
Jan Kosiatyb9f32ae2023-05-12 05:37:32141## Summary Table
142| | Prefs | Features | Switches | Flags | Settings |
143| :- | :- | :- | :--: | :--: | :- |
144| Directly surfaced to the user | | | | | |
145| Localized into the user's language | ❌ | ❌ | ❌ | ❌ | ✅ |
Christian Flach35ff4d4c2023-09-12 15:08:56146| 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:32147| Reported when in use | ❌ | via UMA/crash | ❌ | via UMA<br> `Launch.FlagsAtStartup` | ❌ |
148| Included in chrome://version | ❌ | ✅ | ✅ | ❌ | ❌ |
149| Automatically persistent<br> across restarts | ✅ usually | ❌ | ❌ | ✅ | ✅ via backing prefs |
150
Ming-Ying Chungc23505d62022-09-22 10:07:33151## Related Documents
152
153* [Chromium Feature API & Finch (Googler-only)](http://go/finch-feature-api)
154* [Adding a new feature flag in chrome://flags](how_to_add_your_feature_flag.md)
155* [Runtime Enabled Features](../third_party/blink/renderer/platform/RuntimeEnabledFeatures.md)
156* [Initialization of Blink runtime features in content layer](initialize_blink_features.md)
157* [Integrating a feature with the origin trials framework](origin_trials_integration.md)
158
Elly Fong-Jonesbf59dbb2019-02-15 18:01:27159[base-commandline]: https://cs.chromium.org/chromium/src/base/command_line.h?type=cs&l=98
160[base-feature]: https://cs.chromium.org/chromium/src/base/feature_list.h?sq=package:chromium&g=0&l=53
161[about-flags]: https://cs.chromium.org/chromium/src/chrome/browser/about_flags.cc
162[fieldtrial-config]: https://cs.chromium.org/chromium/src/testing/variations/fieldtrial_testing_config.json
163[flag-metadata]: https://cs.chromium.org/chromium/src/chrome/browser/flag-metadata.json
164[prefs]: https://www.chromium.org/developers/design-documents/preferences
Ming-Ying Chungc23505d62022-09-22 10:07:33165[profile-register]: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/profiles/profile.h;l=189;drc=b0378e4b67a5dbdb15acf0341ccd51acda81c8e0